HydraSwap
Published in

HydraSwap

A window into AMM 2.0 — Introducing Volatility Adjusted Fee

A window into AMM 2.0 — Introducing Volatility Adjusted Fee @HydraSwap

Introduction

This paper introduces a mechanism for adjusting the fees on constant product automated market makers with the level of market volatility. When liquidity providers (LPs) provide liquidity to automated market makers (AMMs) they take on a short volatility exposure. The fees charged by AMMs should adjust based on the level of market volatility. The constant fee approach used by AMMs is unable to protect liquidity providers during turbulent markets. Conversely the constant fee ends up being too high during stable periods, and decentralized exchanges powered by AMMs are unable to compete vs centralized exchanges. Moreover constant fee is inappropriate for different asset pools with different realized volatilities. Volatility adjusted fee ensures that the Liquidity Providers (LPs) are fairly compensated for the risk they assume when providing liquidity across different market conditions and pools.

We start with deriving the closed-form formula for LP wealth over time as a function of variance in the absence of fees. We define a measure called ‘AMM velocity’ which is equal to the trading turnover as a function of TVL (total value locked i.e. total liquidity provided by LPs). We then derive a formula for pricing AMM fee as a function of price variance and AMM velocity. We then introduce a practical approach to implementing this on-chain using hourly exponentially weighted moving average variance. We demonstrate with backtests how a volatility adjusted fee model can significantly enhance LP returns by adjusting pricing appropriately with market conditions. Moreover we show that such a fee model incentivizes trading volumes by significantly lowering AMM fees during calmer markets.

Background — Impermanent Loss, Volatility and Fees

Impermanent loss i.e. the loss that a market maker faces when providing liquidity to an automated market maker is a function of the market volatility. The more the market moves, the higher the loss that liquidity providers face.

This is easy to see. Let’s take a uni v2 style constant product market maker. Suppose an LP measuring their wealth in USD, provides liquidity to an ETH-USD pool. Typically such an LP would look to hedge out their ETH exposure externally in order to be delta neutral in USD terms. If the value of ETH-USD drops, the LP gets delivered more ETH and less USD. In order for them to remain delta neutral in USD, they need to sell the additional ETH. The opposite happens if ETH-USD goes up in price i.e. LP needs to buy back ETH. This buy-high, sell-low dynamic is the short gamma exposure that LPs take on when providing liquidity. The more volatile the market, the higher is the cost of doing this gamma rebalancing.

LPs get compensated for this negative gamma exposure from the AMM fees. The negative cost of this gamma increases with volatility and so a constant AMM fee does not compensate LPs appropriately for the risk that they take when providing liquidity.

Calculus of LP Wealth

Let’s say an LP provides liquidity to a constant-product AMM pool in tokens X and Y and measures wealth in Y. Treating Y as numeraire, we have marginal price Pt = Y/X and XY= k = L² from the constant product invariant. X and Y denote the LP token balances and L is a constant denoting liquidity supplied by the LP.

In the absence of fees, LP wealth in the pool (W) is given by:

So the LP wealth at any time is a function of the square root of the asset price.

The square root of price follows a geometric brownian motion with drift = μ/2 - σ²/8 and volatility = σ/2 (see Appendix 1)

The expected value of the square root of price at time t is given by:

(1)

Assuming μ=0, we see that LP wealth at time t, is given by:

(2)

The expected LP wealth decays by ⅛ the variance of the asset price with time. The expected change in LP wealth between time interval t and t + Δt is given by:

(3)

Impermanent loss from the lens of dynamic hedging

The above formula can also be derived by looking at the dynamic hedging p&l of a delta neutral LP.

Value of LP assets in the pool (W) are given by:

LP hedges its delta by taking a short L/sqrt(Pₜ) position in X

Change in value of LP assets in pool + delta hedge p&l in a small time interval dt is given by:

Using the stochastic process of a square root derivative (Appendix 1), applying Ito’s multiplication and integrating from t to t + Δt, we get the same result as (3) which is expected.

Volatility drag, AMM Velocity and AMM Fee

The volatility drag experienced by LP wealth depends on the variance of the asset price. This means that a constant fee does not correctly compensate LPs for the level of risk assumed for liquidity provision. The fee needs to reflect the level of volatility i.e. the risk present in the market.

There is however another variable in the mix. The total fee is a function of the percentage fee and the volume being traded against the AMM.

The total fee earned by LP in a time interval Δt is given by:

This Total Fee should be such that it compensates LPs for the volatility drag between t to t + Δt given by:

We define velocity as the ratio of volume traded to the TVL of the AMM pool. We set the percentFee as below to ensure fair compensation for LPs.

