An Automated Market Maker (AMM) is a decentralized exchange protocol that uses mathematical formulas to determine asset prices and facilitate trading. These smart contracts employ liquidity pools to execute trades without the need for intermediaries. This model is widely used in decentralized finance (DeFi) to allow permissionless, automated transactions between digital assets.
How does an AMM work?
AMM protocols incentivize asset deposits through reward fees and yield opportunities. ensuring liquidity availability and market stability. The higher the liquidity in a pool, the less impact large trades have on price, which reduces slippage and creates a more favorable trading environment. This stability attracts more traders to the platform, increasing trading volume and transaction fees (which are redistributed to liquidity providers). Here is a general overview of how it works.
Users, known as liquidity providers, deposit assets into a liquidity pool.
The pool assigns a proportional share of the pool assets to the provider, represented by liquidity provider (LP) tokens.
The deposited assets create a market where traders can swap between the available pairs.
The AMM uses a mathematical formula (e.g., constant product formula or Balancer weighted equation) to determine asset prices.
The formula adjusts the price dynamically based on the relative quantities of assets in the pool and market conditions.
Traders initiate swap transactions directly with the pool.
The smart contract calculates the trade outcome using its pricing formula and updates the asset ratios in the pool.
As asset ratios change, the contract updates asset prices based on the new proportions.
A fee is charged for each trade and added to the liquidity pool.
This fee is distributed to liquidity providers as compensation for supplying liquidity.
Liquidity providers can withdraw assets at any time by redeeming LP tokens.
Upon withdrawal, the provider receives a proportionate share of the total pool assets, including accrued fees.
Types of AMM models
AMMs employ various models to support trading and liquidity provision. Each with unique characteristics and mechanisms to determine how assets are traded. Common models include:
Constant product market maker (CPMM): Maintains a constant product formula (x * y = k), where x and y represent the quantities of two assets in a liquidity pool. When the supply of token X rises, the supply of token Y must decrease, and vice versa, to keep the product K constant. Uniswap is a well-known example of a CPMM.
Constant sum market maker (CSMM): Allows for the linear trading of assets, maintaining a constant sum (x + y = k). This design enables arbitrageurs to deplete one of the reserves if the off-chain reference price between tokens does not maintain a 1:1 ratio. This scenario can eliminate one side of the liquidity pool concentrating liquidity in a single asset and leaving no liquidity available for traders. The CSMM model is seldom utilized.
Constant mean market maker (CMMM): Extends the constant product model to multiple assets while maintaining a constant mean price. For example, a pool of three assets would yield the equation: (xyz)^(1/3) = k. This model can accommodate various asset types in a single pool and is designed to provide better liquidity and price stability across a wider range of trades. Balancer is an example of a CMMM.
Hybrid market maker: Combines features of constant product and constant sum models, enabling flexibility in trading strategies. This flexibility helps to optimize capital efficiency while accommodating diverse liquidity options. Curve is a prime example of this type of AMM.
Dynamic market maker: Adjusts pricing formulas based on market conditions, trading volume, or other factors, providing a more responsive trading environment. This adaptability can reduce slippage and optimize liquidity during periods of high volatility. Dynamic protocols such as Maverick aim to balance the need for liquidity with real-time market conditions.
What problems do AMMs solve?
AMMs address inefficiencies in liquidity provisioning and centralized control of markets.
AMMs decentralize liquidity provisioning by creating asset pools and incentivizing liquidity providers to contribute assets to them. Unlike centralized or order book-based systems, where liquidity is provided by centralized market makers or a platform’s own capital, AMMs rely on a distributed network of participants to supply liquidity.
This democratization of liquidity increases market efficiency by eliminating the need for centralized actors and order books. AMMs also operate 24/7, overcoming the limitations of market hours in traditional financial systems.
Benefits and challenges of AMMs
AMMs deliver significant advantages for traders in terms of decentralization, accessibility, and continuous liquidity. However, it also introduces unique challenges such as price slippage and impermanent loss.
Benefits
Decentralization: AMMs operate without a central authority or intermediaries, enabling permissionless, automated trading.
Continuous liquidity: Liquidity is available at all times regardless of market conditions, the presence of market makers, or active traders.
Lower fees: The absence of intermediaries results in lower transaction fees compared to traditional exchanges.
Automated, permissionless trading: Trade execution is fully automated without requiring counterparties, making trading faster and more efficient.
Challenges
Price slippage: As the ratio of assets in the liquidity pool shifts, pricing accuracy fluctuates which can result in significant price slippage.
Impermanent loss: Liquidity providers risk impermanent loss when the value of assets committed to the pool is less than the value of holding the same assets outside the pool. This is especially pronounced during times of high market volatility.
Limited pricing mechanisms: AMMs rely on predefined formulas for price determination, which may not always reflect real-time market prices. particularly for low-liquidity assets or during times of volatile market activity.
Security risks: AMM protocols can be vulnerable to smart contract exploits, front-running, or other security threats, potentially leading to loss of funds for traders and liquidity providers.
Who uses AMMs?
AMMs are used by decentralized exchanges, traders, liquidity providers, and DeFi platforms.
Decentralized exchanges (DEXs): Platforms like Uniswap, Curve, and Balancer use AMMs to facilitate trading without intermediaries.
Traders: AMMs never close and allow traders to swap assets without intermediaries. They offer more diverse trading opportunities through flexibility in token combinations, and provide efficient market creation for new or less-traded tokens.
Liquidity providers: Users with capital can deposit assets into liquidity pools in exchange for a portion of transaction fees.
DeFi platforms: DeFi protocols integrate AMMs to enhance liquidity, and trading efficiency within their ecosystems.
Yield Farmers: Users who strategically provide liquidity to AMM pools in an effort to maximize returns.
Popular AMMs
Several AMMs have gained widespread usage in decentralized finance.
Uniswap, a pioneer in the AMM space, uses the constant product formula for asset swaps.
SushiSwap, a fork of Uniswap, adds governance and staking features while maintaining similar mechanics.
Balancer operates as a multi-asset AMM, allowing for pools of more than two assets with adjustable weightings. Unlike paired asset pools consisting only of 50/50 weightings, Balancer weighted pools allow more than two tokens and a variety of weightings such as 80/20 or 60/20/20.
Curve Finance specializes in stablecoin trading, offering low-slippage swaps between assets of similar value.
Related Terms
No items found.
Cyfrin Updraft
Learn smart contract development, how to write secure smart contracts, and scalable protocols from world's leading experts.