Skip to content

✨ Add DeFindex protocol adaptor#2479

Open
MattPoblete wants to merge 5 commits into
DefiLlama:masterfrom
paltalabs:feat/defindex-adaptor
Open

✨ Add DeFindex protocol adaptor#2479
MattPoblete wants to merge 5 commits into
DefiLlama:masterfrom
paltalabs:feat/defindex-adaptor

Conversation

@MattPoblete

@MattPoblete MattPoblete commented Mar 13, 2026

Copy link
Copy Markdown

Summary

  • Adds yield adaptor for DeFindex, a yield aggregator built on Stellar
  • Fetches strategy data from the DeFindex API (/strategies/apy?timestamp=<ts>&network=mainnet)
  • Computes TVL in USD using DefiLlama's coin price API for Stellar assets
  • Returns APY (7d), TVL, underlying tokens, and pool metadata per strategy
  • Enables timetravel support with start timestamp (2025-05-15)
  • Filters out pools with tvlUsd < 1

Test plan

  • Run npm run test --adapter=defindex and verify strategy data is returned
  • Confirm tvlUsd and apyBase are non-zero for active strategies
  • Confirm chain is "Stellar" and pool IDs are unique
  • Confirm timetravel works by passing a historical timestamp

Summary by CodeRabbit

  • New Features
    • Added support for Defindex strategies on Stellar — view 7-day APY, underlying asset symbols, and TVL in USD with direct links to each strategy.
    • Historical (time-travel) APY retrieval enabled so past rates can be queried.
    • Very small pools (TVL < $1) are omitted to keep listings relevant and clean.

Review Change Stack

Add yield adaptor for DeFindex protocol to retrieve APY and TVL data.
@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 05cc2578-91e9-472e-89e3-9693c17ca5ab

📥 Commits

Reviewing files that changed from the base of the PR and between a738c7b and c0e68be.

📒 Files selected for processing (1)
  • src/adaptors/defindex/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/adaptors/defindex/index.js

📝 Walkthrough

Walkthrough

New Defindex Stellar adaptor exporting apy(timestamp), timetravel, start timestamp, and url; it fetches Defindex strategies, prefetches Stellar coin metadata from coins.llama.fi, computes per-strategy tvlUsd, filters tiny pools, and returns normalized strategy objects.

Changes

Defindex Stellar Adaptor

Layer / File(s) Summary
HTTP helpers & constants
src/adaptors/defindex/index.js
Adds axios/utils imports, DEFINDEX_API, STELLAR_DECIMALS, START_TIMESTAMP, and getWithRetry (GET with retries & exponential backoff).
Coin metadata mapping
src/adaptors/defindex/index.js
Adds fetchCoinData(assets) that queries coins.llama.fi for stellar:<asset> keys and returns lookup entries with price, symbol, and decimals (falls back to STELLAR_DECIMALS).
APY fetch & transform
src/adaptors/defindex/index.js
Adds apy(timestamp = null) which GETs /strategies/apy?timestamp=<ts>&network=mainnet, prefetches coin metadata for unique strategy assets, computes tvlUsd = strategy.tvl / 10^decimals * price, omits tvlUsd < 1, maps remaining strategies to objects with pool (lowercased <address>-stellar), chain: 'Stellar', project: 'defindex', symbol, tvlUsd, apyBase (from strategy.apy7d), underlyingTokens, and url, then filters via utils.keepFinite.
Module exports
src/adaptors/defindex/index.js
Exports timetravel: true, start: 1747281600, apy, and url: "https://www.defindex.io/strategies".

Sequence Diagram(s)

sequenceDiagram
  actor Caller
  participant Adaptor as Defindex Adaptor
  participant DefindexAPI as defindex API
  participant PricingAPI as coins.llama.fi

  Caller->>Adaptor: apy(timestamp?)
  Adaptor->>DefindexAPI: GET /strategies/apy?timestamp=<ts>&network=mainnet
  DefindexAPI-->>Adaptor: strategies list
  Adaptor->>Adaptor: extract unique assets
  Adaptor->>PricingAPI: GET /coins/markets?keys=stellar:<asset>,...
  PricingAPI-->>Adaptor: prices, symbols, decimals
  Adaptor->>Adaptor: compute tvlUsd (strategy.tvl / 10^decimals * price)
  Adaptor->>Adaptor: filter tvlUsd >= 1, build result objects
  Adaptor-->>Caller: array of strategy objects (pool, chain, project, symbol, tvlUsd, apyBase, underlyingTokens, url)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through endpoints near and far,
