How Uniswap Works

The Basics of Automated Market Making

Uniswap uses an Automated Market Maker (AMM) model, which replaces the traditional order book with a mathematical formula. This formula, x * y = k, maintains a constant product between the quantities of two tokens in a liquidity pool.

Key Components

Liquidity Pools

Smart contracts that hold token pairs and enable trading based on the AMM formula.

Liquidity Providers

Users who deposit token pairs to earn fees from trades.

Trading Mechanism

When users want to swap tokens:

  1. They select the input token and desired output token
  2. The protocol calculates the exchange rate based on the pool ratios
  3. A small fee is taken from each trade (0.3% in V2, variable in V3)
  4. The fee is distributed to liquidity providers

Price Discovery

Prices are determined by the ratio of tokens in each pool. As users trade, they slightly impact the price, creating arbitrage opportunities that help maintain price alignment with other markets.

Concentrated Liquidity (V3)

Uniswap V3 introduced concentrated liquidity, allowing liquidity providers to:

  • Focus their capital within specific price ranges
  • Earn higher fees for the same amount of capital
  • Create more efficient markets

Getting Started

To interact with Uniswap, you'll need:

  • A Web3 wallet (like MetaMask)
  • ETH for gas fees
  • Tokens you want to trade