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

[Feat] - Rewards API v2 #281

Merged
merged 13 commits into from
Dec 6, 2024
Merged

[Feat] - Rewards API v2 #281

merged 13 commits into from
Dec 6, 2024

Conversation

gowthamsundaresan
Copy link
Collaborator

@gowthamsundaresan gowthamsundaresan commented Nov 6, 2024

We want to track:

  1. latest cumulative reward amounts per token for all EL stakers
  2. historical cumulative rewards reward amounts per token for all EE users
  3. current maxApy of all strategies for Avs & Operators

Data Pipeline

  • Added new User table will track all wallet logins on EE frontend. Historical rewards data is maintained only for these Users.
  • Added seedLogsDistributionRootSubmitted which indexes the DistributionRootSubmitted event on the RewardsCoordinator contract
  • Added seedStakerRewardSnapshots seeder that looks at the latest log's snapshot timestamp and stores the snapshot for that date for all Stakers. Data is retrieved from EL public data bucket
  • In case a new DistributionRootSubmitted event takes place, EL's data bucket automatically gets updated with the new state along with the latest snapshot date. seedStakerRewardSnapshots recognizes that the latest snapshot date is newer than the latest date from our db and hence refreshes state for all Stakers.
  • seedMetricStakerRewards runs at at a daily frequency along with other historical seeders, and a tracks historical rewards data for all EE users.

API

GET /staker/:address?withRewards=true

{
    "address": "0xe401d18f6f835c12ca54e54a2f16a802b651eaa7",
    "operatorAddress": "0x5accc90436492f24e6af278569691e2c942a676d",
    .
    .
    .
    "rewards": {
        "aggregateApy": 0.029141812770664556,   <--- Actual APY basis staker's current distribution across strategies
        "tokenAmounts": [
	    {
                tokenAddress: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
                cumulativeAmount: "0.000044758427756304"
            },
            {
                tokenAddress: "0x127500cd2030577f66d1b79600d30dcdba2ed32d"
                cumulativeAmount: "0.0001762127170875"
            }
	],
        "strategyApys": [
            {
                "strategyAddress": "0xacb55c530acdb2849e6d4f36992cd8c9d50ed8f7",
                "apy": 0.029141812770664556,
                "tokens": [
                    {
                        "tokenAddress": "0xba50933c268f567bdc86e1ac131be072c6b0b71a",
                        "apy": 0.004170045564822437
                    },
                    {
                        "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                        "apy": 0.024971767205842117
                    }
                ]
            }
        ],
        "avsApys": [
            {
                "avsAddress": "0x1de75eaab2df55d467494a172652579e6fa4540e",
                "apy": 0.0037592025441822805,
                "strategies": [
                    {
                        "strategyAddress": "0xacb55c530acdb2849e6d4f36992cd8c9d50ed8f7",
                        "apy": 0.0037592025441822805,
                        "tokens": [
                            {
                                "tokenAddress": "0xba50933c268f567bdc86e1ac131be072c6b0b71a",
                                "apy": 0.0037592025441822805
                            }
                        ]
                    }
                ]
            },
            {
                "avsAddress": "0x870679e138bcdf293b7ff14dd44b70fc97e12fc0",
                "apy": 0.025382610226482274,
                "strategies": [
                    {
                        "strategyAddress": "0xacb55c530acdb2849e6d4f36992cd8c9d50ed8f7",
                        "apy": 0.025382610226482274,
                        "tokens": [
                            {
                                "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                                "apy": 0.024971767205842117
                            },
                            {
                                "tokenAddress": "0xba50933c268f567bdc86e1ac131be072c6b0b71a",
                                "apy": 0.00041084302064015656
                            }
                        ]
                    }
                ]
            }
        ]
    }
}

Update: Token-wise APY split for Operators and Avs

In this update, we do away with summing APYs across strategies to provide aggregateApy for Operators and Avs as it may be misleading because the aggregateApy is in fact not achievable. Instead, we maintain a strategy-wise APY for Avs and a strategy-wise, Avs-wise APY for Operators. These are further divided into token-wise APYs.

