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

# Perp Funding

The instantaneous funding rate is calculated as follows.

First, we take the impact notional amount (INA), a per-market constant:

```python Formula theme={null}
INA = 4000
```

Next, we determine the impact ask price (IAP) and impact bid price (IBP). These are defined as the average execution price for a market sell (buy) of the impact notional amount respectively. We use these values to calculate the perpetual premium:

```python Formula theme={null}
Premium = (max(0, IBP - Spot) - max(0, Spot - IAP)) / Spot
```

Where:

* `IBP` is the impact bid price.
* `Spot` is the spot price of the underlying base asset.
* `IAP` is the impact ask price.

Finally, we calculate the funding rate **per hour** as:

```python Formula theme={null}
Funding Rate = Premium / perpConvergence + clamp(UnderlyingRate - Premium/perpConvergence, 0.00625%, -0.00625%) 
```

Where:

* `UnderlyingRate= 0.00125%` (equivalently, 0.01% per 8 hours) and
* `perpConvergence = 8`

The funding paid from longs to shorts is then calculated as follows:

```python Formula theme={null}
Funding = -Perp Size x Funding Rate x Spot x Time Held
```

Where:

* `Perp Size` is the number of perpetual contracts (this number is negative for shorts).
* `Time Held` is the duration the position is open for in hours.

The perpetual funding rates are capped at

* `PERP_MAX_FUNDING = 0.057% per hour for ETH/BTC and 0.4% for all others`
* `PERP_MIN_FUNDING = -0.057% per hour for ETH/BTC and 0.4% for all others`

In other words, the maximum rate longs can pay shorts will be 0.057% of the spot price per hour. Similarly, the maximum rate shorts can pay longs will be 0.057% per hour (represented as -0.057%).

> 📘 The funding rate quoted above and returned by the API is a **per-hour** rate, not a per-8-hour rate.


## Related topics

- [Perpetuals](/perpetuals.md)
- [public/get_latest_signed_feeds](/api-reference/market-data/publicget_latest_signed_feeds.md)
- [public/set_socialization_feed_data](/api-reference/other/publicset_socialization_feed_data.md)
