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

# Funding

In our trading system, funding is calculated and credited to or debited from your account hourly. Funding calculation is a three-step process involving the premium, funding rate, and funding value.

Funding uses the index price directly, not the mark price — see [Mark Price](/latest/perps/formulas/mark-price) for how the mark price differs and what it's used for instead (margin, PnL, and liquidation).

Funding rates are represented as decimal rates across formulas and API responses. For example, `0.0001125` means `0.01125%`.

## Key Definitions

| Term                      | Description                                                                                                             |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| **maxLeverage**           | Maximum leverage supported for the market                                                                               |
| **impactNotional**        | Fixed notional used to compute impact prices                                                                            |
| **impactBidPrice**        | Average price to sell `impactNotional` into bids                                                                        |
| **impactAskPrice**        | Average price to buy `impactNotional` from asks                                                                         |
| **indexPrice**            | Current market index price for the asset                                                                                |
| **averagePremium**        | 1-hour average of the per-minute premium values (see below)                                                             |
| **timeFactor**            | `8` (premium normalization factor; each hourly funding rate uses one-eighth of `averagePremium` before adding interest) |
| **interestRateComponent** | `0.0000125` (`0.00125%` hourly interest cost adjustment)                                                                |
| **minimumFundingRate**    | `-0.005` (`-0.5%` lower bound)                                                                                          |
| **maximumFundingRate**    | `0.005` (`0.5%` upper bound)                                                                                            |
| **positionQuantity**      | Size of the position — positive for long, negative for short                                                            |

## Impact Prices

`impactNotional` is calculated as:

```
impactNotional = 100 USDT × maxLeverage
```

With the current `maxLeverage` of `5`, the impact notional is `500 USDT`.

The impact bid and impact ask are not top-of-book prices. They are the average execution
prices for filling `impactNotional` against the order book. On a deep book they should be
close to the best bid and ask; on a thin book they may differ.

<Note>
  **Example**

  If `impactNotional` is `500 USDT` and the bid side has price levels with quote notionals
  (`price × quantity`) of `200 USDT` at `84,820`, `150 USDT` at `84,780`, and at least
  `150 USDT` at `84,700`, selling `500 USDT` walks those three levels:

  ```
  impactBidPrice = 500 / ((200 / 84820) + (150 / 84780) + (150 / 84700))
                 ≈ 84771.97
  ```

  The impact bid is lower than the best bid because part of the trade fills at lower prices.
  The impact ask is calculated the same way on the ask side.
</Note>

## Calculation Formulas

| Field            | Formula                                                                                                 | Description                               |
| ---------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| **premium**      | `(MAX(0, impactBidPrice - indexPrice) - MAX(0, indexPrice - impactAskPrice)) / indexPrice`              | Premium, calculated every minute          |
| **fundingRate**  | `MIN(MAX(averagePremium / timeFactor + interestRateComponent, minimumFundingRate), maximumFundingRate)` | Funding rate, calculated hourly           |
| **fundingValue** | `-(positionQuantity × indexPrice × fundingRate)`                                                        | Funding value, credited or debited hourly |

<Note>
  **Understanding Funding Rates**

  * **Positive fundingRate** → **Longs pay shorts**
  * **Negative fundingRate** → **Shorts pay longs**

  The sign of the rate tells our system which side is “over-represented” or “under-represented”. When the rate is below zero, it means the position/contract is trading below the index price; shorts are effectively being subsidized to hold that position, so they must transfer the funding fee to longs.
</Note>

<Note>
  **Example**

  Assume:

  * `averagePremium = 0.0008`
  * `indexPrice = 100,000`
  * `positionQuantity = 1`

  The hourly funding rate is:

  ```
  fundingRate = MIN(MAX(0.0008 / 8 + 0.0000125, -0.005), 0.005)
              = 0.0001125
  ```

  A long `1 BTC` position pays:

  ```
  fundingValue = -(1 × 100,000 × 0.0001125)
               = -11.25
  ```
</Note>

## Usage in API

Funding calculations are used in the [Get Account Fundings](/latest/perps/rest-api/get-account-fundings) response, where you can see the hourly funding credited to or debited from your account for each open position.
