Conversation
📝 WalkthroughWalkthroughA new adapter for Blackhole CLMM on Avalanche is introduced. It fetches pool data from a subgraph, resolves on-chain balances and token prices, computes APY and volume metrics, and returns a consolidated list of pool objects with detailed financial data. Changes
Sequence DiagramsequenceDiagram
participant Main as Main Orchestrator
participant GA as getGaugeApy
participant GV as getPoolVolumes
participant SG as Subgraph
participant GM as GaugeManager
participant OC as On-Chain RPC
participant TP as Token Pricing
Main->>GA: Fetch gauge APY data
GA->>SG: Query liquidity pools
SG-->>GA: Pool data returned
GA->>GM: Resolve gauge addresses
GM->>OC: Contract calls
OC-->>GM: Gauge addresses
GM-->>GA: Addresses resolved
GA->>OC: Fetch reward rates & balances
OC-->>GA: Rate & balance data
GA->>TP: Get token prices (batched)
TP-->>GA: Price data with fallback
GA->>GA: Calculate APY per pool
GA-->>Main: APY results
Main->>GV: Fetch volume data
GV->>SG: Query current & historical pools
SG-->>GV: Pool snapshots
GV->>OC: Resolve on-chain balances
OC-->>GV: Balance data for TVL
GV->>GV: Compute 1d/7d volumes
GV-->>Main: Volume results
Main->>Main: Left-join volumes onto APY
Main-->>Main: Format consolidated output
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/blackhole-clmm/index.js`:
- Line 6: The header comment incorrectly says "Ethereum" while this adapter's
runtime config uses CHAIN = 'avax'; update the comment at the top of
src/adaptors/blackhole-clmm/index.js to reflect the actual chain by replacing
"Ethereum" with "Avalanche (avax)" or similar, ensuring consistency with the
CHAIN constant and any references to CHAIN in this file (e.g., CHAIN = 'avax')
so future maintainers aren't misled.
- Around line 317-326: The subgraph query requests token1Price but the code
reads pair.token0Price, so the BLACK fallback price is never set; update the
GraphQL selection to request token0Price (or alternatively read token1Price) so
the accessed property on the returned pair matches the queried field, ensuring
prices[`${CHAIN}:${BLACK}`] is populated and apyReward can use the fallback;
locate the query and the subsequent conditional that references pair.token0Price
and make the field names consistent (query token0Price or change the access to
token1Price).
| const { request, gql } = require('graphql-request'); | ||
| const utils = require('../utils'); | ||
|
|
||
| // Blackhole CL (Algebra) on Ethereum |
There was a problem hiding this comment.
Update the chain header comment to match runtime config.
Line 6 says Ethereum, but this adapter runs on CHAIN = 'avax'. This is easy to misread during maintenance.
📝 Proposed fix
-// Blackhole CL (Algebra) on Ethereum
+// Blackhole CL (Algebra) on Avalanche📝 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.
| // Blackhole CL (Algebra) on Ethereum | |
| // Blackhole CL (Algebra) on Avalanche |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/adaptors/blackhole-clmm/index.js` at line 6, The header comment
incorrectly says "Ethereum" while this adapter's runtime config uses CHAIN =
'avax'; update the comment at the top of src/adaptors/blackhole-clmm/index.js to
reflect the actual chain by replacing "Ethereum" with "Avalanche (avax)" or
similar, ensuring consistency with the CHAIN constant and any references to
CHAIN in this file (e.g., CHAIN = 'avax') so future maintainers aren't misled.
| { | ||
| pair(id: "${blackUsdcPool}") { | ||
| token1Price | ||
| } | ||
| } | ||
| ` | ||
| ); | ||
| if (pair && pair.token0Price) { | ||
| prices[`${CHAIN}:${BLACK}`] = { price: Number(pair.token0Price) }; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
cd src/adaptors/blackhole-clmm && cat -n index.js | sed -n '310,330p'Repository: DefiLlama/yield-server
Length of output: 1054
🏁 Script executed:
cd src/adaptors/blackhole-clmm && rg -n 'token0Price|token1Price|blackUsdcPool|BLACK|USDC' index.js -B 3 -A 3 | head -100Repository: DefiLlama/yield-server
Length of output: 2270
🏁 Script executed:
cd src/adaptors/blackhole-clmm && rg -n 'token0|token1' index.js | head -50Repository: DefiLlama/yield-server
Length of output: 2170
🏁 Script executed:
cd src/adaptors/blackhole-clmm && rg -n 'USDC|stablecoin|price' index.js | grep -i 'usdc\|stable' | head -20Repository: DefiLlama/yield-server
Length of output: 48
🏁 Script executed:
cd src/adaptors/blackhole-clmm && rg -n 'blackUsdcPool\|0x0D9Fd6dd9b1FF55fB0A9bB0e5f1B6a2D65b741A3' . -B 5 -A 10Repository: DefiLlama/yield-server
Length of output: 48
🏁 Script executed:
rg -n 'token0Price|token1Price' --type js | head -30Repository: DefiLlama/yield-server
Length of output: 3123
🏁 Script executed:
cd src/adaptors/blackhole-clmm && head -100 index.jsRepository: DefiLlama/yield-server
Length of output: 2514
🏁 Script executed:
cd src/adaptors/blackhole-clmm && grep -n 'basicSubgraph\|gql' index.js | head -20Repository: DefiLlama/yield-server
Length of output: 426
Fix BLACK fallback price field mismatch in subgraph query.
Line 319 queries token1Price, but line 324 accesses pair.token0Price. This causes the fallback price to never be set, forcing apyReward to 0 when primary BLACK pricing is unavailable.
Proposed fix
const { pair } = await request(
basicSubgraph,
gql`
{
pair(id: "${blackUsdcPool}") {
- token1Price
+ token0Price
}
}
`
);
if (pair && pair.token0Price) {
prices[`${CHAIN}:${BLACK}`] = { price: Number(pair.token0Price) };
}📝 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.
| { | |
| pair(id: "${blackUsdcPool}") { | |
| token1Price | |
| } | |
| } | |
| ` | |
| ); | |
| if (pair && pair.token0Price) { | |
| prices[`${CHAIN}:${BLACK}`] = { price: Number(pair.token0Price) }; | |
| } | |
| { | |
| pair(id: "${blackUsdcPool}") { | |
| token0Price | |
| } | |
| } | |
| ` | |
| ); | |
| if (pair && pair.token0Price) { | |
| prices[`${CHAIN}:${BLACK}`] = { price: Number(pair.token0Price) }; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/adaptors/blackhole-clmm/index.js` around lines 317 - 326, The subgraph
query requests token1Price but the code reads pair.token0Price, so the BLACK
fallback price is never set; update the GraphQL selection to request token0Price
(or alternatively read token1Price) so the accessed property on the returned
pair matches the queried field, ensuring prices[`${CHAIN}:${BLACK}`] is
populated and apyReward can use the fallback; locate the query and the
subsequent conditional that references pair.token0Price and make the field names
consistent (query token0Price or change the access to token1Price).
Summary by CodeRabbit