On a decentralized exchange, you can swap tokens without placing an order or having a counterparty fill it one trade at a time, yet the price is calculated instantly. This is made possible by an AMM (automated market maker).
Tokens mentioned in the article: $UNI Current price: 4.684 (24h +0.11%).
How is it different from an order book?
Most centralized exchanges use order books: buyers and sellers each place orders with their quoted prices, and a matching engine pairs orders with compatible prices to execute trades.
AMMs take a different approach: they have a liquidity pool preloaded with two tokens. Traders exchange directly with the pool, and a formula automatically determines the price.
Constant product formula:
Uniswap V2 uses the constant product formula x × y = k: ignoring fees, the product of the quantities of the two tokens in the pool remains unchanged before and after a swap.
The more of one token is bought from the pool, the less remains, and the higher its price gets. So the more you buy in a single trade, the higher the average execution price—this is where price impact (slippage) comes from.
Who provides the funds for the pool:
The funds in a pool come from liquidity providers (LPs): they deposit two tokens in proportion to the pool’s current price and earn a share of the swap fees. Uniswap V2 charges a 0.3% fee on each swap, which historically all went to LPs. Later, governance enabled a protocol fee, so the protocol takes a portion of the fees from V2 pools on Ethereum mainnet (as of late 2025, 0.25% goes to LPs and 0.05% to the protocol).
Uniswap V3 introduced concentrated liquidity, allowing LPs to provide liquidity only within price ranges they choose. This makes the same amount of capital more efficient, but once the price moves outside that range, they stop earning fees.
How prices stay in line with the rest of the market:
An AMM itself has no idea what the price is elsewhere; its quotes are determined solely by the ratio of the two tokens in the pool. When its price differs from other markets, arbitrage traders buy low and sell high, pushing the price back toward alignment.
My take:
Once you understand AMMs, concepts like slippage, pool depth, and impermanent loss all fit together: they’re really just different ways the same formula plays out under different conditions. Don’t trade with borrowed money—stress can push you into making bad decisions.
If you found this useful, save it so you can come back and review it later.