Funding Mechanism

Brief introduction of funding mechanism

Funding mechanism is the core component of a perpetual contract. It is designed to incentivize a perpetual market to be traded closely to its underlying market price (Index Price).

In general, funding is calculated algorithmically based on the premium between the Mid-Price of a perpetual contract and its Index Price (the underlying price). When perpetual trades at a premium relative to Index Price, traders who are long will make funding payments to traders who are short, incentivizing more traders to sell or short, and driving the perpetual price down towards Index Price. In this scenario, by simultaneously longing the underlying market and short the same size of perpetual contract, arbitrageurs could make risk-free profit from the funding payment and the price convergence movement. By contrast, when perpetual trades at a discount relative to index, shorts will pay longs, and arbitrageurs could make risk-free profit by simultaneously longing the perpetual and short the same size of spot asset.

A quick review of existing funding mechanisms

Periodic funding and trade-based funding are the two major approaches applied by crypto exchanges.

Most centralized crypto exchanges are applying the periodic funding approach. In this approach, for instance, average premium is calculated for each 8 hours, and at the end of each 8 hours, funding payment based upon average premium will be made between traders who are longing and shorting.

This design, however, has a problem, as funding payments are only made at the funding settlement time, which makes room for gaming the system. If traders close their positions before the settlement time, they’ll escape from paying for fundings. When the premium is high in a bull market, this gaming behavior could make the perpetual price more volatile.

To mitigate this problem, some exchanges apply trade-based funding. In this approach, within a time fraction when premium is unchanged, funding payment is calculated by multiplying the (moderated) premium and the time fraction length for traders who are holding the position. Whenever premium changes, the funding payment will be calculated based on the new premium. By this way, no one could escape from any funding payment.

The trade-based funding approach is quite computationally intensive if we frequently calculate the payment for all accounts. To mitigate this problem, Perpetual Protocol applies a cumulative value of funding approach to save computation resources. In this approach, it stores a global cumulative funding value for each perpetual contract market, this value is updated by adding the new funding to the cumulative funding as time passes. When a trader initiates or modifies a position, the trader's entry funding level which equals to the current funding level will be recorded. Thereafter, the accrued funding at any time can be calculated as the -Position Size*( Funding Level- Entry Funding Level). The accrued funding is part of unrealized profit or loss of a position, which should be used to calculated the account net value.

OpenWorld funding mechanism

To deal with the complexity of RWAs

OpenWorld Funding Mechanism is designed to accommodate the complexity of RWAs that have non-trading periods, constrained price not reflecting asset true value, and price gaps due to events like stock split.

While perpetual contracts in OpenWorld are traded 24/7, most RWAs have non-trading periods. In non-trading periods, the index price is obsolete and shouldn’t not be used to calculate the premium for funding. Otherwise, it would undermine OpenWorld’s price discovery functionality by punishing any deviation from the obsolete price. As it’s hard to anticipate when the underlying market is alive, we use the live data feed of index price to drive the calculation of the fundings. In non-trading periods, as no live data is available, no additional fundings will be made automatically.

For certain traditional markets, there’re price limits (ceiling and floor). When an underlying market hit price limits, its price could not reflect the fair price of that market. Therefore, we do not calculate fundings in this situation as well, so that the perpetual contract price in OpenWorld would better reflect the fair market price.

Another complexity comes from equity assets, which occasionally have anticipated price gaps due to corporate actions like dividend payment and stock split. We also have the price gaps when rolling over the future contracts if we use the active future price as the underlying price source for a perpetual contract. To deal with this problem, in OpenWorld, assuming the market is efficiently operated by rational investors, especially by professional market marker and arbitrageurs, the funding mechanism will gradually compensate the expected price change in such case, and the trade price of a perpetual contract would switch smoothly from the current index price to the new expected index price, so that the “jump risk” could be eliminated. This would be discussed later in the part of “pricing path for anticipated price gaps”.

We borrow the idea of Perpetual Protocol to calculate the funding level, a cumulative value of all historical funding payments. By looking the historical funding level and market price of a perpetual contract, users can easily calculate the return of longing or shorting a position given any period of time.

Funding mechanism algo explained

For each perpetual contract market, each minute, we only update its funding level once, depending on whether a valid average premium exists in that minute. For a user holding a position on this perpetual contract, the Accrued Funding equals to the negative Position Size multiplying the difference between the current Funding Level and the Entry Funding Level when the trader trade the position last time. Once a user trades this position, Accrued Funding will be settled/realized in one’s account DAI balance before updating Entry Funding Level (If there’s still positions left). The algo is as follows:

Each minute, calculate the Average Trading Premium:

Starting from the beginning of each minute, set i=0, Average Trading Premium=0
Within that minute, when there’s update on index price    #the underlying market is live
if the index price is valid    #the price is not hitting the price limits
	if there’re both bid and ask order on the order book	#perpetual market is active
		Mid Price=(Bid1 Price+Ask1 Price)/2
		Trading Premium= Mid Price-Index Price
		Average Trading Premium= (Trading Premium + Average Trading Premium*i)/(i+1)
		i=i+1

At the end of each minute, we update the Funding Level by:

