> For the complete documentation index, see [llms.txt](https://docs.reya.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.reya.xyz/developers/pricing-and-funding/funding.md).

# Funding

Perpetual funding keeps the order book trading near the index price. Reya recalculates the funding rate every **5 seconds** and accrues funding continuously into position PnL.

## How the funding rate is computed

```
premium   = (reference − index) / index
rate_8h   = premium + clamp( interestRate_8h − premium, ±interestClamp )
dailyRate = clamp( rate_8h × 3, ±dailyRateCap )
```

* **`reference`** — the composite [impact price](/developers/pricing-and-funding/mark-price.md) when available, or the Stork CEX-mark feed when the composite impact price is unavailable because the book is too thin or EMA-VWAP has not yet been primed by a trade.
* **`premium`** — how far the book trades from the index, as a fraction of the index.
* **`interestRate_8h`** — a fixed per-8h interest term. When the premium is small the interest term dominates; when the premium is large the `clamp` absorbs the interest term.
* **`dailyRate`** — the on-chain convention is a **daily** rate (`rate_8h × 3`), bounded by `dailyRateCap`.

**Sign:** `dailyRate > 0` ⇒ **longs pay shorts**; `dailyRate < 0` ⇒ shorts pay longs.

The rate is recomputed from the current book and index every 5 seconds, with no time-weighted averaging.

### Worked-example parameters

| Parameter          | Value                                               |
| ------------------ | --------------------------------------------------- |
| `interestRate_8h`  | 0.01% (`0.0001`)                                    |
| `interestClamp`    | ±0.05% (`0.0005`)                                   |
| `dailyRateCap`     | 96% / day (`0.96`) — a safety bound, rarely binding |
| Recompute interval | 5 s                                                 |

These values illustrate the calculation below; they are not a live parameter feed or defaults for every market. API 3.7.7 does not expose the configured interest term, clamp or daily cap. Read the current `fundingRate` from `GET /v2/perpMarket/{symbol}/summary` or the market-summary WebSocket channel; see [public configuration and live values](/developers/reference/markets-and-assets.md#public-configuration-and-live-values). Use the reported rate for your integration rather than recomputing it from this example. The API rate's hourly percentage units are explained below.

## How funding is charged

Funding uses a capped daily rate and accrues per side as:

```
fundingValueDelta = dailyRate × markPrice × elapsedDays × baseMultiplier
```

Your position's share is folded into its **realised PnL** on every position update — there is no separate funding transfer to track. Note that funding accrues against the **mark price**, not the index.

`GET /v2/wallet/{address}/positionRisk` reports, as `fundingSinceChange`, the funding an open position has accrued since its size last changed (a fill, a liquidation or an ADL unwind). Positive means the position received funding. This is the funding not yet folded into realised PnL, and it resets to zero at the next change. It is already counted in the account's [margin balance](/developers/risk/margin-system.md#reading-margin-from-the-api), so do not add it again.

## Funding freshness and outages

Reya checks funding-rate freshness before allowing new trades.

**Stale funding pauses new trading — not your positions.** Each market has a staleness window (a small multiple of the 5 s push cadence). If no fresh funding rate arrives within that window, opening or changing a position is temporarily rejected until a new rate is pushed. Liquidations and auto-deleveraging keep working throughout, and viewing margin, adding collateral, and withdrawing are unaffected.

**An outage is never charged retroactively.** Funding accrues on-chain from the timestamp of the last pushed rate, so a gap in pushes does not silently accumulate. When pushes resume, the market charges **at most one staleness window** of funding — a short, bounded amount — at the newly-pushed rate, and **forgives the rest of the gap**. There is no backfill or catch-up charge for the missed period. This is a fixed, pre-committed policy: the on-chain outcome is final and is **not** reconciled or adjusted off-chain afterwards.

## Worked example

ETH index = **$3,000**, book reference (impact) price = **$3,030** — the book is trading 1% rich:

* `premium = ($3,030 − $3,000) / $3,000 = +1.00%`
* `interestRate_8h − premium = 0.01% − 1.00% = −0.99%`, clamped to **±0.05%** → **−0.05%**
* `rate_8h = 1.00% + (−0.05%) = 0.95%`
* `dailyRate = 0.95% × 3 = 2.85% / day` (well inside the 96%/day cap)

Because `dailyRate > 0`, **longs pay shorts**. Holding a 10 ETH long (\~$30,000 notional) for one hour at this rate accrues ≈ `$30,000 × 2.85% ÷ 24 ≈ $35.6` paid (illustrative — the rate is recomputed every 5 s, so it varies over the hour).

## What the API reports

The mechanism above works in a **daily** rate, but the off-chain API normalises what it returns. The `fundingRate` value in market data is an **hourly** rate, **already expressed as a percentage** — the service takes the on-chain daily rate, divides by 24, and multiplies by 100 (`fundingRate = dailyRate ÷ 24 × 100`). So the `2.85% / day` from the worked example above surfaces as a `fundingRate` of `≈ 0.119` (i.e. ≈ 0.119% per hour); multiply by 24 to recover the daily percentage used in the accrual formula. Venues that quote decimal rates show numbers 100 times smaller.

### Funding rate history

`GET /v2/fundingRateHistory/{symbol}/{resolution}` returns a perp market's funding over time, newest first. Because funding accrues continuously, there are no settlement records to list. Instead, each entry summarises one `resolution` interval (`1m`, `5m`, `15m`, `30m`, `1h`, `4h` or `1d`), aligned to UTC, with `timestamp` as the interval start:

* `fundingRate`: the last rate sampled in the interval, in the hourly-percentage units above. Rates are sampled about once a minute, so this is a point-in-time snapshot, not an average.
* `fundingPerUnit`: the funding one unit of a long accrued over the interval, in rUSD. It is read from the market's on-chain funding tracker, exactly as positions are charged, so it covers every rate change in between, and consecutive entries add up. Positive means longs paid shorts. For a constant position, `size × fundingPerUnit` summed over entries is the funding it paid or received. It is omitted when no tracker measurement falls in the interval.

Intervals without rate samples are skipped. `limit` defaults to 200, with a maximum of 1,000. To page back, pass the oldest returned `timestamp` minus 1 as the next `endTime`; an empty page means there is no older data. Rates sampled while a market was `PREOPEN` are indicative: no position paid them. For the current rate, use `GET /v2/perpMarket/{symbol}/summary`.
