Hydra Market Maker (HMM)

1. Motivation

Constant product market makers (CPMM) have allowed savers to become passive market makers. They provide liquidity in DEXes while earning yield from transaction fees. This has been one of the key innovations in DeFi leading to where we are today. However it is just a start and it is far from the optimal setup. Uni v3 is a great improvement allowing LPs to figure out their own sweet spot when providing liquidity. There still remains a wide gap between passive liquidity provision and how sophisticated market makers function.
In the current setup the CPMMs offer a basic pricing mechanism and the sophisticated market makers do the heavy lifting off chain. Solana has the potential to change that and allow AMMs to become a lot more sophisticated as it alleviates the computational and gas bottlenecks we currently see on Ethereum. This would lead to reduction in overall time & cost overhead for sophisticated market makers as well as improve the P&L profile of purely passive LPs.
With HMM we aim to continue on the path of innovation and introduce further sophistication in the AMM process. In version1 we will introduce a smarter pricing mechanism for incentivising arbitrageurs while protecting the P&L of LPs and improving their impermanent loss profile.
In version 2 we will combine compensation parameter with uni v3 style concentrated liquidity using the mechanics described further down in this paper. We will also introduce a volatility adjusted fee for correctly compensating LPs based on the level of volatility in the market.

2. HMM Model v1.0: Compensation Parameter

