feat(prices): gate price source on USE_PRICE_SERVICE and stop serving table-backed prices#442
Open
matheus1lva wants to merge 9 commits into
Open
feat(prices): gate price source on USE_PRICE_SERVICE and stop serving table-backed prices#442matheus1lva wants to merge 9 commits into
matheus1lva wants to merge 9 commits into
Conversation
…RICE_SERVICE Null GraphQL prices/tvls price fields (unusable per-block spot data) and gate the indexer on USE_PRICE_SERVICE so past-day prices can come from yearn-prices without writing the Postgres price table.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
matheus1lva
force-pushed
the
decomission-price-table
branch
from
July 18, 2026 21:35
368b2c8 to
a503035
Compare
Cache under the (chain,token,day) key only for genuine price-service results; block-accurate lens/yprice fallbacks and unknowns are no longer reused across other blocks in the same day. Move getBlockTime inside fetchPriceServiceUsd's try so an RPC blip falls through to the fallback. Make cache get/set no-op before init, mirroring wrap, so jobs during startup don't throw.
Remove additions not in the spec: the fail-closed USE_PRICE_SERVICE startup assertion, the priceServiceMetrics/recordServiceOutcome trial instrumentation, and the /api/prices/spot fallback. Spec names fetchPriceServiceUsd (batchHistorical) as the only service lookup; current-day/latest falls back yDaemon -> lens as before.
Accept any-case 'true' instead of JSON.parse (throws on True/yes/on and crashes the hot price path). Skip WaveyDb price-table writes in service mode.
Service mode: price service only, no fallbacks, no mq writes, no utc/day handling. Table mode: unchanged legacy path. Drop day-cache and revert cache init guards.
17 tasks
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.
Summary
Adds a
USE_PRICE_SERVICEflag that routes the indexer's price lookups to the yearn-prices service instead of the Postgrespricetable, skipping table reads and writes when it's on. The GraphQL/REST read layer stops serving the table-backed per-block prices, which were yDaemon spot snapshots captured at ingestion time rather than historical prices.How to review
Start in
packages/ingest/prices.ts. The fetch path splits into__fetchErc20PriceUsdFromTable(default, unchanged) and__fetchErc20PriceUsdFromService. The service path keys on UTC day: past days come from the price servicebatchHistoricalendpoint at day granularity; current-day and latest fall back to yDaemon then lens, and neither is written back as a historical close. Only a genuinepriceserviceresult is cached under the(chain, token, day)key, so a block-accurate fallback never leaks onto other blocks in the same day.maybePersistPriceis the one gate that skips table writes in service mode.On the read side,
resolvers/prices.tsreturns[], andresolvers/tvls.tsdrops thepricejoin and keepspriceUsd/priceSourceas null/'na'for response-shape compatibility.The
if(toif (churn inprices.tsis formatter noise, safe to skim.Test plan
USE_PRICE_SERVICE=false(default), confirm ingest prices and TVL behave as before.USE_PRICE_SERVICE=true, confirm ingest resolves historical prices from the service, thepricesresolver returns[], andtvlsrows come back withpriceUsd: null.bun --filter ingest test(prices.unit.spec.ts, prices.service-cache.spec.ts),bun --filter web test(prices.spec.ts, tvls.spec.ts).Risk / impact
USE_PRICE_SERVICEdefaults tofalse, so the table-backed path is unchanged unless the flag is set. Toggling needs a process restart, not a live flip. In service mode the indexer stops writing to thepricetable. The GraphQLpricesfield returns empty for everyone, so point consumers at prices.yearn.dev. The field stays for response compatibility, with full removal as a follow-up.