By MEV DAO Research

Got fewer tokens than the quote said? Might just be the market. Might be a sandwich: a bot spotted your swap in the mempool, bought right before you, sold right after you in the same block, and walked off with the gap.

Here's how to check with plain Etherscan, roughly what it cost you, and three things to change.

How the attack works

On a regular RPC your swap sits in the public mempool for a few seconds first. Anybody can read it. How much, which pool, what slippage.

The bot jumps in ahead and buys the same token. Price goes up. Your swap goes through at the worse price, inside your slippage, so it looks fine. Then the bot dumps into the bump you created.

That front buy is sized on purpose, to shove you down to your minimum out. Whatever slippage you set, assume the bot is aiming for nearly all of it.

If you want the long version with worked numbers, it's on our blog: What is a sandwich attack and how to avoid getting sandwiched.

How to check your own swap

No special tools needed. Etherscan does the job.

  1. Open your swap on Etherscan. Note the block number and where your transaction sits in it.
  2. Click into the block and look at the transaction list.
  3. Check the transactions right before and right after yours. Same pair, same direction just before you, and the reverse just after, usually from the same address or contract? That's the pattern.
  4. Open the one after yours. If it sells about what the one before bought, you've got both slices of bread.

MEV explorers such as EigenPhi will also flag sandwiches if you paste in a transaction hash, which is faster when you want to scan a lot of old trades.

Ballpark the damage like this: what would your swap have paid from the pool as it stood just before the bot bought? Subtract what you actually got. That's about what the sandwich took.

Who actually gets sandwiched

Bots are picky. Every sandwich costs them gas on two transactions and usually a builder tip, so they only go after trades that leave room. Thin pools. Big slippage (memecoin buys at 5 to 15 percent are a gift). Trades that are big for the pool. All of it sent through a plain public RPC.

Small ETH/USDC swap, deep pool, 0.5 percent slippage? Usually not worth their gas. 3 ETH into some brand new token at 10 percent? Oh, they'll take that.

Setting one: lower your slippage

This one is free. Use the lowest slippage that still lets the trade go through. On liquid pairs, 0.1 to 0.5 percent is usually fine. Thin pairs need more, but once you're past a few percent you're leaving a lot on the table.

If you build swaps in code, work out the minimum out from a fresh quote instead of hardcoding a big buffer:

// quote: expected amount out from your router or quoter, as a bigint const slippageBps = 50n; // 0.5% const amountOutMin = (quote * (10_000n - slippageBps)) / 10_000n; 

Tight slippage does mean more failed swaps when the price moves for normal reasons. The next setting helps with that too.

Setting two: use a private RPC

A private RPC sends your transaction to block builders directly and skips the public mempool, so sandwich bots never see it. Flashbots Protect and MEV Blocker are the two free options most people use. Add one in MetaMask as a custom network RPC and your swaps go out privately from then on.

They aren't the same thing, though. Refunds from backruns work differently, the builder lists differ, and so does what happens when a swap fails. Our comparison is in What is MEV protection on Ethereum and should you use it.

Quick caveat. A private RPC hides you from the public mempool, that's all. Set 20 percent slippage on a pool your own trade can move and you can still get a terrible price.

Setting three: swap through an intent-based DEX

Intent-based DEXs like CoW Swap and UniswapX flip the model. Instead of sending a raw swap, you sign an order that says what you want, and solvers compete to fill it. Since your order never sits in the mempool as a normal swap, there's nothing to sandwich in the usual way. You often get a better price too, because solvers can match orders against each other.

The downsides are that fills can take a bit longer and not every token is supported, especially very new ones.

A quick checklist before your next swap

  • Is the pool deep enough for the trade size? If not, split it.
  • Is slippage as low as it can reasonably be?
  • Is your wallet pointed at a private RPC?
  • For bigger trades, would an intent-based DEX fill it instead?

None of this needs code, and it takes about five minutes to set up. Sandwich bots aren't going away, but they mostly hunt easy targets. Being a slightly harder one is usually enough.

MEV DAO Research writes about MEV, wallet safety and Ethereum trading at mevdao.org.