New Framework for Funding Rates

TLDR

We design a new funding rate mechanism for an AMM-based exchange that compensates the exchange for the risk of long-short imbalance and can be extended to adapt to arbitrage demand. See the full write-up here.

Motivation

We aim to design a perpetual futures exchange for long-tail underlyings. We choose to design an AMM-based exchange rather than a limit orderbook. Because an AMM-based exchange will match buyers (longs) and sellers (shorts) asynchronously, it is possible for an imbalance to exist, exposing the exchange to inventory risk due to implicitly being the counterparty to every trade. Hence, we look towards the current landscape of perpetual futures exchanges as well as literature on (high-frequency) market making to explore how to design a funding rate mechanism that can correct this imbalance.

Current funding rates

Since perpetual futures do not have an expiration date for settlement, Shiller, 1993 originally envisioned funding payments as a mechanism for daily settlement and Angeris et al., 2022 derives model-free expressions for funding payments using a no-arbitrage argument.

In orderbook-based exchanges, funding payments periodically settle the difference between mark and index price, thereby ensuring mark price to closely track index price. More formally, funding rate F at some time t is defined as

F = P + \text{clamp}(I-P, -\delta, \delta)
P = \frac{(\text{bid}-\text{index})_+-(\text{index}-\text{ask})_+}{\text{index}}, \; I=\text{quote interest}-\text{base interest}
\text{clamp}(I-P, -\delta, \delta) = \begin{cases} I-P &\text{if } -\delta<I-P\leq \delta\\ -\delta &\text{if }I-P \leq -\delta\\ \delta &\text{if }I-P> \delta \end{cases}

where P represents the premium, I approximates the risk-free rate (see this for crypto risk-free rates), and the clamp function ensures that the funding rate equals the risk-free rate if P and I are within \pm \delta. While the exact implementation may differ, such as specifying the order size that determines impact bid/ask price or a different derivation of the risk-free rate term, most orderbook-based exchanges share this formula (for a comprehensive analysis, see UXD’s comparison of funding rates). Importantly, most centralized exchanges settle funding payments every 8 hours (e.g. BitMex, Binance) or every 1 hour (e.g. FTX), which concentrates trades around the settlement period.

On the other hand, AMM-based exchange funding rates are typically defined differently. Because longs and shorts are not matched one-to-one, there might exist a long-short imbalance. This imbalance imposes inventory risk on the exchange because an AMM-based exchange is implicitly the counterparty to all traders. As a result, funding payments can no longer just be a periodic settlement from one side of the contract to the other, but must act additionally as an incentive mechanism for traders (arbitrageurs) to help correct the long-short imbalance by opening positions on the underweight side and receiving funding payments. Hence, funding rates are usually defined to scale with the long-short imbalance L-S where L, S \geq 0 denote the total open interest of longs and shorts respectively.

For example, Deri defines funding rate F = fa(L-S) where a determines price impact and f is a function of total liquidity while Kwenta (and Synthetix) defines funding rate F = \text{clamp}(\frac{L-S}{L+S}, -1, 1)\cdot i_{max} where i_{max} = 10\%/\text{day}.

Overlay similarly defines funding rate F = 2k \cdot \frac{|L-S|}{L+S}, but rather than transferring the funding payments between the traders’ margin accounts, settlement is done by decreasing overweight open interest and increasing underweight open interest. As such, assuming the worst case scenario where no arbitrageurs help correct the long-short imbalance, k is calibrated such that with high confidence, the value-at-risk of the imbalance decays to zero at some future time.

Market making literature

The problem of determining a funding rate has parallels to the problem of high-frequency market making. In particular, we examine Avellaneda-Stoikov models, which use stochastic control to solve for optimal bid and ask quotes by modelling the arrival of traders on a limit orderbook while accounting for inventory risk. Typically, these models consider a market maker who maximizes her CARA utility. More precisely, the market maker has an objective function of the form

\text{maximize} \quad \mathbb{E}[-\exp(-\gamma(X_T + q_T S_T - \psi(q_t)))]

where at some time T, X_T is cash, q_T is number of stocks, S_T is stock price, and \psi penalizes inventory, taking forms like \psi(q_t) = l(|q_t|) where l is a liquidity premium for inventory or \psi(q_t) = \frac{1}{2} \gamma \sigma^2 \int_0^T q_t^2 dt where holding an inventory is also penalized over time (Guéant, 2017). However, a limitation of these stochastic control approaches is the over-simplification of market dynamics to make the problem analytically tractable, such as assuming CARA utility, Brownian motion of stock prices, and Poisson process of order arrival rates.

Risk-based funding rates

