Skip to content

✨Add defindex adapter for Stellar#17920

Closed
MattPoblete wants to merge 4 commits intoDefiLlama:mainfrom
paltalabs:feat/defindex-adapter
Closed

✨Add defindex adapter for Stellar#17920
MattPoblete wants to merge 4 commits intoDefiLlama:mainfrom
paltalabs:feat/defindex-adapter

Conversation

@MattPoblete
Copy link

@MattPoblete MattPoblete commented Feb 4, 2026

Summary

  • Adds a new adapter for DeFindex, a vault-based DeFi protocol on Stellar
  • Uses a fetch-based approach via the DeFindex API (/vault/discover) to retrieve vault data and total managed funds

Why 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

  1. Fetches all mainnet vaults from api.defindex.com/vault/discover
  2. Iterates over each vault's totalManagedFunds
  3. Adds each asset and its amount to the TVL calculation

Test plan

  • Run pnpm tvl defindex to verify the adapter returns valid TVL data

Summary by CodeRabbit

  • New Features

    • Added Defindex TVL tracking, aggregating managed funds by asset and reporting totals under the Stellar TVL view.
    • Vaults with missing or empty managed-funds data are safely skipped to avoid incorrect totals.
  • Documentation

    • Included a methodology description explaining how the TVL is calculated.

Copilot AI review requested due to automatic review settings February 4, 2026 14:36
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

Adds 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 api, and exports stellar.tvl plus a methodology string.

Changes

Cohort / File(s) Summary
Defindex TVL Module
projects/defindex/index.js
New module implementing async tvl(api) under stellar: fetches cached Defindex vaults, skips vaults with missing/empty totalManagedFunds, aggregates total_amount per fund asset into api keys, and exports a methodology string describing the calculation.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 I hopped through vaults at break of day,

Totals gathered, neatly put away,
By stellar light the sums align,
Defindex counted, roots and vine,
A rabbit's cheer for code, sublime.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
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.
Description check ⚠️ Warning PR description lacks most required template fields for new protocol listings; only provides summary and implementation details without project metadata. Complete the description template with required fields: project name, Twitter, audit links, website, logo, current TVL, treasury addresses, chain, Coingecko/Coinmarketcap IDs, short description, token info, and category.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a new DeFindex adapter for Stellar, which is the primary objective of the pull request.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@llamabutler
Copy link

Error while running adapter at :

Please revert changes to package.json / package-lock.json

@llamabutler
Copy link

The adapter at projects/defindex exports TVL:

stellar                   1.37 M

total                    1.37 M 

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 getConfig helper 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.

Copy link
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

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

@llamabutler
Copy link

The adapter at projects/defindex exports TVL:

stellar                   1.37 M

total                    1.37 M 

@g1nt0ki g1nt0ki mentioned this pull request Feb 11, 2026
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.

2 participants