Deep Dive into Automated Market Maker (AMM)
Introduction
The Diatomix team is developing their solution on the Algorand Network in collaboration with the network’s DEXs, liquidity providers, and community. Diatomix will focus on creating a solution that can hedge impermanent loss, be easily integrated with DEXs, and drive adoption in the Algorand ecosystem. This product will allow liquidity providers to hedge their positions in a single step when they contribute capital to a pool.
In AMM (automated market maker) protocols, there are various participants including Liquidity Providers, Exchange Users (Traders), and the Protocol Foundation. LPs add assets to liquidity pools in a DEX, and earn a cut from each trade. Traders submit exchange orders and pay swap fees to LPs and gas fees for transaction verification. The Protocol Foundation consists of founders, designers and developers responsible for protocol improvement and development. The assets involved include the pool tokens, pool shares, and protocol tokens. Pool shares represent ownership in the portfolio of assets in the pool, and Protocol tokens typically represent voting rights and can be used for liquidity provision and governance.
Who are the participants?
1. Liquidity Providers
A liquidity pool in a decentralized exchange can be created by a smart contract with an initial supply of crypto assets. Liquidity providers can add more assets to increase the pool’s reserve and receive pool shares proportional to their contribution. Liquidity providers earn transaction fees and can remove funds freely by surrendering pool shares, potentially with a withdrawal penalty.
2. Exchange User (Trader)
A trader submits an exchange order to a liquidity pool by specifying the input and output asset and either an input asset or output asset quantity; the smart contract automatically calculates the exchange rate based on the conservation function as well as the transaction fee and executes the exchange order accordingly. Arbitrage traders take advantage of price differences between markets by executing trades to profit from the closing of price gaps.
3. Protocol Foundation
A protocol foundation consists of protocol founders, designers, and developers responsible for architecting and improving the protocol. The development activities are often funded directly or indirectly through accrued earnings such that the foundation members are financially incentivized to build a user-friendly protocol that can attract high trading volume.
What are the Assets involved within AMM protocols?
- Risk Assets
AMM (Automatic Market Maker) based decentralized exchanges are intended for assets that are less liquid and more risky and can support an IDO (Initial DEX Offering) by setting up liquidity pools. To be eligible for an IDO, a risk asset may need to be whitelisted and meet the protocol’s technical requirements (such as ERC20 for Ethereum-based AMMs).
2. Base Assets
Different protocols have different requirements for trading pairs in AMM-based DEXs. Some protocols (e.g. Bancor) require every risk asset to be paired with a designated base asset (BNT). Others (e.g. Uniswap V1) require a risk asset to be paired with ETH. Still others (e.g. Balancer and Curve) allow for direct pairing of multiple risk assets in liquidity pools without a designated base asset.
3. Pool Shares
Also known as “liquidity shares” and “LP shares”, pool shares represent proportional ownership over a liquidity pool, and are distributed to LPs. Shares accrue trading fees proportionally and can be redeemed at any time to withdraw funds from the pool.
4. Protocol Tokens
Protocol tokens in AMM-based DEXs represent voting rights and are also known as governance tokens. They are valuable assets that can incentivize participation, such as through rewards for liquidity provision. AMMs compete for funds and trading volume and can use liquidity mining to incentivize early pool establishment and trading by issuing native protocol tokens to LPs and exchange users.
Fundamental AMM Economics
Rewards
AMM protocols often run several reward schemes, including liquidity reward, staking reward, governance rights and security reward distributed to different actors to encourage participation and contribution.
- Trading fees
LPs are rewarded for supplying assets to a liquidity pool, as they have to bear the opportunity costs associated with funds being locked in the pool. LPs receive their share of trading fees paid by exchange users.
2. Governance rights
An AMM can incentivize liquidity provision and swapping by offering governance rights in the form of protocol tokens. Governance issues such as protocol treasury management are discussed in governance portals where protocol tokens are used as ballots for voting on proposals.
Explicit Costs
Interacting with AMM protocols involves various costs, including charges for services performed and fees for blockchain network interaction. Participants should expect three types of fees: liquidity withdrawal penalty, swap fee, and gas fee.
- Liquidity withdrawal penalty
Withdrawing liquidity from an AMM negatively affects the pool’s usability by increasing slippage, so some AMMs may impose a liquidity withdrawal penalty to prevent this.
2. Swap fee
Users of liquidity pools for token exchanges pay swap fees to compensate LPs for supplying assets and for the divergence loss. The fees are charged on every trade and distributed to pool shareholders; a small percentage which might go to the AMM foundation for protocol development.
3. Gas fee
Every interaction with an AMM protocol incurs a gas fee for the cost of transaction verification by the validating nodes on the underlying blockchain.
Implicit Costs
- Slippage
Slippage refers to the difference between the expected and actual price of a trade in an AMM. It occurs due to the continuous pricing curve in AMMs and increases with trade size and smaller liquidity pools. Slippage tolerance must be set for trades to be executed, making them vulnerable to attacks like sandwich attacks.
2. Divergence loss
LPs supplying assets to an AMM protocol are exposed to volatility risk and the loss of time value of their funds. The swap changes the asset composition of the pool, leading to a change in the value of the entire pool, which is called “divergence loss.” AMMs charge swap fees to compensate LPs for this loss. When assets are bonded in a pool, changes in the price of one asset affect all others, exposing LPs to risk from assets they don’t hold. For single-asset supply AMMs, LPs are exposed to additional risk.
Different types of AMM Models
Constant function market makers (CFMMs) are a type of first-generation automated market makers (AMMs) that include protocols such as Bancor, Curve, and Uniswap. These AMM exchanges are based on a constant function, where the combined assets of trading pairs must remain unchanged. In non-custodial AMMs, user deposits for trading pairs are pooled within a smart contract that traders can use for token swapping liquidity. Traders trade against the smart contract instead of other traders as in order book exchanges.
1. Constant Product Market Maker (CPMM)
The initial form of CFMM (Constant Function Market Maker) was the constant product market maker (CPMM), which gained prominence through the utilization on the first AMM-based decentralized exchange, Bancor. CPMMs (Constant Product Market Makers) operate using the formula x*y=k, which determines the price range of two tokens based on the available amounts (liquidity) of each token. When the supply of token X increases, the token supply of Y must decrease, and vice-versa, to maintain the constant product K. When plotted, the result forms a hyperbola, where liquidity can always be obtained, but at progressively higher prices that tend towards infinity at both extremes.
2. Constant Sum Market Maker (CSMM)
The second type of CFMM is the constant sum market maker (CSMM), which is well-suited for trades with no impact on price but does not offer unlimited liquidity. CSMMs follow the formula x+y=k, which creates a straight line when plotted. This design unfortunately allows arbitrageurs to drain one of the reserves if the off-chain reference price between the tokens is not 1:1. This scenario would result in the depletion of one side of the liquidity pool, causing all of the liquidity to be concentrated in just one asset, making it unavailable for traders. Due to this, CSMM is not widely adopted by AMMs.
3. Constant Mean Market Maker (CMMM)
The third type is a constant mean market maker (CMMM), which enables the creation of AMMs that can have more than two tokens and be weighted outside of the standard 50/50 distribution. In this model, the weighted geometric mean of each reserve remains constant. For a liquidity pool with three assets, the equation would be the following: (x*y*z)^(⅓)=k. This allows for variable exposure to different assets in the pool and enables swaps between any of the pool’s assets.
Problems of First-Generation AMM Models
Many of the early versions of Automatic Market Makers are hampered by the issue of impermanent loss and low capital utilization, affecting both liquidity providers and traders alike.
Impermanent Loss
Impermanent loss is the difference in value over time between holding tokens in an automated market maker (AMM) and holding them in a wallet. It occurs when the market-wide price of tokens inside an AMM diverges from external markets, and since AMMs don’t adjust their exchange rates, arbitrageurs buy or sell the under or overpriced assets to match the market-wide price, causing a loss for liquidity providers.
Low capital efficiency
Traditional AMM designs require large amounts of liquidity for the same level of price impact as order book-based exchanges. This is because a significant portion of AMM liquidity is only available when the pricing curve becomes exponential and most of the liquidity will never be used by traders due to the extreme price impact. This leads to AMMs being referred to as “lazy liquidity” that is underutilized and poorly provisioned. Market makers on order book exchanges can control the price points at which they buy and sell tokens which leads to high capital efficiency but requires active participation and oversight of liquidity provisioning.
Enhancing AMM Efficiency with Hybrid, Dynamic, Proactive and Virtual Solutions
1. Hybrid CFMMs
Advanced hybrid CFMMs (Constant Function Market Makers) have emerged which combine multiple functions and parameters to achieve specific behaviours such as reduced risk exposure for liquidity providers or reduced-price impact for traders. For example, Curve AMMs use an advanced formula to create denser pockets of liquidity and reduce price impact within a given range of trades. They enable low price impact trades by using an exchange rate curve that is mostly linear and becomes parabolic only when the liquidity pool is pushed to its limits. Liquidity providers earn more in fees and arbitrageurs still profit from rebalancing the pool. Curve is mainly designed for stablecoins but has recently launched support for more volatile token pairs with concentrated liquidity.
2. Dynamic Automated Market Maker (DAMM)
Sigmadex uses a dynamic automated market maker (DAMM) model which incorporates Chainlink Price Feeds and implied volatility to dynamically distribute liquidity along the price curve. This adapts to changing market conditions by concentrating liquidity near the market price during low volatility periods and expanding it during high volatility periods to protect traders from impairment loss, resulting in a more robust market maker.
3. Proactive Market Maker (PMM)
DODO is using a Proactive Market Maker (PMM) model to increase liquidity on its protocol by mimicking the human market-making behaviors of a traditional central limit order book. It uses accurate market prices from Chainlink Price Feeds to proactively move the price curve of each asset in response to market changes, increasing liquidity near the current market price and facilitating more efficient trading and reducing impairment loss for liquidity providers.
4. Virtual Automated Market Makers (vAMM)
Virtual automated market makers (vAMMs) like Perpetual Protocol use smart contracts to allow traders to gain exposure to a wide variety of crypto assets in a highly efficient manner. They use the same constant product formula as CPMMs, but instead of relying on a liquidity pool, traders deposit collateral. However, open positions in synthetic assets are at risk of liquidation if the price moves against them.
5. Replicating Market Maker (RMM)
Replicating Market Makers (RMMs) expand the capabilities of decentralized exchanges even further, enabling the production of liquid derivatives that are accessible to anyone. Formulated by Angeris et al. [Replicating Market Makers, March 2021], an RMM is a more general type of CFMM that can replicate different financial derivative payoffs. RMM liquidity pools act as spot price markets for derivatives and do not rely on external oracles, eliminating oracle manipulation attack vectors.
Conclusion
To conclude, the first-generation AMMs were limited by impermanent loss and low capital efficiency, impacting both liquidity providers and traders. However, recent advancements in AMM models have emerged to address these limitations. Hybrid CFMMs, Dynamic Automated Market Makers (DAMMs), Proactive Market Makers (PMMs), Virtual Automated Market Makers (vAMMs), and Replicating Market Makers (RMMs) are all examples of new solutions that aim to improve the efficiency and robustness of automated market making. These solutions incorporate different techniques such as advanced formulas, dynamic distribution of liquidity, proactive market making, virtual market making, and replicating financial derivatives, to achieve specific objectives such as reduced risk exposure, reduced price impact, and efficient trading. With these new models, the DeFi industry is likely to see improved liquidity, increased efficiency, and more robust automated market making in the future.
Please find below, the links to other articles as part of Diatomix,