Although funding rates should be designed to both incentivize arbitrageurs to help correct the long-short imbalance and to compensate the exchange for taking on inventory risk in the temporary absence of arbitrageurs, we will first look at the latter objective. This is because a funding rate mechanism is particularly crucial for any AMM-based exchange. Designs such as Perpetual Protocol v1 that relied on paying out funding from the exchange itself resulted in insolvency in the event of an adverse price movement. At the same time, it is trivial to charge an arbitrarily large funding rate. Note that funding payments should also be a continuous payment from traders’ margin accounts to avoid frontrunning risk.

Assuming the worst case scenario, i.e. the absence of arbitrageurs, we set funding rate such that the total funding payment received makes our inventory risk acceptable. We can capture inventory risk with a monetary risk measure and allow the funding payments to decay the inventory risk to zero over time. If the funding rate is less than the risk-free rate, we will simply charge the risk-free rate. More precisely, we require total funding payment \bar{F}_t to satisfy

\bar{F}_t \cdot \int_t^{t+\tau} e^{-\gamma (s-t)} ds = \rho_{t+\tau}(X)-\Pi_t

where \rho_{t+\tau} is a monetary risk measure evaluated over the time horizon from t to t + \tau, X is inventory, \Pi_t is the cumulative funding revenue, and \gamma is a discount factor. Note that instantaneous funding rate at time t+\Delta t is F_{t+\Delta t} = \frac{\bar{F}_t\cdot e^{-\gamma\Delta t}}{P_{t+\Delta t}\cdot \max(L,S)} for \Delta t \in [0,\tau). If a new transaction happens at time t' < t+\tau, we will recompute \bar{F}_{t'}, which defines finding rate for time [t', t'+\tau).

Now, consider a long-heavy market L > S. If we simply set X to be the imbalance liability (a short position with open interest L-S), then the funding payments provide only the bare minimum for covering the exchange’s inventory risk, and there will be no funding payments left for the shorts to receive. To incentivize arbitrageurs who may take on potential market risk to help correct the imbalance, we need to compensate them sufficiently — a risk-based amount is reasonable. So instead, set X to be a short position with open interest L and split the funding payments received pro-rata between the exchange and the shorts. A similar argument holds if the market is short-heavy.

We can choose \gamma \propto \frac{|L-S|}{L+S} so that as the long-short imbalance relative to the total open interest increases, the exchange and arbitrageurs will receive more funding payments, or equivalently receive the total funding payment (\rho_{t+\tau}(X)-\Pi_t) faster. We can choose \tau to be relatively small, such as 1 day, to reduce model risk.

Note that one limitation of this risk-based formulation is funding overcharge, despite being in part mitigated by the \Pi_t term. Intuitively, the overweight side will consistently pay for the worst case scenario but will never receive a refund if that scenario does not happen. One possible solution is to choose \rho to be the expectile value-at-risk so that it also captures the upside from the imbalance liability.

Adaptive funding rates

The above formulation decreases risk by compensating the exchange for the imbalance liability. Risk can alternatively be decreased by correcting the imbalance through adjusting the funding rate to reflect the demand of arbitrageurs. Hence, an alternative formulation is to let the total funding payment consist of two separate parts: a base compensation to the exchange for inventory risk and an additional floating rate that adapts to arbitrage demand.

Setting this floating rate is a trade-off between exploration and exploitation, commonly addressed in reinforcement learning. In fact, various market making literature have explored the application of reinforcement learning for choosing strategies such as setting an optimal bid ask spread (Hambley et al., 2022), given it assumes no knowledge of the market environment and offers a model-free alternative to stochastic control approach literature.

Moreover, several recent papers have explored deep reinforcement learning to combat dimensionality issues. Sadighian, 2019 introduces a crypto market-making framework using advanced policy-gradient algorithms and finds favorable results on real limit orderbook data. Deep value-based algorithms like double deep Q-networks, when coupled with adversarial reinforcement learning, have also significantly outperformed to benchmarks like extensions to the Avellaneda-Stoikov model (Gašperov and Kostanjčar, 2021).

For our application, we can consider the following: define a floating rate f=\gamma\cdot\frac{L-S}{L+S} similar to many of the existing exchanges, and let \gamma\in G be a variable for some finite set G = \{\delta, 2\delta, \cdots, (A-1)\delta, A\delta\} and A > 0. By defining our reward function for choosing \gamma_t as r_t(\gamma_t) = (\Pi_{t'}-\Pi_t)-(X_{t'}-X_t) where we observe a new transaction at time t', we can apply multiplicative weights algorithm (Abernethy and Kale, 2013) to find optimal \gamma_{t'}. With additional constraints on the reward function, we can further extend the learning model to continuous space by applying continuum-armed bandit algorithms (Penna and Reid, 2011). It remains to be shown however if this can be practically implemented in crypto.

Questions

  1. Right now, we envision a “hybrid” funding rate, consisting of a base compensation for inventory risk plus an additional floating rate adapting to arbitrage demand. However, does it make more sense for the funding rate to be solely risk-based or solely adaptive?
  2. How practical is the reinforcement learning approach? Is there a framework that can possibly be implemented on chain?
