Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add get validators apy endpoint #11293

Merged
merged 5 commits into from
Apr 28, 2023
Merged

add get validators apy endpoint #11293

merged 5 commits into from
Apr 28, 2023

Conversation

patrickkuo
Copy link
Contributor

@patrickkuo patrickkuo commented Apr 25, 2023

Description

Added a new endpoint suix_getValidatorsApy to get the list of APY for all active validators.
the APY is calculated using the current staking pool and 30 days staking pool exchange rate

this PR also added cache for validator exchange rate, which will be repopulated when epoch change, get_states method will be using this cache instead of resolving the rate from move tables to improve the read performance.

Test Plan

Tested manually on testnet

{
    "jsonrpc": "2.0",
    "result": {
        "apys": [
            {
                "address": "0x44b1b319e23495995fc837dafd28fc6af8b645edddff0fc1467f1ad631362c23",
                "apy": 0.03927171044129407
            },
            {
                "address": "0x3d618b03660f4e8b4ec99c52af08a814f5248154937782d22b5a8f2e44ba15fc",
                "apy": 0.03927182250212513
            },
            {
                "address": "0x24e8511a01aa7ab06eb8ce61d6c002ac5b8b7e0fde809554ca3662fb184ce257",
                "apy": 0.03927171891132608
            },
            {
                "address": "0x4ce8d9d329879f3b361c9515f48acc0f91b283a7305f6c9c789b0c8d1ebf43f2",
                "apy": 0.039271936185637735
            },
            {
                "address": "0x4c05f4f76ed81d210e9a29ac0756c7a3129e4b9ecacbbb9fc1579505947630cf",
                "apy": 0.039272011483796776
            },
            {
                "address": "0x6881875df60daf5528d66a62b66dc5710bf06b220fa9266ffdfeeb9cd8d6ed94",
                "apy": 0.039271851914000955
            },
            {
                "address": "0xab4fb3eeaa7b0ab4f91eedab33adf140c6750e60ca5e44b3df82491937d7bab4",
                "apy": 0.039271687290090895
            },
            {
                "address": "0x2079cb58f32c868deb0f4f20f509b7f034c7bea84c964cb1316f77fc987445b8",
                "apy": 0.03927190475122777
            },
            {
                "address": "0xaaec0462f9286f2aa9db25143eaa428cc6527b1ef669772b40b011983837de77",
                "apy": 0.03927179016703497
            },
            {
                "address": "0xf941ae3cbe5645dccc15da8346b533f7f91f202089a5521653c062b2ff10b304",
                "apy": 0.03927192198581797
            },
            {
                "address": "0x2622b55585033f26b0a86b378de1a6284c2dda531e52ef30ea87a8df81f4630a",
                "apy": 0.03927168099244316
            },
            {
                "address": "0x43ff72d09170ab4712d7bf26f0475d7f94f60f7076d5da9ebcfe7dde87faf2a7",
                "apy": 0.039271755979213285
            },
            {
                "address": "0x9062fc51d91056246dc31f2b818a4ddb113a044ec22c8dd0674616bbe56f7192",
                "apy": 0.039271682672775476
            },
...

@vercel
Copy link

vercel bot commented Apr 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Apr 28, 2023 6:30pm
explorer-storybook ⬜️ Ignored (Inspect) Apr 28, 2023 6:30pm
sui-wallet-kit ⬜️ Ignored (Inspect) Apr 28, 2023 6:30pm
wallet-adapter ⬜️ Ignored (Inspect) Apr 28, 2023 6:30pm

@patrickkuo patrickkuo marked this pull request as ready for review April 28, 2023 18:32
@patrickkuo patrickkuo merged commit e5f6d39 into main Apr 28, 2023
@patrickkuo patrickkuo deleted the pat/apy branch April 28, 2023 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants