What Is a Sandwich Attack? Front-Running on Solana Explained
A sandwich attack is one of the quieter ways a memecoin trade loses value — not to a rug, not to a bad call, but to a bot that saw your swap coming and squeezed a slice out of it. You still get your tokens. You just get them at a worse price than the chart showed when you tapped buy. This post explains exactly what's happening, why some traders get targeted and others don't, how the dynamics differ on Solana versus Ethereum, and what actually reduces your exposure.
What MEV and front-running mean
Before the sandwich, two concepts. MEV stands for Maximal Extractable Value — the profit a party can capture by controlling the order in which transactions get included in a block. Whoever decides "this swap goes first, that one goes second" holds a small amount of power, and that power has a dollar value. MEV is the name for harvesting it.
Front-running is the simplest form: a bot sees a transaction that is about to move a price, and rushes its own transaction in ahead of it to profit from the move it knows is coming. On a public blockchain, pending transactions are not secret. If you broadcast "I'm about to buy 5 SOL of this token," anyone watching can read that intent and react before your trade settles.
A sandwich attack is front-running plus a follow-up trade on the other side. The attacker wraps your swap between two of their own — one before, one after — and pockets the difference. Hence the name.
The sandwich mechanic, step by step
Here is the full sequence, with a token swap on an automated market maker (read what an AMM is if that term is new). The whole thing happens in a fraction of a second.
- Step 1 — your swap becomes visible. You submit a buy with a loose slippage tolerance, say 20%. That tolerance is a promise: "fill me as long as the price doesn't move more than 20% against me." The transaction is now pending and observable.
- Step 2 — the bot front-runs. It places its own buy of the same token just before yours. This pushes the pool price up. Because of how AMMs price trades, every buy moves the price along a curve — the bot's buy moves it up the curve, and now the next buy (yours) starts from a higher point.
- Step 3 — your swap fills at the worse price. Your buy executes against the now-inflated price. Your 20% tolerance is wide enough to absorb the move the bot just created, so the trade goes through instead of reverting. You receive fewer tokens than you would have a moment earlier.
- Step 4 — the bot back-runs. Immediately after your buy, the bot sells the tokens it bought in step 2 — now at the higher price your own purchase helped create. It exits with a profit. The price drifts back down. The bot's gain is, roughly, the value your loose tolerance left on the table.
The cruel detail: nothing failed. There is no error, no rejection. Your trade did exactly what you authorized — it filled within your slippage limit. The bot simply found the gap between the price you saw and the worst price you were willing to accept, and lived inside it.
Why loose slippage and thin liquidity make you a target
Sandwiching is only worth a bot's effort when two conditions line up: there is room to move the price, and there is room inside your tolerance to hide the move.
- Wide slippage tolerance is the invitation. If you set 20% or 30% or "auto-high" to make sure volatile launches fill, you are telling the network you will accept a much worse price than the current one. That headroom is exactly what a sandwich bot fills. A tight tolerance — a few percent — leaves far less to skim, and often makes the attack unprofitable after the bot's own fees.
- Thin liquidity amplifies every trade. In a shallow liquidity pool, a small buy moves the price a lot. That means the bot needs little capital to shift the price meaningfully before your trade, and your own buy moves it further still — bigger skim. Deep, liquid pools are much harder and less rewarding to sandwich.
- Large, obvious orders stand out. A big buy into a thin pool is a loud signal. The bigger the price impact your single transaction will cause, the more there is to extract by sitting on both sides of it.
Put bluntly: a small, tightly-bounded trade into a deep pool is a bad target. A large, loosely-bounded trade into a thin pool is the ideal one. Most retail memecoin buys that get sandwiched are the second kind — fresh launches, thin liquidity, slippage cranked up to force the fill.
How Solana differs from Ethereum here
Sandwiching is most famous on Ethereum, and the mechanics there are textbook: Ethereum has a public mempool — a shared waiting room where pending transactions sit, visible to everyone, before a block is built. Searchers watch that mempool, spot a juicy swap, and bid through an auction to have their front-run and back-run placed around it in the next block. The ordering is decided openly and the target sits in plain view for seconds.
Solana works differently, and it matters for how the attack plays out — without making anyone immune.
- No single global mempool. Solana has no one shared waiting room. Transactions are forwarded toward the current block producer (the "leader"), and there are effectively many partial, validator-local views rather than one canonical queue everyone reads from.
- A rotating leader builds blocks. One validator is the leader at a time and rotates on a schedule. That leader sees the flow of transactions heading to it and has influence over ordering for its slots. Extraction tends to cluster around who is building the block and what they can see, rather than around an open, public auction.
- Fast blocks, different timing. Solana's blocks come quickly, so the window is short — but "short" is not "safe." Bots colocate near validators and watch transaction flow closely; a fraction of a second is plenty to wrap a visible swap.
The honest takeaway: the plumbing differs — no public mempool, leader-based ordering instead of an open auction — so the exact path of an attack is not identical to Ethereum's. But the underlying incentive is the same, and sandwiching does happen on Solana. If you want the deeper mechanics, the Solana MEV deep-dive walks through the leader model and extraction in detail.
The defenses that actually reduce it
No single setting makes you untouchable, but a few habits move you from easy target to poor target — which is usually enough, because bots chase the easiest value.
- Set tight, sensible slippage. This is the biggest lever. Use the smallest tolerance that still reliably fills for the pool you're trading. A few percent on a liquid token; somewhat higher only when a volatile launch genuinely needs it. The goal is to leave almost no headroom for a bot to hide a price push inside. If you're unsure how the number works, read how slippage works on Solana — the distinction between price impact and slippage tolerance is exactly what attackers exploit.
- Don't telegraph huge orders into thin pools. A large buy into shallow liquidity is the loudest possible signal. Splitting size, or simply trading deeper pools, reduces both your price impact and the reward for sandwiching you.
- Prefer protected or private routing. If your transaction never sits where a bot can read it before it lands — and instead lands atomically with no foreign trade slipped in beside it — there is nothing to wrap. On Solana, this is the role Jito bundles play: an atomic, off-mempool group of transactions that execute together in order, so no buy can be inserted between the front and back of your trade. That's why serious bots route race-sensitive trades through them — see Jito bundles for traders for how that works, and MEV protection explained for the broader picture.
- Mind priority fees, not just slippage. Getting a trade to land promptly is its own defense — a transaction that lingers gives bots more time to react. The priority fees breakdown covers when paying for faster inclusion is worth it.
The honest caveat, stated plainly: nothing eliminates MEV entirely. Tight slippage, sensible sizing, and protected routing reduce your exposure — sometimes dramatically — but they shrink the problem, they don't delete it. Anyone promising a setting that makes sandwiching impossible is overselling. Treat reduction, not immunity, as the realistic goal.
How MoonHydra fits
MoonHydra is a non-custodial Solana trading bot you drive from Telegram. A few things about how it relates to sandwich exposure, kept honest:
- Sane default slippage limits. The bot ships with sensible default tolerances rather than a wide-open setting, which is the single most effective thing a tool can do to shrink the headroom a sandwich bot needs. You can adjust the number per trade — tighten it for liquid tokens, loosen it only when a volatile launch truly requires it.
- Routing through Jupiter. Trades route via Jupiter's aggregation rather than through any custom contracts of our own — MoonHydra has none. That keeps execution on well-trodden infrastructure where protected-routing options exist.
- Non-custodial by design. Your keys stay yours, encrypted with AES-256-GCM; the bot signs trades, it doesn't hold your funds. That's a custody point, not a sandwich one — but it's worth saying clearly.
- Simple, flat pricing. A flat 1% per trade on buys and sells, no subscription. We don't add hidden routing markups on top.
What MoonHydra does not claim: that it makes you immune to MEV. No tool can. What sensible defaults and protected routing do is move you toward being a poor target rather than an easy one — and on a network where bots chase the easiest value, that is most of the battle.
Bottom line
A sandwich attack costs you the gap between the price you saw and the worst price you agreed to accept. The bot front-runs your buy to push the price up, lets your trade fill high, then sells right after to bank the difference. You are targeted when your slippage is loose and the pool is thin, because that's where the value to extract is largest and easiest to hide. Solana's leader-based ordering and lack of a public mempool change the path of the attack but not the incentive behind it. The defenses are unglamorous and effective: tight, sensible slippage; don't shove huge orders into shallow pools; use protected routing for race-sensitive trades; and accept that the realistic goal is reducing exposure, not erasing it.
Next: read how slippage works on Solana to set your tolerance with intent, MEV protection explained for the full defensive picture, and Jito bundles for traders for the routing that leaves nothing to sandwich — or open the bot at t.me/moonhydrabot.
Ready to put this into practice?
MoonHydra is a multi-wallet Solana memecoin trading bot on Telegram. 1% per trade. AES-256-GCM encrypted. Non-custodial.
Open MoonHydra