These bots are automated systems that scan pending blockchain transactions for profit opportunities created by transaction ordering. In DeFi, they often watch the public mempool for swaps, liquidations, and arbitrage opportunities, then react faster than normal users can. The most notorious example is the sandwich attack, where a bot places one trade before a victim and another after the victim in order to profit from the price movement the victim creates.
The key thing to understand is that these bots are not “hacking” wallets in the normal sense. They are exploiting transparent order flow and predictable smart-contract behavior. If your pending transaction reveals that it will move a token price, a bot may try to wrap around it and extract value before the block is finalized. That is why MEV bot behavior feels invisible until you compare the expected swap price with the one you actually received.
This content is for educational purposes only and should not be considered financial or investment advice.
Key Takeaways
- Attack bots watch pending order flow for profit: They react to visible transactions before those transactions are finalized.
- Sandwich attacks target swaps with visible price impact: The attacker buys first, lets the victim push price, then sells after the victim.
- Wide slippage and thin liquidity make users easier targets: Loose settings give bots more room to extract value.
- The practical harm is worse execution: Users often receive fewer tokens or pay more than expected even though the transaction “succeeds.”
- Mitigation is mostly about execution discipline: Routing, slippage control, order sizing, and private order flow matter more than slogans.
What These Bots Actually Do
An MEV bot continuously monitors pending transactions and compares them against strategies it knows how to monetize. If it sees a profitable swap, liquidation, or arbitrage path, it constructs transactions that can be inserted before, after, or alongside the target transaction. The bot is not just looking for “cheap coin goes up.” It is looking for situations where transaction position itself creates profit.
A useful mental model is to think of the bot as an automated queue trader. It does not only care about the transaction content. It cares about standing in the right place in line. If moving one slot ahead or behind your swap changes the pool price in its favor, that queue position becomes worth money.
For the higher-level transaction-ordering problem behind this, the closest local companion is What Is MEV in Crypto.
How a Sandwich Attack Works
A sandwich attack usually unfolds around a visible DEX trade that will move price enough to be exploitable. The attacker sees the victim’s transaction in the public order flow before confirmation and quickly submits two transactions:
- Front trade: The attacker buys the token first, pushing the price higher.
- Victim trade: The victim’s swap executes at the now-worse price.
- Back trade: The attacker sells into the victim’s price impact and captures profit.
The victim often only notices that the final execution looks worse than the quote they expected. On-chain, the transaction still appears successful. But economically, part of the trade value has been extracted by the attacker through ordering. This is why sandwich attacks are such a good example of user-harmful MEV: the protocol works as designed, but the user gets a meaningfully worse outcome.
One operator insight is that the victim’s own transaction creates the profit opportunity. The attacker is not guessing random price movement. It is reacting to an already visible intention to move the pool.
Why Bots Can See the Opportunity Early
Many blockchains expose pending transactions before they are included in a block. That gives bots a preview of the trade size, route, slippage tolerance, and sometimes the exact contract method being called. If the transaction is large enough and the pool is thin enough, the bot can simulate the likely price movement and decide whether a surrounding trade is profitable.
The mempool is a major part of that visibility. If you want the queue mechanics behind how pending transactions sit in public view, see Bitcoin Mempool Explained: How the Transaction Queue Works. The underlying concept is the same even though the most aggressive sandwich behavior is mainly associated with smart-contract trading environments.
What Makes a Trade Easy to Sandwich
- Large order size relative to pool depth: Bigger visible price impact creates a larger profit window.
- Wide slippage tolerance: The bot knows your transaction can still execute even after adverse price movement.
- Thin liquidity: Shallow pools are easier to move with less capital.
- Public routing: If the order flow is visible before settlement, the bot has time to respond.
- Slow or predictable execution paths: Routes that are easy to simulate can be targeted more reliably.
This is why users sometimes blame “DEX volatility” when the real issue is execution quality. The market may not have moved on its own. The order itself may have been the thing that created the exploitable move.
How the Harm Shows Up for Users
For most users, the result is not a wallet alert saying “you were sandwiched.” It shows up indirectly:
- Worse token output than quoted
- Higher effective purchase price
- More slippage than expected
- Failed or reverted swaps when conditions move too far
- Unexpectedly poor fills in volatile pools
After the fact, the best way to understand what happened is to inspect the surrounding transactions and their ordering. The local guide for that skill is How to Read a Blockchain Transaction.
Bots vs Normal Arbitrage
Not all bot activity is equally harmful. Some bots perform arbitrage that helps align prices across pools after dislocations appear. Those trades can still capture value, but they do not necessarily extract it directly from one visible victim in the same way a sandwich attack does. Sandwiching is different because it intentionally degrades another user’s execution.
A second operator insight is that users should separate “bots exist” from “this specific bot behavior harmed me.” Professional execution systems, market makers, arbitrageurs, and harmful sandwichers may all look like fast bot activity on-chain, but the economic effect on the user is not the same.
Practical Usage: How to Reduce Sandwich Risk
- Use tighter slippage settings when possible: This narrows the attacker’s room to move price and still let your trade execute.
- Avoid very large swaps into thin pools: Splitting orders or using deeper liquidity can reduce obvious targets.
- Check route quality before signing: Some routes expose you to more predictable price impact than others.
- Consider tools with private order flow: Some wallets and routers try to reduce public exposure before the trade lands.
- Be skeptical during volatile token launches: Fast-moving, thin-liquidity conditions are especially attractive to searcher bots.
There is no perfect retail defense, but better execution habits help. The practical goal is not to beat professional searchers at their own game. It is to avoid making your transaction an easy target in the first place.
Risks and Common Mistakes
- Thinking the bot “stole the wallet”: In most sandwich cases, the wallet was not compromised. The trade was simply exploited through ordering.
- Confusing slippage with random bad luck: Sometimes the poor fill was caused by visible attackable order flow, not by natural price movement alone.
- Using wide slippage by default: This can create unnecessary room for extraction in already risky pools.
- Ignoring liquidity depth: A pool can look active but still be too thin for a large order.
- Assuming every failed trade is an attack: Congestion, route problems, and contract behavior can also cause poor execution or reverts.
Sources
Frequently Asked Questions
What are sandwich and searcher bots?
They are automated systems that monitor visible transactions for ways to profit from ordering, arbitrage, liquidations, or related execution opportunities.
What is a sandwich attack in crypto?
It is an attack where a bot trades before and after a victim’s swap, using the victim’s own price impact to generate profit and worsen the victim’s execution.
Why do sandwich attacks happen on DEXs?
They happen because many DEX trades are visible before final settlement, and pool pricing can be modeled in advance. That gives bots time to react to profitable swaps.
Can users stop these bots completely?
No, not completely. But tighter slippage, better routing, deeper liquidity, and reduced public order-flow exposure can lower the chance of being an easy target.
Does every bad swap mean I was sandwiched?
No. Poor execution can also come from normal volatility, low liquidity, route issues, or network conditions. You usually need to inspect surrounding transactions to know what happened.




