Skip to content

fix: hydration dex better underlying + stablepools#2421

Merged
0xkr3p merged 2 commits intoDefiLlama:masterfrom
0xkr3p:fix/hydration-dex
Feb 25, 2026
Merged

fix: hydration dex better underlying + stablepools#2421
0xkr3p merged 2 commits intoDefiLlama:masterfrom
0xkr3p:fix/hydration-dex

Conversation

@0xkr3p
Copy link
Contributor

@0xkr3p 0xkr3p commented Feb 25, 2026

Summary by CodeRabbit

  • New Features

    • Expanded token & pricing coverage, including decimals and additional assets.
    • Added LP underlying composition mapping and stableswap pool handling with per-pool TVL and reward token mapping.
  • Refactor

    • Parallelized data fetching and introduced unified token price retrieval.
    • Revised TVL computation for omnipool and stableswap pools for greater accuracy; preserved error handling.

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9468f4e and e2f82cd.

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

📝 Walkthrough

Walkthrough

Hydration 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

Cohort / File(s) Summary
Core adaptor
src/adaptors/hydration-dex/index.js
Expanded cgMapping and added lpUnderlyingTokens, decimalsMap; added stableswap composition/balance/yield fetchers; introduced getTokenPrices, calculateOmnipoolTvl; switched TVL from DOT-calibration to multi-token price-based calculations; added stableswap pool processing and refined underlying token resolution and symbol cleaning.
Metadata & manifest
manifest_file, package.json
Package/manifest updates accompanying adaptor changes (non-API, metadata/config edits).
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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 I hopped through mappings, found new names,

Prices now dance, not DOT-bound frames,
Stableswaps joined the grassy trail,
TVL counted by weight and scale,
Cheers — a carrot for every new token tale! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main changes: improved underlying token resolution and addition of stableswap pool support to the Hydration DEX adaptor.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 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.

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: 3

🧹 Nitpick comments (1)
src/adaptors/hydration-dex/index.js (1)

91-96: decimalsMap is populated but never used.

decimalsMap is built from asset data (lines 91, 95) but is never referenced anywhere in the file. Consider removing it to avoid confusion, or use it where asset.decimals is 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.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d115d4 and 9468f4e.

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

@0xkr3p 0xkr3p merged commit c9988f8 into DefiLlama:master Feb 25, 2026
1 of 2 checks passed
@0xkr3p 0xkr3p deleted the fix/hydration-dex branch February 25, 2026 16:11
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.

1 participant