On a decentralized exchange, you can swap tokens without placing orders or having a counterparty take each order, yet the price is always calculated on the spot. This is made possible by AMMs (automated market makers).

Related token: $UNI quoted at 4.786 (24h +0.36%).

How is it different from an order book:

Most centralized exchanges use order books: buyers and sellers each place orders with their prices, and the matching engine pairs up orders with matching prices to execute trades.

AMMs take a different approach: they prepare a liquidity pool containing two tokens, and traders exchange directly with the pool. 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 amounts of the two tokens in the pool remains unchanged before and after a swap.

The more of a token is bought from the pool, the less remains, and the higher its price gets. So the more you buy in a single transaction, the higher the average execution price—this is what causes price impact (slippage).

Who provides the funds for the pool:

The funds in the 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 used to go 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, LPs receive 0.25% and the protocol 0.05%).

Uniswap V3 introduced concentrated liquidity, allowing LPs to provide liquidity only within a price range of their choice, making the same amount of 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 itself doesn’t know the price 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 parity.

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. Take the time to understand the rules before you dive in, and don’t make decisions based on gut feeling.

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