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

# Funding

Unlike other derivatives, perpetual futures never expire. To tether the price of the perp to the spot asset, traders pay hourly funding based on the deviation.

The payment amount is determined by the funding rate. If the perp price is higher than the spot price, then the funding rate is positive and longs pay shorts; if the perp price is lower than the spot price, then the funding rate is negative and shorts pay longs. Significant deviations in either direction cause proportionally higher funding rates.&#x20;

Funding is entirely peer-to-peer, VDEX does not charge a funding fee.

#### Formulas

<details>

<summary>Funding Rate</summary>

**Variables**

* `pOracle` = spot price
* `pImpact` = order book impact price
* `s` = position size
* `d` = premium deviation

**Formulas**

`d = (max(pImpactBid - pOracle, 0) - max(pOracle - pImpactAsk, 0))/pOracle`

`8-Hour Funding Rate (F) = dAverage + clamp (0.0001 - dAverage, -0.0005, 0.0005)`

`Funding Payment = s * pOracle * F`

**Methodology**

The deviation between the perp price and spot price is measured through *d*. This is done through the impact and oracle prices respectively. The impact price is like the mid price, but incorporates order book depth.

*d* is sampled every 5 seconds and averaged over the hour, creating *dAverage*. This value represents the relative difference between the perp price and spot price, so a *dAverage* of -0.01 means the perp trades 1% below spot.

The funding rate tracks *dAverage* while filtering out small deviations. The clamp applies an interest rate of **0.0001** and bounds of **±0.0005**, producing a baseline funding rate of **0.01%** when **dAverage** remains within **±0.05%**. The interest rate represents the difference in cost to borrow USD versus spot crypto, defaulting to longs paying shorts. The clamp ensures that the funding rate is predictable and stable under normal market conditions.

Due to precedent, the 8-hour funding rate is calculated. However, funding is paid and displayed hourly. The results in a baseline rate of 0.00125%.

<figure><picture><source srcset="/files/Fu71251Cw5yWo8FaTcFo" media="(prefers-color-scheme: dark)"><img src="https://4101695250-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXaqXFw9hEdwD1MWWRwfI%2Fuploads%2FFWUOsUFapnJU3GcM6ZQC%2Fimage.png?alt=media&amp;token=7595e982-c359-4df1-91d4-836c634f3038" alt=""></picture><figcaption></figcaption></figure>

</details>

<details>

<summary>Example</summary>

* The interest rate is 0.01%
* The spot price of XAU is $3,000
* The impact price of the perpetual is $2,985; 0.5% below spot

1. Calculate the premium deviation, *dAverage*

   `d = (max(pImpactBid - pOracle, 0) - max(pOracle - pImpactAsk, 0))/pOracle`

   `d = (max(2985 - 3000, 0) - max(3000 - 2985, 0))/3000`

   `d = (0 - 15)/3000 = -0.5%`

   $$d\_{\text{Average}} = \frac{1}{720} \sum\_{i=1}^{720} d\_i$$, sampled every 5 seconds
2. Calculate the clamped difference

   `clamped difference = min(max(0.01% - dAverage, -0.05%), 0.05%)`

   `clamped difference = min(max(0.01% - (-0.5%), -0.05%), 0.05%)`

   `clamped difference = min(max(0.51%, -0.05%), 0.05%)`

   `clamped difference = min(0.51%, 0.05%) = 0.05%`
3. Calculate the Funding Rate, *f*

   `8-Hour Funding Rate (F) = dAverage + clamp (0.01% - dAverage, -0.05%, 0.05%)`

   `8-Hour Funding Rate (F) = -0.5% + 0.05%`

   `8-Hour Funding Rate (F) = -0.45%`

   `1-Hour Funding Rate  = -0.05625%`

</details>


---

# 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.vdex.trade/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.
