Skip to content

Blackhole cl adaptor#2425

Open
0xnabeel wants to merge 3 commits intoDefiLlama:masterfrom
BlackHoleDEX:blackhole-cl-adaptor
Open

Blackhole cl adaptor#2425
0xnabeel wants to merge 3 commits intoDefiLlama:masterfrom
BlackHoleDEX:blackhole-cl-adaptor

Conversation

@0xnabeel
Copy link
Contributor

@0xnabeel 0xnabeel commented Feb 26, 2026

Summary by CodeRabbit

  • New Features
    • Added support for Blackhole CLMM liquidity pools on Avalanche
    • Displays pool APY rates and volume metrics (1-day and 7-day)
    • Shows total value locked and reward token information for pools

@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

A 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

Cohort / File(s) Summary
Blackhole CLMM Adapter
src/adaptors/blackhole-clmm/index.js
New adapter implementation with pool volume extraction via subgraph and on-chain balance lookups, APY computation through gauge reward rates and TVL calculations, batched token price resolution with BLACK token fallback pricing, and orchestration logic that merges volume and APY data into consolidated pool objects. Includes constants for contract addresses, subgraph URL, and ABIs.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Hoppy day! A new adapter springs to life,
Blackhole CLMM dance through Avalanche's snow,
Subgraphs query, balances resolved with might,
APY blooms, volumes flow just right,
Data harmonized—a rabbit's delight! 🌙✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

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.
Title check ❓ Inconclusive The title 'Blackhole cl adaptor' is vague and uses abbreviated terminology ('cl' for Concentrated Liquidity) without clearly conveying the main change or context to someone unfamiliar with the project's shorthand conventions. Clarify the title to be more descriptive, such as 'Add Blackhole CLMM adapter for Avalanche' or 'Implement Blackhole Concentrated Liquidity adapter', which better communicates the purpose and scope.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 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.

@0xnabeel 0xnabeel marked this pull request as ready for review February 27, 2026 11:22
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

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

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 257164c and f24a733.

📒 Files selected for processing (1)
  • src/adaptors/blackhole-clmm/index.js

const { request, gql } = require('graphql-request');
const utils = require('../utils');

// Blackhole CL (Algebra) on Ethereum
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
// 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.

Comment on lines +317 to +326
{
pair(id: "${blackUsdcPool}") {
token1Price
}
}
`
);
if (pair && pair.token0Price) {
prices[`${CHAIN}:${BLACK}`] = { price: Number(pair.token0Price) };
}
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

🧩 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 -100

Repository: DefiLlama/yield-server

Length of output: 2270


🏁 Script executed:

cd src/adaptors/blackhole-clmm && rg -n 'token0|token1' index.js | head -50

Repository: 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 -20

Repository: DefiLlama/yield-server

Length of output: 48


🏁 Script executed:

cd src/adaptors/blackhole-clmm && rg -n 'blackUsdcPool\|0x0D9Fd6dd9b1FF55fB0A9bB0e5f1B6a2D65b741A3' . -B 5 -A 10

Repository: DefiLlama/yield-server

Length of output: 48


🏁 Script executed:

rg -n 'token0Price|token1Price' --type js | head -30

Repository: DefiLlama/yield-server

Length of output: 3123


🏁 Script executed:

cd src/adaptors/blackhole-clmm && head -100 index.js

Repository: DefiLlama/yield-server

Length of output: 2514


🏁 Script executed:

cd src/adaptors/blackhole-clmm && grep -n 'basicSubgraph\|gql' index.js | head -20

Repository: 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.

Suggested change
{
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).

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