Skip to content

Centrifuge adaptor#2666

Open
0x4Graham wants to merge 5 commits into
DefiLlama:masterfrom
0x4Graham:centrifuge-adaptor
Open

Centrifuge adaptor#2666
0x4Graham wants to merge 5 commits into
DefiLlama:masterfrom
0x4Graham:centrifuge-adaptor

Conversation

@0x4Graham
Copy link
Copy Markdown

@0x4Graham 0x4Graham commented May 11, 2026

Summary by CodeRabbit

  • New Features
    • Centrifuge protocol integration now available, providing APY metrics across multiple blockchains with real-time and historical yield data analysis.

Review Change Stack

0x4Graham and others added 2 commits May 11, 2026 17:45
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 11, 2026

Warning

Rate limit exceeded

@0x4Graham has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 44 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d0cb87d4-c0b3-4c6c-a268-68c7e1adfe57

📥 Commits

Reviewing files that changed from the base of the PR and between 6f45d8d and b548378.

📒 Files selected for processing (1)
  • src/adaptors/centrifuge-protocol/index.js
📝 Walkthrough

Walkthrough

This 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.

Changes

Centrifuge Adaptor

Layer / File(s) Summary
Configuration and Data Definitions
src/adaptors/centrifuge-protocol/index.js
SDK imports, API endpoints, numeric constants, chain-ID-to-name mappings, GraphQL query for active vaults, and ABI fragments for on-chain totalAssets and convertToAssets calls.
Data Fetching Helpers
src/adaptors/centrifuge-protocol/index.js
getHistoricalBlock resolves chain and timestamp to block height via external API; fetchVaults paginates through all active vaults from Centrifuge GraphQL.
Core Chain Processing Logic
src/adaptors/centrifuge-protocol/index.js
processChain extracts vault and asset metadata, fetches historical block heights for 1-day and 7-day snapshots, executes batched multicalls for TVL and share conversion at current and historical blocks with graceful fallback, fetches USD prices, computes TVL in USD, and calculates annualized APY from geometric share-price growth.
Adaptor Entry Point
src/adaptors/centrifuge-protocol/index.js
Exported apy function loads all vaults, groups and deduplicates by (chain, tokenId), runs per-chain computation, and returns pools with finite numeric APY values.
Module Exports
src/adaptors/centrifuge-protocol/index.js
Exports adaptor configuration with timetravel: false, the apy entrypoint, and Centrifuge app URL.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A rabbit hops through Centrifuge's halls,
Fetching vaults with GraphQL calls,
Computing APY with blocks in time,
Share prices dance—geometric and prime,
Now yield flows fast, the harvest is mine! 🌱

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Centrifuge adaptor' is concise and directly describes the main change—adding a new Centrifuge protocol APY adapter. It clearly identifies the primary purpose of the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

Error while running centrifuge adapter:

Test Suites: 1 failed, 1 total
Tests: 1 failed, 267 passed, 268 total
Snapshots: 0 total
Time: 0.364 s
Ran all test suites.

