What Is a “Sandwich Attack” and How Does It Exploit the Actions of Other Traders in an AMM?
A sandwich attack is a form of front-running where a malicious trader observes a pending transaction (Victim Trade) on the blockchain. The attacker places a buy order (Attack Buy) immediately before the Victim Trade and a sell order (Attack Sell) immediately after it, all within the same block.
The Attack Buy drives up the price, making the Victim Trade execute at a worse price. The Attack Sell then capitalizes on the price increase, profiting from the victim's slippage tolerance.