Skip to content

fix(historical): EOD table lookup, Llama miss, persist today - #51

Closed
matheus1lva wants to merge 14 commits into
mainfrom
fix/historical-open-day-last-close
Closed

fix(historical): EOD table lookup, Llama miss, persist today#51
matheus1lva wants to merge 14 commits into
mainfrom
fix/historical-open-day-last-close

Conversation

@matheus1lva

@matheus1lva matheus1lva commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Historical lookup is always equality on the requested timestamp converted to UTC EOD (floor(ts/86400)*86400+86399). Hit → return. Miss → DeFiLlama/registry (Llama first). On success we persist even for the current UTC day (mutable row) so later same-day requests are table hits and do not 429-stampede Llama. Future-day keys are still not persisted. Exact and batch share this path.

Course correction: the previous-closed-EOD carry is gone. We do not substitute yesterday's close for today's request, and we do not 404 the current day without trying Llama when today's EOD key is missing.

Related

Works alongside yearn/kong#466 (Kong retries/heals 5xx). This service no longer avoids Llama for the open day; it fills and caches today's EOD instead.

How to review

  • persistResolvedPrices: closed or today, not future; observation window vs toFetchTimestamp
  • handleHistorical / handleBatchHistorical: miss → resolve → persist (including today)
  • No carryOpenDayFromLastClose / previousClosedDayEnd

Test plan

  • bunx vitest run (462 passed, 2 skipped)
  • Today EOD already in DB → table hit, no Llama
  • Today miss → Llama once, persist today's EOD, second request is table hit
  • Closed past day hit/miss+persist unchanged
  • Future day still not persisted

Do not merge until Kong #466 is reviewed alongside.

@matheus1lva

Copy link
Copy Markdown
Collaborator Author

Course correction on this PR (rejected serving yesterday’s close for the open UTC day).

New behavior (exact + batch): always look up token_prices at the requested timestamp converted to UTC EOD. Hit → return. Miss → DeFiLlama (existing registry is fine if Llama is first). On success, persist including the current UTC day so later same-day requests are table hits (this is what stops the 429 stampede). Future timestamps still are not persisted.

Removed carryOpenDayFromLastClose / previousClosedDayEnd entirely. We do not 404 today without trying Llama when today’s EOD key is missing, and we do not return yesterday’s price for today’s request.

@matheus1lva matheus1lva changed the title fix(historical): serve open UTC day from previous closed EOD fix(historical): EOD table lookup, Llama miss, persist today Sep 1, 2026
@matheus1lva matheus1lva closed this Sep 1, 2026
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