fix: hydration dex better underlying + stablepools#2421
fix: hydration dex better underlying + stablepools#24210xkr3p merged 2 commits intoDefiLlama:masterfrom
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughHydration DEX adaptor adds expanded token mappings, LP underlying compositions, stableswap pool handling, price-based TVL calculation, parallel stableswap data fetching, and helper utilities for prices, balances, compositions, and yield metrics; error handling and exported API remain unchanged. Changes
sequenceDiagram
participant Caller
participant DataFetcher as Data Fetcher
participant PriceFetcher as Price Fetcher
participant OmnipoolProcessor as Omnipool Processor
participant StableswapProcessor as Stableswap Processor
participant PoolOutput as Pool Output
Caller->>DataFetcher: request pools data
par Parallel Fetching
DataFetcher->>DataFetcher: fetchOmnipoolPools()
DataFetcher->>DataFetcher: fetchStableswapCompositions()
DataFetcher->>DataFetcher: fetchStableswapBalances()
DataFetcher->>DataFetcher: fetchStableswapYieldMetrics()
end
DataFetcher->>PriceFetcher: getTokenPrices(tokens)
PriceFetcher-->>DataFetcher: return price map
DataFetcher->>OmnipoolProcessor: process omnipool with prices
OmnipoolProcessor->>OmnipoolProcessor: calculateOmnipoolTvl()
OmnipoolProcessor->>OmnipoolProcessor: resolve underlying tokens (lpUnderlyingTokens / cgMapping)
OmnipoolProcessor-->>PoolOutput: emit omnipool entries
DataFetcher->>StableswapProcessor: process stableswap with prices and balances
StableswapProcessor->>StableswapProcessor: calculate TVL from balances + prices
StableswapProcessor->>StableswapProcessor: derive composition symbols and rewards
StableswapProcessor-->>PoolOutput: emit stableswap entries
PoolOutput-->>Caller: return combined pools array
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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: 3
🧹 Nitpick comments (1)
src/adaptors/hydration-dex/index.js (1)
91-96:decimalsMapis populated but never used.
decimalsMapis built from asset data (lines 91, 95) but is never referenced anywhere in the file. Consider removing it to avoid confusion, or use it whereasset.decimalsis currently accessed directly (e.g., line 215 in the stableswap section).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/adaptors/hydration-dex/index.js` around lines 91 - 96, The decimalsMap object is built in the assetNodes.forEach block but never used; either remove its declaration/population to avoid dead code, or replace direct reads of asset.decimals elsewhere (e.g., in the stableswap logic where asset.decimals is accessed) to read from decimalsMap using the assetRegistryId key. Locate the assetNodes.forEach that populates symbolMap/decimalsMap and either delete decimalsMap and its assignments, or change consumers (search for places using asset.decimals) to reference decimalsMap[asset.assetRegistryId] and ensure decimalsMap is defined in the needed scope.
🤖 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/hydration-dex/index.js`:
- Around line 405-416: In calculateOmnipoolTvl, guard against division by zero
when computing lrnaPrice from dotEntry.assetHubReserve: check if
dotEntry.assetHubReserve is missing or equals "0" (or parsed dotLrna === 0)
before computing lrnaPrice and either return an empty result or set lrnaPrice to
0/skip pool calculations so Infinity doesn't propagate; update the logic around
dotEntry.assetHubReserve, dotLrna and lrnaPrice to handle the zero/missing case
safely.
- Around line 62-66: The lpUnderlyingTokens map has a duplicate
'coingecko:tether' in the '3-Pool' entry (lpUnderlyingTokens['3-Pool']) which
reduces distinct underlying tokens; update the '3-Pool' array to include the
correct third asset (e.g., replace the second 'coingecko:tether' with the actual
token such as 'coingecko:dai' if that is correct) after verifying the pool
composition, ensuring the array contains three distinct coingecko identifiers.
- Line 56: Update the token-to-CoinGecko ID mapping so the sUSDS key maps to the
correct CoinGecko ID: replace the current 'sdai' value for the sUSDS entry with
'susds' (i.e., change the sUSDS: 'sdai' mapping to sUSDS: 'susds' in the token
mapping object in src/adaptors/hydration-dex/index.js) so price lookups for
sUSDS use the correct CoinGecko ID.
---
Nitpick comments:
In `@src/adaptors/hydration-dex/index.js`:
- Around line 91-96: The decimalsMap object is built in the assetNodes.forEach
block but never used; either remove its declaration/population to avoid dead
code, or replace direct reads of asset.decimals elsewhere (e.g., in the
stableswap logic where asset.decimals is accessed) to read from decimalsMap
using the assetRegistryId key. Locate the assetNodes.forEach that populates
symbolMap/decimalsMap and either delete decimalsMap and its assignments, or
change consumers (search for places using asset.decimals) to reference
decimalsMap[asset.assetRegistryId] and ensure decimalsMap is defined in the
needed scope.
Summary by CodeRabbit
New Features
Refactor