When you swap tokens on a decentralized exchange, there are no orders to place and no counterparty taking each order one by one, yet prices are still calculated in real time. The mechanism behind this is an AMM (automated market maker).

Corresponding token: $UNI quoted at 4.884 (24h +4.16%).

— How is it different from an order book? —

Most centralized exchanges use order books: buyers and sellers place orders at their chosen prices, and a matching engine pairs orders with compatible prices to execute trades.

AMMs take a different approach: they use a liquidity pool pre-funded with two tokens. Traders swap directly with the pool, and a formula automatically determines the price.

— The constant product formula —

Uniswap V2 uses the constant product formula x × y = k: ignoring fees, the product of the amounts of the two tokens in the pool stays the same before and after a swap.

The more of a token is bought from the pool, the less remains, and the higher its price rises. 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 funds to the pool? —

The pool’s funds 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 went entirely to LPs. Governance later enabled a protocol fee, so the protocol takes a portion of the fees from V2 pools on Ethereum mainnet (since 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 a price range of their choosing, making more efficient use of the same amount of capital. But once the price moves outside that range, they stop earning fees.

— How does the price stay in line with the broader market? —

An AMM itself has no knowledge of prices elsewhere; its quoted price is determined solely by the ratio of the two tokens in the pool. When a price difference arises between the pool and 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 fit together: they’re really just different ways the same formula behaves under different conditions. It’s best to invest only what you can afford to lose.

What would you like to hear about next? Wallets or something else?

This view may not be correct; proceed at your own risk.