✨Add defindex adapter for Stellar#17920
Conversation
📝 WalkthroughWalkthroughAdds a new Defindex TVL module that fetches cached vault data, iterates vaults and their totalManagedFunds, aggregates each fund's total_amount by asset into the provided Changes
Sequence Diagram(s)sequenceDiagram
participant Module as Defindex module
participant API as Cached Defindex API
participant Adapter as tvl api (param)
Module->>API: GET /cached/vaults
API-->>Module: vaults list
Module->>Module: iterate vaults
alt vault has totalManagedFunds
Module->>Module: iterate funds -> sum total_amount by asset
Module->>Adapter: api.add(asset, amount)
Adapter-->>Module: ack
else missing/empty totalManagedFunds
Module-->>Module: skip vault
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 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 |
|
Error while running adapter at :
|
|
The adapter at projects/defindex exports TVL: |
There was a problem hiding this comment.
Pull request overview
This PR adds a new adapter for DeFindex, a vault-based DeFi protocol on Stellar. The adapter uses a fetch-based approach via the DeFindex API to retrieve vault data and calculate total value locked (TVL).
Changes:
- Added DeFindex adapter using the
getConfighelper to fetch vault data from the DeFindex API - Implements TVL calculation by summing all assets managed by DeFindex vaults including idle and invested funds
- Added a dev script for local testing
Reviewed changes
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| projects/defindex/index.js | Main adapter implementation that fetches vault data from DeFindex API and calculates TVL for Stellar chain |
| package.json | Adds dev-defindex script for local testing/development |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@projects/defindex/index.js`:
- Line 4: Rename the mistyped constant DEFINDEX_VAIULTS_INFO_URL to
DEFINDEX_VAULTS_INFO_URL and update every reference to it (e.g., the use on the
later line referenced in the comment) so the identifier matches the corrected
spelling; ensure the string value remains
`${DEFINDEX_API_BASE_URL}/vault/discover?network=mainnet` and run a quick
grep/IDE refactor to catch all occurrences.
- Around line 6-18: In the tvl function, add defensive checks before iterating
and using properties: ensure res is truthy and res.vaults is an array before
assigning vaults; inside the vault loop verify vault is an object and
vault.totalManagedFunds is an array; inside the fund loop ensure fund is an
object and that fund.asset exists and fund.total_amount is a finite number (or
coercible) before calling api.add; skip entries that fail these checks and
continue processing valid ones to avoid runtime errors from unexpected API
responses.
|
The adapter at projects/defindex exports TVL: |
Summary
/vault/discover) to retrieve vault data and total managed fundsWhy fetch instead of on-chain queries?
DefiLlama's SDK does not have full support for Stellar (no RPC helpers, no contract call abstractions, limited chain tooling). Implementing direct on-chain queries to Stellar/Soroban smart contracts would require significant custom work outside the scope of a standard adapter.
Instead, this adapter fetches TVL data from DeFindex's own API, which already aggregates total managed funds per vault (both idle and invested in strategies).
How it works
api.defindex.com/vault/discovertotalManagedFundsTest plan
pnpm tvl defindexto verify the adapter returns valid TVL dataSummary by CodeRabbit
New Features
Documentation