Skip to content

Addin yPrism and v3 api#2322

Merged
0xkr3p merged 3 commits intoDefiLlama:masterfrom
neelra8n:master
Feb 2, 2026
Merged

Addin yPrism and v3 api#2322
0xkr3p merged 3 commits intoDefiLlama:masterfrom
neelra8n:master

Conversation

@neelra8n
Copy link
Contributor

@neelra8n neelra8n commented Jan 30, 2026

Added support for tracking Prism token across Ethereum mainnet and Layer 2 networks (bsc).
Updated api endpoint for fetching apy

NOTE: Please update the price feed for yPrism

Summary by CodeRabbit

  • New Features

    • Added Prism (yPrism) pool support across Ethereum, Base, Arbitrum, and BSC
    • Updated public link to the Prism vaults page
  • Improvements

    • Consolidated APY retrieval to a single unified source for more reliable rates
    • Improved handling when APY data is missing
    • Refined chain-specific pool processing logic and flow

✏️ Tip: You can customize this high-level summary in your review settings.

@neelra8n neelra8n changed the title Addin yPrism and v3 apis Addin yPrism and v3 api Jan 30, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

The adaptor now uses a single Vaults API to read APY (from data.data.vault.metrics.apy), converts it to percentage, adds error checks for missing APY, and integrates Prism (yPrism) into pool generation with chain-specific handling for Ethereum, Base, Arbitrum, and BSC. URL export updated to the vaults/yprism page.

Changes

Cohort / File(s) Summary
Yield.fi adaptor core
src/adaptors/yieldfi/index.js
Replaces multiple APY endpoints with a single Vaults API (gw.yield.fi), extracts APY from data.data.vault.metrics.apy and scales to percentage, adds error handling for missing APY, introduces YPRISM_CONTRACTS and integrates yPrism/Prism into pool generation across chains, adjusts chain-specific pool logic (Ethereum, Base, Arbitrum, BSC), and updates exported URL to https://yield.fi/vaults/yprism.

Sequence Diagram(s)

sequenceDiagram
  participant Adapter as "Adaptor (yieldfi)"
  participant VaultAPI as "Vaults API (gw.yield.fi)"
  participant ChainProc as "Chain Processors\n(Ethereum, Base, Arbitrum, BSC)"
  participant Output as "Pools Output"

  rect rgba(100,149,237,0.5)
  Adapter->>VaultAPI: GET /vaults/{vaultId} (fetch vault data)
  VaultAPI-->>Adapter: 200 OK with data.data.vault.metrics.apy
  end

  rect rgba(60,179,113,0.5)
  Adapter->>Adapter: extract APY, convert decimal→percentage\nvalidate APY present
  Adapter->>ChainProc: send vault + APY + contract mappings (YUSD, yPrism, vy*)
  end

  rect rgba(255,165,0,0.5)
  ChainProc->>ChainProc: apply chain-specific logic\ninclude/exclude yPrism per chain
  ChainProc-->>Output: emit generated pool entries
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble code and chase a light,
Prism petals glinting in the night,
APYs gathered from a single stream,
Chains align to join the dream,
Vaults now hum — a rabbit's delight. 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Addin yPrism and v3 api' is directly related to the main changes in the pull request, which add yPrism token support and update to the v3 API endpoint for APY fetching.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@llamatester
Copy link

The yieldfi adapter exports pools:

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

Nb of pools: 36
 

