Sandwich Attack: The Hidden Threat in DeFi Trading
When talking about sandwich attack, a type of front‑running where a trader’s order is squeezed between two malicious trades. Also known as MEV sandwich, it exploits the way transactions are ordered in a block and can rip profit from unsuspecting users.
One of the core players in a sandwich attack is front‑running, the practice of observing a pending transaction and placing a trade before it to profit from the price movement it causes. Front‑running fuels the attack because the attacker watches a large buy (or sell) hit a liquidity pool, a smart‑contract‑based reservoir of tokens that enables instant swaps. By buying just before the target order and selling right after, the attacker creates a “sandwich” that squeezes the original trader’s price.
The economic engine behind these moves is MEV, Miner Extractable Value (or Maximal Extractable Value) that represents profit miners or validators can capture by reordering, inserting, or omitting transactions. MEV provides the incentive for bots to watch mempools, calculate optimal trade sizes, and execute sandwich attacks at lightning speed. In practice, MEV requires sophisticated bots, low‑latency infrastructure, and deep knowledge of the underlying smart contracts, the code that runs automated trades on blockchain platforms.
Understanding these relationships helps traders spot warning signs. If you notice a sudden price spike right before a large swap lands, that’s a classic sandwich pattern. Many DeFi platforms now offer transaction simulation tools that let you preview slippage and potential front‑running before you hit confirm. Meanwhile, some protocols integrate anti‑MEV mechanisms like time‑locked orders or private transaction relays to hide trade intent.
Below you’ll find a curated set of articles that dive deeper into sandwich attacks, front‑running tactics, MEV economics, and practical defenses you can apply to your own trading strategy.

Explore the most common AMM vulnerabilities, real-world DeFi exploits, and practical steps to safeguard your automated market maker contracts.
- Read More