Fetched Stellar coins and each strategy's star,
I weighed their TVL and trimmed the small,
Lowercased pools and packaged them all,
Sent APYs back — a tidy haul! ✨

🚥 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 clearly summarizes the main change: adding a DeFindex protocol adaptor, which matches the changeset that introduces a new adaptor file for DeFindex with timetravel support and APY computation.
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.

@MattPoblete MattPoblete marked this pull request as ready for review March 25, 2026 17:08
Copilot AI review requested due to automatic review settings March 25, 2026 17:08

Copilot AI left a comment

Copy link
Copy Markdown

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 yield adapter for the DeFindex protocol on Stellar, fetching vault discovery data from DeFindex’s API and enriching it with USD TVL from DefiLlama coin prices.

Changes:

  • Added a new defindex adapter that pulls vaults from /vault/discover?network=mainnet.
  • Added DefiLlama coin-price lookup for Stellar assets and computes tvlUsd.
  • Returns per-vault pool objects including apyBase, tvlUsd, underlyingTokens, and metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/adaptors/defindex/index.js Outdated
Comment thread src/adaptors/defindex/index.js Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/defindex/index.js (1)

32-36: Hardcoded decimals assumption for all Stellar assets.

Using STELLAR_DECIMALS = 7 for all assets is standard for native Stellar assets (stroops), but custom tokens could potentially have different precision. The DefiLlama price API returns a decimals field per coin that's currently being discarded in fetchCoinData.

If all DeFindex vaults only hold standard Stellar assets, this is fine. Otherwise, consider capturing and using the decimals from the price API response.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adaptors/defindex/index.js` around lines 32 - 36, The TVL calculation
currently assumes a fixed STELLAR_DECIMALS when converting fund.total_amount to
human units; update the logic in the tvlUsd calculation to read a per-asset
decimals value from coinData (the decimals field returned by fetchCoinData) and
use that for the divisor (i.e., divide by 10 ** decimals), falling back to
STELLAR_DECIMALS if decimals is missing; also ensure fetchCoinData stores the
decimals for each coin so tvlUsd (and any other uses) can look up
coinData[asset].decimals instead of always using STELLAR_DECIMALS; reference
tvlUsd, vault.totalManagedFunds, coinData, and fetchCoinData when making the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/adaptors/defindex/index.js`:
- Line 50: The generated URL has a double slash because API_BASE_URL already
ends with '/' and the request builds `${API_BASE_URL}/vault/${vault.address}`;
fix by removing the extra slash when composing the URL (e.g., build it as
`${API_BASE_URL}vault/${vault.address}`) or normalize API_BASE_URL by trimming
its trailing slash before use so that the call that uses API_BASE_URL and
vault.address produces a single slash.
- Around line 55-59: The module currently exports url: API_BASE_URL which is a
URL object; change the export to a plain string so consumers can perform string
operations—replace the exported value in module.exports (the url property) with
a string version of API_BASE_URL (e.g., API_BASE_URL.toString() or
API_BASE_URL.href or the literal URL string) while leaving apy and timetravel
unchanged.

---

Nitpick comments:
In `@src/adaptors/defindex/index.js`:
- Around line 32-36: The TVL calculation currently assumes a fixed
STELLAR_DECIMALS when converting fund.total_amount to human units; update the
logic in the tvlUsd calculation to read a per-asset decimals value from coinData
(the decimals field returned by fetchCoinData) and use that for the divisor
(i.e., divide by 10 ** decimals), falling back to STELLAR_DECIMALS if decimals
is missing; also ensure fetchCoinData stores the decimals for each coin so
tvlUsd (and any other uses) can look up coinData[asset].decimals instead of
always using STELLAR_DECIMALS; reference tvlUsd, vault.totalManagedFunds,
coinData, and fetchCoinData when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3c3760ba-8b70-4ee8-897c-a8e351277c19

📥 Commits

Reviewing files that changed from the base of the PR and between 2174e93 and 71bb2de.

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

Comment thread src/adaptors/defindex/index.js Outdated
Comment thread src/adaptors/defindex/index.js
- Convert API_BASE_URL from URL object to plain string to fix double-slash
  in vault URLs and ensure module.exports.url is a string
- Store per-asset decimals from coins API response and use them in TVL
  calculation instead of always assuming STELLAR_DECIMALS=7
