> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ostium.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getRolloverHistory

> Fetch a pair's rollover accumulators and average 8-hour rates over time.

```ts theme={null}
const history = await client.getRolloverHistory({
  pairId: 0,
  from: Date.now() - 7 * 86_400_000,
  to: Date.now(),             // optional, defaults to now
  intervalMs: 6 * 3_600_000,  // optional, defaults to 1 hour
});
```

A pair's rollover over time, for cost-to-hold charts. `Pair.rolloverRate` from [getPairs](/developer/reference/get-pairs.md) 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

```ts theme={null}
interface GetRolloverHistoryParams {
  pairId: string | number;
  from: number;        // Unix milliseconds
  to?: number;         // Unix milliseconds, defaults to Date.now()
  intervalMs?: number; // spacing between points, defaults to one hour
}
```

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

## Response schema

```ts theme={null}
type Response = Array<{
  timestamp: number;   // block time, Unix seconds UTC
  block: string;
  accLong: string;     // raw accumulators, same values as Pair.rollover
  accShort: string;
  rate8h: { long: string; short: string };
}>;
```

`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()`](/developer/reference/math-helpers) 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.