Conversation
📝 WalkthroughWalkthroughAdds a new HyperSwap V3 adapter that paginates a Goldsky subgraph to collect pools, computes per-pool APY (1d and 7d estimates), filters pools under $10k TVL, enriches with Merkl reward APY, and exports Changes
Sequence Diagram(s)sequenceDiagram
participant Adapter as HyperSwapV3 Adapter
participant Subgraph as Goldsky Subgraph
participant Prices as Price Fetcher
participant Merkl as Merkl Reward Service
Adapter->>Subgraph: Paginated GraphQL queries (fetch pools)
Subgraph-->>Adapter: Pool pages (aggregated)
Adapter->>Prices: Fetch token prices for pools
Prices-->>Adapter: Token price data
Adapter->>Merkl: Request reward APY for pools
Merkl-->>Adapter: Reward APY data
Adapter-->>Adapter: Compute TVL, apyBase, apyBase7d, filter (<$10k), sanitize
Adapter-->>Client: Return final APY list (exports apy())
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
|
The hyperswap-v2 adapter exports pools: Test Suites: 1 passed, 1 total |
|
The hyperswap-v3 adapter exports pools: Test Suites: 1 passed, 1 total |
|
The hyperswap-v3 adapter exports pools: Test Suites: 1 passed, 1 total |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/adaptors/hyperswap-v3/index.js`:
- Around line 93-99: The code builds tokenAddresses from pools and calls
utils.getPrices but never uses the resulting prices variable; remove the dead
fetch or implement TVL calculation using the prices. Either delete the
tokenAddresses set creation and the await
utils.getPrices(Array.from(tokenAddresses)) call (and the unused prices
identifier), or instead use prices when computing pool.tvl (or similar) by
referencing prices[`${CHAIN}:${tokenId}`] in the pool formatting logic so TVL is
derived from token balances × price; update functions referencing
tokenAddresses, pools, CHAIN, and prices accordingly.
|
The merkl adapter exports pools: |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/adaptors/hyperswap-v3/index.js`:
- Around line 99-114: The 7-day APY calculation currently sums pool.poolDayData
regardless of how many days exist, potentially producing misleading apyBase7d
for new pools; update the logic around apyBase7d and volumeUSD7d to first
inspect pool.poolDayData.length (or compute days = pool.poolDayData?.length ||
0) and only compute apyBase7d when days >= 7 (set apyBase7d = null otherwise)
or, if you prefer scaling, annualize using the actual days (e.g., use
volumeUSD7d / days * 365 when days > 0) so the calculation in the block that
sets apyBase7d matches the actual available day count; touch the variables
apyBase7d, volumeUSD7d and the surrounding block that calls calculateApyBase to
implement this guard or scaling.
| const dayData = pool.poolDayData?.[0]; | ||
| const volumeUSD1d = Number(dayData?.volumeUSD) || 0; | ||
|
|
||
| const volumeUSD7d = pool.poolDayData | ||
| ? pool.poolDayData.reduce( | ||
| (sum, day) => sum + Number(day.volumeUSD || 0), | ||
| 0 | ||
| ) | ||
| : 0; | ||
|
|
||
| const apyBase = calculateApyBase(volumeUSD1d, pool.feeTier, tvlUSD); | ||
|
|
||
| const apyBase7d = | ||
| volumeUSD7d > 0 | ||
| ? ((volumeUSD7d * Number(pool.feeTier)) / 1e6 / tvlUSD) * 52 * 100 | ||
| : null; |
There was a problem hiding this comment.
Avoid misleading 7d APY when fewer than 7 days of data exist.
apyBase7d is computed even if poolDayData has fewer than 7 entries, which can skew results for newer pools. Consider gating on poolDayData.length >= 7 (or scaling by actual day count).
🔧 Proposed fix (guard on day count)
- const volumeUSD7d = pool.poolDayData
+ const dayCount = pool.poolDayData?.length || 0;
+ const volumeUSD7d = pool.poolDayData
? pool.poolDayData.reduce(
(sum, day) => sum + Number(day.volumeUSD || 0),
0
)
: 0;
@@
- const apyBase7d =
- volumeUSD7d > 0
- ? ((volumeUSD7d * Number(pool.feeTier)) / 1e6 / tvlUSD) * 52 * 100
- : null;
+ const apyBase7d =
+ dayCount >= 7 && tvlUSD > 0
+ ? ((volumeUSD7d / dayCount) * 365 * (Number(pool.feeTier) / 1e6) / tvlUSD) * 100
+ : null;🤖 Prompt for AI Agents
In `@src/adaptors/hyperswap-v3/index.js` around lines 99 - 114, The 7-day APY
calculation currently sums pool.poolDayData regardless of how many days exist,
potentially producing misleading apyBase7d for new pools; update the logic
around apyBase7d and volumeUSD7d to first inspect pool.poolDayData.length (or
compute days = pool.poolDayData?.length || 0) and only compute apyBase7d when
days >= 7 (set apyBase7d = null otherwise) or, if you prefer scaling, annualize
using the actual days (e.g., use volumeUSD7d / days * 365 when days > 0) so the
calculation in the block that sets apyBase7d matches the actual available day
count; touch the variables apyBase7d, volumeUSD7d and the surrounding block that
calls calculateApyBase to implement this guard or scaling.
|
NEW HYPERSWAP V2 SUBGRAPH:
|
resolves #2264
Summary
Adds hyperswap v3 pools with reward incentives using the dedicated the subgraph and merkl rewards helper
Resources
Notes
The hyperswap v2 adapter we only get the tvl as the subgraph is dead. I am reaching out to the team to ask about the status and whether we can utilise their private api
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.