Add staking data to vault snapshot hooks#316
Conversation
- Fix SQL column reference in vault hooks: use (t.defaults->>'inceptBlock')::bigint instead of t.incept_block - Correct import paths in staking pool hook (6 levels deep) - Fix price extraction to destructure priceUsd property - Wrap decimals in Number() for bigint type compatibility This resolves snapshot extraction failures that prevented staking data from being indexed.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
For vaults that has real rewards i couldnt find any easily, is there any easy to test on fetching rewards dat? |
These should have staking enabled: |
murderteeth
left a comment
There was a problem hiding this comment.
i indexed just usdc-1 0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204 on mainnet + the staking contracts. i run this gql
query {
vault(chainId: 1, address: "0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204") {
staking {
available
source
rewards {
symbol
apr
perWeek
}
}
}
}
i get this error
{
"errors": [
{
"message": "Cannot return null for non-nullable field Staking.source.",
"locations": [
{
"line": 8,
"column": 7
}
],
"path": [
"vault",
"staking",
"source"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"stacktrace": [
"Error: Cannot return null for non-nullable field Staking.source.",
" at completeValue (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:601:13)",
" at executeField (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:498:19)",
" at executeFields (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:412:22)",
" at completeObjectValue (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:912:10)",
" at completeValue (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:642:12)",
" at executeField (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:498:19)",
" at executeFields (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:412:22)",
" at completeObjectValue (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:912:10)",
" at completeValue (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:642:12)",
" at eval (webpack-internal:///(rsc)/../../node_modules/graphql/execution/execute.mjs:495:9)",
" at process.processTicksAndRejections (node:internal/process/task_queues:105:5)",
" at async Promise.all (index 0)",
" at async execute (webpack-internal:///(rsc)/../../node_modules/@apollo/server/dist/esm/requestPipeline.js:249:37)",
" at async processGraphQLRequest (webpack-internal:///(rsc)/../../node_modules/@apollo/server/dist/esm/requestPipeline.js:178:32)",
" at async internalExecuteOperation (webpack-internal:///(rsc)/../../node_modules/@apollo/server/dist/esm/ApolloServer.js:646:16)",
" at async runHttpQuery (webpack-internal:///(rsc)/../../node_modules/@apollo/server/dist/esm/runHttpQuery.js:141:29)",
" at async runPotentiallyBatchedHttpQuery (webpack-internal:///(rsc)/../../node_modules/@apollo/server/dist/esm/httpBatching.js:40:16)",
" at async ApolloServer.executeHTTPGraphQLRequest (webpack-internal:///(rsc)/../../node_modules/@apollo/server/dist/esm/ApolloServer.js:557:20)"
]
}
}
],
"data": {
"vault": {
"chainId": 1,
"address": "0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204",
"name": "USDC-1 yVault",
"staking": null
}
}
}
|
Ok so it took me some time to understand why the hell that vault for eg was not pulling rewards. So here i have it: And on the graphql playground: |
murderteeth
left a comment
There was a problem hiding this comment.
i can see staking data for 0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204 now! but i also notice when running the indexer that the opboost hook is failing
ZodError: [
{
"code": "custom",
"fatal": true,
"path": [
"stakingPool"
],
"message": "Invalid input"
}
]
at Object.get error [as error] (/home/murdertxxth/git/kong/node_modules/zod/lib/types.js:43:31)
at ZodObject.parse (/home/murdertxxth/git/kong/node_modules/zod/lib/types.js:143:22)
at Object.process (/home/murdertxxth/git/kong/packages/ingest/abis/yearn/staking/registry/opboost/event/hook.ts:15:6)
at EvmLogsExtractor.extract (/home/murdertxxth/git/kong/packages/ingest/extract/evmlogs.ts:74:39)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async handler (/home/murdertxxth/git/kong/packages/ingest/extract/index.ts:32:7)
at async Worker.bullmq_1.Worker [as processFn] (/home/murdertxxth/git/kong/packages/lib/mq.ts:90:7)
at async Worker.processJob (/home/murdertxxth/git/kong/node_modules/bullmq/src/classes/worker.ts:741:22)
at async Worker.retryIfFailed (/home/murdertxxth/git/kong/node_modules/bullmq/src/classes/worker.ts:944:16) {
issues: [
{
code: 'custom',
fatal: true,
path: [Array],
message: 'Invalid input'
}
],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [
{
code: 'custom',
fatal: true,
path: [Array],
message: 'Invalid input'
}
]
}
|
Apparently i had a left over chain.local which i forgot T.T, removed it and also updated the abi. |
murderteeth
left a comment
There was a problem hiding this comment.
lgtm. let me merge tho. indexing the pools will take some time, so we need to disable the fanout cron, index the pools manually, then re-enable the cron.
Summary
Implements staking rewards data indexing for Yearn vaults across multiple chains. This adds support for four types of staking systems (VeYFI, Juiced, V3 Staking, OP Boost) using an event-driven discovery pattern, and embeds staking APR and reward data directly in vault snapshot hooks.
Closes #305
Implementation Details
Staking Registry Discovery (Event-Driven)
yearn/staking/registry/juiced- Ethereum, Arbitrum, Polygonyearn/staking/registry/v3- Ethereum, Arbitrum, Polygonyearn/staking/registry/opboost- Optimismyearn/staking/registry/veyfi- Ethereum (special handling to query stakingToken)stakingPoolthings whenStakingPoolAddedorRegisterevents are detectedStaking Pool Snapshots
yearn/staking/poolABI and snapshot hookAPR = (rewardPerDuration * rewardPrice) / (vaultPrice * totalStaked) / 10^decimals * (secondsPerYear / rewardDuration)Vault Integration
{available: false, rewards: []}StakingandStakingRewardCritical Bug Fixes
t.incept_block→(t.defaults->>'inceptBlock')::bigintpriceUsdpropertyNumber()How to review
config/abis.yamlto understand registry sources and chainspackages/ingest/abis/yearn/staking/registry/*/event/hook.tsfor thing creation logicpackages/ingest/abis/yearn/staking/pool/snapshot/hook.tsfor APR calculationpackages/web/app/api/gql/typeDefs/vault.tsfor API schemaFiles to focus on:
staking/pool/snapshot/hook.ts(lines 100-120)Test plan
Automated:
Manual:
make devManual testing