Nest V1 adapter#2349
Conversation
Nest V1 adapter
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new Nest v1 Node.js adapter that fetches pool data from a backend, validates and normalizes records into the DefiLlama pool shape, filters invalid/zero-tvl entries, and exports Changes
Sequence Diagram(s)sequenceDiagram
participant Consumer as Consumer
participant Adapter as Adapter (nest-v1)
participant Utils as utils.getData
participant Backend as Backend API
rect rgba(200,220,255,0.5)
Consumer->>Adapter: call apy()
Adapter->>Utils: getData(poolsUrl)
Utils->>Backend: HTTP GET pools
Backend-->>Utils: JSON array
Utils-->>Adapter: return array
Adapter->>Adapter: mapBackendPoolToDefiLlama(items)
Adapter-->>Consumer: return filtered normalized pools
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 nest-v1 adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/adaptors/nest-v1/index.js`:
- Around line 14-18: Validate required fields before mapping: ensure pool.pool,
pool.chain, and pool.symbol are present and non-empty (e.g., if any of those are
null/undefined/empty, return null or skip the entry) so you don't call
String(pool.pool) or utils.formatChain/formatSymbol on missing values; also
replace String('nest-v1') with the literal 'nest-v1'. Update the mapping code
that produces the object (the block using pool.pool,
utils.formatChain(pool.chain), and utils.formatSymbol(pool.symbol)) to perform
checks and bail out early for malformed entries to prevent producing strings
like "undefined".
|
The nest-v1 adapter exports pools: Test Suites: 1 passed, 1 total |
| pool.apyBase === undefined || pool.apyBase === null | ||
| ? null | ||
| : Number(pool.apyBase), | ||
| rewardTokens: |
There was a problem hiding this comment.
pls include apyReward if the pool has reward tokens
There was a problem hiding this comment.
Pools on Nest receive emission rewards in NEST token instead of LP fees. We're not sure which category to include it to (rewards or base APY) but Thena (similar protocol) displays similar rewards as Base. LPs don't get rewards in extra tokens or additional yield which is why we left apyReward empty
There was a problem hiding this comment.
Looking at the Thena adapter you referenced, it actually separates these
correctly: apyBase is trading fee APY from the hypervisor, apyReward is
masterchef token emissions
For Nest pools:
- apyBase should be trading fees (may be 0 if pools don't generate fees)
- apyReward should be NEST emission APY
- rewardTokens should include the NEST token address
| // Your Blaze API helper endpoint (adjust host/port as needed) | ||
| const BACKEND_POOLS_URL = | ||
| process.env.NEST_DEFI_LLAMA_POOLS_URL || | ||
| 'https://blaze.nest.aegas.it/api/defillama/pools'; |
There was a problem hiding this comment.
we aim to get tvl and calculate apy from onchain using our defillama sdk or subgraphs. are you able refactor this?
There was a problem hiding this comment.
No unfortunately - APY is calculated via custom backend solution similar to Merkl that tracks LP activity and applies specific formula based on TVL, liquidity involved, current ranges and other factors. It's simply not possible to reproduce from the contract events only
0xkr3p
left a comment
There was a problem hiding this comment.
thanks for the PR @olecsiuyae, I've left a few comments
The V3 APY values appear to be v high, at defillama we typically use much wider ranges for non-stable pairs like +/-30%
|
Hello @0xkr3p, thank you for your review. I have added my responses in the corresponding branches. Regarding the APY values, we use +-10% range for volatile pools and +-3 ticks for stablecoin pairs. If it's absolutely necessary we can use a wider range for volatile pools |
hey @olecsiuyae, added a comment regarding rewards. Yes, that would be great, thank you! |
|
The nest-v1 adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/adaptors/nest-v1/index.js`:
- Around line 29-32: The apyBase field is incorrectly hardcoded to 0 instead of
reading the backend value; change the apyBase mapping (the object that currently
sets apyBase: 0) to mirror the apyReward pattern by reading pool.apyBase and
converting to Number or null when undefined/null (i.e., use the same conditional
logic used for apyReward to set apyBase from pool.apyBase).
|
Hi @0xkr3p, I’ve added the required updates. Please let me know if any additional changes are needed |
|
The nest-v1 adapter exports pools: Test Suites: 1 passed, 1 total |
Thanks @olecsiuyae, can you include the fee in the pool meta instead of V3 pool, other than that everything looks good! |
|
Hi @0xkr3p, We’ve added the required changes to our backend. Pool metadata now includes the fee instead of the pool type. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/adaptors/nest-v1/index.js (1)
29-34:Number()on a non-numeric string silently producesNaN— consider guarding.If the backend ever returns a non-numeric string for
apyBaseorapyReward(e.g."N/A"),Number(...)yieldsNaN, which will propagate into DefiLlama's data pipeline. A quickisFiniteguard keeps it consistent with thetvlUsdhandling above.Also, the
apyBaseternary (lines 29-31) is indented differently from theapyRewardternary (lines 32-34).Proposed fix
- apyBase: pool.apyBase === undefined || pool.apyBase === null - ? null - : Number(pool.apyBase), - apyReward: pool.apyReward === undefined || pool.apyReward === null + apyBase: pool.apyBase == null + ? null + : Number.isFinite(Number(pool.apyBase)) ? Number(pool.apyBase) : null, + apyReward: pool.apyReward == null ? null - : Number(pool.apyReward), + : Number.isFinite(Number(pool.apyReward)) ? Number(pool.apyReward) : null,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/adaptors/nest-v1/index.js` around lines 29 - 34, The apyBase and apyReward mappings use Number(pool.apyBase) / Number(pool.apyReward) which will produce NaN for non-numeric strings; update both mappings to mirror the tvlUsd handling by checking that pool.apyBase and pool.apyReward are not null/undefined and that Number(...) is finite (e.g., via isFinite(Number(...))) before assigning the numeric value, otherwise set null; also normalize the ternary indentation so both apyBase and apyReward use the same formatting style as each other.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/adaptors/nest-v1/index.js`:
- Around line 29-34: The apyBase and apyReward mappings use Number(pool.apyBase)
/ Number(pool.apyReward) which will produce NaN for non-numeric strings; update
both mappings to mirror the tvlUsd handling by checking that pool.apyBase and
pool.apyReward are not null/undefined and that Number(...) is finite (e.g., via
isFinite(Number(...))) before assigning the numeric value, otherwise set null;
also normalize the ternary indentation so both apyBase and apyReward use the
same formatting style as each other.
This PR adds adapter for the Nest platform
Summary by CodeRabbit
New Features
Bug Fixes