-
Notifications
You must be signed in to change notification settings - Fork 7.1k
fix yieldseeker #18717
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
base: main
Are you sure you want to change the base?
fix yieldseeker #18717
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,29 @@ | ||
| const { yieldAgentsTvl } = require('./yieldAgents'); | ||
| const { getConfig } = require('../helper/cache'); | ||
| const ADDRESSES = require('../helper/coreAssets.json'); | ||
|
|
||
| const API_URL = 'https://api.yieldseeker.xyz/v1/agent-analytics'; | ||
|
|
||
| function normalizeToken(token) { | ||
| if (token.toLowerCase() === ADDRESSES.GAS_TOKEN_2) return ADDRESSES.null; | ||
| return token.toLowerCase(); | ||
| } | ||
|
|
||
| async function tvl(api) { | ||
| const { agentAnalytics = [] } = await getConfig('yieldseeker/yield-agents/', API_URL); | ||
| const ownerTokens = []; | ||
| for (const agent of agentAnalytics) { | ||
| if (!agent?.snapshot?.tokenBalances || typeof agent.snapshot.tokenBalances !== 'object') continue; | ||
| const tokens = Object.keys(agent.snapshot.tokenBalances).map(normalizeToken); | ||
| if (tokens.length > 0) { | ||
| ownerTokens.push([tokens, agent.agentWalletAddress]); | ||
| } | ||
| } | ||
| await api.sumTokens({ ownerTokens, permitFailure: true }); | ||
|
Comment on lines
+14
to
+21
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore the share-to-underlying conversion that was removed here. This inline replacement no longer preserves the old 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| module.exports = { | ||
| methodology: 'Counts the tokens held across all YieldSeeker agent wallets. Wallet addresses are obtained from the YieldSeeker API, and token balances are read on-chain.', | ||
| // NOTE(krishan711): Can't time travel yet cos the agent list is obtained via API. re-enable once agent list is enumerable onchain | ||
| timetravel: false, | ||
| doublecounted: true, | ||
| base: { | ||
| tvl: yieldAgentsTvl, | ||
| }, | ||
| base: { tvl }, | ||
| }; | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden
agentAnalyticsbefore iterating it.getConfig()can fall back to cached payloads on fetch errors, and the destructuring default here only handlesundefined. If the API/cache returns a truthy non-array shape, Line 14 will throw onfor...ofand take the adapter down. Normalizing withArray.isArrayavoids a hard failure on schema drift.Suggested guard
async function tvl(api) { - const { agentAnalytics = [] } = await getConfig('yieldseeker/yield-agents/', API_URL); + const response = await getConfig('yieldseeker/yield-agents/', API_URL); + const agentAnalytics = Array.isArray(response?.agentAnalytics) ? response.agentAnalytics : []; const ownerTokens = [];📝 Committable suggestion
🤖 Prompt for AI Agents