Funding rates: under the hood

Aditya Palepu
DerivaDEX
Published in
9 min readJun 23, 2020

This post digs into the math behind how exchanges determine their funding rates. If you’re new to funding rates (the tool that enables perpetual swaps), check out our previous post. If you’re looking for technical specifics, read on.

It seems every exchange has its own way of computing a perpetual swap’s funding rate! How do the leading exchanges do it, and which approach is best? Let’s study the designs for BitMEX, Bybit, Binance, FTX, and Deribit.

Want to get early access to DerivaDEX, the most open, secure, performant way to trade perpetual swaps? Complete our user research survey here and we’ll get in touch! https://derivadex.typeform.com/to/vxqfLt

Funding Rate Refresher

The funding rate is how the price of a perpetual swap is kept close to the price of the underlying asset. It works by sending periodic payments between long and short traders. On BitMEX, for example, if the BTC/USD perpetual swap (XBTUSD) is trading above the spot price of Bitcoin, the funding rate would be positive. This means that long traders would pay short traders (discouraging long positions and incentivizing short positions). On the other hand, if the BTC/USD perpetual swap is trading below the spot price of Bitcoin, the funding rate would be negative. This means that short traders would pay long traders (discouraging short positions and encouraging long positions, thus raising the perpetual swap’s price up towards the underlying).

BitMEX

BitMEX, as the pioneer of perpetual swaps, established the first definition of the funding rate. It consists of two components — the premium index and an interest rate. The premium index measures the difference between the perpetual swap’s price and the underlying asset it’s tracking. The interest rate accounts for the borrowing of the quote currency (e.g. USD) and lending of the base currency (e.g. BTC) that a perpetual swap mimics. But how are these calculated?

funding_rate (F) = premium_index (P) + clamp(interest_rate (I) — premium_index (P), 0.05%, -0.05%)

Let’s unwrap this — as a heads up, it gets scarier before it gets better, but we’ll walk through it together so it all makes sense. Don’t worry if you don’t know what some of the terminology is, we’ll get to that.

Interest rate (I)

interest_rate (I) = (interest_quote_index - interest_base_index) / funding_interval
  • Interest quote index: fixed to 0.06% daily rate for BTC
  • Interest base index: fixed to 0.03% daily rate for USD
  • Funding interval: 3 (since BitMEX employs 8-hour funding windows)

Thus, the interest rate component here is a constant 0.01%.

Premium index (P)

premium_index = (max(0, impact_bid_price — mark_price) — max(0, mark_price — impact_ask_price)) / spot_price + fair_basis

A quick note on impact prices: the idea here is to derive a truer sense of the order book. Imagine an order book where the best available bid is 0.01 BTC at a price of $10K. A reasonably-sized sell order would easily wipe through this and move to the next level below $10K. On the other hand, imagine an order book where the best available bid is 1000 BTC at a price of $10K. This price level is much stronger and can withstand a large sell order.

  • Impact bid price: the average fill price if 10 BTC were sold through the order book. This means the value may be lower than the best available buy order on the market if a theoretical 10 BTC sell order would go beyond this first level.
  • Impact ask price: the average fill price if 10 BTC were bought through the order book. This means the value may be higher than the best available sell order on the market if a theoretical 10 BTC buy order would go beyond this first level.
  • Fair basis: a decaying measure of the most recent funding rate, defined as: funding_rate * (time_until_funding / funding_interval). You can think of this like a memory of the most recent funding rate. So you can see here, as we get closer to the next funding time stamp, this value will approach 0.
  • Fair price (interchangeably referred to as mark price): a smoother, more robust representation of the market price as opposed to simply using the last traded price, which can be manipulated. This is defined as: index_price * (1 + fair_basis). We discuss index price just below this.
  • Spot price (interchangeably referred to as index price): a weighted-representation (based on several leading exchanges, such as Coinbase, Bitstamp, and Kraken) of the underlying price the perpetual swap is tracking.

Great! We have all the variables defined, so can now more easily understand how the premium index is computed. As an addendum, in certain situations the math actually further simplifies as follows:

# impact_bid_price <= mark_price <= impact_ask_price
premium_index = fair_basis
# mark_price <= impact_bid_price <= impact_ask_price
premium_index = (impact_bid_price - mark_px) / spot_price + fair_basis
# impact_bid_price <= impact_ask_price <= mark_price
premium_index = -(mark_px - impact_ask_price) / spot_price + fair_basis

