Trading Mechanics

You're the Filling: How Sandwich Attacks Quietly Tax Your Trades

You hit swap. The preview said one number. The result was worse. You shrugged and blamed volatility.

IgnizIgniz Research
5 min read
Cover image for the article "You're the Filling: How Sandwich Attacks Quietly Tax Your Trades"

You hit swap. The preview said one number. The result was worse. You shrugged and blamed volatility.

It might not have been volatility. You might have just been lunch.

Sandwich attacks are one of the most common ways traders bleed value on-chain without ever noticing. They do not announce themselves. There is no error message, no liquidation, no dramatic candle. Just a slightly worse fill, over and over, quietly skimming off the top of your trades. Let's pull back the curtain.

The pending transaction problem

Here is the thing most people never think about. When you submit a trade on-chain, it does not execute instantly. It sits in a waiting area, visible to anyone watching, before it gets confirmed.

That waiting room is public. Your intended trade, the size, the token, the direction, can be seen by others before it actually happens. On a traditional exchange your order goes straight to a private matching engine. On-chain, you are often announcing your move to a crowd before you make it.

Most of that crowd does not care about your trade. But some of them run software specifically designed to spot trades they can profit from. And a swap with loose settings is exactly what they are hunting for.

How the sandwich works

The name describes the shape perfectly. Your trade is the filling. Two of theirs are the bread.

Picture your buy order sitting in the waiting room. An observer spots it. Here is the sequence that follows:

The front slice. They rush a buy in just ahead of yours, paying to get priority. Their purchase nudges the price up a little.

Your trade, the filling. Yours executes next, but now at the slightly higher price their buy created. You get fewer tokens than you would have. You feel nothing unusual.

The back slice. Immediately after, they sell into the price bump that your own trade pushed even higher. They pocket the difference.

You paid more than you should have. They captured exactly that amount, minus their costs. The market looks like it moved naturally. In reality, you were gently squeezed between two transactions engineered around yours.

The cruel elegance is that nothing breaks. Your trade succeeds. The chain confirms it. You walk away thinking you got a normal fill, when a small tax was extracted from you in the span of a single block.

Why slippage tolerance is the unlocked door

This is the part that actually matters, because this is the part you control.

When you swap, you set a slippage tolerance. This is the maximum price movement you are willing to accept before the trade cancels. Set it to a high number and you are telling the network you will accept a much worse price than quoted.

Attackers love a high slippage setting. It is the size of the gap they get to exploit. If you allow a generous tolerance, you have handed them room to push the price against you and still have your trade go through. You set the ceiling on how much they can take, and many people set that ceiling absurdly high without realizing it.

A tight slippage setting does the opposite. It shrinks the profitable window so much that the attack often stops being worth attempting. If pushing the price would cause your trade to cancel, there is nothing to sandwich. The attempt fails and they move on to easier prey.

This is why the single most important habit is treating slippage as a security setting, not a convenience knob. Loosening it to force a stubborn trade through is like propping your front door open because your keys are annoying.

The traps that widen the gap

A few common situations make you a softer target. Knowing them is half the defense.

Low liquidity pairs. Thin markets move more per trade, so the same swap creates a bigger price swing for an attacker to work with. The less depth behind a token, the more a sandwich can extract. Trading illiquid pairs with loose settings is the highest-risk combination there is.

Oversized trades. A large swap moves price more, which means more room to squeeze. Breaking a big trade into smaller pieces reduces how much any single one can be exploited, though it is not a complete shield on its own.

Blind copy-paste settings. People find a slippage number that made a past trade succeed and reuse it forever, even in conditions where it is wildly too generous. Settings should match the specific trade, not a habit you formed three months ago.

Ignoring the preview gap. If the quoted price and the expected received amount imply a huge acceptable range, that range is your exposure. Glance at it before confirming. A number that looks too loose usually is.

A thirty second pre-trade checklist

Before you confirm your next swap, run this.

Look at your slippage setting and actually read it. Is it as tight as the trade can tolerate? If you bumped it up earlier to force something through, bump it back down. Check the liquidity of the pair. Thin pool plus loose slippage is the danger zone. If the market is shallow, tighten everything and consider trimming your size. Question any trade that needs loose settings to go through. If a swap only succeeds with a wide tolerance, that resistance is information. The trade is telling you the conditions are bad, not that you should overrule it. Size with the pool in mind. Ask whether your trade is large relative to the available depth. If it is, smaller pieces reduce how juicy a target you present.

None of this takes long. The habit costs you seconds. The absence of the habit costs you a small tax on every trade you make, forever.

The reframe that protects you

Stop thinking of slippage as the setting that gets your trade to go through. Start thinking of it as the setting that decides how much a stranger is allowed to take from you.

Sandwich attacks survive on inattention. They are not sophisticated heists. They are automated software waiting patiently for someone to leave the gap open. The traders who get sandwiched repeatedly are almost never unlucky. They are usually just generous with a number they never stopped to understand.

You cannot make the waiting room private. But you can make yourself a worse target. Tighten the gap, respect the depth, and read the settings you have been clicking past. Do that and the bots scrolling for an easy meal will pass right over you, looking for someone who left the door open instead.

You do not have to be the filling.

This is educational content about on-chain trading mechanics and self-protection, not financial advice. Trading conditions vary, and no single setting guarantees a safe fill. Always understand the specific mechanics of any venue before trading on it.

Share

Stay up to date with Igniz and the future of trading.