On decentralized exchanges, you can swap tokens without placing an order or having another party take your order—and yet the price is calculated in real time. This is made possible by AMMs (automated market makers).

$UNI is the governance token of Uniswap, the protocol that popularized AMMs. Current price: 7.187 (24h -1.59%).

【How is it different from an order book?】

Most centralized exchanges use order books: buyers and sellers place orders at their desired prices, and the matching engine pairs orders with compatible prices for execution.

AMMs take a different approach: a liquidity pool containing two tokens is prepared in advance, and traders swap directly with the pool. A formula automatically determines the price.

【Constant Product Formula】

Uniswap V2 uses the constant product formula x × y = k: excluding 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 the source of price impact (slippage).

【Who Provides the Pool’s Funds】

The pool’s funds come from liquidity providers (LPs): they deposit two tokens in proportion to the pool’s current prices and earn a share of the swap fees. Uniswap V2 charges a 0.3% fee on each swap, which originally went entirely to LPs. Later, governance enabled a protocol fee, so the protocol takes a portion of the fees from Ethereum mainnet V2 pools (since the end of 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, which makes their capital more efficient. But once the price moves outside that range, they no longer earn fees.

【How Prices Stay in Line with the Outside Market】

An AMM doesn’t know what the price is elsewhere; its quotes are determined solely by the ratio of the two tokens in the pool. When a price difference arises with other markets, arbitrage traders buy low and sell high, pushing the price back toward alignment.

【Summary】

Once you understand AMMs, concepts like slippage, pool depth, and impermanent loss all fall into place: they’re really just different ways the same formula plays out under different conditions. Take the time to understand the principles before you trade—don’t place orders based on gut feeling.

If there’s anything I missed, let’s discuss it in the comments.