Skip to content

Add trackedTVLUSD field to Pool and PoolManager#45

Open
moose-code wants to merge 3 commits into
mainfrom
feat/tracked-tvl
Open

Add trackedTVLUSD field to Pool and PoolManager#45
moose-code wants to merge 3 commits into
mainfrom
feat/tracked-tvl

Conversation

@moose-code

Copy link
Copy Markdown
Member

Raw totalValueLockedUSD is unreliable for ranking because it includes:

  • pools with UNKNOWN token metadata (bad decimals, TVL math blows up),
  • very-high static fee wrappers/LSTs (fee > 5%, not an AMM pool),
  • dynamic-fee hooks we don't trust for pricing.

Add Pool.isTracked (computed once at Initialize, stable) and Pool.trackedTVLUSD = isTracked ? totalValueLockedUSD : 0. Aggregate the latter on PoolManager.trackedTVLUSD using the same delta pattern as totalValueLockedETH. Hot path cost is a boolean check + one BigDecimal ternary + one subtract/add per swap/modifyLiquidity — negligible next to the existing TVL math.

Trusted-dynamic-fee-hook allowlist is plumbed via an optional ChainConfig.trustedDynamicFeeHooks field (defaults to [] per chain).

moose-code and others added 3 commits April 23, 2026 10:17
Raw totalValueLockedUSD is unreliable for ranking because it includes:
- pools with UNKNOWN token metadata (bad decimals, TVL math blows up),
- very-high static fee wrappers/LSTs (fee > 5%, not an AMM pool),
- dynamic-fee hooks we don't trust for pricing.

Add Pool.isTracked (computed once at Initialize, stable) and
Pool.trackedTVLUSD = isTracked ? totalValueLockedUSD : 0. Aggregate the
latter on PoolManager.trackedTVLUSD using the same delta pattern as
totalValueLockedETH. Hot path cost is a boolean check + one BigDecimal
ternary + one subtract/add per swap/modifyLiquidity — negligible next to
the existing TVL math.

Trusted-dynamic-fee-hook allowlist is plumbed via an optional
ChainConfig.trustedDynamicFeeHooks field (defaults to [] per chain).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extend trackedTVLUSD from "isTracked ? raw : 0" to the same whitelist-tier
pattern Uniswap applies to tracked swap volume (getTrackedAmountUSD):

  both tokens whitelisted  -> totalValueLockedUSD
  one token whitelisted    -> (whitelisted side × ethPriceUSD) × 2
  neither whitelisted      -> 0
  isTracked=false          -> 0  (UNKNOWN / dynamic / high-fee wrappers)

This collapses the "tiny-cap token paired with a whitelist token" class of
garbage (PsyopAnime $4.5×10¹⁷, GEAF/USDC $10¹², etc.) because the garbage
lives on the non-whitelist side and the rule only trusts the whitelist side.

Additive only — totalValueLockedUSD and every other existing field are
unchanged. Adds Token.isWhitelisted (set once at token creation) so the
tier check is two boolean reads per swap, not a whitelist array lookup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previous rule doubled the whitelisted-side value on the assumption of a
balanced pool. Concentrated liquidity in v4 means that assumption can be
very wrong — an out-of-range position is fully one-sided, and a whitelist-
heavy imbalanced pool (e.g. WBTC/cbBTC when cbBTC isn't whitelisted) gets
its TVL inflated up to 2×.

Use just the whitelisted side's value. Always undercounts for balanced
pools, never overcounts. Ranking is preserved. Exact TVL is recovered by
adding missing tokens to the whitelist (promotes the pool to the "both"
tier).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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