Funding Rates and Payments

Shanky
LEVERJ
Published in
6 min readOct 3, 2020

--

Perpetual swaps are the most popular futures products in the world of crypto. Leverj offers two perpetual swap contracts: BTCUSD and ETHUSD.

Perpetual swaps, as the name suggests are “perpetual”. This means it does not have an expiration date. In other words a trader could possibly hold a position for ever as far as the trader has enough margin to cover that position.

In a futures product that has an expiration date, the futures price and the spot price converge as one gets closer to the expiration date. This closes any arbitrage gap and allows for a fair settlement for those who hold the position to expiration. It also forces traders to close positions in case the position is not favorable or profitable to them.

In the absence of an expiration date, the funding mechanism provides a means to converge the futures prices and the spot prices for perpetual swaps. It reduces the arbitrage gap and allows for fair markets for everyone. If you are interested in generally understanding the concept of funding then you could watch and read a couple of posts on the subject:
1. Deribit Insights Video on Perpetual Swap Funding
2. What Happens 5 Minutes Before and After Funding Time on Bitmex?

(We do not endorse these posts but encourage readers to treat these as additional references to understand how and why funding works. Leverj will put out a post about the underlying philosophy of funding in future.)

Now that the fundamentals of funding are understood, it’s time to delve into the mechanics of funding rate calculations and funding payments on Leverj.

How is funding rate calculated on Leverj?

Funding rates are determined every hour and updated basis the prices from the immediate previous hour. The hourly funding rate is calculated using the following formula:

Calculated Daily Funding Rate = Power((Future Price — Index Price),1.25)/Index Price

Calculated Hourly Funding Rate = Calculated Daily Funding Rate/24

Hourly Funding Rate = Minimum(0.16, Calculated Hourly Funding Rate)

Please note that the positive rate is illustrated here. There is a maximum cap on the negative side as well. Think of it as Maximum(-0.16, Power((Future Price - Index Price),1.25)/(24*Index Price)), when Index Price > Future Price. In other words, rate cannot be more than +0.16 or less than -0.16.

The Future Price used in the hourly funding rate calculation is the future price determined from the immediate previous hour. It is calculated using the following formula:

Future Price = TWAP(Median(bid, ask))

TWAP stands for Time Weighted Average Price. Let’s illustrate this with an example. In a 5 minute interval, let’s assume we have 1 price measure every minute then we will end up with 5 price points for the 5 minute interval. Say these prices were 350, 352, 355, 360, and 351. The TWAP for these 5 samples will simply be the average of 5 price points, which in this specific example will be 353.6.

For the purposes of calculating the hourly funding rate, price is measured every minute. Which means under normal circumstances you will have 60 samples for a given hour. In each of these 60 samples, you will have 2 data points: one for the best bid and another for the best ask. The median of these two values, which is simply the arithmetic mean of these two values, is factored into the calculation of the Future Price.

Median(Best Bid, Best Ask) = (Best Bid + Best Ask)/2

TWAP of these 60 median values becomes the Future Price.

The Index Price is calculated using the following formula:

Index Price = TWAP(index)

In other words, index value is read once every minute and an average of those 60 samples become the Index Price.

Once the Future Price and Index Price are calculated for an hour, these two values go into the calculation of the Hourly Funding Rate. Remember that last hour’s Future Price and Index Price go into the calculation of this hour’s Hourly Funding Rate.

Next, let’s look at the rest of the formula and understand what it implies.

Minimum(0.16, Power((Future Price — Index Price),1.25)/(24*Index Price))

First things first! This formula says that the funding rate cannot be more than 0.16 for a given hour. The formula takes the lesser of the two values: 0.16 or the one that is calculated basis the Future Price and Index Price from the previous hour.

Assuming the rate is less than 0.16, the following calculation will apply:

Power((Future Price — Index Price), 1.25) / (24*Index Price)

You already know how the Future Price and Index Price are calculated. If the Future Price is higher than the Index Price, the rate is going to be positive and if it’s the reverse, i.e. Future Price is less than Index Price, then it’s going to be negative.

This difference is raised to the power 1.25. This means the rates are not a linear function of the difference. It is a polynomial function as illustrated in the diagram below. More the difference, greater the impact.

Power 1.25 polynomial curve

The division by 24 adjusts the rate for an hourly basis, as opposed to the rates for a day. Remember, we mentioned that funding rates are calculated every hour. Division by the Index Price calibrates the rate relative to the instrument price.

On the Leverj trading UI, current rates are visible in the order entry panel.

Funding information in the highlighted box

Funding amount and payment

The Hourly Funding Rate is multiplied by the notional position value to obtain the funding amount.

Funding Amount = Hourly Funding Rate * Notional Position Value

Let’s work out a simple example. If the funding rate is 0.04% for a given hour and if the notional position is 100, then the funding amount for that hour equals 0.04. The notional position value and the funding amount are in DAI.

Rates are calculated every hour and payments are recorded every hour as well. If you see a positive amount then it means you earned that amount in that given hour. If the amount is negative then its your funding cost. Funding is a zero sum game. One side pays and the other side receives.

Impact of funding costs

If you end up paying funding costs, please keep in mind that the amount impacts the notional value of your position. This means, every time you incur funding cost your notional value is proportionately increased and it impacts your liquidation price.

Let’s take a simple example and some approximate values to illustrate this impact.

Assume that you entered a position at a notional value of 10,000 DAI at 20x leverage. Then your initial margin is 500 DAI (10,000/20) and your maintenance margin is 50 DAI (0.5% of the notional amount). Your liquidation price therefore is notional amount - net margin, which in this case is 9550 DAI. Net margin is initial margin - maintenance margin.

Liquidation price is also impacted by maximum possible leverage for an instrument. This example assumes maximum leverage of 100x.

Given this position and the margin, if you incur a funding cost of 5 DAI, then your new notional value becomes 10005 DAI. Your effective margin then becomes 450.225 DAI. This is obtained exactly the same way as in the previous paragraph. Margin becomes 500.25 and maintenance margin becomes 50.025, net of which is 450.225. Your new liquidation price is 10005 DAI - 450.225 DAI, which is 9554.775 DAI. After the funding cost of 5 DAI, your new liquidation price therefore has moved by 4.775 DAI against you in this specific example.

Summary

This was an attempt to describe the math behind the funding rates and payments. Please review and ask any questions you may have. Please remember that this is an initial version of the funding calculations. It’s the exchange’s endeavor to keep the markets fair for all participants. In that light feedback is very welcome. Basis feedback and data collected from previous payments, both the funding rates and frequencies may be adjusted in the times to come.

Don’t hesitate to drop us a note in our Telegram channel if you have any questions.

Please keep in mind

US Persons are not allowed to trade on Leverj. Users from sanctioned country or Specially Designated National (SDN) as per OFAC are also not allowed to use the system.

Before you trade, please make sure you are legally permitted to trade cryptocurrencies, derivatives, and any other instruments offered on this platform from your home jurisdiction.

Nothing in this article constitutes an offer, solicitation, or investment advise. The content is for educational purposes only. Images and screenshots may be from our test environments and do not represent data on the live system.

Follow us:

Website | Twitter | Telegram | Reddit

--

--