# Funding Rate Policies

Funding rates are the mechanism by which perpetual contract prices converge to the underlying index price. Payments flow between long and short traders based on the spread between mark and index prices.

#### Calculation

The funding rate is computed in basis points (bps) using the formula:

```
base_rate_bps = (mark_price - index_price) / index_price * 10,000
effective_rate_bps = base_rate_bps * ticks_elapsed
```

Where `ticks_elapsed` is the number of funding intervals since the last application.

#### Tick-Based Intervals

Funding is applied on a tick schedule rather than continuously:

* **Funding tick** = `timestamp / funding_interval`
* Funding only applies when `current_tick > last_funding_tick`
* Skipped if `index_price == 0` or `mark_price == index_price`

This batching approach ensures deterministic funding across all nodes.

#### Payment Direction

| Condition      | Long Traders | Short Traders |
| -------------- | ------------ | ------------- |
| `mark > index` | Pay          | Receive       |
| `mark < index` | Receive      | Pay           |

Payment amount per position:

```
notional = base_position * mark_price
payment = -(notional * effective_rate_bps / 10,000)
```

The negation ensures longs pay when the rate is positive (mark above index).

#### State Updates

On each funding application:

1. `collateral` balances adjusted by payment amount
2. `realized_pnl` updated on each position
3. Market state records:
   * `last_funding_tick` — prevents duplicate payments
   * `cumulative_funding_bps` — running total for historical reference
   * Updated `mark_price` and `index_price`

#### Zero-Sum Property

Funding is always zero-sum between counterparties. The system does not create or destroy value through funding—it only transfers between longs and shorts.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-v2.fermilabs.xyz/trading/funding-rate-policies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
