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

# Funding

Funding rates are periodic payments between long and short position holders. They keep perpetual futures prices aligned with the underlying spot price by incentivizing the less popular side.

## Overview

* **Positive funding rate**: Longs pay shorts. This happens when there is more long open interest than short (market is skewed long).
* **Negative funding rate**: Shorts pay longs. This happens when there is more short open interest than long (market is skewed short).
* **Zero rate**: No payment. Open interest is balanced.

Funding is peer-to-peer. The protocol does not collect funding payments.

## Funding rate calculation

The funding rate is based on the imbalance between long and short open interest:

```
Funding Rate = (Long OI - Short OI) / Total OI x Max Funding Rate
```

Where:

* `Long OI` and `Short OI` are the total long and short open interest in the market
* `Total OI = Long OI + Short OI`
* `Max Funding Rate = 0.75%` per 8-hour interval

The rate is capped at 0.75% per 8-hour interval in either direction.

### Example

* Long OI: 100 TAO, Short OI: 60 TAO, Total OI: 160 TAO
* Skew: (100 - 60) / 160 = 0.25
* Funding Rate: 0.25 x 0.75% = 0.1875% per 8 hours
* Longs pay shorts at this rate

## Payment timing

Funding accrues continuously while a position is open. The accumulated funding is applied when the position is modified or closed.

The rate displayed is the 8-hour rate. The actual cost depends on how long you hold:

```
Funding Payment = Position Notional x Oracle Price x Funding Rate x (Time Held / 8 hours)
```

Maximum accumulation is capped at 32 hours (4 funding intervals). If funding hasn't been updated for longer than that, only the last 32 hours count.

## Interest fee

Separate from the directional funding rate, an interest fee is charged to **both** long and short positions based on vault utilization. This compensates vault depositors for capital at risk.

```
Interest Rate = 20% x utilization^2 + 0.01%
```

Where `utilization = total mark-to-market exposure / available reserves`. The interest rate is capped at 80%.

Unlike funding, interest is always a cost to the position holder regardless of direction.

## Impact on P\&L

Both funding and interest reduce your margin over time:

```
Net P&L = Price P&L - Funding Paid + Funding Received - Interest Paid - Trading Fees
```

For long-held positions, funding and interest can become significant costs. Check the current rates on each market before opening a position.
