The HydraSwap HMM: Game-Changing AMM for Liquidity Providers
DEXes, AMMs and Traditional Market Makers
One of the most significant advances of decentralized finance (DeFi) has been the evolution of decentralized exchanges (DEXes) along with automated market makers (AMMs). These decentralized protocols have turned passive savers into Liquidity Providers (LPs) for trading activities.
Traditional market makers (MMs) provide liquidity in centralized exchanges by posting bids and offers and dynamically managing their sizes and prices using complex mathematical models. This is a highly specialized activity reserved only for sophisticated players.
A more appropriate term for market makers is ‘price makers’ since they create ‘prices’ by showing bids and offers in the market. Traders that simply buy or sell at the bids and offers available in markets are termed ‘price takers’ as they simply take the prices provided to them by price makers. Price makers have to deploy capital in order to provide liquidity and they earn a return on this capital in the form of trading spreads when price takers trade against them. They buy at bids and sell at offer and theoretically pocket the difference.
AMMs allow passive savers to become LPs. Passive LPs provide the capital and get a return from trading fees without worrying about managing their positions actively. AMMs replace the sophisticated price making process of traditional AMMs with (relatively) simple mathematical frameworks that are based on the inventory of tokens in liquidity pools. This means passive LPs can leave assets in these liquidity pools and enjoy returns from market making activities that were earlier exclusively available to active market makers. This has created a new venue where investors can deploy their assets and earn a yield. This also means traders can enjoy abundant liquidity as more capital is deployed in liquidity provisioning activities.
Limitations of Current AMMs
The current crop of AMMs is still way too simplistic when compared to their traditional market making cousins. The most popular form of AMM is the constant product market maker (CPMM), which arrives at ‘fair’ market prices by keeping the product of token inventory balances constant. It relies on arbitrageurs to step in and correct price misalignments with the broader market. In the process a lot of potential profits for passive LPs is left on the table. Sophisticated LPs that provide liquidity to AMMs do a lot of heavy lifting in the form of inventory management off-chain.
One big issue stopping AMMs from evolving closer to traditional MMs is the gas bottlenecks for performing sophisticated calculations on-chain. The entire market making framework and intelligence needs to be done on-chain so that passive LPs can enjoy similar returns to traditional MMs.
Another big issue is the constant fee model that AMMs deploy. AMMs have volatility exposure and the fees should be tied to the level of volatility in the market. 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.
The HMM Vision
Hydra Market Maker’s (HMM) vision is to create an AMM that is on par with the performance of traditional MMs. HydraSwap runs on the lightning-fast Solana chain, which removes the computational and gas cost bottlenecks facing AMMs on EVM-based (Ethereum virtual machine) chains. HMM would be the first to utilize the full technical capabilities of Solana to provide a high performance AMM with significantly improved LP returns and a more reliable trading framework.
Under the current constant product market maker (CPMM) model, passive market makers are beholden to a basic pricing mechanism. In its first version, HMM introduces a smarter pricing mechanism for incentivizing arbitrageurs while protecting the P&L of LPs and improving their impermanent loss profile. Improving the performance of LPs would attract more liquidity. This would lead to traders enjoying greater liquidity, greater depth, more reliable trading during volatile periods, and reduced slippage. Subsequent versions will add volatility sensitive pricing and style price bands.
HMM v1: Introducing the Compensation Parameter ‘C’
The first step is realizing that CPMMs determine the price solely based on their own inventory balances. When a trader interacts with a CPMM, the CPMM rides up or down the constant product price curve. It starts bidding or offering aggressively to incentivize arbitrageurs to step in and help ‘hedge’ out its position as quickly as possible. This is not necessarily the optimal setup. LPs could do better by observing the broader market and making a more informed pricing decision.
The below chart shows the price profile of a 2-asset CPMM. When the token balance of the AMM decreases from X0 to Xi, the price rises from P0 to Pi. The area of the green region represents the magnitude of impermanent loss that LPs face at this new price. CPMM is now bidding token X at a higher price (ignoring fee) determined by the constant product curve. By bidding this high price, CPMM is hoping for arbitrageurs to step in to replenish the token X balance and go back to the original state with 0 impermanent loss. But in this process, the CPMM ends up giving away a chunk of its potential profits to arbitrageurs.
We introduce the compensation parameter that sets the level of compensation LPs are willing to accept vs incentivizing arbitrageurs. HMM looks at the oracle price and uses ‘c’ to determine how aggressively it should bid or offer when it has been given a position (i.e. when it’s token balance has deviated from its starting balance). The price does not need to be as aggressive as under CPMM and arbitrageurs would still step in as long as there is a trading profit to be made.
C controls how much an LP can compensate themselves versus arbitrageurs.
Basically, when C=0, the scenario is the same as CPMM. Arbitrageurs have the exact same incentive for closing out the price discrepancy.
As C goes up, the arbitrageurs are incentivized less.
When C is between 0 to 2, arbitrageurs are getting less than in CPMM. At C=2, the arbitrageurs have no incentive.
By controlling arbitrageur compensation, the LP’s impermanent loss is lowered and PNL profile improved over the CPMM model. We have conducted thorough backtests demonstrating this. We will share these in a follow-up medium post.
Here is the HMM pricing formula (neglecting fees):
HMM Pricing Formula
How HMM Works with the Oracle Price
Oracles are data providers that get feeds from many markets and determine what the mid-market should be.
First, HMM does not only consider the marginal price, looking inwards. HMM starts with a CPMM price and then looks outwards at the oracle price to try and do better than CPMM.
If the CPMM is bidding at a marginal price that is too high compared to the oracle price, the HMM adjusts it closer to the oracle price to improve the performance of LPs.
If C=0 (the oracle price does not matter).
Under the HMM model, the risk of the oracle price being manipulated is eliminated. An attacker will not be able to manipulate the oracle price to induce HMM into showing an incorrect/artificially cheap price. Specifically, the CPMM is like a safety net. If the oracle price is wrong, the price falls back to the CPMM price.
Volatility-adjusted Pricing — Work-in-progress
We will introduce a fee setting that’s based on the level of volatility of the market. This would correctly compensate LPs according to the level of risk in the market. The current AMMs fail to do that. This leads to a reduction in liquidity on offer during volatile times as sophisticated LPs pull back liquidity. As mentioned earlier, LPs in AMMs are short volatility and a fixed fee does not correctly address this risk/reward trade-off for LPs. Conversely, LPs get paid too much when markets are stable and traders end up paying a high cost in stable markets. By dynamically adjusting the level of fees based on market vol, HMM aims to correctly price this market dynamic. This would incentivize LPs to keep providing liquidity even in volatile markets and would enable a more reliable trading experience for users.
With HydraSwap’s HMM core and integrated trading modules, passive LPs will no longer be little fish watching their profits eaten away by sharks. For the first time in DeFi, passive LPs can expect similar returns as sophisticated market makers.
HydraSwap is a Solana DEX powered by an on-chain intelligent and high-performance AMM focused on maximizing the returns for Liquidity Providers. Our vision is to create an AMM that matches the pricing sophistication and returns of specialized market makers.