Intermediate level
The price you receive on a decentralized exchange depends on three things: price impact, which is how far your own trade moves the pool; slippage, which is how far the market moves between your quote and your fill; and routing, which is how the order is split across pools. Size the trade against the liquidity, set a slippage limit you can defend, and let a good router do the rest.
Three prices, not one
Every swap involves three different prices, and most of the confusion people have about DEX trading comes from treating them as one.
| Price | What it is | Who controls it |
|---|---|---|
| The spot price | The price of an infinitely small trade right now. It is what charts and price sites show. | The market |
| The quoted price | The average price your whole trade would get if it executed this instant, against the liquidity that exists this instant. | Your trade size, against the pool |
| The fill price | What you actually received, once the transaction landed in a block a few seconds later. | Everything that happened in between |
The gap between the spot price and the quote is price impact. The gap between the quote and the fill is slippage. They have different causes and different fixes, so it pays to keep them apart.
Price impact: your trade moves the pool
An automated market maker has no order book. It holds two tokens and a formula, and every trade shifts the balance between them. Buy ETH from an ETH and USDC pool and you leave behind more USDC and less ETH, so each additional unit of ETH costs a little more than the last. Your average price is worse than the spot price you started from.
For the classic constant product pool there is a clean way to estimate it. Ignoring the fee, your average price is worse than spot by roughly:
Take a pool holding 100 ETH and 300,000 USDC, so the spot price is 3,000 USDC per ETH.
| You pay | Share of the USDC reserve | ETH you receive | Average price | Worse than spot by |
|---|---|---|---|---|
| 3,000 USDC | 1% | 0.990 | 3,030 | 1% |
| 30,000 USDC | 10% | 9.09 | 3,300 | 10% |
| 75,000 USDC | 25% | 20.0 | 3,750 | 25% |
The pattern is the whole lesson. Price impact scales with the size of your trade relative to the liquidity you are trading against, not with the size of your trade in dollars. Three thousand dollars is nothing in a deep pool and a disaster in a shallow one.
Slippage: the market moves before you land
Your wallet signs the transaction against the quote, but the transaction still has to be picked up and included in a block. On Ethereum that is usually the next block or two, about twelve seconds each. On Solana it is typically well under a second. On a busy layer 2 it is fast too. In that window other trades hit the same pool, and the price you were quoted drifts.
The slippage setting is not a prediction of that drift. It is a limit. It tells the contract: if the result would be worse than this, revert the whole trade instead of filling it. Under the hood it becomes a minimum amount out:
So there are two ways to get it wrong, and they fail in opposite directions:
Set too tight
The trade keeps failing
- Normal market movement pushes the result past the limit and the transaction reverts
- On Ethereum and most EVM chains you still pay gas for a reverted transaction
- On Solana a failed transaction still pays its base and priority fees, though they are small
- Nothing is ever filled at a price you did not accept
Set too loose
The trade fills, badly
- Any bot watching can move the price against you right up to your limit, then move it back
- A thin pool can move that far on its own in a volatile minute
- You approved the worse price in advance, so there is nothing to dispute
- The transaction almost never fails
Why a loose limit invites bots
On chains where pending transactions are visible before they are included, your swap is public for a few seconds. A searcher can place a buy just before yours, let your trade push the price up further, and sell straight after. This is a sandwich, and your slippage tolerance sets the size of the prize: the attacker can extract at most the gap between the quote and your minimum.
That gives a simple rule. A tolerance is an amount you are willing to hand to the market in the worst case, so choose it as a price, not as a way to make an error message go away.
| Pair type | A reasonable starting tolerance | Why |
|---|---|---|
| Stablecoin to stablecoin | 0.05% to 0.1% | The price should barely move, so anything wider is only room for extraction |
| Major pair, deep pool (ETH/USDC, SOL/USDC) | 0.3% to 0.5% | Enough headroom for a block of normal movement |
| Smaller tokens with real liquidity | 0.5% to 2% | Wider books drift faster; check the quote impact first |
| Thin or newly launched tokens | Only what you would accept losing | Anything goes here, which is exactly the problem |
You can also take the public window away entirely. On Ethereum and several layer 2s, a private RPC endpoint or an MEV protection service sends your transaction straight to block builders instead of the public mempool, so there is nothing to sandwich. Intent based swaps, where you sign the outcome you want and professional solvers compete to deliver it, remove the problem by a different route. Both are covered in depth in the MEV guide and the guide to intents and solvers.
Routing: the router splits the order for you
You rarely trade against one pool any more. An aggregator looks at every pool it knows about, across fee tiers and across DEXs, and works out the best way to fill your order. For a large trade it will often split it, sending part through one pool and part through another, or hopping through an intermediate token when that path is deeper.
Split routes
Forty percent through one pool, sixty through another. Each piece moves its pool less, so the total impact is lower than any single pool could offer.
Multi hop routes
Token A to ETH to token B, when the two ETH pools together are deeper than the direct A to B pool. More hops cost a little more gas.
Fee tier choice
The same pair often exists at several fee tiers. A router weighs a cheaper fee against the depth each tier actually holds.
On Solana, Jupiter is the default router most wallets use. On Ethereum and its layer 2s there are several, including the routers built into Uniswap, 1inch, 0x and CoW Swap, and most wallets have one built in. You do not need to pick a winner. You do need to know that two routers quoting the same trade can differ, and that checking a second quote on a large trade is free.
Sizing a trade against the pool
The single most useful habit at this level is to look at the price impact figure before you look at anything else. Every decent interface shows it. Then decide what to do about it.
Read the impact, not just the output
If the interface says 0.1% impact, the pool is deep relative to your trade and you can focus on slippage and fees. If it says 3%, you are paying three percent to the pool before anything else happens.
Compare it with the alternatives
A 1% impact on a token that trades on a major exchange might be worth avoiding by using the exchange. On a token that only exists onchain, it may simply be the cost of admission.
Break it up if it is large
Pools refill as arbitrageurs bring the price back in line. Five trades spaced out over an hour often cost far less than one trade now, if you can tolerate the price moving in the meantime. A TWAP order automates exactly this. See limit orders, DCA and TWAP.
Set slippage last
With the size decided, set a tolerance that covers normal movement for this pair and no more. Then send it.
Checking what you actually got
After the swap, open the transaction on a block explorer and compare the tokens that arrived with the quote you accepted. On an EVM chain, the token transfer lines show exactly what left your wallet and what came in. If the fill is well below the quote, look at the transactions just before and after yours in the same block. A buy of the same token directly before you and a sell directly after is the fingerprint of a sandwich.
Once you can read that, you can tell the difference between an unlucky market, a thin pool, and a bot, and you know which of the three fixes applies. The analyst guide to reading transactions goes further.
A checklist for any swap that matters
- Impact first. Anything above a percent deserves a second thought and a second quote.
- Slippage as a price. Set it to what you would accept losing in the worst case, not to whatever makes the error go away.
- Protection on. Use a private or protected route on chains with a public mempool when the trade is large enough to be worth attacking.
- Right chain. For small trades, the chain with the lowest fees and adequate depth usually wins.
- Verify the fill. Thirty seconds on the explorer teaches you more about execution than any article, including this one.
Common questions
What is a good slippage setting for a DEX swap?
It depends on the pair. Around 0.05% to 0.1% for stablecoin to stablecoin, 0.3% to 0.5% for a deep major pair, and wider only for thin tokens where you have checked the impact first. The tolerance is the most you are willing to give up in the worst case, so choose it as a price you accept rather than a number that stops errors.
Why did my swap fail but still charge me a fee?
Because the network did the work of trying it. When the result would have been worse than your minimum, the contract reverted the trade, but validators still executed the transaction up to that point. On EVM chains that costs gas; on Solana the base and priority fees are still paid, though they are small.
Is price impact the same as slippage?
No. Price impact is how far your own trade moves the pool, and it is known before you sign because it is part of the quote. Slippage is how far the market moves between the quote and the moment your transaction lands, and your tolerance setting caps it.
Do aggregators really get better prices than going direct?
Usually for anything beyond a small trade, because they can split an order across several pools and fee tiers so each piece moves its pool less. For a tiny trade in the deepest pool the result is often identical, and a direct swap can use slightly less gas.
How do I know if I was sandwiched?
Open your transaction on a block explorer and look at its neighbors in the same block. A buy of the same token immediately before yours and a sell immediately after, from the same address or contract, is the classic sign. Protected RPCs and intent based swaps prevent it.
Where to go next
Next: Limit orders, DCA and TWAP onchain
Guide 6 of 16 in the Intermediate level. Your place is kept on this device, so you can pick up exactly here next time.