Skip to main content
A pair’s rollover over time, for cost-to-hold charts. Pair.rolloverRate from getPairs is only the current rate and the subgraph keeps no history, so this reads the contract’s own accumulator-update events over your chain RPC: rpcHttpUrl, else alchemyApiKey, else rpcUrl, else the public endpoint.

Parameters

pairId must be a numeric id. An empty or non-numeric value throws INVALID_PARAMS rather than falling back to pair 0.

Response schema

rate8h is the average 8-hour rate as a percentage over the span since the previous point, in Pair.rolloverRate’s sign convention (negative = trader pays). accLong and accShort are the same values as Pair.rollover, so rolloverFee() works on any point. Every returned point lies within from–to. Its rate is measured from the reading before it, which can sit just before from. A quiet pair has no update events between trades, so its rate across that gap is the average over it.

Cost and limits

A call makes a handful of eth_getLogs requests, split to fit the provider’s range limit, plus one eth_getBlock per point. A week at 6-hour spacing takes about 7 seconds on the public RPC.
  • It throws as soon as the window would produce more than 2000 points; raise intervalMs.
  • A provider that refuses a block range or response size is retried with smaller ranges, but the call gives up after 400 eth_getLogs requests. Set rpcHttpUrl to a provider with wider ranges if you hit that.
  • Rate limits, timeouts and 5xx responses are retried a few times with backoff, then thrown.