A traditional market maker (MM) would adjust it’s bid and offer once given a position. This is called applying a price skew. A CPMM does the same by moving up and down the bonding curve based on the token balances after a trade. Traditional MMs use sophisticated machine learning tools taking into account various signals for adjusting pricing. CPMM however relies purely on its own token inventory and is completely agnostic to what’s happening in the broader market. Sometimes this price adjustment can be too aggressive. This leads to pnl leakage as well as adverse selection of trades.
With HMM v1, we introduce a tweak to the CPMM model and introduce a reference oracle price to make a more informed price adjustment mechanism.
Introducing c, the “Compensation Parameter”
When a trade is entered vs a CPMM, token balances change and the price moves along the bonding curve. The LPs experience impermanent loss which is equal to the area of the shaded region in red (ignoring fees).
The price adjustment incentivizes arbitrageurs to step in to replenish the token balance and reduce the impermanent loss.
In HMM, we introduce a compensation parameter ‘c’ which controls how much LPs are willing to compensate arbitrageurs. By controlling this, we can improve the pnl profile of LPs and show that the expected impermanent loss is lower than that of the naive CPMM model.
‘c’ can range from 0 to 2. At c=0, the HMM price is always the same as the CPMM price and creates a large incentive for arbitrageurs. At c=’2’, the HMM price creates no incentive for arbitrageurs. ‘c’ only comes into play when the HMM price is BETTER than the oracle price. In between, HMM still creates an incentive for arbitrageurs but it does so while keeping an eye on the oracle price. If the marginal price using CPMM is too aggressive compared to the oracle price then HMM tries to adjust it closer to the oracle price which provides better performance for LPs.
HMM Parameters
x,yx, y
:number of base token and quote token currently in the liquidity pool
: DEX price now(
: amount in the pool of the asset x before trade
: oracle price
: amount in the pool of the base token ‘
’ at oracle price i holding
xy=kx*y = k
c c
: compensation parameter ∈ [0,2]
HMM Pricing Formula
Neglecting fees:
Marginal price
when buying
OR selling x and
when buying
OR selling x and
The HMM marginal price has a multiplier of
which is used for raising or lowering the CPMM price
When a trader buys token x vs y, token balance goes from
to x_
We calculate the change in quantity for token y using the below equations.
If the oracle price at the time of trading is equal to or less than the DEX price:
If the oracle price at the time of trading is greater than the DEX price:
if the base token balance after trade is greater than or equal to
if the base token balance after trade is lower than
When a trader sells token x vs y, token balance goes from
We calculate the change in quantity for token y using the below equations.
If the oracle price at the time of trading is equal to or greater than the DEX price:
If the oracle price at the time of trading is less than the DEX price:
if the base token balance after trade is less than or equal to
if the base token balance after trade is greater than
x+>xix+ > x_i
Lower expected Impermanent Loss with HMM vs AMM
Arbitrageurs step in and trade against the AMM until an equilibrium is reached vs outside sources of liquidity. Let R= the price ratio between when liquidity was supplied and now.
Ignoring fees, the impermanent loss in CPMM can be shown to be equal to:
With HMM, we can show the impermanent loss to be equal to:
[(R^(C/2)-Sqrt(R))/(C-1) + Sqrt(R)+1]/(1+R)-1
This impermanent loss in HMM is strictly lower than CPMM!
Immunity to Wrong Oracle Price
We can show that HMM has inbuilt immunity to incorrect/manipulated oracle price. An attacker trying to manipulate the oracle price will not be able to make the HMM price better than AMM.
To illustrate this, if the oracle price is wrong (e.g.
, while true market price is larger than
), HMM will perform the same as a CPMM i.e. attackers will not be able gain an advantage. As long as the oracle price gives the right indication of whether the market price is greater than or less than current DEX price, LPs will be better off, the degree to which is dependent on accuracy of the oracle price.
Mathematically, It can be easily shown that:
so after each trade in HMM neglecting fees:

3. HMM Model v2.0: Concentrated Liquidity++

Uni V3 with concentrated liquidity introduces a flexible and efficient way that can significantly improve capital efficiency and help LPs customize with range orders. While Uni V3 concentrated liquidity gives LPs granular control over what price ranges their capital is allocated to, it introduces potentially bigger impermanent loss should there be any large one-way price action.
This is where HMM, given its significant outperformance over CPMM in protecting P&L for LPs, can be perfectly combined with Uni V3. In detail look, the HMM combination with Uni V3 can be easily adopted only with changes made to the swapping process within each active tick interval.
Same as CPMM, the available liquidity for both tokens within each interval can be easily calculated with
. This can be compared to remaining input token balance (positive or negative) to see if we need to cross the next tick. Within each price interval [
(starting tick price),
(ending tick price)], the output token amount (positive or negative) can be calculated with HMM as below:
is NOT between
(oracle price):
is between
(oracle price):
    If input token is X,
    If input token is Y,

4. Volatility Adjusted Fee

LPs providing liquidity in an AMM pool experience a volatility drag on their position i.e. they have volatility exposure. When markets are moving a lot, LP profits are eroded away by higher impermanent loss. Sophisticated LPs that dynamically rebalance their token inventories bleed more money doing these rebalancings in volatile markets. Conversely, AMMs accumulate profits in calm markets when there is trading activity around a stable price. Constant fee fails to reflect these market dynamics. This means LPs will be more inclined to take away liquidity from AMMs in volatile markets thus exacerbating market moves. In stable times, traders will be less inclined to pay the high fees on DEXes. This is the exact opposite of the desired dynamic!
Volatility sensitive pricing is needed for incentivising LPs to keep funds during volatile times and traders to continue using DEXes in stable times. LPs should earn higher fees in turbulent times and lower fees in calmer markets. This would lead to a fairer and a more robust trading ecosystem.
We present the heuristic for pricing AMM fee below.
Assuming an LP provides liquidity in a 2-asset constant product market making pool composed of tokens X and Y.
Treating Y as numeraire, we have marginal price
denote the LP token balances and L is a constant denoting liquidity supplied by the LP.
Value of LP assets in the pool (
) are given by
The value of LP assets follow a square root price process.
Assuming geometric brownian motion for price
, we have:
​Square root price process is given by:
This means LPs experience a volatility drag =
The above can also be modelled by explicitly calculating the delta-hedging p&l of an LP that constantly hedges its delta to stay hedged in numeraire. This negative gamma pnl experienced by LPs between 2 periods is given by:
is the initial value of the LP deposit and denotes the annualized volatility of log returns.
Considering a single day time frame, the expected value of LP loss equates to
We want the expected fee earned from AMM to exceed that of the LP loss.
Here ADV represents the average daily volume, TVL is the total value locked in the pool and
is the fee rate.
We define velocity as a measure of ADV / TVL. i.e. what multiple of the TVL does the AMM trade daily on average. This gives us the below heuristic for setting min AMM fee.
Last modified 5d ago