Note: The above formula has an implicit assumption that velocity and variance are uncorrelated. We looked at daily uniswap v2 statistics going back to Jun-2020 to check our assumption. The correlation between daily velocity and variance is a mere 1.84%.

Mechanism

Variance Input

The first question we need to answer is what is the right variance value to use in our model. Given we are trying to create a fair fee model, 1-day implied variance derived from the options market would make the AMM fee fair and remove any arbitrage opportunities vs broader options market. In order to derive this fair variance, we will have to look into the portfolio of options that replicates the price of the square-root price derivative as seen above. The theoretical replication can be easily derived using Carr-Madan. However, this approach is impractical for on-chain implementation due to a number of reasons — lack of availability of short dated option quotes, on-chain implementation bottlenecks, speed and efficiency requirements of an AMM.

We will use realized exponentially weighted moving average (EWMA) variance instead as an input to our pricing model. Using EWMA variance as a predictor makes use of a well studied observation in finance called volatility clustering i.e. large variation in prices tend to be followed by large variations and small variations tend to be followed by small variations. EWMA variance has an added advantage that it can be computed easily on-chain. We also use arithmetic returns for the last period instead of log returns for more efficient computation.

EWMA Variance

We use the EWMA variance as a predictor of future variance for calibrating the fee level. We will use hourly returns to keep track of variance using the below formula:

We use hourly variance to ensure that the AMM fee is responsive to changes in market volatility. A shorter window would be too noisy and a longer window too slow to react to market dynamics. In future we would look to calibrate this as well.

Calibrating λ

The parameter in EWMA controls how much weight is given to past variance vs the last period’s returns. We use historical ETHUSD tick data for calibrating . A value of = 0.545 minimizes the mean squared error of EWMA vs subsequent hourly variance.

Estimating Velocity

Recall — we define velocity as the ratio of volume to TVL over a given time window. We use historical trading data across major DEXes to estimate this. We exclude Curve given the focus on stable-swap and extremely low velocity due to high stable-coin TVL. The historical daily velocity i.e. average daily volume (ADV) to TVL in DeFi has averaged around 10%.

Min/Max Fees

We set the minimum fee to 5bps and max fee to 2%.

The below graph shows the evolution of %fee with annualized volatility.

Backtest — Constant fee vs Vol adjusted fee

We conducted the backtest using 1min tick data from Binance to compare the performance of LPs for two liquidity pairs: ETHUSD and SOLUSD since January-2021. The backtests assume that every trade that occurs is an arbitrage trade, that is executed only when minimum margin requirements are met (namely when profits from the trade exceed the fees paid). The constant fee is set to 0.3%, inline with major AMMs. The volatility adjusted fee rate is set as per the mechanism described above.

The volatility adjusted fee model shows significant return improvement vs the constant fee model. The majority of the outperformance comes from high-volatility market environments. For a SOLUSD LP, the backtest shows a 50% higher total fees collected with vol-adjusted model vs constant fee. For ETHUSD the returns were 1.26x vs constant fee.

The below charts show the behavior of the two models in different volatility regimes. We label time periods with low (annualized vol<50%), mid (50%-150%) or high volatility (>150%) based on the level of annualized volatility.

Our first observation is that markets spend a relatively low percentage of time in high volatility regimes. During our backtest window, SOLUSD experienced high volatility 30% of the time and ETHUSD a mere 10% of the time. The vol adjusted fee pool traded significantly lower volumes during this time but outperformed in terms of total fees collected.

During low-mid volatility periods, the vol adjusted pool traded higher volumes than the constant fee pool and collected similar total fees. So not only does the vol-adjusted fee model protect LP during volatile times (by compensating LP with higher fees), but it also leads to higher trading volumes by lowering fee rates during calmer market environments. This can be seen by the significantly lower median fee charged by the vol adjusted fee model vs constant fee.

Conclusion

An AMM that adjusts fee levels based on market variance can significantly enhance LP returns and preserve LP capital during volatile markets. This aligns the AMM fee structure with market dynamics and would incentivize LPs to leave capital in liquidity pools as they are fairly compensated for the market risk. During normal markets, this would incentivize trading volumes by lowering the AMM fee to appropriate levels and enable decentralized exchanges to compete with their centralized counterparts.

Appendix 1

Deriving the square root price process

We start with the price P following a geometric brownian motion and derive the process followed by sqrt(P) in order to understand the evolution of LP wealth over time.

Applying Ito’s multiplication. dt² and dt.dz =0 and dz²=dt, we have:

So we have:

The square root of price follows a geometric brownian motion with drift = μ/2 — σ²/8 and volatility = σ/2

The expected value of square root price at time t is given by:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hydra

Hydra

HydraSwap is building a next-gen DEX powered by a superior AMM focused on Liquidity Providers. By empowering liquidity providers we will make DEX liquidity CEXy