Sample pools:
┌─────────┬───────────────────────────────────────────────────────┬────────────┬───────────┬─────────┬─────────────┬─────────┐
│ (index) │ pool                                                  │ chain      │ project   │ symbol  │ tvlUsd      │ apyBase │
├─────────┼───────────────────────────────────────────────────────┼────────────┼───────────┼─────────┼─────────────┼─────────┤
│ 0       │ '0x19Ebd191f7A24ECE672ba13A302212b5eF7F35cb-ethereum' │ 'ethereum' │ 'yieldfi' │ 'YUSD'  │ 10696385.99 │ 1.39    │
│ 1       │ '0x2e3C5e514EEf46727DE1FE44618027A9b70D92FC-ethereum' │ 'ethereum' │ 'yieldfi' │ 'VYUSD' │ 2958332.14  │ 1.46    │
│ 2       │ '0x8464F6eCAe1EA58EC816C13f964030eAb8Ec123A-ethereum' │ 'ethereum' │ 'yieldfi' │ 'YETH'  │ 2154993.44  │ 0.68    │
│ 3       │ '0x3073112c2c4800b89764973d5790ccc7fba5c9f9-ethereum' │ 'ethereum' │ 'yieldfi' │ 'VYETH' │ 1767634.41  │ 0.7     │
│ 4       │ '0xa01200b2e74DE6489cF56864E3d76BBc06fc6C43-ethereum' │ 'ethereum' │ 'yieldfi' │ 'YBTC'  │ 1305556.78  │ 0.63    │
│ 5       │ '0x1e2a5622178f93EFd4349E2eB3DbDF2761749e1B-ethereum' │ 'ethereum' │ 'yieldfi' │ 'VYBTC' │ 859851.13   │ 0.64    │
│ 6       │ '0xF4F447E6AFa04c9D11Ef0e2fC0d7f19C24Ee55de-arbitrum' │ 'arbitrum' │ 'yieldfi' │ 'VYUSD' │ 165836.42   │ 1.46    │
│ 7       │ '0x4772D2e014F9fC3a820C444e3313968e9a5C8121-base'     │ 'base'     │ 'yieldfi' │ 'YUSD'  │ 115318.58   │ 1.39    │
│ 8       │ '0xF4F447E6AFa04c9D11Ef0e2fC0d7f19C24Ee55de-base'     │ 'base'     │ 'yieldfi' │ 'VYUSD' │ 93613.61    │ 1.46    │
│ 9       │ '0x8c93a6752Bfe29FDA26EbA8df4390c642e6A7f90-arbitrum' │ 'arbitrum' │ 'yieldfi' │ 'VYETH' │ 74113.99    │ 0.7     │
└─────────┴───────────────────────────────────────────────────────┴────────────┴───────────┴─────────┴─────────────┴─────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

Copy link

@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 `@src/adaptors/yieldfi/index.js`:
- Around line 92-100: The code currently assumes data.data.vault.metrics.apy
exists and is a scalar, causing TypeErrors on unexpected responses and
misdocumenting an array; replace the direct access with a null-safe lookup using
optional chaining (e.g., data?.data?.vault?.metrics?.apy) and then normalize
_apy: if it's an array use the first element, if it's a number use it directly;
if missing, log the tokenSymbol and return 0; finally compute latestAPY =
normalizedApy * 100. Make these changes around the variables data, _apy, and
latestAPY in the fetch/response handling block.
- Around line 205-216: The current conditional only processes yETH/vyETH for
'arbitrum' and 'base', but YETH_CONTRACTS contains a 'saga' entry (and saga is
used elsewhere like YUSD_CONTRACTS); update the logic in the block that calls
processToken so that 'saga' is handled: call processToken for
YETH_CONTRACTS['saga'] with token id 'yETH' and chain 'saga'; for vyETH only
call processToken(VYETH_CONTRACTS['saga'], 'vyETH', 'saga') if VYETH_CONTRACTS
has a saga entry (guard on VYETH_CONTRACTS[chain]) or add a clarifying comment
if vyETH support is intentionally missing. Ensure you reference YETH_CONTRACTS,
VYETH_CONTRACTS and processToken when making the change.
🧹 Nitpick comments (1)
src/adaptors/yieldfi/index.js (1)

235-235: Consider using a more general URL.

The exported URL now points specifically to the yPrism vault, but this adaptor serves multiple tokens (yUSD, vyUSD, yETH, vyETH, yBTC, vyBTC, yPrism). A more general URL like https://yield.fi/vaults might better represent the full scope of pools.

Comment on lines 92 to 100
const data = await response.json();
const apyHistory = data.apy_history;