@llamatester

Copy link
Copy Markdown

The defindex adapter exports pools:

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

Nb of pools: 9
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────────────┬───────────┬────────────┬──────────┬────────────────────┬─────────┬────────────────────────────────────────────────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────┐
│ (index) │ pool                                                               │ chain     │ project    │ symbol   │ tvlUsd             │ apyBase │ underlyingTokens                                               │ url                                                                                      │
├─────────┼────────────────────────────────────────────────────────────────────┼───────────┼────────────┼──────────┼────────────────────┼─────────┼────────────────────────────────────────────────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
│ 0       │ 'cbnkcu3hgfkhfof7jtgxqcnke3g3dxs5rdbqukqmiiecykxpiougb2s3-stellar' │ 'Stellar' │ 'defindex' │ 'USDC'   │ 731672.8858105234  │ 8.67    │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://api.defindex.io/vault/CBNKCU3HGFKHFOF7JTGXQCNKE3G3DXS5RDBQUKQMIIECYKXPIOUGB2S3' │
│ 1       │ 'caiz3nmnpen5sqisjv7pd2yy6ni6dipfa4pcrubogde4i7a3dxdlk5oi-stellar' │ 'Stellar' │ 'defindex' │ 'EURC'   │ 181399.8105684247  │ 8.84    │ [ 'CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV' ] │ 'https://api.defindex.io/vault/CAIZ3NMNPEN5SQISJV7PD2YY6NI6DIPFA4PCRUBOGDE4I7A3DXDLK5OI' │
│ 2       │ 'ca2fipj7u6bg3n7eozfi74xpjzoeod4tywxfvcio5vdchtvags6f4ukk-stellar' │ 'Stellar' │ 'defindex' │ 'USDC'   │ 91272.0624143639   │ 7.63    │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://api.defindex.io/vault/CA2FIPJ7U6BG3N7EOZFI74XPJZOEOD4TYWXFVCIO5VDCHTVAGS6F4UKK' │
│ 3       │ 'cbujzl5qad5topd7jmcbq3rhr6rzwy34a4qf7uhiltdh2jf2z3vjgy2y-stellar' │ 'Stellar' │ 'defindex' │ 'USDC'   │ 23665.631912939858 │ 7.65    │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://api.defindex.io/vault/CBUJZL5QAD5TOPD7JMCBQ3RHR6RZWY34A4QF7UHILTDH2JF2Z3VJGY2Y' │
│ 4       │ 'ccdrfmz7ch364atq5ysvtej3g3kpnfvm6ttc6n4t5rehwjs6lgvfp7my-stellar' │ 'Stellar' │ 'defindex' │ 'USDC'   │ 16411.269987528747 │ 7.45    │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://api.defindex.io/vault/CCDRFMZ7CH364ATQ5YSVTEJ3G3KPNFVM6TTC6N4T5REHWJS6LGVFP7MY' │
│ 5       │ 'cc767wiu5qgjmxyhddyjajef2ywphoxozdwd3uuazvs4kqprxckpt2yz-stellar' │ 'Stellar' │ 'defindex' │ 'USDC'   │ 10326.144070762239 │ 7.4     │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://api.defindex.io/vault/CC767WIU5QGJMXYHDDYJAJEF2YWPHOXOZDWD3UUAZVS4KQPRXCKPT2YZ' │
│ 6       │ 'cd4jgs6bb5nzvsnkrni43guc6e3obylclbqzjvtzldvhq5kdaohvoiqf-stellar' │ 'Stellar' │ 'defindex' │ 'USDC'   │ 4180.5243064249635 │ -50.35  │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://api.defindex.io/vault/CD4JGS6BB5NZVSNKRNI43GUC6E3OBYLCLBQZJVTZLDVHQ5KDAOHVOIQF' │
│ 7       │ 'ccktldg6i2mmjckfwxxbxma42lj3xn2iow6m7tk6ewnpjts736etff2n-stellar' │ 'Stellar' │ 'defindex' │ 'EURC'   │ 2080.73584721694   │ -21.14  │ [ 'CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV' ] │ 'https://api.defindex.io/vault/CCKTLDG6I2MMJCKFWXXBXMA42LJ3XN2IOW6M7TK6EWNPJTS736ETFF2N' │
│ 8       │ 'cc24oisyjhwxzifzbrjhflvo5cnn3pqskze5bbbzlssi5z23tkc6gqy2-stellar' │ 'Stellar' │ 'defindex' │ 'CAL6ER' │ 0                  │ 0       │ [ 'CAL6ER2TI6CTRAY6BFXWNWA7WTYXUXTQCHUBCIBU5O6KM3HJFG6Z6VXV' ] │ 'https://api.defindex.io/vault/CC24OISYJHWXZIFZBRJHFLVO5CNN3PQSKZE5BBBZLSSI5Z23TKC6GQY2' │
└─────────┴────────────────────────────────────────────────────────────────────┴───────────┴────────────┴──────────┴────────────────────┴─────────┴────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@MattPoblete MattPoblete changed the title feat(defindex): add DeFindex protocol adaptor ✨ Add DeFindex protocol adaptor Mar 27, 2026