Nb of pools: 44
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────┬─────────────────┬──────────────┬─────────┬────────────────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────┬─────────────────────────────┐
│ (index) │ pool                                                       │ chain           │ project      │ symbol  │ tvlUsd             │ apyBase            │ apyBase7d          │ underlyingTokens                                 │ poolMeta                                                │ url                         │
├─────────┼────────────────────────────────────────────────────────────┼─────────────────┼──────────────┼─────────┼────────────────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼─────────────────────────────────────────────────────────┼─────────────────────────────┤
│ 0       │ '0x381f4f3b43c30b78c1f7777553236e57bb8ae9ff-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDS'  │ 1135343929.620019  │ 10.795639070114715 │ 3.4560795697961444 │ [ '0xdc035d45d973e3ec169d2276ddab16f1e407384f' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 1       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-avax'          │ 'Avax'          │ 'centrifuge' │ 'USDC'  │ 258530803.51330566 │ 11.525251082035549 │ 5.691815153644941  │ [ '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 2       │ '0x4880799ee5200fc58da299e965df644fbf46780b-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDC'  │ 150319798.03185815 │ 11.525251082035549 │ 5.691815153644941  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 3       │ '0x354a9222571259457b2e98b2285b62e6a9bf4ed3-plume_mainnet' │ 'Plume Mainnet' │ 'centrifuge' │ 'USDC'  │ 50908142.868236266 │ 0                  │ -3.482829342741145 │ [ '0x222365ef19f7947e5484218551b56bb3965aa7af' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 4       │ '0x160e0dd4c4f693b05eca83bc2ec6fd51954fc434-pharos'        │ 'Pharos'        │ 'centrifuge' │ 'USDC'  │ 15021240.839260282 │ 10.795639070114715 │ 3.4560795697961444 │ [ '0xc879c018db60520f4355c26ed1a6d572cdac1815' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 5       │ '0x796ba8a2f2d80340ddb6ca8e43e7883812f13cd5-monad'         │ 'Monad'         │ 'centrifuge' │ 'USDC'  │ 4499224.697116716  │ 10.795639070114715 │ 3.4560795697961444 │ [ '0x754704bc059f8c67012fed69bc8a327a5aafb603' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 6       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDC'  │ 4329392.172661554  │ 11.501182898115392 │ 10.27233620782555  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
│ 7       │ '0x04157759a9fe406d82a16bdeb20f9beb9bbeb958-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'JTRSY' │ 2896035.574440894  │ 10.804637136334438 │ 5.003290032952545  │ [ '0x8c213ee79581ff4984583c6a801e5263418c4b86' ] │ 'DeFi Janus Henderson Anemoy Treasury Fund Token'       │ 'https://app.centrifuge.io' │
│ 8       │ '0x74a739ea1dc67c5a0179ebad665d1d3c4b80b712-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDC'  │ 597406.084540568   │ 0                  │ -3.482829342741145 │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 9       │ '0x2d38c58cc7d4ddd6b4daf7b3539902a7667f4519-base'          │ 'Base'          │ 'centrifuge' │ 'USDC'  │ 589817.649560751   │ 0                  │ 8.570631740604462  │ [ '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
└─────────┴────────────────────────────────────────────────────────────┴─────────────────┴──────────────┴─────────┴────────────────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────┴─────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3c31434 and cd0a86b.

📒 Files selected for processing (1)
  • src/adaptors/centrifuge/index.js

Comment thread src/adaptors/centrifuge/index.js Outdated
Comment thread src/adaptors/centrifuge-protocol/index.js
Comment thread src/adaptors/centrifuge-protocol/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>
@github-actions
Copy link
Copy Markdown

Error while running centrifuge adapter:

Test Suites: 1 failed, 1 total
Tests: 1 failed, 261 passed, 262 total
Snapshots: 0 total
Time: 0.395 s
Ran all test suites.

Nb of pools: 43
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────┬─────────────────┬──────────────┬─────────┬────────────────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────┬─────────────────────────────┐
│ (index) │ pool                                                       │ chain           │ project      │ symbol  │ tvlUsd             │ apyBase            │ apyBase7d          │ underlyingTokens                                 │ poolMeta                                                │ url                         │
├─────────┼────────────────────────────────────────────────────────────┼─────────────────┼──────────────┼─────────┼────────────────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼─────────────────────────────────────────────────────────┼─────────────────────────────┤
│ 0       │ '0x381f4f3b43c30b78c1f7777553236e57bb8ae9ff-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDS'  │ 1135392995.3733325 │ 10.795639070114715 │ 3.4560795697961444 │ [ '0xdc035d45d973e3ec169d2276ddab16f1e407384f' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 1       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-avax'          │ 'Avax'          │ 'centrifuge' │ 'USDC'  │ 258538650.89930075 │ 11.525251082035549 │ 5.691815153644941  │ [ '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 2       │ '0x4880799ee5200fc58da299e965df644fbf46780b-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDC'  │ 150323164.57899544 │ 11.525251082035549 │ 5.691815153644941  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 3       │ '0x354a9222571259457b2e98b2285b62e6a9bf4ed3-plume_mainnet' │ 'Plume Mainnet' │ 'centrifuge' │ 'USDC'  │ 50905489.9781162   │ 0                  │ -3.482829342741145 │ [ '0x222365ef19f7947e5484218551b56bb3965aa7af' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 4       │ '0x160e0dd4c4f693b05eca83bc2ec6fd51954fc434-pharos'        │ 'Pharos'        │ 'centrifuge' │ 'USDC'  │ 15020458.062691184 │ 10.795639070114715 │ 3.4560795697961444 │ [ '0xc879c018db60520f4355c26ed1a6d572cdac1815' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 5       │ '0x796ba8a2f2d80340ddb6ca8e43e7883812f13cd5-monad'         │ 'Monad'         │ 'centrifuge' │ 'USDC'  │ 4499325.461302288  │ 10.795639070114715 │ 3.4560795697961444 │ [ '0x754704bc059f8c67012fed69bc8a327a5aafb603' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 6       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDC'  │ 4329489.133294923  │ 11.501182898115392 │ 5.687029227634044  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
│ 7       │ '0x04157759a9fe406d82a16bdeb20f9beb9bbeb958-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'JTRSY' │ 2895788.363820402  │ 10.804637136334438 │ 3.458690115183005  │ [ '0x8c213ee79581ff4984583c6a801e5263418c4b86' ] │ 'DeFi Janus Henderson Anemoy Treasury Fund Token'       │ 'https://app.centrifuge.io' │
│ 8       │ '0x74a739ea1dc67c5a0179ebad665d1d3c4b80b712-ethereum'      │ 'Ethereum'      │ 'centrifuge' │ 'USDC'  │ 597419.4639873875  │ 0                  │ -3.482829342741145 │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 9       │ '0x2d38c58cc7d4ddd6b4daf7b3539902a7667f4519-base'          │ 'Base'          │ 'centrifuge' │ 'USDC'  │ 590012.2032613738  │ 11.501182898115392 │ 5.687029227634044  │ [ '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
└─────────┴────────────────────────────────────────────────────────────┴─────────────────┴──────────────┴─────────┴────────────────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────┴─────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

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>
@github-actions
Copy link
Copy Markdown

The centrifuge-protocol adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 256 passed, 256 total
Snapshots: 0 total
Time: 0.331 s
Ran all test suites.

Nb of pools: 42
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────┬─────────────────┬───────────────────────┬─────────┬────────────────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────┬─────────────────────────────┐
│ (index) │ pool                                                       │ chain           │ project               │ symbol  │ tvlUsd             │ apyBase            │ apyBase7d          │ underlyingTokens                                 │ poolMeta                                                │ url                         │
├─────────┼────────────────────────────────────────────────────────────┼─────────────────┼───────────────────────┼─────────┼────────────────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼─────────────────────────────────────────────────────────┼─────────────────────────────┤
│ 0       │ '0x381f4f3b43c30b78c1f7777553236e57bb8ae9ff-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDS'  │ 1137882455.4808137 │ 10.795639070114715 │ 3.4560795697961444 │ [ '0xdc035d45d973e3ec169d2276ddab16f1e407384f' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 1       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-avax'          │ 'Avax'          │ 'centrifuge-protocol' │ 'USDC'  │ 258504327.11997503 │ 11.525251082035549 │ 5.691815153644941  │ [ '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 2       │ '0x4880799ee5200fc58da299e965df644fbf46780b-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDC'  │ 152803716.92663947 │ 11.525251082035549 │ 5.691815153644941  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 3       │ '0x354a9222571259457b2e98b2285b62e6a9bf4ed3-plume_mainnet' │ 'Plume Mainnet' │ 'centrifuge-protocol' │ 'USDC'  │ 50901770.64185291  │ 0                  │ -3.482829342741145 │ [ '0x222365ef19f7947e5484218551b56bb3965aa7af' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 4       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDC'  │ 6828262.088193597  │ 11.501182898115392 │ 5.687029227634044  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
│ 5       │ '0x04157759a9fe406d82a16bdeb20f9beb9bbeb958-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'JTRSY' │ 5652777.100835733  │ 10.804637136334438 │ 3.458690115183005  │ [ '0x8c213ee79581ff4984583c6a801e5263418c4b86' ] │ 'DeFi Janus Henderson Anemoy Treasury Fund Token'       │ 'https://app.centrifuge.io' │
│ 6       │ '0x796ba8a2f2d80340ddb6ca8e43e7883812f13cd5-monad'         │ 'Monad'         │ 'centrifuge-protocol' │ 'USDC'  │ 4498763.927099585  │ 10.795639070114715 │ 3.4560795697961444 │ [ '0x754704bc059f8c67012fed69bc8a327a5aafb603' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 7       │ '0x74a739ea1dc67c5a0179ebad665d1d3c4b80b712-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDC'  │ 597344.903597108   │ 0                  │ -3.482829342741145 │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 8       │ '0x2d38c58cc7d4ddd6b4daf7b3539902a7667f4519-base'          │ 'Base'          │ 'centrifuge-protocol' │ 'USDC'  │ 589918.764654322   │ 11.501182898115392 │ 5.687029227634044  │ [ '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
│ 9       │ '0x818a3593340622c1d6a51b039e191f2f8c99a1f2-plume_mainnet' │ 'Plume Mainnet' │ 'centrifuge-protocol' │ 'USDC'  │ 547343.2545649513  │ 10.795639070114715 │ 3.4560795697961444 │ [ '0x222365ef19f7947e5484218551b56bb3965aa7af' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
└─────────┴────────────────────────────────────────────────────────────┴─────────────────┴───────────────────────┴─────────┴────────────────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────┴─────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/adaptors/centrifuge-protocol/index.js (1)

56-61: ⚡ Quick win

Add defensive check for API response structure.

If the block API returns an unexpected response format (e.g., missing height field), data.height will be undefined, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 35e51c7 and 6f45d8d.

📒 Files selected for processing (1)
  • src/adaptors/centrifuge-protocol/index.js

Comment thread src/adaptors/centrifuge-protocol/index.js
Comment thread src/adaptors/centrifuge-protocol/index.js Outdated
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

The centrifuge-protocol adapter exports pools:

Test Suites: 1 passed, 1 total
Tests: 262 passed, 262 total
Snapshots: 0 total
Time: 0.312 s
Ran all test suites.

Nb of pools: 43
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────┬─────────────────┬───────────────────────┬─────────┬────────────────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┬─────────────────────────────────────────────────────────┬─────────────────────────────┐
│ (index) │ pool                                                       │ chain           │ project               │ symbol  │ tvlUsd             │ apyBase            │ apyBase7d          │ underlyingTokens                                 │ poolMeta                                                │ url                         │
├─────────┼────────────────────────────────────────────────────────────┼─────────────────┼───────────────────────┼─────────┼────────────────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┼─────────────────────────────────────────────────────────┼─────────────────────────────┤
│ 0       │ '0x381f4f3b43c30b78c1f7777553236e57bb8ae9ff-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDS'  │ 1137941968.0604117 │ 10.795639070114715 │ 3.4560795697961444 │ [ '0xdc035d45d973e3ec169d2276ddab16f1e407384f' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 1       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-avax'          │ 'Avax'          │ 'centrifuge-protocol' │ 'USDC'  │ 258508460.72601497 │ 11.525251082035549 │ 5.691815153644941  │ [ '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 2       │ '0x4880799ee5200fc58da299e965df644fbf46780b-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDC'  │ 152806160.3300991  │ 11.525251082035549 │ 5.691815153644941  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Janus Henderson Anemoy AAA CLO Fund Token'             │ 'https://app.centrifuge.io' │
│ 3       │ '0x354a9222571259457b2e98b2285b62e6a9bf4ed3-plume_mainnet' │ 'Plume Mainnet' │ 'centrifuge-protocol' │ 'USDC'  │ 50904644.6062631   │ 0                  │ -3.482829342741145 │ [ '0x222365ef19f7947e5484218551b56bb3965aa7af' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 4       │ '0x160e0dd4c4f693b05eca83bc2ec6fd51954fc434-pharos'        │ 'Pharos'        │ 'centrifuge-protocol' │ 'USDC'  │ 15020208.622552758 │ 10.795639070114715 │ 3.4560795697961444 │ [ '0xc879c018db60520f4355c26ed1a6d572cdac1815' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 5       │ '0x1121f4e21ed8b9bc1bb9a2952cdd8639ac897784-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDC'  │ 6828371.275322976  │ 11.501182898115392 │ 5.687029227634044  │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
│ 6       │ '0x04157759a9fe406d82a16bdeb20f9beb9bbeb958-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'JTRSY' │ 5652371.161490416  │ 10.804637136334438 │ 3.458690115183005  │ [ '0x8c213ee79581ff4984583c6a801e5263418c4b86' ] │ 'DeFi Janus Henderson Anemoy Treasury Fund Token'       │ 'https://app.centrifuge.io' │
│ 7       │ '0x796ba8a2f2d80340ddb6ca8e43e7883812f13cd5-monad'         │ 'Monad'         │ 'centrifuge-protocol' │ 'USDC'  │ 4498835.864455328  │ 10.795639070114715 │ 3.4560795697961444 │ [ '0x754704bc059f8c67012fed69bc8a327a5aafb603' ] │ 'Janus Henderson Anemoy Treasury Fund Token'            │ 'https://app.centrifuge.io' │
│ 8       │ '0x74a739ea1dc67c5a0179ebad665d1d3c4b80b712-ethereum'      │ 'Ethereum'      │ 'centrifuge-protocol' │ 'USDC'  │ 597354.4554236826  │ 0                  │ -3.482829342741145 │ [ '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ] │ 'Anemoy Tokenized Apollo Diversified Credit Fund Token' │ 'https://app.centrifuge.io' │
│ 9       │ '0x2d38c58cc7d4ddd6b4daf7b3539902a7667f4519-base'          │ 'Base'          │ 'centrifuge-protocol' │ 'USDC'  │ 589964.7704045516  │ 11.501182898115392 │ 5.687029227634044  │ [ '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913' ] │ 'DeFi Janus Henderson Anemoy AAA CLO Fund Token'        │ 'https://app.centrifuge.io' │
└─────────┴────────────────────────────────────────────────────────────┴─────────────────┴───────────────────────┴─────────┴────────────────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┴─────────────────────────────────────────────────────────┴─────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant