# Funding Payments

Funding payments are a mechanism used in perpetual futures markets to ensure that the mark price (the price of the perpetual contract) remains anchored to the index price (the underlying asset's spot price). In a perpetual protocol, these payments are exchanged between long and short position holders and can fluctuate based on market conditions. Here are the main reasons funding payments are used:

* **Price Convergence:** Funding rates encourage the mark price to converge with the index price. When the perpetual price is higher than the spot price, long position holders pay short position holders, making it costly to hold long positions and incentivizing traders to sell or short, which can help lower the mark price towards the index price.
* **Fair Market Conditions:** They prevent the market from being skewed too far in one direction for too long. If many traders are long (buying), funding rates become positive, and these traders will have to pay funding to the short (selling) traders, which could encourage some long traders to close their positions, creating a more balanced market.
* **Speculation and Hedging Balance:** By penalizing the overcrowded side of the market, funding rates balance the speculative nature of perpetual contracts with the needs of those using them for hedging. This creates a more stable and sustainable trading environment.
* **Incentive Mechanism:** In essence, funding rates serve as an incentive mechanism that rewards traders for taking on the risk of holding positions that may be contrary to the majority. This can provide liquidity to the market where it's needed.

### Calculating Funding Payments

The funding payments are settled every hour. Unlike nftperp v1, where insurance fund had a role in funding, the funding in nftperp v2 is purely peer to peer and similar to funding in other centralized perpetual swaps.

1. **Determine the daily premium:** It's calculated as the difference between mark and index price:

$$
premium= mark - index
$$

2. **Clamp the Premium:** The premium is set to zero if the mark price and index price deviate by less than the clamp percentage. Otherwise, the absolute premium is reduced by clamp percentage. This is done to accommodate the bid-ask deviation. In ETH NFTs, the clamp percentage is currently set to 0, while in Ordinals, it is set to 2.5%<br>

3. **Determine the hourly premium:** As nftperp collects the premium every hour, the clamped premium is divided by 24.

   $$
   premiumPerHour = clampedPremium/24
   $$

4. **Compute the Funding payment:** The funding payment for a specific position is determined by multiplying the fundingRate with the position size.

$$
premiumPerHour=premium/24
$$

3. **Determine the Funding Rate:** The premium per hour is divided by the indexPrice to get the funding rate.

$$
fundingRate=premiumPerHour/index
$$

4. **Compute the Funding payment:** The funding payment for a specific position is determined by multiplying the fundingRate with the position size.

$$
fundingPayment= fundingRate\*positionSize
$$

Funding is paid by both AMM LPs and Traders.


---

# 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://nftperp.gitbook.io/core-docs/nftperp/protocol-design/funding-payments.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.