In other words, when the mark price is in between the impact bid and ask prices, the premium index equals the fair basis. When the mark price is below the impact bid price, the premium index will be above the fair basis (this makes sense because when the perpetual swap market is higher than the underlying mark price, the funding rate should be increased). When the mark price is above the impact ask price, the premium index will be below the fair basis (this makes sense because when the perpetual swap market is lower than the underlying mark price, the funding rate should be lowered).

Payment methodology

Now back to the original funding rate formula, which if you recall, is:

funding_rate (F) = premium_index (P) + clamp(interest_rate (I) — premium_index (P), 0.05%, -0.05%)# We can simplify this since interest_rate is a constant
funding_rate = premium_index + clamp(0.01% - premium_index, 0.05%, -0.05%)

First of all, the premium_index and interest_rate are actually averages of 1-minute snapshots (a time-weighted average price, or TWAP) of the definitions outlined above over an 8-hour horizon.

Clamping essentially caps a value to the specified bounds. So in the above scenario, the interest_rate — premium_index can be a maximum of 0.05% and a minimum of -0.05%, or anything in between.

The implications of this are that in practice, the funding rate on BitMEX is most always 0.01%. This is because, anytime the premium index is between -0.04% and 0.06%, the funding rate will equal 0.01% (long traders pay short traders). It’s when the premium index is more extreme that we start getting different values. When it’s below -0.04%, we start getting funding rates below 0.01% and into the negative territory (short traders pay long traders). When it’s above 0.06%, we start getting funding rates above 0.01% (long traders pay short traders).

We now know how to compute the funding rate, but how is it transferred? BitMEX, as mentioned above, employs 3 funding periods at 4 UTC, 12 UTC, and 20 UTC. Let’s take the 12 UTC-20 UTC window of time, for example. The funding rate for this interval of time is computed and fixed based on the previous interval (4 UTC-12 UTC). If, and only if, you hold a position at this funding timestamp of 20 UTC (regardless of how long you may have held the position), will you pay or receive the funding rate fee. The amount you stand to make or lose as a result of the funding rate at the funding timestamp is:

funding_rate_fee = funding_rate * position_notional

One word of caution: notice that the funding rate fee is a function of the position_notional (the total position size multiplied by the current price), meaning as you increase your leverage, the funding rate fee becomes a larger proportion of the collateral you have backing your position.

Whew — that was a doozy! We covered a lot of the nitty gritty details. The other exchanges employ funding rate variations off of this. We won’t be needing to go into as much detail as we just did now.

Bybit

Bybit’s funding rate calculation is as follows:

funding_rate (F) = premium_index (P) + clamp(interest_rate (I) — premium_index (P), 0.05%, -0.05%)

Look familiar? It’s the same top level formula as above! The interest rate is defined in the same way as well:

interest_rate (I) = (interest_quote_index - interest_base_index) / funding_interval

where fixed 0.06% and 0.03% daily interest rate values are used for the quote currency (BTC) and base currency (USD) interest rates, along with a funding rate interval count of 3 (implying every 8 hours). This leads to an interest rate component of 0.01%.

The premium index is defined as follows:

premium_index = (max(0, impact_bid_price — mark_price) — max(0, mark_price — impact_ask_price)) / spot_price + funding_rate_current_interval

This funding_rate_current_interval variable is similar to the fair basis offset used in BitMEX, but unlike what’s seen there, this value is not decaying as we get closer to the end of the interval.

The premium index and interest rates are snapshotted every minute, and the funding rate is computed using a TWAP of these values. The funding rate fee is transferred at 3 daily timestamps (0 UTC, 8 UTC, and 16 UTC) and is based on a trader’s position at this timestamp:

funding_rate_fee = funding_rate * position_notional

Binance

Binance, the leading perpetual swap exchange by volume, defines their funding rate as:

funding_rate (F) = premium_index (P) + clamp(0.01% - premium_index (P), 0.05%, -0.05%)

The 0.01% is a reference to the same interest rate component you’ve seen earlier, but they go ahead and explicitly state the simplified formula in their documentation right from the start, since if you recall:

