Uniswap is a decentralized exchange protocol that lets anyone swap tokens directly from a wallet through smart contracts on Ethereum and compatible networks, without an order book, a broker or a custodian. In DeFi, it is the best-known implementation of the automated market maker model, where prices come from a formula applied to pooled reserves rather than from matched buy and sell orders.
The protocol has no account registration and no listing approval: any pair of tokens can receive a pool, and any participant can supply liquidity and earn trading fees. This permissionless design made Uniswap a core building block of decentralized finance, but it also exposes traders and liquidity providers to risks that differ sharply from those of a centralized exchange.
How Uniswap prices a swap
Uniswap prices a swap by applying a pricing invariant to the token reserves held in a pool. In the classic design, the pool keeps the product of its two reserves constant, expressed as x · y = k. When a trader adds token A to the pool and withdraws token B, the ratio of reserves shifts and the price of token B rises for the next trade.
Because each trade moves the reserves, a larger order relative to pool depth receives a worse average price. This effect is called price impact, and the difference between the quoted and the executed price is slippage. Traders set a slippage tolerance, and the contract reverts the transaction if the final price falls outside it.
Every swap pays a trading fee that stays in the pool and accrues to liquidity providers. Arbitrageurs keep pool prices aligned with external markets: when a pool price drifts, they trade against it until the gap is closed, which is the main price discovery mechanism of the protocol.
The table below summarizes the components that participate in a single swap.
| Component | Role | Who controls it |
|---|---|---|
| Pool contract | Holds reserves and enforces the invariant | Immutable code |
| Router contract | Finds a path across pools and checks limits | Immutable code |
| Trader wallet | Signs the transaction and pays gas | The trader |
| Liquidity provider | Supplies reserves and earns fees | Any participant |
| Arbitrageur | Aligns pool prices with other markets | Independent bots and traders |
Protocol versions and their design choices
Uniswap has evolved through several versions, each deployed as separate, non-upgradeable contracts, so older versions continue to operate alongside newer ones. Each version changed how liquidity is represented and how efficiently capital is used.
The most significant shift came with concentrated liquidity in version 3, which lets providers place capital within a chosen price range. Within that range, the same capital supports far deeper trading than a full-range position, but it stops earning fees once the price leaves the range.
| Version | Key innovation | Liquidity position | Practical effect |
|---|---|---|---|
| Version 1 | Pools paired only with ETH | Fungible share | Simple but required two hops for most pairs |
| Version 2 | Direct token-to-token pools and price oracles | Fungible ERC-20 share | Broad pair coverage, uniform liquidity |
| Version 3 | Concentrated liquidity and multiple fee tiers | Non-fungible position | Higher capital efficiency, active management |
| Version 4 | Single contract for all pools and custom hooks | Position within a shared contract | Lower gas costs and programmable pool logic |
Version 3 introduced fee tiers, commonly 0.01%, 0.05%, 0.30% and 1.00%, so that stable pairs can trade cheaply while volatile pairs compensate providers for higher risk. Version 4 adds hooks, which are external contracts that run custom logic at defined points of a pool’s lifecycle, such as dynamic fees or on-chain limit orders.
Uniswap compared with other trading venues
Uniswap differs from a centralized exchange mainly in custody, settlement and price formation. A user keeps control of funds until the moment of the swap, and settlement is atomic on-chain, meaning the transaction either completes fully or not at all.
| Feature | Uniswap | Centralized exchange | Order-book DEX |
|---|---|---|---|
| Custody | User wallet | Exchange holds funds | User wallet |
| Price formation | Pool formula and arbitrage | Matched limit orders | Matched limit orders on-chain |
| Listing | Permissionless | Exchange approval | Usually permissionless |
| Identity checks | None at protocol level | Typically required | None at protocol level |
| Main cost | Pool fee plus gas | Trading fee | Fee plus gas or relayer cost |
Other automated market makers apply different curves. Some specialize in stablecoin swaps with a flatter curve near parity, while others support weighted pools with more than two assets. Uniswap remains the reference design against which most of these variants are measured.
Providing liquidity and governance
A liquidity provider deposits both tokens of a pair and receives a claim on a proportional share of the reserves and fees. The provider earns income from trading volume but carries impermanent loss, the shortfall compared with simply holding the tokens when their relative price changes.
Concentrated positions magnify both outcomes. A narrow range earns more fees per unit of capital while the price stays inside it, but suffers larger relative loss and needs frequent rebalancing. The decision table below shows typical strategies.
| Situation | Typical range choice | Reason |
|---|---|---|
| Stablecoin pair near parity | Very narrow range | Price rarely moves, so capital stays productive |
| Major volatile pair | Moderate range with monitoring | Balances fee income against rebalancing |
| Passive provider | Full or wide range | Avoids leaving the range and manual work |
| New or illiquid token | Wide range or avoid | High volatility and potential manipulation |
Protocol governance runs through the UNI governance token. Holders, or the delegates they choose, vote on proposals affecting treasury funds, deployments to new networks and the protocol fee switch, which can redirect a portion of pool fees away from providers. Governance cannot alter deployed pool contracts, which limits its power over existing liquidity.
Risks, limitations and common mistakes
Uniswap removes counterparty custody risk but introduces smart contract, market and user-interface risks. Public transactions wait in a visible mempool before inclusion, which enables maximal extractable value strategies such as sandwich attacks that worsen a trader’s price.
| Problem | Cause | Mitigation |
|---|---|---|
| Buying a counterfeit token | Anyone can create a pool for any contract | Verify the token contract address |
| Sandwich attack | High slippage tolerance in a public mempool | Use a tight tolerance or private routing |
| Large price impact | Order too big for pool depth | Split the order or use an aggregator |
| Unexpected loss as a provider | Impermanent loss exceeds fee income | Model scenarios before depositing |
| Lingering token approvals | Unlimited allowances granted to contracts | Grant limited approvals and revoke unused ones |
A common misconception is that open-source code means safe tokens. The protocol itself has a strong security record, yet it does not vet the assets traded through it. Regulatory treatment of the interface, of token listings and of liquidity income also varies by jurisdiction and remains an unsettled legal area.
Understanding it simply
Imagine a currency exchange booth with no staff. Instead of a clerk, there is a large jar of two currencies and a fixed rule that sets the rate. When you put one currency in and take the other out, the jar becomes lopsided, so the rule automatically makes the next exchange a little more expensive in the same direction.
People who fill the jar earn a small fee from every exchange. Uniswap is that booth built from software on a blockchain. The rule sets the price, not a person, and anyone can use it or help fill it, which is both its main strength and its main source of risk.
Applied in practice
A small online retailer that accepts stablecoin payments wants to convert part of its weekly receipts into ETH to cover network fees. The finance manager connects a company wallet to the Uniswap interface on a lower-cost Ethereum layer-2 network and swaps about 5,000 units of a dollar stablecoin through a 0.05% fee pool.
Before signing, the manager checks the quoted price impact, which is below 0.1% because the pool is deep, and sets a slippage tolerance of 0.5%. The swap settles in a single transaction within seconds, and the network fee costs a few cents. Total cost, including the pool fee, is about 2.5 units of stablecoin.
The outcome is a fast, self-custodied conversion with no exchange account and no withdrawal delay. The company records the transaction hash for accounting and revokes the token approval afterward, a simple habit that limits exposure if the interface or a contract is ever compromised.