Add trackedTVLUSD field to Pool and PoolManager#45
Open
moose-code wants to merge 3 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Raw totalValueLockedUSD is unreliable for ranking because it includes:
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).