Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/adaptors/yo-protocol/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
const superagent = require('superagent');
const {
formatChain,
getPrices,
getERC4626Info,
} = require('../utils');
const { formatChain, getPrices, getERC4626Info } = require('../utils');
const { getVaultReward } = require('./services');

const PROJECT_NAME = 'yo-protocol';
const API_URL = 'https://api.yo.xyz/api/v1/vault/stats';
const MERKL_API_URL =
'https://api.merkl.xyz/v4/opportunities/?creatorAddress=0xd7A77013933A97A2c08dad7d59937119E76C879a&status=LIVE&chainName=Base';
'https://api.merkl.xyz/v4/opportunities/?creatorAddress=0x8C9200d94Cf7A1B201068c4deDa6239F15FED480&status=LIVE';
const symboToNameMap = {
yoETH: 'Yield Optimizer ETH',
yoBTC: 'Yield Optimizer BTC',
yoUSD: 'Yield Optimizer USD',
yoEUR: 'Yield Optimizer EUR',
yoGOLD: 'Yield Optimizer GOLD',
};

const apy = async () => {
Expand Down Expand Up @@ -74,7 +71,7 @@ const apy = async () => {
url: `https://app.yo.xyz/vault/base/${vault.contracts.vaultAddress}`,
...(vaultReward && {
apyReward: Number(vaultReward.apr),
rewardTokens: [vault.asset.address],
rewardTokens: ['0x1925450f5e5fb974b0aae1f3408cf5286fbd1a72'],
}),
Comment on lines 72 to 75
Copy link

@coderabbitai coderabbitai bot Jan 29, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Inspect reward token fields in Merkl payload (if present)
curl -s 'https://api.merkl.xyz/v4/opportunities/?creatorAddress=0x8C9200d94Cf7A1B201068c4deDa6239F15FED480&status=LIVE' \
  | jq '.[0] | {identifier, rewardTokens, rewardToken, chainId}'

Repository: DefiLlama/yield-server

Length of output: 196


🏁 Script executed:

# Examine the code context around lines 72-75
head -85 src/adaptors/yo-protocol/index.js | tail -25

Repository: DefiLlama/yield-server

Length of output: 690


🏁 Script executed:

# Check if there are multiple chains referenced in this adaptor
grep -n "chainId\|chain\|Chain" src/adaptors/yo-protocol/index.js | head -20

Repository: DefiLlama/yield-server

Length of output: 283


🏁 Script executed:

# Look for other hardcoded token references in the file
grep -n "0x" src/adaptors/yo-protocol/index.js

Repository: DefiLlama/yield-server

Length of output: 255


🏁 Script executed:

# Look for vaultReward assignment and how it's obtained
grep -B 10 -A 5 "vaultReward" src/adaptors/yo-protocol/index.js | head -40

Repository: DefiLlama/yield-server

Length of output: 1223


🏁 Script executed:

# Get full details of multiple opportunities from Merkl API
curl -s 'https://api.merkl.xyz/v4/opportunities/?creatorAddress=0x8C9200d94Cf7A1B201068c4deDa6239F15FED480&status=LIVE' \
  | jq '.[] | {identifier, chainId, rewardTokens, rewardToken}' | head -60

Repository: DefiLlama/yield-server

Length of output: 1360


🏁 Script executed:

# Check if there are any environment or config files that might map tokens
find src/adaptors/yo-protocol -type f -name "*.js" -o -name "*.json" | xargs cat

Repository: DefiLlama/yield-server

Length of output: 3258


The hardcoded reward token should be obtained from the opportunity data or clearly documented as a fallback.

The token '0x1925450f5e5fb974b0aae1f3408cf5286fbd1a72' is hardcoded at line 74 for all opportunities and chains, despite processing multiple vaults dynamically. The Merkl API response contains no reward token information (all rewardTokens and rewardToken fields are null), so this token is applied uniformly regardless of chain or opportunity configuration. If reward tokens differ by chain or opportunity, this will incorrectly label rewards across the board.

🤖 Prompt for AI Agents
In `@src/adaptors/yo-protocol/index.js` around lines 72 - 75, The code is
hardcoding rewardTokens to '0x1925450f5e5fb974b0aae1f3408cf5286fbd1a72' when
building the object (see vaultReward, apyReward, rewardTokens), which mislabels
rewards for other chains/opportunities; change the logic to first read reward
token(s) from the opportunity/vault data (check fields like
opportunity.rewardTokens, opportunity.rewardToken, vaultReward.*) and use those
if present, otherwise fall back to a documented chain-specific constant or null;
update the construction that spreads ...(vaultReward && { apyReward:
Number(vaultReward.apr), rewardTokens: [...] }) to derive rewardTokens from the
opportunity/vaultReward data or from a clearly named fallback constant so it’s
not silently hardcoded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we use only 1 token for reward distribution - 0x1925450f5e5fb974b0aae1f3408cf5286fbd1a72 thats why it's hardcoded

Copy link

Choose a reason for hiding this comment

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

@AndonMitev, thank you for the clarification! That makes sense – if yo-protocol uses a single reward token (0x1925450f5e5fb974b0aae1f3408cf5286fbd1a72) for all reward distributions across all vaults, then hardcoding it is the correct approach. I've noted this for future reviews.


✏️ Learnings added
Learnt from: AndonMitev
Repo: DefiLlama/yield-server PR: 2316
File: src/adaptors/yo-protocol/index.js:72-75
Timestamp: 2026-01-29T16:48:52.786Z
Learning: In src/adaptors/yo-protocol/index.js, the reward token address 0x1925450f5e5fb974b0aae1f3408cf5286fbd1a72 is intentionally hardcoded because yo-protocol uses only one token for reward distribution across all vaults and chains.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

};

Expand Down
8 changes: 7 additions & 1 deletion src/adaptors/yo-protocol/services.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const superagent = require('superagent');

const YOGOLD_ADDRESS = '0x586675a3a46b008d8408933cf42d8ff6c9cc61a1';

exports.getVaultReward = async (url) => {
const response = (await superagent.get(url)).body;

Expand All @@ -14,7 +16,11 @@ exports.getVaultReward = async (url) => {
response
.filter(
(opportunity) =>
opportunity.status === 'LIVE' && typeof opportunity.apr === 'number'
opportunity.status === 'LIVE' &&
typeof opportunity.apr === 'number' &&
opportunity.type !== 'INVALID' &&
(opportunity.chainId !== 1 ||
opportunity.identifier.toLowerCase() === YOGOLD_ADDRESS)
)
.forEach((opportunity) => {
vaultRewardMap.set(opportunity.identifier.toLowerCase(), opportunity);
Expand Down
Loading