# 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="/files/pbbMdEPalncTCp3gIMKt" 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: 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.vdex.trade/trading/vdexcore/funding.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.