@0xkr3p 0xkr3p left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hey @MattPoblete, thanks for the PR just a couple of minor changes. Additionally, can you use the keepFinite filter on the pools?

Comment thread src/adaptors/defindex/index.js Outdated
Comment thread src/adaptors/defindex/index.js Outdated
Replace vault/discover with strategies/apy endpoint, add timetravel
support with start timestamp, and filter pools with tvlUsd < 1.
@MattPoblete MattPoblete marked this pull request as draft April 18, 2026 22:43

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/adaptors/defindex/index.js (1)

7-19: Minor: consider reusing utils.getPrices and guarding empty input.

Other adaptors use the shared exports.getPrices helper in src/adaptors/utils.js for coins.llama.fi lookups, which already handles the chain:address keying and response parsing. Reusing it would reduce duplication. Also, if assets is ever empty, the request URL becomes https://coins.llama.fi/prices/current/ (trailing slash, empty keys) and may 404; a short-circuit if (!assets.length) return {}; would make this robust independent of the caller's guard on line 28.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adaptors/defindex/index.js` around lines 7 - 19, The fetchCoinData
function should short-circuit when given no assets and reuse the shared
getPrices helper to avoid duplication: add an early guard in fetchCoinData
(e.g., if (!assets || !assets.length) return {}) and replace the manual axios
call/response parsing with a call to the shared exports.getPrices (from
src/adaptors/utils.js) so keys are constructed as chain:address and the response
is parsed consistently; update fetchCoinData to map assets -> keys, call
getPrices('stellar', keys) (or equivalent exported function name), and return
the normalized address -> {price,symbol,decimals} result expected by callers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/adaptors/defindex/index.js`:
- Around line 24-28: Replace the broken GET to
`${API_BASE_URL}/strategies/apy?timestamp=${ts}&network=mainnet` with a request
to `${API_BASE_URL}/vault/discover?network=mainnet`, remove the `ts`/timestamp
param, and then map the returned payload's `vaults` array to the code paths that
previously used `strategies`; specifically, replace uses of `strategies` with
`vaults`, use each vault's top-level numeric `apy` instead of `strategy.apy7d`,
and compute TVL by aggregating `vault.totalManagedFunds[].total_amount` (or
picking the appropriate total_amount entry) in place of `strategy.tvl`; also
update the existence check from `if (!strategies.length)` to check
`vaults.length` so the function returns [] when no vaults are returned.
- Line 48: The adapter assigns apyBase from strategy.apy7d but other adaptors
convert 7-day APY to percentage by multiplying by 100, so confirm whether
strategy.apy7d from DeFindex is already a percent; if it's a fraction (e.g.,
0.05) change the assignment to multiply by 100 (replace apyBase: strategy.apy7d
with apyBase: strategy.apy7d * 100) and ensure any negative strategy.apy7d
values are accepted only if they represent real losses (add validation or a
comment in the code near apyBase/strategy.apy7d to document the expected unit
and handle/normalize unexpected values).
- Line 50: The current per-strategy frontend URL uses Stellar Expert (`url:
\`https://stellar.expert/explorer/public/contract/${strategy.address}\``) but
the reviewer flagged this as incorrect for DeFindex and also noted line 59
should point to `https://www.defindex.io/vaults` (not `/strategies`); confirm
the correct DeFindex frontend pattern with the DeFindex team and then update the
URL assignment where `url` is set (using `strategy.address`) to the validated
per-strategy DeFindex route (e.g., change to
`https://www.defindex.io/vaults/${strategy.address}` only if confirmed), and
similarly replace any `/strategies` endpoint occurrences with `/vaults` if that
is the agreed route.

---

