Skip to content

Honor euro-price TTL inside updatePrices#110

Merged
TaprootFreak merged 1 commit into
developfrom
fix/euro-price-cache-bypass
May 14, 2026
Merged

Honor euro-price TTL inside updatePrices#110
TaprootFreak merged 1 commit into
developfrom
fix/euro-price-cache-bypass

Conversation

@TaprootFreak
Copy link
Copy Markdown

Summary

  • PricesService.updatePrices() fetched simple/price?ids=tether&vs_currencies=eur,btc on every invocation, bypassing the existing EURO_PRICE_TTL (60s) that getEuroPrice() and getDepsPrice() already honored via refreshEuroPriceIfStale().
  • Since updatePrices() is driven by ApiService.updateWorkflow() on every new block (POLLING_DELAY is 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.
  • Replace the direct fetchEuroPrice() call with refreshEuroPriceIfStale() so the same TTL applies to every entry point.

Test plan

  • yarn build (note: existing TS errors in savings/savings.core.service.ts are pre-existing on develop, unrelated to this change)
  • On a running instance: confirm the upstream call rate to the tether/eur endpoint drops to at most 1 per minute
  • Verify GET /prices/eur continues to return a current rate

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.
@TaprootFreak TaprootFreak marked this pull request as ready for review May 14, 2026 16:32
@TaprootFreak TaprootFreak merged commit 3e07af1 into develop May 14, 2026
1 check passed
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.
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