if (!apyHistory || !Array.isArray(apyHistory) || apyHistory.length === 0) {
const _apy = data.data.vault.metrics.apy;
if (!_apy) {
console.error(`No APY history data found for ${tokenSymbol}`);
return 0;
}

// Get the latest APY (first entry in the array is the most recent)
const latestAPY = apyHistory[0].apy;

console.log(`${tokenSymbol} latest APY: ${latestAPY.toFixed(2)}%`);
const latestAPY = _apy * 100;
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add null-safe access to prevent runtime errors on unexpected API responses.

If the API returns an unexpected structure (e.g., missing vault or metrics), accessing data.data.vault.metrics.apy will throw a TypeError before the error handler catches it. Also, the comment on line 99 mentions "first entry in the array" but _apy is used as a scalar value.

🛡️ Proposed fix with optional chaining
     const data = await response.json();
-    const _apy = data.data.vault.metrics.apy;
+    const _apy = data?.data?.vault?.metrics?.apy;
     if (!_apy) {
       console.error(`No APY history data found for ${tokenSymbol}`);
       return 0;
     }

-    // Get the latest APY (first entry in the array is the most recent)
+    // Convert APY from decimal to percentage
     const latestAPY = _apy * 100;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const data = await response.json();
const apyHistory = data.apy_history;
if (!apyHistory || !Array.isArray(apyHistory) || apyHistory.length === 0) {
const _apy = data.data.vault.metrics.apy;
if (!_apy) {
console.error(`No APY history data found for ${tokenSymbol}`);
return 0;
}
// Get the latest APY (first entry in the array is the most recent)
const latestAPY = apyHistory[0].apy;
console.log(`${tokenSymbol} latest APY: ${latestAPY.toFixed(2)}%`);
const latestAPY = _apy * 100;
const data = await response.json();
const _apy = data?.data?.vault?.metrics?.apy;
if (!_apy) {
console.error(`No APY history data found for ${tokenSymbol}`);
return 0;
}
// Convert APY from decimal to percentage
const latestAPY = _apy * 100;
🤖 Prompt for AI Agents
In `@src/adaptors/yieldfi/index.js` around lines 92 - 100, The code currently
assumes data.data.vault.metrics.apy exists and is a scalar, causing TypeErrors
on unexpected responses and misdocumenting an array; replace the direct access
with a null-safe lookup using optional chaining (e.g.,
data?.data?.vault?.metrics?.apy) and then normalize _apy: if it's an array use
the first element, if it's a number use it directly; if missing, log the
tokenSymbol and return 0; finally compute latestAPY = normalizedApy * 100. Make
these changes around the variables data, _apy, and latestAPY in the
fetch/response handling block.

@llamatester
Copy link

The yieldfi adapter exports pools:

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

Nb of pools: 37
 

Sample pools:
┌─────────┬───────────────────────────────────────────────────────┬────────────┬───────────┬─────────┬─────────────┬─────────┐
│ (index) │ pool                                                  │ chain      │ project   │ symbol  │ tvlUsd      │ apyBase │
├─────────┼───────────────────────────────────────────────────────┼────────────┼───────────┼─────────┼─────────────┼─────────┤
│ 0       │ '0x19Ebd191f7A24ECE672ba13A302212b5eF7F35cb-ethereum' │ 'ethereum' │ 'yieldfi' │ 'YUSD'  │ 10696653.91 │ 1.46    │
│ 1       │ '0x2e3C5e514EEf46727DE1FE44618027A9b70D92FC-ethereum' │ 'ethereum' │ 'yieldfi' │ 'VYUSD' │ 2958429.94  │ 1.54    │
│ 2       │ '0x8464F6eCAe1EA58EC816C13f964030eAb8Ec123A-ethereum' │ 'ethereum' │ 'yieldfi' │ 'YETH'  │ 2160886.71  │ 0.72    │
│ 3       │ '0x3073112c2c4800b89764973d5790ccc7fba5c9f9-ethereum' │ 'ethereum' │ 'yieldfi' │ 'VYETH' │ 1772467.79  │ 0.74    │
│ 4       │ '0xa01200b2e74DE6489cF56864E3d76BBc06fc6C43-ethereum' │ 'ethereum' │ 'yieldfi' │ 'YBTC'  │ 1312011.36  │ 0.68    │
│ 5       │ '0x1e2a5622178f93EFd4349E2eB3DbDF2761749e1B-ethereum' │ 'ethereum' │ 'yieldfi' │ 'VYBTC' │ 864102.33   │ 0.69    │
│ 6       │ '0xF4F447E6AFa04c9D11Ef0e2fC0d7f19C24Ee55de-arbitrum' │ 'arbitrum' │ 'yieldfi' │ 'VYUSD' │ 165841.09   │ 1.54    │
│ 7       │ '0x4772D2e014F9fC3a820C444e3313968e9a5C8121-base'     │ 'base'     │ 'yieldfi' │ 'YUSD'  │ 115326.39   │ 1.46    │
│ 8       │ '0xF4F447E6AFa04c9D11Ef0e2fC0d7f19C24Ee55de-base'     │ 'base'     │ 'yieldfi' │ 'VYUSD' │ 93616.25    │ 1.54    │
│ 9       │ '0x8c93a6752Bfe29FDA26EbA8df4390c642e6A7f90-arbitrum' │ 'arbitrum' │ 'yieldfi' │ 'VYETH' │ 74319.05    │ 0.74    │
└─────────┴───────────────────────────────────────────────────────┴────────────┴───────────┴─────────┴─────────────┴─────────┘
This adapter contains some pools with <10k TVL, these pools won't be shown in DefiLlama

@0xkr3p 0xkr3p merged commit d19f923 into DefiLlama:master Feb 2, 2026
2 checks passed
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.

3 participants