Skip to content

feat: add Curve LP virtual-price fallback to price warmup#11

Open
matheus1lva wants to merge 1 commit into
mainfrom
feat/curve-fallback
Open

feat: add Curve LP virtual-price fallback to price warmup#11
matheus1lva wants to merge 1 commit into
mainfrom
feat/curve-fallback

Conversation

@matheus1lva

Copy link
Copy Markdown
Collaborator

Summary

Curve LP tokens that DefiLlama can't price leave a gap in the underlying price
table, and that gap cascades into every derived vault price built on top of
them. This adds an on-chain fallback: when DefiLlama has no price for an
underlying, the warmup prices the Curve LP from its pool's get_virtual_price
scaled by coin0's USD price, filling the gap before derived prices compute.

Changes

  • src/curve.ts (new): priceCurveLpUsd resolves a token's Curve pool via
    the AddressProvider registry and prices it as get_virtual_price() / 1e18 * price(coin0). Registry and pool lookups are memoized. Returns null for
    non-registered LPs or when coin0 has no price, so callers treat it as a clean
    miss.
  • scripts/warmup-prices.ts: new warmCurveFallbackPrices phase runs
    between the direct and derived phases. It only attempts timestamps that
    neither defillama nor a prior curve run already filled (today always
    refreshes), so repeat runs skip work already on disk.
  • src/rpc.ts: add memoized getChainClient(chainId) that reads
    RPC_URL_<chainId>. Both warmup phases drop their per-function client and
    block-number maps in favor of it and the existing cache inside
    estimateBlockByTimestamp, removing two redundant cache layers.
  • src/types.ts: register curve in SOURCE_PRIORITY, ranked below market
    sources and above derived, so derived vault pricing consumes a curve
    underlying when no better source exists.

Testing

  • bun run typecheck passes.
  • No test suite in repo. A reviewer should confirm a known DefiLlama-unpriceable
    Curve LP gets a row with source=curve, and that the derived phase picks up
    that underlying when building the vault price.

Underlying Curve LP tokens DefiLlama can't price leave gaps that cascade
into derived vault prices. Add on-chain fallback pricing the LP from its
pool's get_virtual_price * coin0 USD, run as a warmup phase before derived.

- src/curve.ts: priceCurveLpUsd resolves pool via Curve AddressProvider, memoized
- warmup: warmCurveFallbackPrices phase, skips defillama/curve-filled days
- rpc: memoized getChainClient; both phases drop redundant local client/block caches
- types: register 'curve' in SOURCE_PRIORITY below market sources, above derived
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