Add SpringX's info to the Yields adapter#2710
Conversation
📝 WalkthroughWalkthroughThis PR adds a new SpringX adaptor that retrieves yield and TVL data from SpringX contracts on the Plasma chain. The adaptor fetches pool metadata, calculates USD valuations using external price data, computes scaled APY values, and exports filtered results meeting a minimum TVL threshold. ChangesSpringX Yield Adaptor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The springx adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/adaptors/springx/index.js (1)
16-19: ⚡ Quick winDeduplicate coin keys before calling the prices endpoint.
Duplicate assets across pools create an unnecessarily long URL and extra lookup work. Build
coinsKeyfrom aSetfirst.Proposed change
- let coinsKey = pools.map((pool) => `${chain}:${pool.asset}`); + let coinsKey = [...new Set(pools.map((pool) => `${chain}:${pool.asset.toLowerCase()}`))]; let { coins } = await utils.getData( `https://coins.llama.fi/prices/current/${coinsKey}`, );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/adaptors/springx/index.js` around lines 16 - 19, The coinsKey built via pools.map includes duplicate asset keys; change construction to deduplicate (e.g., create a Set from pools.map or iterate pools to add `${chain}:${pool.asset}` to a Set) and use the unique keys when calling utils.getData for the prices endpoint (the call that currently passes coinsKey to `https://coins.llama.fi/prices/current/${coinsKey}`), ensuring you convert the Set back into the expected comma-separated string or array form before the request.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/adaptors/springx/index.js`:
- Around line 42-44: The PID comparison in the tvl lookup can fail when
ABI-decoded types differ (string vs number) causing valid pools to be dropped;
in the block using farmToTvls, tvlRows, and tvlInfo (where you call
tvlRows.find(item => item.pid === pool.pid)), normalize types before comparing
(e.g., coerce both item.pid and pool.pid to the same type with Number(...) or
String(...)) so the find matches regardless of ABI decoding differences and
valid pools are not silently filtered out.
- Around line 29-38: The loop that calls api.abi.call for each key (iterating
farmAddresses, setting farmToTvls) must be changed to batched parallel calls to
avoid N+1 RPC latency/timeouts: collect targets from Object.keys(farmAddresses),
split into chunks (e.g., 50), and for each chunk use Promise.all to call
api.abi.call({ target, abi: abi.getTvl, chain }) in parallel, then write results
into farmToTvls[item.toLowerCase()] preserving the same key format;
alternatively, if your SDK exposes a multicall helper, use that with abi.getTvl
to fetch many targets at once and map responses back to farmToTvls. Ensure
errors per-call are handled so one failure doesn’t abort the whole batch.
---
Nitpick comments:
In `@src/adaptors/springx/index.js`:
- Around line 16-19: The coinsKey built via pools.map includes duplicate asset
keys; change construction to deduplicate (e.g., create a Set from pools.map or
iterate pools to add `${chain}:${pool.asset}` to a Set) and use the unique keys
when calling utils.getData for the prices endpoint (the call that currently
passes coinsKey to `https://coins.llama.fi/prices/current/${coinsKey}`),
ensuring you convert the Set back into the expected comma-separated string or
array form before the request.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7d17f725-f1a4-4d67-be7f-c8f9713df3c6
📒 Files selected for processing (1)
src/adaptors/springx/index.js
Summary by CodeRabbit
Release Notes