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

# Funding Fee

### Overview

Funding is a periodic fee designed to keep open interest balanced between long and short positions. Unlike a trading fee, funding is not a cost of using the platform — it only activates when the market is skewed toward one side, and it scales with how skewed that market is.Positions on the side of the imbalance pay funding into the protocol's liquidity pool. There is no direct long-vs-short transfer: if longs are the crowded side, longs pay; if shorts are the crowded side, shorts pay. The opposite side pays nothing for that period.

### Formula

```
Funding Payment = Position Notional × FundingMax × R²
```

**Position Notional** — the USD value of your position, calculated as position size × oracle price at the moment of settlement.**FundingMax** — the maximum funding rate for the market, reached only when open interest is entirely one-sided. This value is configurable per market and calibrated so that even in a worst-case, fully one-sided scenario sustained over a set period, the accumulated cost stays within a defined cap.**R** — the open interest imbalance ratio:

```
R = |Long OI − Short OI| / (Long OI + Short OI)
```

R always falls between 0 and 1:

* **R = 0** when long and short open interest are exactly balanced → funding rate is 0, nobody pays.
* **R = 1** when open interest is entirely one-sided (all longs or all shorts) → funding rate equals FundingMax, the maximum possible rate.

Because the imbalance ratio is squared, funding responds gently to small, everyday fluctuations in positioning and rises sharply only as the market approaches a genuine extreme. A mild imbalance produces a small fraction of the maximum rate; a severe, sustained imbalance is what drives the rate toward its cap.

### How it's charged

Funding is settled periodically. The settlement interval is currently **every 8 hours**, though this interval may be adjusted over time as market conditions evolve — check the trading panel for the current cycle length and countdown to the next settlement. At each settlement:

1. The protocol reads the open interest imbalance (R) and the resulting rate at that exact moment.
2. Each open position on the crowded side is charged: its notional value at that moment, multiplied by the rate.
3. The charge is deducted directly from the position; there is no fee collected by the protocol itself — it flows into the pool that backs the other side of the market.

If a settlement fails to process for any reason, it is caught up automatically at the next settlement cycle.

### What happens when you resize a position

Funding is only ever calculated using your position size **at the exact moment of settlement** — it does not look back at what your size was earlier in the period.

* **No change:** your position is simply charged based on its unchanged size.
* **You increase your position before the next settlement:** the next charge uses your new, larger size.
* **You decrease your position before the next settlement:** the next charge uses your new, smaller size.
* **You close your position before the next settlement:** no new funding is charged for that period, since there's no open position left when settlement occurs. Funding already charged in prior periods is not refunded.
* **You open a new position shortly before a settlement:** it will be included in that settlement using its size at that moment, even if it was only open briefly.

Your cumulative funding is simply the sum of every individual settlement charge since you opened the position:

```
Cumulative Funding = Σ (position notional at settlement × rate at settlement)
```

Each settlement is calculated independently based on the state . At that instant — there's no averaging or proportional splitting across a period in which your size changed.

#### Example

The mechanics below apply regardless of the current settlement interval — this example uses a 4-hour cycle purely for illustration. A trader's position changes as follows:

| Time               | Event              | Position Size | Charged at next settlement    |
| ------------------ | ------------------ | ------------- | ----------------------------- |
| 10:00              | Opens position     | 1 BTC         | —                             |
| 12:00 (settlement) | —                  | 1 BTC         | A = 1 × oracle price × rate   |
| 13:00              | Increases to 2 BTC | 2 BTC         | —                             |
| 16:00 (settlement) | —                  | 2 BTC         | B = 2 × oracle price × rate   |
| 17:00              | Reduces to 0.5 BTC | 0.5 BTC       | —                             |
| 20:00 (settlement) | —                  | 0.5 BTC       | C = 0.5 × oracle price × rate |

**Cumulative Funding = A + B + C**
