Centrifuge adaptor#2666
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis pull request introduces a complete APY adaptor for the Centrifuge protocol. It fetches vault metadata from Centrifuge's GraphQL API, resolves historical block heights from timestamps, executes on-chain multicalls to retrieve TVL and share conversion data at multiple points in time, and computes annualized APY from share-price growth ratios. ChangesCentrifuge Adaptor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
Error while running centrifuge adapter: Test Suites: 1 failed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/centrifuge/index.js`:
- Around line 26-46: The GraphQL query/handler only fetches a single page
(VAULTS_QUERY and fetchVaults()), so active vaults are truncated when >200;
update VAULTS_QUERY to request pagination cursors (e.g., pageInfo { hasNextPage
endCursor }) and convert the static query to accept variables (first, after),
then change fetchVaults() to loop/recursively fetch pages while
pageInfo.hasNextPage is true, passing the returned endCursor as the after
variable and concatenating all vaults' items before returning the full list.
- Around line 149-172: The code currently sets apyBase to 0 when both apyBase
and apyBase7d are unavailable, misrepresenting missing data as a real 0%; update
the pools.push creation (the object built where pool, chain, project, symbol,
tvlUsd are set) so that apyBase is null/undefined (or omitted) when apyBase is
null and apyBase7d is null, instead of falling back to 0—use the existing
apyBase and apyBase7d variables to decide this and keep apyBase7d unchanged.
- Around line 54-57: The axios calls in getHistoricalBlock (and the nearby
axios.post usage) lack timeouts and can hang; update the HTTP requests to
include a timeout (e.g., pass a timeout option or use an axios instance with a
default timeout) so requests fail fast on upstream stalls. Specifically, modify
the axios.get call inside getHistoricalBlock and the related axios.post
invocation to include a timeout value (e.g., { timeout: 5000 }) or use a shared
axios client configured with a sane default timeout to ensure the adaptor
doesn't block indefinitely.
🪄 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: 80586b35-d325-4eef-9c91-abd2d35de72c
📒 Files selected for processing (1)
src/adaptors/centrifuge/index.js
- Add cursor-based pagination to fetchVaults() for >200 vaults - Add 15s HTTP timeout to axios calls - Use null instead of 0 when APY cannot be computed Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Error while running centrifuge adapter: Test Suites: 1 failed, 1 total |
The CI test checks that the project field matches a known protocol slug from api.llama.fi/protocols, which lists it as "centrifuge-protocol". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The centrifuge-protocol 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/centrifuge-protocol/index.js (1)
56-61: ⚡ Quick winAdd defensive check for API response structure.
If the block API returns an unexpected response format (e.g., missing
heightfield),data.heightwill beundefined, causing downstream issues. Although the call site wraps this in try-catch, explicitly validating the response makes the error clearer.🛡️ Suggested defensive check
async function getHistoricalBlock(chain, timestamp) { const { data } = await http.get( `https://coins.llama.fi/block/${chain}/${timestamp}` ); + if (!data?.height) { + throw new Error(`No block height returned for ${chain} at ${timestamp}`); + } return data.height; }🤖 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/centrifuge-protocol/index.js` around lines 56 - 61, In getHistoricalBlock, validate the HTTP response shape before returning: after awaiting http.get(...) check that data exists and data.height is a finite number (or non-null) and if not throw a clear Error mentioning missing/invalid height from the coins.llama.fi response; this makes failures explicit for callers and preserves the existing try/catch handling that may wrap this function.
🤖 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/centrifuge-protocol/index.js`:
- Around line 63-77: fetchVaults currently assumes the GraphQL response shape
and will throw if data.data or data.data.vaults is missing; update fetchVaults
to validate the response after the http.post call (check that response &&
response.data && response.data.data && response.data.data.vaults and that
vaults.pageInfo and vaults.items exist) and handle malformed responses by
logging an error via the adapter logger, either returning an empty array or
throwing a descriptive Error (so callers won't crash unpredictably); ensure
validation occurs inside fetchVaults (and wrap the per-page fetch in try/catch)
so callers of fetchVaults are protected from unexpected response shapes.
- Around line 155-160: The code currently falls back to 6 for decimals (decimals
= v.asset?.decimals ?? 6) which can wildly miscalculate tvlUsd; change the logic
to detect missing v.asset?.decimals and skip that vault (continue) or at minimum
emit a clear warning before using a fallback. Concretely, check if
v.asset?.decimals is undefined/null for the current vault (and that
pricesByAddress[v.assetAddress.toLowerCase()] exists) and if so either continue
to the next item or call your logger/console.warn with the assetAddress and
assetSymbol, then only compute tvlUsd from ta.output using the validated
decimals value; ensure you reference decimals, v.asset?.decimals,
v.assetAddress, ta.output and tvlUsd so reviewers can locate the fix.
---
Nitpick comments:
In `@src/adaptors/centrifuge-protocol/index.js`:
- Around line 56-61: In getHistoricalBlock, validate the HTTP response shape
before returning: after awaiting http.get(...) check that data exists and
data.height is a finite number (or non-null) and if not throw a clear Error
mentioning missing/invalid height from the coins.llama.fi response; this makes
failures explicit for callers and preserves the existing try/catch handling that
may wrap this function.
🪄 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: 001cebb6-3c6e-42ff-8df6-7f5854000a05
📒 Files selected for processing (1)
src/adaptors/centrifuge-protocol/index.js
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The centrifuge-protocol adapter exports pools: Test Suites: 1 passed, 1 total |
Summary by CodeRabbit