Why a DEX trade fails with slippage exceeded and how to fix it
You set a slippage tolerance. You click swap. The transaction runs for minutes. Then Etherscan shows a red "Fail" with the reason: slippage exceeded.
The wallet shows the transaction went through. The DEX says it failed. What happened is that the trade did execute on chain - but the amount of tokens you actually received was lower than your minimum, so the data/verify-contract-owner-and-proxy/">smart contract intentionally reverted the transaction.
Two unrelated things cause this. Knowing which one hit you changes how you fix it.
Price impact from the AMM itself
A constant-product AMM like Uniswap v2 uses the formula x * y = k. Every trade shifts the ratio. On a pool with shallow liquidity - a pair with small reserves - a single trade can move the price noticeably. The larger your trade relative to the pool size, the worse the price you get.
The DEX shows you a preview before you sign. If the pool has $10,000 of token A and $8,000 of token B, and you try to swap $5,000 worth, the price impact might be 15%. Your preview might say "you will receive 420 tokens." You set slippage to 0.5%. The trade runs and the actual output is 360 tokens. 360 is less than 420 * (1 - 0.005) ≈ 418. The contract rejects it.
This is not an attack. It is math. The fix is to either accept a higher slippage or break your trade into smaller pieces. Breaking a large swap into several smaller swaps lets each one execute at less punitive price impact. Or you route through a DEX aggregator like 1inch or Paraswap that splits the order across multiple pools.
MEV sandwich attack
A front-running bot watches the mempool for your pending transaction. It sees your swap will move the price. The bot buys just before you, you buy at the worse price, then the bot sells at a profit. This pushes your actual output below your minimum.
The attacker only takes the trade if it is profitable. Smaller trades are rarely targeted. Trades on high-liquidity pools are harder to sandwich because the required capital is large. A token with small liquidity and a sudden price spike is a common target.
The fix: use a private mempool service or a DEX that has built-in MEV protection. Some DEXs offer "flash" swap modes that batch your transaction with the price check in one atomic call. This is not always available. The more reliable fix is to set a reasonable slippage - not zero, not 50% - and accept that on volatile pairs you may need to retry.
How to read the failure on Etherscan
Open the failed transaction. Look at the Transaction Action line. It will often show a green check for the token spend and a red X for the receive. Click the Logs tab. Find the event named Swap or Sync. That event contains the actual input and output amounts.
On Uniswap v2 the Swap event has three fields: amount0In, amount1In, amount0Out, amount1Out. Compare the output to the minAmountOut parameter you sent. The difference is what caused the revert.
On Etherscan's Details tab you see the input data. Decode it using the method described in How to decode any transaction input data using a contract ABI. The fourth or fifth parameter in a swap call is almost always amountOutMin. That is the number you set. Compare it to the actual output from the event log.
Adjusting slippage safely
Most DEX UIs show a slippage setting as a percentage. The default is usually 0.5% or 1%. For stablecoin pairs on deep liquidity that is fine. For a new token on a thin pool, it is too tight.
Do not set slippage to 20% unless you understand the price impact. A slippage of 20% means you accept losing up to 20% of your expected output. That is a big number. A 3% to 5% slippage handles most common failures without giving up too much.
The DEX preview shows the price impact explicitly. If it shows 8% price impact and you set 0.5% slippage, the trade will fail. Set the slippage to at least the displayed price impact plus 0.5%.
No single setting works for every situation. A minute later the pool state changes and the same trade might go through at 0.5%. The failure tells you the state when you signed was wrong. Try again.
Not financial advice. basiliskawakens.xyz publishes market data and general information about digital assets. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.
Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.