interest_rate (I) = (interest_quote_index - interest_base_index) / funding_interval
interest_rate (I) = (0.06% - 0.03%) / 3
interest_rate (I) = 0.01%

Although this seems identical so far to BitMEX’s approach, a critical difference lies in the computation of the premium_index:

premium_index (P) = max(0, impact_bid_price − mark_price) − max(0, mark_price − impact_ask_price) / spot_price

You may notice that there is no concept of decaying fair basis or funding rate current interval involved in this calculation, like you would find on BitMEX and Bybit.

This premium index is computed every second, and averaged out over the 8-hour duration to set the funding rate. Here lies another big difference with BitMEX — the funding rate computed applies to the current interval, not the following one.

The funding rate fee is transferred at 3 daily timestamps (0 UTC, 8 UTC, and 16 UTC) and is based on a trader’s position at this timestamp:

funding_rate_fee = funding_rate * position_notional

FTX

FTX defines their funding rate as:

funding_rate = (1_hour_TWAP_of_premium) / 24

Whoa, this looks very different from what we’ve seen earlier. Indeed, FTX takes a very different approach than the exchanges we’ve looked at thus far. Every second, FTX will compute a premium:

premium = mark_price — underlying_index_price

mark_price is defined as the median(last_price, best_bid, best_offer). These second-by-second snapshots are averaged out over the course of an hour, and then scaled down by a factor of 24. This ultimately creates the effect of the perpetual swap settling like a daily future (every 24 hours).

Additionally, you may notice that there’s no interest rate component in this formula either. If you recall, the interest rate components in the previous formulas were 0.01% and made a positive contribution to the funding rate. Positive funding rates imply long traders paying short traders. FTX’s absence of an interest rate component results in a less positive funding rate, less incentivization of shorts, and thus generally can be found to trade slightly higher than some other exchanges we’ve discussed above.

The funding rate fee is transferred every hour on the hour and is based on a trader’s position at this timestamp:

funding_rate_fee = funding_rate * position_notional

Deribit

Deribit defines their funding rate as:

funding_rate = max(0.05%, premium_rate) + min(-0.05%, premium_rate)

Much like we just saw in the case of FTX, there is no interest rate component to this funding rate calculation, but only a premium rate, which is defined as :

premium_rate = ((mark_price - underlying_index) / underlying_index)
mark_price = underlying_index + 30_sec_ema(fair_price - underlying_index)
fair_price = avg(impact_bid_price + impact_ask_price)

Depending on the value of the premium rate, the funding rate formula above simplifies in the following manner:

# -0.05% <= premium_rate <= 0.05%
funding_rate = 0%
# premium_rate <= -0.05%
funding_rate = premium_rate + 0.05%
# premium_rate >= -0.05%
funding_rate = premium_rate - 0.05%

The biggest difference between Deribit and any of the exchanges above is that funding payments are continuous. The calculated funding rate (defined as an 8-hour rate) will actually result in funding rate fee transfers in millisecond frequencies (as opposed to 1 hour or 8 hour intervals) in the following manner:

funding_rate_fee = position_notional * funding_rate * time_fraction
time_fraction = 1/28800000

We arrived at this value for time fraction since the Deribit funding rate realizes over 8 hours, but payments are done every millisecond, thus the funding rate needs to be scaled down by a factor of 8 hours * 60 minutes/hour * 60 seconds/hour * 1000 ms/second = 28800000.

Which funding rate model is best?

There’s no right answer to this per se. BitMEX created the first perpetual swap and funding rate architecture, and many exchanges have more or less copied that since then. One of the advantages to BitMEX’s approach is that the funding rate is locked and known for an entire 8-hour interval which gives traders and position-holders more certainty. However, these infrequent payouts can make the mechanism tying a perpetual swap to the underlying more disjointed. Also, traders can sneak in just before the funding rate event to benefit from the fee transfer, or may miss out on the funding payment by closing a position just a little too early. On the other hand, Deribit’s continuous funding approach results in a smoother price action and should theoretically keep a perpetual swap more in line with the underlying. However, it comes with the downside of funding rate uncertainty for traders.

--

--

Aditya Palepu
DerivaDEX

Co-Founder & CEO @ DEX Labs. Duke Eng '13 (ECE/CS). Blockchain, ML/AI enthusiast. Previously DRW algorithmic trader. D.C. sports fanatic and burrito lover.