What Are Automated Market Makers?
AMMs are decentralized exchanges that use algorithmic “money robots” to provide liquidity for traders buying and selling crypto assets. Instead of relying on order books where buyers and sellers create liquidity, AMMs use liquidity pools - smart contracts that hold reserves of two or more tokens.Core Components
Liquidity Pools: Smart contracts containing reserves of multiple tokens that allow deposits and withdrawals according to specific mathematical rules. Liquidity Providers (LPs): Users who deposit tokens into pools to earn trading fees in return for providing liquidity. Traders: Users who swap one token for another using the liquidity in the pools. Mathematical Formula: A constant mathematical relationship that determines token prices and swap rates.The Constant Product Formula (x × y = k)
The foundation of most AMMs is the constant product formula:x × y = k
Where:
x= reserves of Token A in the pooly= reserves of Token B in the poolk= a constant that must remain unchanged after trades
How Price Discovery Works
Price Calculation: The price of Token A is calculated as:- Pool contains 1,000 ETH and 2,000,000 USDC
- Price of ETH = 2,000,000 USDC ÷ 1,000 ETH = $2,000 per ETH
- k = 1,000 × 2,000,000 = 2,000,000,000
Trading Mechanics
When a trader wants to swap tokens, the AMM maintains the constantk while adjusting reserves:
Before Trade: x = 1,000 ETH, y = 2,000,000 USDC, k = 2,000,000,000
Trader swaps 100 USDC for ETH:
- New USDC reserve: y = 2,000,100 USDC
- To maintain k: x = 2,000,000,000 ÷ 2,000,100 = 999.95 ETH
- ETH received: 1,000 - 999.95 = 0.05 ETH
Automatic Rebalancing and Price Impact
Continuous Price Adjustment
AMMs automatically rebalance prices through the constant product mechanism: Buying Pressure: When traders buy ETH, the ETH reserve decreases and USDC reserve increases, making ETH more expensive. Selling Pressure: When traders sell ETH, the ETH reserve increases and USDC reserve decreases, making ETH cheaper. Price Impact: Larger trades cause bigger changes in reserves, resulting in greater price impact and slippage.Slippage Example
For the same pool (1,000 ETH, 2,000,000 USDC): Small Trade (10 USDC):- Expected ETH: ~0.005 ETH
- Actual ETH received: 0.004975 ETH
- Slippage: ~0.5%
- Expected ETH: ~100 ETH
- Actual ETH received: ~90.9 ETH
- Slippage: ~9.1%
Liquidity Provision and Fee Generation
How LPs Earn Returns
Trading Fees: Typically 0.3% of each trade is distributed to LPs proportional to their pool share. Fee Calculation:Impermanent Loss Risk
What It Is: When token prices change, LPs may have less value than if they held tokens separately. Simple Example:- LP deposits: 1 ETH + 2,000 USDC (ETH price = $2,000)
- ETH price rises to $3,000
- Holding separately: 1 ETH (5,000
- In AMM pool: ~0.816 ETH (4,898
- Impermanent loss: $102 (2.04%)
Types of AMM Formulas
Constant Product (x × y = k)
- Best for: Most token pairs, especially volatile assets
- Examples: Uniswap V1/V2, SushiSwap
- Characteristics: Infinite price range, uniform liquidity distribution
Constant Sum (x + y = k)
- Best for: Stablecoins with similar values
- Characteristics: Linear price relationship, no slippage within range
- Problem: Can be drained if tokens deviate in price
Hybrid Models
- Curve Finance: Combines constant product and constant sum for stablecoins
- Balancer: Multi-token pools with weighted formulas
- Custom curves: Specialized formulas for specific use cases
AMM Evolution and Innovation
Historical Development
2017 - Bancor: First AMM implementation with continuous liquidity 2018 - Uniswap V1: Popularized x×y=k formula on Ethereum2020 - Uniswap V2: Added ERC-20/ERC-20 pairs, improved price oracles 2021 - Uniswap V3: Introduced concentrated liquidity for capital efficiency
Why AMMs Matter
Permissionless: Anyone can create markets for any token pair Always Available: No need to wait for matching buyers/sellersComposable: Can be integrated into other DeFi protocols Transparent: All transactions and mechanics are on-chain
Limitations of Basic AMMs
Capital Inefficiency
Uniform Distribution: Liquidity spread across entire price range (0 to ∞) Low Utilization: Most liquidity sits unused at extreme prices Example: For USDC/USDT, why provide liquidity at 2.00 when trading happens at 1.01?High Slippage for Large Trades
Price Impact: Large trades cause significant price movement Thin Liquidity: Spread-out liquidity means less depth at current price Capital Requirements: Need huge amounts of capital for deep liquidityPrerequisites for Advanced Topics
Understanding these AMM fundamentals prepares you for:- Capital efficiency improvements through concentrated liquidity
- Advanced AMM designs like DLMM and dynamic fees
- Optimal trading strategies and MEV protection
- Protocol design decisions and implementation choices
Next Steps
After mastering these concepts, you’re ready to explore:- The Capital Efficiency Crisis - Understanding why traditional AMMs waste ~99.5% of liquidity
- Concentrated Liquidity Solutions - How modern AMMs achieve 200x-25,000x efficiency gains
- Implementation Decisions - Choosing between different AMM approaches for your use case
x × y = k represents the foundation of decentralized trading, enabling permissionless, automated markets that have processed trillions of dollars in trading volume across DeFi protocols.