Uniswap lets you swap one ERC-20 token for another directly on-chain, without an order book or counterparty. Instead of matching buyers and sellers, it uses liquidity pools — smart contracts that hold reserves of two tokens and price swaps algorithmically. Anyone can trade against a pool, and anyone can deposit tokens into one to earn fees.
It is the dominant decentralized exchange on Ethereum and most L2s, handling billions of dollars in daily volume.
Protocol Versions#
Uniswap has gone through several major versions. Each is a separate set of smart contracts — older versions remain deployed and functional.
V2 introduced the core AMM model: every pool holds a 50/50 reserve of two tokens, priced along a constant-product curve (x * y = k). Simple and battle-tested, but capital-inefficient — liquidity is spread evenly across all possible prices, so most of it sits idle.
V3 added concentrated liquidity. Liquidity providers choose a price range for their capital, so the same dollar amount can generate far more trading depth where it matters. V3 also introduced multiple fee tiers per pair (0.01%, 0.05%, 0.3%, 1%). This is the most widely integrated version today.
V4 moves all pools into a single “singleton” contract for gas savings and introduces hooks — plugin contracts that can customize pool behavior (dynamic fees, on-chain limit orders, custom oracles, etc.). V4 is newer and has less tooling and documentation than V3.
UniswapX is a separate intent-based system that runs alongside the on-chain protocol. Users sign an order off-chain, and competing “fillers” find the best execution — potentially routing across multiple DEXs or using private liquidity. On-chain settlement acts as a fallback.
Which Version Should I Use?#
There are two decisions: which pool version your swaps route through, and which router contract you call. In practice, the router decides for you — modern routers can route through multiple pool versions in a single transaction.
Choosing a pool version#
You rarely need to pick this explicitly. The router (or the Uniswap frontend) will find the pool with the best price for your pair. But it helps to understand the trade-offs:
| V2 | V3 | V4 | |
|---|---|---|---|
| Liquidity model | Full-range (simple, passive) | Concentrated (more efficient, active management) | Concentrated + hooks |
| Maturity | Oldest, most forked | Most liquidity, most integrations | Newest, least tooling |
| When you’d target it directly | Pair only has a V2 pool; or you want the simplest on-chain integration | Default choice — deepest liquidity for most pairs | You need custom pool logic (dynamic fees, on-chain limit orders) |
If you’re unsure, target V3. It has the deepest liquidity for nearly all major pairs and the most documentation.
Choosing a router#
This is the more consequential decision. It determines your approval flow, your Solidity interface, and which pool versions you can reach:
| Scenario | Use | Why |
|---|---|---|
| New project, EOA-initiated swaps | UniversalRouter | Best gas, Permit2 approvals, routes through V2 + V3 + V4 |
| Contract-to-contract swap, want typed Solidity | SwapRouter02 | Clean function signatures, easier to compose and debug from Solidity |
| Learning / prototyping | SwapRouter (V3) | Simplest interface, most tutorials and examples; see the ISwapRouter guide |
| Existing integration that works | Keep what you have | No need to migrate unless you need V4 or Permit2 |
The UniversalRouter uses encoded command bytes instead of named functions, which makes it harder to read and debug in Solidity — that’s why on-chain contracts often prefer SwapRouter02 even though UniversalRouter is technically superior.
For a full comparison (approval flows, gas costs, code examples), see SwapRouter vs SwapRouter02 vs UniversalRouter.
For deployment addresses across all supported chains, see the official Uniswap deployment list.
Key Infrastructure#
These contracts support the routers above. You don’t swap through them directly, but you’ll encounter them in most integrations:
- Permit2 — a shared approval contract. Instead of granting each router a separate ERC-20 allowance (an on-chain transaction), you approve Permit2 once per token, then sign off-chain permits for each swap. This saves gas and means you don’t need new approvals when Uniswap deploys new router versions.
- QuoterV2 — simulates a swap off-chain (via
eth_call) and returns the expected output amount. Use this to calculate a safeamountOutMinimumfor slippage protection before submitting a real swap.
Source Code#
| Repository | Contains |
|---|---|
| v2-periphery | IUniswapV2Router02 — the V2 router interface |
| v3-periphery | ISwapRouter, IQuoterV2, and other V3 periphery interfaces |
| swap-router-contracts | ISwapRouter02 — the combined V2 + V3 router |
| universal-router | UniversalRouter — command-based, no typed Solidity interface |
| permit2 | Permit2 signature-based approval system |
| v4-core | V4 singleton pool contract and hook interfaces |
| v4-periphery | V4 routing and position management |