@somnia-chain/markets-sdk / react / useFundingRateSeries
Function: useFundingRateSeries()
useFundingRateSeries(
pool,intervalSeconds,window):IndexerQueryState<FundingRateSeries<FundingRateCandle>>
Defined in: packages/sdk/src/hooks.ts:424
A pool's funding-rate rollups over [from, to) at one resolution (3600 | 14400 |
86400), densified onto the grid and oldest-first. The read for a funding chart.
Poll plus nudge: the rollups are re-read when the live tail observes a settlement on this pool, so the tip advances at settlement time rather than on the next poll tick. Callers should not re-implement that — the whole point of this hook.
THE CALLER OWNS THE CLOCK. from/to are required and must be stable across
renders: a Date.now() read inside this hook would change the query deps on every
render and refetch forever. Snap your window to the grid
(Math.floor(now / interval) * interval) and it will be stable between buckets.
Reading the result:
avgFundingRate8his already per-8h. Convert with the helpers infunding.ts(fundingRate1h,annualizedFundingRate) — never by hand in a component.coverageis a 1e18-scaled ratio in [0, 1]. A bucket at rate 0 with LOW coverage is a pause, not a measured zero — hatch it.filled: truemarks a slot with no row at all; both cases arecoverage: "0", and onlyfilledseparates them.- Cumulative funding is exact and needs none of that reasoning:
realizedFundingPerBase(first.cumulativeFundingStart, last.cumulativeFundingEnd)telescopes across gaps, because the index is flat over uncovered time.
Parameters
pool
string | undefined
intervalSeconds
number
window
from
number
to
number
limit?
number