Perpetual contracts are inspired by traditional futures contracts, but differ in that there is no expiry date and therefore no final settlement or delivery. Funding payments are therefore used to incentivize the price of the perpetual to trade at the price of the underlying.
Funding is calculated like an interest rate, and is determined by a funding rate which is calculated algorithmically based on the price of the underlying and market prices for the perpetual. When the rate is positive, traders who are long will make payments to traders who are short. When the rate is negative, this is reversed and shorts will pay longs. Traders make or receive payments in proportion to the size of their market position. These payments are exchanged solely between traders, and are neither paid nor received by the exchange.
Funding payments are exchanged continuously every second. The funding rate is updated every hour, but is represented as an 8-hour rate, indicating the amount of funding accounts may expect to pay/receive over an 8-hour period.
Funding Payment Calculation
The funding amount paid or received by an account over some period of time of length T is calculated according to the formula:
- F = (-1) * R * (T / 8 hours) * B * X
- F is the change in account balance over the given period
- R is the funding rate as an 8-hour rate
- B is the position balance of the account (positive or negative)
- X is the on-chain index price
Note that funding payments do not compound.
Funding Rate Calculation
Rates are represented as 8-hour rates unless stated otherwise.
The funding rate has two components, the interest rate component and the premium component. The interest rate component aims to account for the interest rate differential between the base and quote currencies. We currently use the fixed rate:
- Interest Rate Component = 0.01%
The premium component takes into account market activity for the perpetual. It is calculated at the start of every minute based on the current order book and off-chain index price according to the formula:
- Premium = (Max(0, Impact Bid Price - Index Price) - Max(0, Index Price - Impact Ask Price)) / Index Price
Where the impact bid and impact ask prices are defined as:
- Impact Bid Price = Average execution price for a market sell of the impact notional value
- Impact Ask Price = Average execution price for a market buy of the impact notional value
And the impact notional amount is defined as:
- Impact Notional Value = 500 USDC / Initial Margin Requirement
For example, at a 10% initial margin requirement, the impact notional value is 5000 USDC.
At the end of each hour, the 1-hour premium is calculated as the simple average (i.e. TWAP) of the 60 premiums calculated over the course of the last hour. The funding rate is then calculated as:
- Funding Rate = 1-Hour Premium + Interest Rate Component
Index Price for Funding
Funding payments occur on-chain, so the calculation of funding payments from the funding rate uses an on-chain index given by a MakerDAO v2 oracle. The funding rate itself is calculated off-chain, and uses an off-chain index which is updated more frequently than the on-chain index. The indices are each calculated the same way, as the median spot price from seven exchanges: Binance, Bitfinex, Bitstamp, Coinbase Pro, Gemini, Kraken, and Upbit.
Funding Rate Updates
After the funding rate is calculated by dYdX, it is immediately sent to the funding rate smart contract. Once the Ethereum transaction is mined, the new funding rate takes effect and is used to update account balances every second.
Funding Rate Limits
The funding rate is limited in three ways. These limitations are enforced by the smart contract.
- The max absolute funding rate is 0.75%.
- The max change in a single smart contract update is 0.75%.
- The max change over a 55-minute period is 0.75%.