Skip to main content

How Does a Front-Runner Calculate the Optimal Size for Their Sandwich Attack Trades?

A front-runner uses a sophisticated bot to calculate the optimal size for their sandwich trades based on the victim's order size, the liquidity pool's depth, and the victim's slippage tolerance. The bot aims to maximize the price impact caused by its buy order, ensuring the victim's trade executes at the worst possible price (within the slippage limit), while also minimizing the front-runner's capital exposure and transaction fees.

This involves solving a complex optimization problem using the AMM's formula.

What Is a “Sandwich Attack” and How Is It a Form of MEV?
What Is a “Sandwich Attack” in the Context of DeFi and How Does It Utilize Front-Running?
How Does Slippage Tolerance Setting Affect a User’s Vulnerability to a Sandwich Attack?
Can a Front-Runner Deliberately Cause a Transaction to Revert Using Slippage?