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

# Funding

### Overview

The funding mechanism is a crucial component of perpetual futures trading. It ensures that the price of the perpetual contract closely tracks the underlying asset’s spot price. Unlike traditional futures contracts, perpetual futures do not have an expiration date. To maintain price stability and avoid significant deviations from the spot price, a periodic funding mechanism is implemented.

Funding payments occur at each hour mark. Traders holding long and short positions pay or receive a funding fee based on the difference between the contract price and the spot price. These payments are fully peer-to-peer with no fees taken by the exchange. The funding payment for an account position depends on the size and side of the position, as well as the funding rate.

The funding rate represents the deviation of the impact bid/ask prices from the index price, which is equivalent to the spot market price of the underlying asset.

When the funding rate is positive, users with long positions pay a funding fee to users with short positions. When the funding rate is negative, users with short positions pay a fee to users with long positions.

### Premium Calculation

For each minute, at a random time, Lighter calculates the premium of each market, which represents the deviation of the impact bid/ask prices from the index price for the corresponding market:

$$
\text{premium}\_t
=================

\frac{
\max(0,\ \text{ImpactBidPrice}\_t - \text{index}\_t)
----------------------------------------------------

\max(0,\ \text{index}\_t - \text{ImpactAskPrice}\_t)
}{
\text{index}\_t
}
$$

{% hint style="info" %}
For the premium to be positive (i.e. for long positions to pay funding to short positions), the impact bid price needs to be higher than the index price. When $$\text{ImpactBidPrice}\_t \leq \text{index}\_t \leq \text{ImpactAskPrice}\_t$$, the $$\text{premium}\_t$$ is 0.
{% endhint %}

### Funding Rate Calculation

At the end of each hour, a 1-hour premium is calculated as the time-weighted average of the 60 premiums calculated over the course of the last hour. In addition to the premium component, each market has a fixed interest rate component that accounts for the difference in interest rates of the base and quote currencies. The funding rate is then calculated as:

$$
\begin{aligned}
\text{premium}
&= \text{Average of premium}\_t \text{ since the latest funding}
\times \text{FundingPremiumMultiplier}
\\\[4pt]
\text{smallClamp}
&= \text{SmallClamp} \times \text{FundingPremiumMultiplier}
\\\[4pt]
\text{smallClampedPremium}
&= \text{premium}

* \operatorname{clamp}\bigl(
  \text{InterestRate} - \text{premium},\
  -\text{smallClamp},\
  +\text{smallClamp}
  \bigr)
  \\\[4pt]
  \text{fundingRate}
  &= \frac{
  \operatorname{clamp}\bigl(
  \text{smallClampedPremium},\
  -\text{BigClamp},\
  +\text{BigClamp}
  \bigr)
  }{8}
  \\\[4pt]
  \text{where}\quad
  \operatorname{clamp}(x, a, b)
  &= \max\bigl(a, \min(b, x)\bigr)
  \end{aligned}
  $$

Dividing the 1-hour premium by 8 ensures that funding payments for the premium are distributed over 8 hours, closely aligning with the approach adopted by centralized perpetual exchanges.

#### Parameters

The values used for the majority of the markets are the following:

$$
\text{SmallClamp} = 0.05%,
\qquad
\text{BigClamp} = 4%,
\qquad
\text{InterestRate} = 0.01%
$$

* $$\text{SmallClamp}$$ pulls the $$\text{premium}$$ towards the $$\text{InterestRate}$$. If $$\text{InterestRate} - \text{smallClamp} \leq \text{premium} \leq \text{InterestRate} + \text{smallClamp}$$, then $$\text{fundingRate} = \text{InterestRate} / 8$$. In other words, if the premium is within 5 basis points (scaled by the market’s $$\text{FundingPremiumMultiplier}$$) of the interest rate, funding defaults to the normal value of 1 basis point per 8 hours.
* $$\text{BigClamp}$$ limits funding payments to $$4%$$ per 8 hours, or $$0.5%$$ per hour.
* $$\text{FundingPremiumMultiplier}$$ is configurable per market and ranges over $$(0, 1]$$. It is set to $$1$$ for crypto markets, $$1/2$$ for RWA markets, and $$1/100$$ for Pre-IPO and Prelaunch markets.

These are defaults, not universal values. Per-market values are returned by `orderBookDetails` in `base_interest_rate`, `funding_clamp_small`, and `funding_clamp_big`.

#### Example

For a crypto market ($$\text{FundingPremiumMultiplier} = 1$$) with a premium of $$0.1%$$:

$$
\begin{aligned}
\text{smallClampedPremium}
&= 0.1%

* \operatorname{clamp}\bigl(
  0.01% - 0.1%,\
  -0.05%,\
  +0.05%
  \bigr)
  \= 0.05%
  \\\[4pt]
  \text{fundingRate}
  &= \frac{\operatorname{clamp}(0.05%,\ -4%,\ +4%)}{8}
  \= 0.00625%
  \end{aligned}
  $$

### Funding Payment

The funding payment for account $$i$$ in market $$j$$ is calculated as follows:

$$
\text{funding}\_{i,j}
=====================

-,\text{position}\_{i,j}
\times
\text{index}\_j
\times
\text{fundingRate}\_j
$$

A positive $$\text{funding}\_{i,j}$$ is credited to the account and a negative value is charged.

Current base interest rates include 0.01%, 0.0032% for many RWA markets, and 0 for FX, US10Y and STRC. The large clamp is 4% except for ARC (20%) and RIVER (16%). Query `orderBookDetails` for current per-market values.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.lighter.xyz/trading/funding.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
