You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 405879c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(api): block-time pricing + historical provider coverage for rewards
/provider-estimated-rewards?block=N now produces a self-consistent snapshot
that matches jsinfo's stored monthly JSON: prices are as-of the block, and
the provider set is the chain's pairing list at that block (not today's).
Before this change, a historical-block query:
• Priced tokens at the CURRENT LAVA price (drifts from jsinfo as price moves)
• Iterated the CURRENT provider set (missed providers who've since
unbonded/deregistered — ~14/48 missing on March 17, worth ~$2,922 USD)
After:
• block-time LAVA price via CoinGecko /coins/lava-network/history, passed
through as a price-override map down to processRewardTokens
• provider set fetched with x-cosmos-block-height header so chain RPC
returns the historical pairing list
Changes:
- rpc/block.ts: export fetchBlockTime(height) for block → ISO timestamp
- rpc/pricing.ts: fetchTokenUsdPriceAt(denom, date) and buildHistoricalPriceMap
with indefinite caching (historical prices don't change)
- rpc/providers.ts: optional blockHeight on fetchProvidersForSpec +
fetchProvidersWithSpecs. Default undefined → current state, unchanged for
every non-rewards caller (/providers, /specs, etc.)
- rpc/rewards.ts: optional priceOverrides on fetchRewardsBySpec. Threads into
processRewardTokens where it takes precedence over the live price cache.
- routes/provider-estimated-rewards.ts: when ?block= is set, fetches block
time → builds historical price map → passes both blockHeight and overrides
down. meta.priceTimestamp = block time; meta.priceLavaUsd = historical price.
- tests: new assertions for block-time pricing, historical provider coverage,
and that live-mode doesn't accidentally call historical helpers. 112/112.
0 commit comments