Skip to main content
Automated Market Makers (AMMs) revolutionized decentralized finance by replacing traditional order books with algorithmic trading systems that provide liquidity for cryptocurrency exchanges without requiring buyers and sellers to directly match orders.

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 pool
  • y = reserves of Token B in the pool
  • k = a constant that must remain unchanged after trades

How Price Discovery Works

Price Calculation: The price of Token A is calculated as:
price_of_A = reserve_B / reserve_A
Example:
  • 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 constant k 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
Result: The price automatically adjusts based on supply and demand through the mathematical relationship.

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%
Large Trade (200,000 USDC):
  • 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:
LP_fees = (LP_tokens / total_LP_tokens) × total_trading_fees
Example: If you own 1% of pool tokens and the pool generates 10,000infees,youearn10,000 in fees, you earn 100.

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 (3,000)+2,000USDC=3,000) + 2,000 USDC = 5,000
  • In AMM pool: ~0.816 ETH (2,449)+2,449USDC=2,449) + 2,449 USDC = 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 Ethereum
2020 - 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/sellers
Composable: 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 0.50or0.50 or 2.00 when trading happens at 0.990.99-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 liquidity

Prerequisites 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:
  1. The Capital Efficiency Crisis - Understanding why traditional AMMs waste ~99.5% of liquidity
  2. Concentrated Liquidity Solutions - How modern AMMs achieve 200x-25,000x efficiency gains
  3. Implementation Decisions - Choosing between different AMM approaches for your use case
The constant product formula 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.