How do decentralized exchanges work?
There is no order book and no company matching trades — just a pool of two tokens and a formula. Here is what that means for the price you actually get.
Logos are trademarks of their respective owners, shown for identification only. Their use does not imply endorsement. Licences.

On this page
- What is a decentralized exchange?
- How does an automated market maker set the price?
- Who supplies the tokens in the pool?
- Why is the price you get different from the price you see?
- How does a DEX compare with a centralized exchange?
- What mistakes do beginners make on decentralized exchanges?
- Questions readers ask
- Sources
- A decentralized exchange (DEX) is a set of smart contracts that swaps tokens directly from users' wallets, without a company holding funds.
- Uniswap and similar DEXs use an automated market maker: a pool of two tokens priced by a formula such as x × y = k.
- Liquidity providers fund the pools and, on Uniswap v2, share a 0.30% fee charged on every trade.
- The bigger your trade relative to the pool, the worse your average price — this is price impact.
- Slippage settings and front-running bots (MEV) can also cost you; set limits before you sign.
A decentralized exchange lets you swap tokens through smart contracts instead of a company. Uniswap-style exchanges use an automated market maker: a pool of two tokens priced by a formula such as x × y = k. Each trade changes the pool's balances, and that change is what moves the price.
What is a decentralized exchange?
On a centralized exchange you deposit money with a company, and the company's computers match your buy order with someone else's sell order. A decentralized exchange, or DEX, removes the company. It is a set of smart contracts on a blockchain that anyone can call from their own wallet. Your tokens stay in your wallet until the moment of the trade, and the swap settles in a single on-chain transaction.
The hard part is setting a price without a company running an order book. The design Uniswap and similar exchanges use is the automated market maker (AMM): rather than waiting for a counterparty, you trade against a pool of tokens that is always ready to quote a price. Uniswap's documentation describes its pairs as automated market makers, standing ready to accept one token for the other.
How does an automated market maker set the price?
Picture a pool that holds two tokens, say ether (ETH) and the dollar stablecoin USDC. Uniswap v2 uses the constant product rule: the number of ETH (x) multiplied by the number of USDC (y) must stay equal to a constant (k) after every trade, before fees. The quoted price is simply the ratio of the two balances.
When you buy ETH, you add USDC to the pool and take ETH out. ETH becomes scarcer in the pool, so each extra unit costs more. Uniswap's documentation notes that this makes large trades receive progressively worse rates than small ones. The only way the relative price changes is through trading, and if the pool drifts away from prices elsewhere, arbitrage traders step in and buy or sell until it lines up again.
| You pay (USDC) | ETH received | Average price |
|---|---|---|
| 1,000 | 0.496 | $2,016 (+0.8%) |
| 10,000 | 4.748 | $2,106 (+5.3%) |
| 50,000 | 19.952 | $2,506 (+25.3%) |
Percentages compare with the $2,000 starting price. Figures are for the hypothetical pool above and include the 0.30% fee; network fees are extra.

Who supplies the tokens in the pool?
The pool's tokens come from liquidity providers (LPs). An LP deposits both tokens in equal value and receives pool tokens that represent a pro-rata share of the reserves; these can be redeemed for the underlying tokens at any time. In Uniswap v2 the 0.30% trading fee is added to the reserves, which is how LPs get paid.
Fees are only half the story. Because the pool rebalances automatically as prices move, an LP can end up worse off than if they had simply held the two tokens — a gap known as impermanent loss.
Newer designs change the economics. Uniswap v3 introduced concentrated liquidity, which lets an LP choose a price range. Uniswap's documentation gives the reason: in the v2 DAI/USDC pool only about 0.50% of the capital sat in the narrow range where most trading actually happened. A ranged position puts capital to work where trades occur, but once the price leaves the range it stops earning fees and ends up holding just one of the two tokens.
Why is the price you get different from the price you see?
Three separate effects can make your fill worse than the quote:
- Price impact. Your own trade moves the pool, as the example shows. Uniswap's docs put it simply: the more liquidity available at a price, the lower the price impact for a given trade size.
- Slippage. Other trades can land before yours while your transaction waits to be included in a block. You set a slippage tolerance, for example 1%; if the execution price falls outside it, the transaction fails instead of filling.
- Front-running. ethereum.org explains maximal extractable value (MEV) as value captured by including, excluding or reordering transactions. In a sandwich attack, a bot buys just before a large pending trade and sells right after it, leaving the victim with more slippage and a worse execution.
How does a DEX compare with a centralized exchange?
Neither model is simply better; they put risk in different places.
| Feature | Centralized exchange | Decentralized exchange (AMM) |
|---|---|---|
| Custody | The exchange holds your funds | You keep custody until the swap executes |
| Price discovery | Order book of bids and asks | Pool balances and a formula |
| Who provides liquidity | Market makers and other traders | Anyone who deposits into the pool |
| Account checks | Identity checks are usual | No account; you connect a wallet |
| Main risks | Exchange failure, frozen withdrawals | Contract bugs, price impact, front-running, fake tokens |
For the order-book side of the comparison, see bid-ask spread and market liquidity explained.
What mistakes do beginners make on decentralized exchanges?
- Trusting the token name. Different tokens can share the same name and ticker. Check the contract address against the issuer's official site.
- Trading a large amount in a small pool. Check the displayed price impact; if it is several percent, split the trade or reconsider it.
- Setting slippage tolerance very high to avoid failed transactions, which invites sandwich attacks.
- Forgetting the network fee. On busy networks a gas fee can exceed the trading fee on small swaps.
- Leaving unlimited approvals to contracts you no longer use; review them as explained in token approvals explained.
Questions readers ask
Do decentralized exchanges hold my funds?
Not in the way an exchange company does. Your tokens stay in your wallet until you sign a swap; during the swap they go into the pool contract and the other token comes back in the same transaction.
Why did my swap fail but I still paid a fee?
If the price moves beyond your slippage tolerance, the contract cancels the trade, but the network still charges for the computation used. That is the gas fee.
Is an AMM the same as a liquidity pool?
The pool is the stock of tokens; the AMM is the rule that prices trades against it. In everyday use the terms often overlap.
Can a DEX price be wrong?
Briefly, yes. A pool's price only changes when someone trades with it, so it can lag other markets until arbitrage traders close the gap. That lag is one reason pool prices make risky oracles; see what is a blockchain oracle.
A decentralized exchange replaces the order book with a pool and a formula, so the price you pay depends on how big your trade is compared with the pool. Before you swap, check the token's contract address, the price impact, your slippage limit and the network fee — the contract will not do that for you.
Sources
- Uniswap documentation, How Uniswap works (v2 protocol overview) (2020)Primary source
- Uniswap documentation, Swaps: price impact and slippage (2021)Primary source
- Uniswap documentation, Concentrated liquidity (Uniswap v3 concepts) (2021)Primary source
- ethereum.org, Maximal extractable value (MEV) (2026)Primary source
- ethereum.org, Decentralized finance (DeFi) (2026)Primary source
Educational content only — not financial, investment, legal or tax advice. Crypto-assets are high-risk and you could lose all the money you put in. Rules differ by country; check with your national regulator. See our risk disclosure and editorial policy.