The apy in the Avs/Operator tables has been replaced with maxApy denoting that we no longer track aggregate APY for an Avs/Operator but rather the max APY of all their strategies

GET /operators/:address?withRewards=true

{
    "address": "0x5accc90436492f24e6af278569691e2c942a676d",
    "metadataName": "EigenYields",
    "maxApy": "",
    .
    .
    .
    "rewards": [
        {
            "avsAddress": "0x1de75eaab2df55d467494a172652579e6fa4540e",
            "maxApy": "",
            "strategyApys": [
                {
                    "strategyAddress": "0xbeac0eeeeeeeeeeeeeeeeeeeeeeeeeeeeeebeac0",
                    "apy": 0.000018261137983002154,
                    "tokens": [
                        {
                            "tokenAddress": "0xba50933c268f567bdc86e1ac131be072c6b0b71a",
                            "apy": 0.000018261137983002154
                        }
                    ]
                },
               .
               .
               .
            ]
        },
        {
            "avsAddress": "0x870679e138bcdf293b7ff14dd44b70fc97e12fc0",
            "maxApy": "",
            "strategyApys": [
                {
                    "strategyAddress": "0xacb55c530acdb2849e6d4f36992cd8c9d50ed8f7",
                    "apy": 0.026510931980104506,
                    "tokens": [
                        {
                            "tokenAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
                            "apy": 0.026085463854873266
                        },
                        {
                            "tokenAddress": "0xba50933c268f567bdc86e1ac131be072c6b0b71a",
                            "apy": 0.00042546812523124104
                        }
                    ]
                },
                .
                .
                .
            ]
        }
    ]
}
GET /avs/:address?withRewards=true

{
    "address": "0x1de75eaab2df55d467494a172652579e6fa4540e",
    "metadataName": "ARPA Network",
    "maxApy": "",
    .
    .
    .
    "rewards": {
        "strategyApys": [
            {
                "strategyAddress": "0xbeac0eeeeeeeeeeeeeeeeeeeeeeeeeeeeeebeac0",
                "apy": 0.00002032000765858778,
                "tokens": [
                    {
                        "tokenAddress": "0xba50933c268f567bdc86e1ac131be072c6b0b71a",
                        "apy": 0.00002032000765858778
                    }
                ]
            },
            .
	    .
	    .
            {
                "strategyAddress": "0x66ea956907f7ed2fd816106f2f4d8c384c6d4f92",
                "apy": 146.58075841765498,
                "tokens": [
                    {
                        "tokenAddress": "0xba50933c268f567bdc86e1ac131be072c6b0b71a",
                        "apy": 146.58075841765498
                    }
                ]
            }
        ]
    }
}

Protected /auth routes for wallet login

  1. When a user logs in with wallet on frontend, it calls the /check-status route to get details about the User
GET /auth/users/:address/check-status
{
    "isRegistered": false,   <--- set to true after registration successful with the /register route
    "isTracked": false,   <--- set to true after the historical seeder tracks them the first time
    "isStaker": true,   <--- states whether the user has deposited into EL in the past
}
  1. In case !isRegistered, the frontend will request a nonce on behalf of the user and prompt them to sign with their wallet
GET /auth/users/:address/nonce

{ 
    "nonce": "0x90fe698e544a6c79421a3e5df2d3231900e5f4be4feca9e6f9913496de8cb746"
}
  1. The frontend then prompts the /register route to add the wallet as an EE user
POST /auth/users/:address/register (body contains signature and nonce)

{
    "isNewUser": true
}

@gowthamsundaresan gowthamsundaresan linked an issue Nov 6, 2024 that may be closed by this pull request
@gowthamsundaresan gowthamsundaresan linked an issue Nov 11, 2024 that may be closed by this pull request
@gowthamsundaresan gowthamsundaresan changed the title [Feat] - Staker Rewards [Feat] - Rewards API v2 Nov 11, 2024
@gowthamsundaresan gowthamsundaresan marked this pull request as ready for review December 3, 2024 09:10
@uditdc uditdc merged commit ac6d678 into dev Dec 6, 2024
1 check passed
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.

[Feat] - Staker Rewards [Feat] - Token-wise APY
2 participants