How Do Automated Market Makers (AMMs) Create the Vulnerability for Sandwich Attacks?
AMMs, such as Uniswap, use a constant product formula (x y = k) to determine asset prices and execute trades. When a large trade is executed, it significantly shifts the ratio of assets in the liquidity pool, causing a predictable price change.
This deterministic price impact, combined with the public visibility of the pending transaction in the mempool, creates a clear, exploitable arbitrage opportunity that is the basis for the sandwich attack.