7 Likes

This is a really good overview of the current frameworks for funding rates and were they could go in the future. I also really appreciated the uxd overview that was linked, had not seen that one before.

A far less technical read than other resources linked but the perpetual pvp ponzi provides an in depth analysis of current vAMM and funding rate design results in little price discovery, heavily overweight long-short imbalances, and eventual insurance fund blowups and is nice to read in the context of understanding funding rate design and outcomes of the exchange.

Reading through the risk based funding rate section I would like to understand the blurb on overpaying

Intuitively, the overweight side will consistently pay for the worst case scenario but will never receive a refund if that scenario does not happen

Would there be a way to collect this data from popular perp platforms? It would be interesting to analyze how much overweight sides are paying extra over time.

Synthetix just launched v2 of their perps platform. A traditional funding rate is purely based on the difference between the mark and the index at a given time. Synthetix will now change change the funding rate based on the time that there is a skew (r = c * skew is now dr/dt = c * sk). They give the example

If a market currently has 2m in long skew, and stays there for 24 hours without any additional trades, the funding rate will continually move upwards until the long skew is decreased

This might the start of exploration into adaptive funding rates? Given no arbitragers over a period of time the rate will continually increase to incentivize them more. Would be curious your thoughts on this @max

Overall though I do believe that adaptive funding rates will become even more crucial as perps are listed for assets that are thinly trades or simply don’t trade on other markets (ie nftperp is one of the few platforms in which you can trade nft floors having a controlled long-short imbalance will be crucial for their exchange’s health)

2 Likes

The risk based funding is somewhat forward-looking, instead of charging for the current net PnL from the imbalance for example. We may be charging more than what we actually needed to eliminate risk at time t+\tau, but any overcharge will be included in the \Pi_{t+\tau} term to reduce the funding in the next interval.

Definitely would be interesting to analyze this for other perp platforms. We can potentially use their skew to calculate the risk as well as the implied risk-based funding rate, and compare that with their actual funding rate to see if they charged extra / too little.

Yes, interesting approach to update funding rate but not too sure about incrementing the rate linearly wrt time. Curious to see how the trader activity changes based on this.

Agreed. We’re looking to publish more on adaptive funding rates and hope to see others exploring different approaches.

1 Like

If one wants to make the RL approach immediately usable on chain, here is one line of attack; make it single parameter and a clear max time during which liabilities are held and, so at the end of each funding period the the reward is negative if the LPs are not hedged out. This reduces from general RL to a bandit setting.

The main problem I see is conceptual; since it is not clear how a perpetual market can generate surplus (aka is not zero sum) it is not clear what to leverage as the reward of the market maker. If it is simply profits then it seems hard to avoid pathologies like the perpetual pvp ponzi, since it is unclear why anyone would want to participate in what will be clearly negative sum (0 minus network fees)

In general mechanism design requires we understand what it is we are trying to generate (welfare or profits) and what the agents valuations are beyond monetary transfers. Generic perpetual mechanisms abstracted from what the index is seem to lack the valuations part.

3 Likes

Do you consider the GMX funding rate as “adaptive”? Also is anyone actually going to analyze other perp platforms with data or does it fall under a “nice to have” thought right now?

I think you can argue that GMX’s funding rate (borrow fee) is adaptive because its based on the LP pool utilization. But I don’t see any clear justification for the 0.01% multiplier. Seems like there’s room to improve there.

Yeah it’s a nice-to-have for us (at the moment).

is there any discussion on how the mark price of the amm is determined for these new funding rate frameworks?

is it just a simple oracle-based amm or something else? if so the funding under a normal OB method posted would be 0 since mark twap = index twap?

A far less technical read than other resources linked but the perpetual pvp ponzi provides an in depth analysis of current vAMM and funding rate design results in little price discovery, heavily overweight long-short imbalances, and eventual insurance fund blowups and is nice to read in the context of understanding funding rate design and outcomes of the exchange.

vanilla vAMM described in that post ( the perpetual pvp ponzi) have:

  • full price discovery, user positions can determine the exact amount of imbalance of longs/shorts toward the index price they want to go
  • heavily overweight long-short imbalance occurring iff when prices drift further from initialization than fees collected can rebalance (just as technically possible for any aggressive estimated new funding charge design as well)
  • insurance fund blowups that arguably didnt occur from funding rate payments

what do you think? im all for improving funding design but i dont think its the single solution for these criticism / risks associated with virtual liquidity

1 Like

The model above assumes that the amm is oracle-based, so you’re right that the funding under OB method will return 0. We are exploring methods for defining mark price and planning to release another write-up on that!

I agree - funding rate wouldn’t magically address all the problems. I believe the better approach is to clarify the objective of the AMM and try to price it, which is definitely not easy if we want to consider how traders respond to such pricing (which was the motivation for Bandit Funding Rates)

2 Likes