Funding Level= Funding Level + Average Trading Premium * Funding Gravity

Funding Gravity is a scaling factor that controls how much funding payment should be made each minute based on the Average Trading Premium.

For a user, once building a position, we record the Entry Funding Level for this position in this account:

Entry Funding Level= Funding Level

The ongoing Accrued Funding at any time for this position will determined by:

Accrued Funding = - Position Size *(Funding Level - Entry Funding Level) 

Accrued Funding is a kind of un-realized profit that impact Net Account Value (NAV).

Once a trade changes the position size in one’s account, Accrued Funding will be settled/realized in one’s account DAI balance before updating Entry Funding Level (If there’s still position left).

Example of a trading cycle with funding mechanism

In day 1, Alice had $10000, and bought 1 BTC perpetual contract (with leverage) at price $15000, when the BTC’s funding level is $1000. Just after this bought, Alice DAI balance changed to $10000-1(BTC bought) *$15000(BTC bought price) =-$5000, BTC balance changed to 1, the NAV=-$5000 (DAI balance) +1(BTC position size) *$15000(BTC price) =$10000

In day 10, BTC perpetual contract price raised to $18000. Between day 1 and day 10, BTC perpetual contract is traded at premium to BTC spot price, so the funding level is raised to 1100. At this time, Alice’s unrealized profit from price change is $18000-$15000=$3000, and unrealized loss from funding level change (the Accrued Funding) is-1(BTC position size) *($1100(funding level)-$1000(entry funding level)) = -$100. So his net profit is $3000-$100=$2900. His NAV changed to -$5000 (DAI balance) +1(BTC position size) *$18000(BTC price)- 1(BTC position size) *($1100(funding level)-$1000(entry funding level)) =$12900, which is exactly 2900 higher than the 10000 principal.

In day 20, Alice exited the position by selling 1 BTC at price 21000, when the BTC’s funding level raised to 1300. When selling the 1 BTC, the profit & loss from the price change and funding level change is realized. The DAI balance=-$5000+$21000-1*($1300(exiting funding level)-$1000(entry funding level)) =15700. Compared with day 1, $6000 profit was made from price change, and $300 loss was made from funding payment.

Pricing path for anticipated index price gap of RWAs

Note:

In this section, for illustration and simplicity, we assume price doesn’t change within each minute, there’s no transaction cost, and the interest rate is 0.

OpenWorld’s funding mechanism is designed to deal with all anticipated price gaps through profit-seeking market forces without intervention by any central entity. It has the bellowing wonderful features:

1. Price gap is replaced by a smoothed price curve, so that the gap risk is eliminated.

2. No adjustment is made by any centralized entity that needs to be trusted.

3. Fairly treating long buyers and short sellers in a competitive landscape regardless of the direction of anticipated price movement.

Here’s how it works:

Assuming a market is efficiently priced by market makers and arbitrageurs, the perpetual contract should be priced by the Non-Arbitrage Principle: In the non-arbitrage pricing, for each funding interval (each minute), the expected funding level change (the payment from long buyer to short seller) should equals to the expected price change, so that there would be no arbitrage opportunity. As funding level change is determined by average trading premium, we can get:

When there is anticipated price change at the time T in the future, we could use Non-Arbitrage Principle to calculate the fair price of a perpetual contract at each time before the price change happens through Backward Deduction. At the beginning, we can get the expected fair price at T-1 by Non-Arbitrage Principle based on the expected fair price at T. Thereafter, and the expected fair price of T-n could be backwardly deduced.

The detailed deduction process is as follows:

By formular (1), we can get

By definition:

By risk-neutral pricing, the expected Index Price before time T is:

By formula (3), (4) and (5), we can get:

By formular (6), we can get

By formular (2) and (7), we can get

This is how we get the non-arbitrage priced Average Trading Premium in T-1 minute! And the price of T-1 minute should be:

By the same logic of getting formula (7), we can get

Now by backward deduction, we can get

And the price of T-n minute should be:

Job done!

Example: Illustration on pricing path for anticipated price gap

Assuming a stock is currently traded at $100, and it is announced that it will pay a $20 dividend for investors who hold the stock in the time of 1000 minutes. Investors expect the stock price will decrease to $80 at that time to reflect this. Assuming the funding gravity parameter of its perpetual contract is 0.003. Through backward deduction, the perpetual contracts price is expected to switch smoothly towards the anticipated new index price. And for each minute, the funding payment (funding level change) will equal to the price change so that no arbitrage opportunity exists. For a trader who passively long this position, the expected total return is zero as the profit/loss from funding and from price change could be cancelled out.

Example: Calculating the perpetual contract fair price before future contract rollover

Assuming the crude oil perpetual contract has a funding gravity of 0.001. Currently the April contract of the WTI crude oil future is used as its underlying price source. And in the next 300 trading minute, May contract will be used as the underling price instead. April contract is traded at $80 and May contract is traded at $85. The fair trading premium should be (85-80)/(1+0.001)^300= 3.7, and the fair price of the perpetual contract should be 80+3.7=83.7. Any significant deviation from this value could bring arbitrage opportunity for professional traders.

Last updated