Honor euro-price TTL inside updatePrices#110
Merged
Merged
Conversation
updatePrices() fetched the tether/eur reference on every block tick, bypassing the existing 60s in-memory cache that getEuroPrice() and getDepsPrice() already respected. With block intervals of 6-12s this generated ~5-10x more upstream calls than the cache was designed to allow, exhausting the monthly CoinGecko quota. Route the call through refreshEuroPriceIfStale() so the same TTL applies to all entry points.
3 tasks
TaprootFreak
added a commit
that referenced
this pull request
May 14, 2026
When fetchPrice() returns null/undefined (e.g. CoinGecko returns {}
for an unlisted collateral token), updatePrices() left the cache
entry untouched and the 5-minute staleness check (timestamp +
300_000 < now) was still true on the next block tick. Combined
with the 6-12s block polling that drives updatePrices(), this
made the same handful of unlisted tokens generate ~50 upstream
calls per hour per API instance — the dominant CoinGecko quota
consumer after #110.
Bump the entry's timestamp on a failed fetch too, so the retry
honours the same 5-minute window as a successful fetch.
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
PricesService.updatePrices()fetchedsimple/price?ids=tether&vs_currencies=eur,btcon every invocation, bypassing the existingEURO_PRICE_TTL(60s) thatgetEuroPrice()andgetDepsPrice()already honored viarefreshEuroPriceIfStale().updatePrices()is driven byApiService.updateWorkflow()on every new block (POLLING_DELAYis 6s for mainnet, 12s for polygon), this generated 5-10x more upstream calls than the 60s cache window intended — enough to exhaust the monthly CoinGecko Pro quota.fetchEuroPrice()call withrefreshEuroPriceIfStale()so the same TTL applies to every entry point.Test plan
yarn build(note: existing TS errors insavings/savings.core.service.tsare pre-existing ondevelop, unrelated to this change)GET /prices/eurcontinues to return a current rate