Nitpick comments:
In `@src/adaptors/defindex/index.js`:
- Around line 7-19: The fetchCoinData function should short-circuit when given
no assets and reuse the shared getPrices helper to avoid duplication: add an
early guard in fetchCoinData (e.g., if (!assets || !assets.length) return {})
and replace the manual axios call/response parsing with a call to the shared
exports.getPrices (from src/adaptors/utils.js) so keys are constructed as
chain:address and the response is parsed consistently; update fetchCoinData to
map assets -> keys, call getPrices('stellar', keys) (or equivalent exported
function name), and return the normalized address -> {price,symbol,decimals}
result expected by callers.
🪄 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: 74cb4374-54d6-4e58-b8c0-286355ef14e6

📥 Commits

Reviewing files that changed from the base of the PR and between 5aca39b and 1a2aff4.

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

Comment thread src/adaptors/defindex/index.js Outdated
project: 'defindex',
symbol,
tvlUsd,
apyBase: strategy.apy7d,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect a sample payload to see the magnitude/shape of apy7d.
TS=$(date +%s)
curl -s "https://api.defindex.io/strategies/apy?timestamp=${TS}&network=mainnet" \
  | python3 -c "import sys,json; d=json.load(sys.stdin); print(json.dumps(d[:3] if isinstance(d,list) else d, indent=2))"

Repository: DefiLlama/yield-server

Length of output: 193


🏁 Script executed:

cat -n src/adaptors/defindex/index.js | head -80

Repository: DefiLlama/yield-server

Length of output: 2376


🏁 Script executed:

# Search for apy7d usage and related context
rg "apy7d" -B 3 -A 3

Repository: DefiLlama/yield-server

Length of output: 34306


🏁 Script executed:

# Check if there are any transformations or calculations on apy values
rg "apyBase" -B 2 -A 2 | head -50

Repository: DefiLlama/yield-server

Length of output: 2367


🏁 Script executed:

# Look for test files or sample data
fd -e "test\|spec\|json" | grep -i defindex

Repository: DefiLlama/yield-server

Length of output: 48


🏁 Script executed:

# Look for DeFindex documentation or tests
find . -path ./node_modules -prune -o -type f \( -name "*defindex*" -o -name "*test*" -o -name "*spec*" \) -print | grep -i defindex

Repository: DefiLlama/yield-server

Length of output: 48


🏁 Script executed:

# Check for any comments or documentation about defindex apy format
rg "defindex|DeFindex" -i -B 2 -A 2 --type md --type txt

Repository: DefiLlama/yield-server

Length of output: 48


🏁 Script executed:

# Search for negative APY mentions
rg "negative|apy.*-|negative.*apy" -i | grep -i defindex

Repository: DefiLlama/yield-server

Length of output: 48


🏁 Script executed:

# Check if there are any GitHub issues or comments about the defindex format
find . -name "*.md" -o -name "*.txt" | xargs grep -l -i "defindex" 2>/dev/null

Repository: DefiLlama/yield-server

Length of output: 50


🏁 Script executed:

# Search for any PR comments, commit messages, or issues mentioning defindex format
git log --all --oneline --grep="defindex" -i 2>/dev/null | head -20

Repository: DefiLlama/yield-server

Length of output: 138


🏁 Script executed:

# Check if there's a changelog or updates file
find . -type f \( -name "CHANGELOG*" -o -name "CHANGES*" -o -name "NEWS*" \) | xargs grep -i defindex 2>/dev/null

Repository: DefiLlama/yield-server

Length of output: 50


🏁 Script executed:

# Look at git history of the defindex file itself
git log --oneline src/adaptors/defindex/index.js 2>/dev/null | head -10

Repository: DefiLlama/yield-server

Length of output: 138


🏁 Script executed:

# Check if robo-vault provides clues (it multiplies by 100)
cat -n src/adaptors/robo-vault/index.js | grep -B 10 -A 5 "apy7d \* 100"

Repository: DefiLlama/yield-server

Length of output: 607


🏁 Script executed:

# Check the actual commit to see what changed
git show 1a2aff49 --stat 2>/dev/null | head -30

Repository: DefiLlama/yield-server

Length of output: 1740


🏁 Script executed:

# Get the diff for that commit to understand the strategy API change
git show 1a2aff49 -- src/adaptors/defindex/index.js 2>/dev/null | head -100

Repository: DefiLlama/yield-server

Length of output: 2580


