AMM and Liquidity Pools
Core Concepts of AMM
AMM (Automated Market Maker) is a trading system where prices are automatically determined by algorithms. Unlike traditional order books, buyers and sellers are not directly matched. Instead, they trade with a reserve called a liquidity pool.
The innovation of AMMs is that anyone can provide liquidity. In the past, becoming a market maker required contracts with exchanges, large capital, and technical expertise. With AMMs, anyone with assets can become a liquidity provider and earn trading fees.
Constant Product Formula
x × y = k
This is the most basic AMM formula used by Uniswap V2.
- x: Amount of token A in the pool
- y: Amount of token B in the pool
- k: Constant (invariant)
Core rule: No matter what trade occurs, the value of x × y must remain at k.
Calculation Example
An ETH-USDC pool contains 1,000 ETH and 3,000,000 USDC.
k = 1,000 × 3,000,000 = 3,000,000,000
A user wants to swap 10 ETH for USDC:
- Add 10 ETH to pool: x' = 1,000 + 10 = 1,010 ETH
- To maintain k: y' = k / x' = 3,000,000,000 / 1,010 = 2,970,297 USDC
- USDC received by user: 3,000,000 - 2,970,297 = 29,703 USDC
- Effective price: 29,703 / 10 = 2,970 USDC per ETH
The trade executed at a slightly worse price than the market price of 3,000 USDC. This is price impact.
Price Curve
The constant product formula creates a hyperbolic price curve.
- The larger the trade, the worse the price becomes
- More liquidity means a flatter curve (less slippage)
- Complete depletion of one token is theoretically impossible (price goes to infinity)
Liquidity Pool Structure
Pool Composition
A liquidity pool is a smart contract where two tokens are deposited as a pair.
Uniswap V2 Pool Characteristics:
- Two tokens are deposited in a 50:50 ratio (by value)
- Anyone can deposit assets and become a liquidity provider (LP)
- LPs receive a portion of trading fees
Pool Creation
Anyone can create a new pool.
- Choose two tokens (e.g., a new token and ETH)
- Deposit initial liquidity (the ratio determines the initial price)
- Once the pool is created, anyone can trade
The initial liquidity provider determines the price. Depositing at the wrong ratio means losing to arbitrageurs.
Trading Fees
Based on Uniswap V2, each trade incurs a 0.3% fee.
- Fees are automatically added to the pool
- LPs share fees proportional to their deposit ratio
- Withdrawing returns principal + accumulated fees
Pools with high trading volume generate higher LP returns. However, impermanent loss must also be considered.
LP Tokens
What Are LP Tokens
When you provide liquidity, you receive LP tokens. These are tokens representing your share of the pool.
Example:
- Total pool liquidity: $1,000,000
- I deposited $10,000
- My share: 1%
- LP tokens received: 1% of total LP token supply
LP Token Value
LP token value is proportional to the total pool value.
- When trading fees accumulate → LP token value increases
- When underlying token prices rise → LP token value increases
- When impermanent loss occurs → LP token value relatively decreases
LP Token Uses
LP tokens are themselves tokens and can be used in other DeFi protocols.
- Staking: Stake LP tokens for additional rewards (yield farming)
- Collateral: Some lending protocols accept LP tokens as collateral
- Transfer: Can be moved to other wallets
Uniswap Version Differences
Uniswap V2
- Constant product formula (x × y = k)
- 50:50 ratio liquidity
- Simple and easy to understand
- Low capital efficiency
Uniswap V3 - Concentrated Liquidity
Uniswap V3 introduced Concentrated Liquidity.
Key changes:
- LPs specify a price range for providing liquidity
- Liquidity is only active within that range
- Capital efficiency improved up to 4,000x
Example: When ETH is $3,000:
- V2: Liquidity spread across all price ranges ($0 to infinity)
- V3: Concentrated at $2,800~$3,200 → More fees with the same capital
Tradeoffs:
- Pros: Increased fee revenue, capital efficiency
- Cons: Requires management (liquidity deactivates when price leaves range), amplified impermanent loss
Uniswap V4 (Upcoming)
- Custom logic through Hooks
- Singleton architecture for gas savings
- Native ETH support
Other AMM Models
Curve - Stable Swap
An AMM optimized for trading between stablecoins.
Features:
- Minimizes slippage for trades between similarly-priced assets
- Near 1:1 exchange possible in pools like USDC-USDT-DAI
- Uses a flatter curve than constant product
Formula (simplified): A hybrid of constant sum (x + y = k) and constant product (xy = k)
Balancer - Weighted Pools
Allows multiple tokens with various ratios instead of just two.
Examples:
- 80% ETH + 20% USDC pool
- 25% ETH + 25% BTC + 25% LINK + 25% UNI pool (like an index fund)
Advantages:
- Portfolio composition flexibility
- Automatic rebalancing (while earning fees)
Trader Joe - Liquidity Book
An evolved model from Uniswap V3's concentrated liquidity.
Features:
- Discrete price bins
- More granular liquidity placement possible
- Dynamic fees
Limitations of AMMs
Capital Inefficiency (V2)
Uniswap V2 style AMMs spread liquidity across all price ranges. Since most trades occur near the current price, liquidity at extreme price levels goes largely unused.
Impermanent Loss
The biggest risk of AMMs. When prices fluctuate, LPs may experience losses compared to simply holding. This is covered in detail in the next article.
Oracle Dependency
AMM prices can diverge from external markets. Arbitrageurs align the prices, but LPs may incur losses in the process.
MEV Vulnerability
The transparent structure of AMMs makes them vulnerable to frontrunning. Pending transactions are visible to everyone and can be exploited.
Characteristics of Healthy Pools
When choosing a pool to provide liquidity or trade:
Trading Volume
- High volume = More fee revenue
- Low volume = Fee revenue may not offset impermanent loss
TVL (Total Value Locked)
- High TVL = Low slippage, stable
- Low TVL = High slippage, price manipulation risk
Volume to TVL Ratio
- High ratio = Capital being used efficiently
- Low ratio = Idle liquidity
Token Verification
- Pools composed of known, verified tokens
- New/unverified token pools carry rug pull risk
Summary
AMMs are systems that automatically determine prices in liquidity pools based on the constant product formula. LPs deposit assets, receive LP tokens, and earn trading fees as income. Uniswap V3's concentrated liquidity significantly improves capital efficiency but comes with the tradeoffs of management complexity and amplified impermanent loss. Various AMM variants like Curve and Balancer are optimized for specific use cases.
Next article: Providing Liquidity and LP Tokens - How to Earn Trading Fees