When swapping tokens on a decentralized exchange, there are no placed orders or counterparties accepting orders one by one, yet prices can still be calculated at any time. The mechanism behind this is the AMM (automated market maker).
$UNI is the governance token of Uniswap, which popularized AMMs. Current price: 5.138 (24h +0.058%).
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 the matching engine pairs orders with matching prices to execute trades.
AMMs take a different approach: a liquidity pool containing two tokens is prepared in advance, and traders exchange directly with the pool. A formula automatically determines the price.
The constant product formula:
Uniswap V2 uses the constant product formula x × y = k: excluding 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 goes. So the more you buy in one 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 the pool come from liquidity providers (LPs): they deposit two tokens in proportion to the pool’s current price and earn a share of swap fees. Uniswap V2 charges a 0.3% fee on each swap, which originally all went to LPs. Governance later activated a protocol fee, so the protocol takes a portion from V2 pools on Ethereum mainnet (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, making 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 outside market:
An AMM doesn’t know what the price is elsewhere; its quoted price is determined solely by the ratio of the amounts of the two tokens in the pool. When there’s a price difference 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 connect: they’re really just different ways the same formula plays out under different conditions. Knowledge can help you avoid pitfalls, but it can’t replace position management.
Comment 1 if you learned something; if anything wasn’t clear, keep asking in the comments.
Just sharing my thoughts; this is not investment advice.