🏁 Script executed:

# Check if there are any comments in the PR or related issues
git log -p 1a2aff49 -- src/adaptors/defindex/index.js 2>/dev/null | grep -A 20 -B 5 "apy7d\|apy\|strategy" | head -80

Repository: DefiLlama/yield-server

Length of output: 48


Confirm that apy7d units match DefiLlama's percentage format (not fraction).

The codebase pattern shows that other adaptors explicitly multiply by 100 (e.g., robo-vault: item.apy7d * 100, nest-credit: Number(apy7dSrc) * 100, hydro-inflow: result.avg_7_days * 100). If the DeFindex API returns apy7d as a decimal fraction (e.g., 0.05 for 5%), the current code will record it as 0.05 instead of 5, resulting in APY values 100× too small. Either verify that the API already returns percentages, or apply the * 100 transformation to match the codebase pattern. Also confirm whether negative apy7d values reflect genuine realized losses or indicate a data format issue.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/adaptors/defindex/index.js` at line 48, The adapter assigns apyBase from
strategy.apy7d but other adaptors convert 7-day APY to percentage by multiplying
by 100, so confirm whether strategy.apy7d from DeFindex is already a percent; if
it's a fraction (e.g., 0.05) change the assignment to multiply by 100 (replace
apyBase: strategy.apy7d with apyBase: strategy.apy7d * 100) and ensure any
negative strategy.apy7d values are accepted only if they represent real losses
(add validation or a comment in the code near apyBase/strategy.apy7d to document
the expected unit and handle/normalize unexpected values).

Comment thread src/adaptors/defindex/index.js Outdated
@MattPoblete MattPoblete marked this pull request as ready for review May 8, 2026 14:17
@github-actions

Copy link
Copy Markdown

The defindex adapter exports pools:

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

Nb of pools: 4
 

Sample pools:
┌─────────┬────────────────────────────────────────────────────────────────────┬───────────┬────────────┬────────┬────────────────────┬─────────────────────┬────────────────────────────────────────────────────────────────┬──────────────────────────────────────┐
│ (index) │ pool                                                               │ chain     │ project    │ symbol │ tvlUsd             │ apyBase             │ underlyingTokens                                               │ url                                  │
├─────────┼────────────────────────────────────────────────────────────────────┼───────────┼────────────┼────────┼────────────────────┼─────────────────────┼────────────────────────────────────────────────────────────────┼──────────────────────────────────────┤
│ 0       │ 'cdb2wmkqqnvzmeby7q7gz5c7e7iafsnmz7ggvd6wktcewk7xoiavzsap-stellar' │ 'Stellar' │ 'defindex' │ 'USDC' │ 1023113.1287161862 │ 9.146720305476563   │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://www.defindex.io/strategies' │
│ 1       │ 'cc5ce6mwisdxt3mlnq7r3fvilfvfeih3cowgh45gjkl6bd2zhf7f7jvi-stellar' │ 'Stellar' │ 'defindex' │ 'EURC' │ 229041.83086693622 │ 9.324999622537478   │ [ 'CDTKPWPLOURQA2SGTKTUQOWRCBZEORB4BWBOMJ3D3ZTQQSGE5F6JBQLV' ] │ 'https://www.defindex.io/strategies' │
│ 2       │ 'ccsrx5e4337qmcmc3ko3rdfyi57t5nzv5xb3w3twe4uscaskgl5urkjl-stellar' │ 'Stellar' │ 'defindex' │ 'USDC' │ 26.047604241222857 │ 0                   │ [ 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75' ] │ 'https://www.defindex.io/strategies' │
│ 3       │ 'cdpwnuw7umcsvo36vajsqhqecispjlcvpdaskhrc5seroaazduq5dg2z-stellar' │ 'Stellar' │ 'defindex' │ 'XLM'  │ 15.477533314009655 │ 0.09549003029878378 │ [ 'CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA' ] │ 'https://www.defindex.io/strategies' │
└─────────┴────────────────────────────────────────────────────────────────────┴───────────┴────────────┴────────┴────────────────────┴─────────────────────┴────────────────────────────────────────────────────────────────┴──────────────────────────────────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@0xkr3p

0xkr3p commented May 11, 2026

Copy link
Copy Markdown
Contributor

hi @MattPoblete, thanks for the changes. How can users deploy into the pools? I can't seem to find anywhere to deposit on https://www.defindex.io/strategies

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.

4 participants