> ## 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 your account hourly. Funding calculation is a three-step process involving the premium, funding rate, and funding value.

## Key Definitions

| Term                      | Description                                                  |
| ------------------------- | ------------------------------------------------------------ |
| **railsBidPrice**         | Highest bid price on Rails order book                        |
| **railsAskPrice**         | Lowest ask price on Rails order book                         |
| **indexPrice**            | Current market index price for the asset                     |
| **averagePremium**        | 1-hour average of the premium (see below)                    |
| **timeFactor**            | `1` (normalization factor in hours)                          |
| **interestRateComponent** | `0.0000125` (interest cost adjustment)                       |
| **minimumFundingRate**    | `-0.04` (lower bound)                                        |
| **maximumFundingRate**    | `0.04` (upper bound)                                         |
| **positionQuantity**      | Size of the position — positive for long, negative for short |

## Calculation Formulas

| Field            | Formula                                                                                  | Description                                                                                     |
| ---------------- | ---------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| **premium**      | `(MAX(0, railsBidPrice - indexPrice) - MAX(0, indexPrice - railsAskPrice)) / indexPrice` | Premium, calculated every minute                                                                |
| **fundingRate**  | `averagePremium / timeFactor + interestRateComponent`                                    | Funding rate, calculated hourly (bounded between `minimumFundingRate` and `maximumFundingRate`) |
| **fundingValue** | `-(positionQuantity × indexPrice × fundingRate / 100)`                                   | Funding value, credited 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>

## 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 your account for each open position.
