# Funding Rates

Funding helps keep a perpetual price near its external reference price. Funding is not a protocol trading fee. It transfers value between long and short positions.

* If funding is positive, longs pay shorts.
* If funding is negative, shorts pay longs.

Meridian charges funding hourly. Product parameters can change, so use the Trading API for current values.

## Funding Cycle

Each hour follows the same cycle:

1. **Sample.** Throughout the hour, the exchange compares the order book with the mark price and records a basis sample.
2. **Average.** At the start of the next hour, the exchange averages the samples from the hour that just ended.
3. **Bound.** The exchange converts the average to an hourly rate and applies the product's clamp, baseline, and maximum.
4. **Charge.** The exchange multiplies the rate by the mark price and applies the result to every open position in the product.
5. **Settle.** Each position carries the charge in its equity until a later position change realizes it into balance.

## Basis Samples

The exchange samples the basis throughout the hour. Each sample works as follows:

1. Read the current mark price and a snapshot of the order book.
2. Calculate the impact bid and impact ask from the snapshot.
3. Compare the mark price with the impact prices to get the basis.
4. Record the basis for the hourly average.

An impact price is the average execution price for a configured USD amount. To find the impact bid, the exchange fills the amount against the bids, starting from the best bid and moving down. The impact ask fills the same way against the asks, moving up. Impact prices use more book depth than the best bid or best ask alone, so a small order at the top of the book has little effect.

The sample's basis measures how far the book trades away from the mark price:

<MathBlock tex={String.raw`\text{basis} = \begin{cases} \dfrac{\text{impact bid} - \text{mark}}{\text{mark}} & \text{if mark} < \text{impact bid} \\[1em] \dfrac{\text{impact ask} - \text{mark}}{\text{mark}} & \text{if mark} > \text{impact ask} \\[1em] 0 & \text{otherwise} \end{cases}`} />

A positive basis means buyers pay more than the mark price, so longs pay funding. A negative basis means sellers accept less, so shorts pay.

If one side of the book has less depth than the impact amount, the sample uses the depth available. The exchange skips the sample if:

* Either side of the book is empty.
* No mark price is available.
* The market is in a scheduled [mark-price gap](/trading/perpetual-futures/position-fees).

## Hourly Rate

At the start of each hour, the exchange averages the previous hour's samples. Each sample has equal weight. The exchange scales this average to one hour by dividing it by 8:

<MathBlock tex={String.raw`\text{premium} = \frac{\text{average basis}}{8}`} />

A sustained premium is therefore spread over about eight hours of funding rather than charged in one hour.

The exchange then applies three product settings:

* `fundingClampApr`: a dead zone. If the absolute premium is at or below the clamp, the exchange treats the premium as zero.
* `fundingBaselineApr`: a constant rate added to the premium.
* `fundingMaxApr`: the maximum absolute rate. It caps the premium plus the baseline.

<MathBlock tex={String.raw`\text{hourly rate} = \begin{cases} \text{baseline} & \text{if } |\text{premium}| \le \text{clamp} \\[0.5em] \text{bound}(\text{premium} + \text{baseline},\ -\text{max},\ +\text{max}) & \text{otherwise} \end{cases}`} />

The product API expresses these settings as decimal annual rates. The hourly equivalent of each one is:

<MathBlock tex={String.raw`\text{hourly setting} = \frac{\text{annual setting}}{365 \times 24}`} />

## Funding Payment

The exchange converts the hourly rate to a per-unit USD amount with the mark price at the hour:

<MathBlock tex={String.raw`\text{funding per unit} = \text{hourly rate} \times \text{mark price}`} />

Each position pays or receives its size multiplied by the funding per unit. The exchange applies funding to all open positions in a product at the same time, in the first seconds of the hour.

### Example

These settings are illustrative, not live values.

| Input                | Value                      |
| -------------------- | -------------------------- |
| Average basis        | 0.08%                      |
| `fundingClampApr`    | 4.38% (0.0005% per hour)   |
| `fundingBaselineApr` | 10.95% (0.00125% per hour) |
| `fundingMaxApr`      | 438% (0.05% per hour)      |
| Mark price           | 100,000 USD                |

1. Premium: 0.08% / 8 = 0.01% per hour.
2. The premium is above the 0.0005% clamp, so the exchange keeps it.
3. Add the baseline: 0.01% + 0.00125% = 0.01125% per hour.
4. The result is below the 0.05% maximum, so the hourly rate is 0.01125%.
5. Funding per unit: 0.01125% × 100,000 = 11.25 USD.

A 0.5-unit long pays 5.625 USD. A 0.5-unit short receives 5.625 USD.

### Hours Without Funding

The exchange does not charge funding for a product in an hour if:

* The previous hour has no valid samples. In this case, the baseline is not charged either.
* The product is in a mark-price gap at the start of the hour. mPerps can charge [position fees](/trading/perpetual-futures/position-fees) during gaps instead.
* The product was listed during the current hour. Funding starts at the first hour boundary after listing.
* The product is not active when the exchange applies funding.
* The funding update fails an exchange safety check.

The exchange does not charge a skipped hour later.

## Projected Funding

`GET /v1/funding/projected-rate` applies the same calculation to the samples recorded so far in the current hour. WebSocket `Ticker` publishes the same value in `fr1h`. The projection can change until the hour ends.

`fundingRate1h` on the product is the most recent rate the exchange charged.

## Accounting

The product stores a cumulative per-unit funding value. Each position stores the cumulative value from its last settlement. The difference, multiplied by the position size, is the position's outstanding funding.

Outstanding funding affects account equity before it is realized into balance. A trade, liquidation, or other position state change can realize it.

Funding actions settle in the exchange action sequence.

## API Data

* `GET /v1/funding` returns product funding updates.
* `GET /v1/product` returns `fundingRate1h`, cumulative funding, and the product parameters.
* Archive API `GET /v1/subaccount/funding` returns account funding history.
