Skip to main content

What Is the Formula for the Constant Product Market Maker (CPMM) and How Is It Exploited?

The formula is $x y = k$, where $x$ and $y$ are the reserves of the two tokens in the liquidity pool, and $k$ is a constant. The formula is exploited because every trade must maintain this constant, leading to predictable price changes.

When a large trade dramatically changes the ratio of $x$ and $y$, it causes a price shift that is immediately visible. A front-runner exploits this predictability by placing orders around the victim's trade to profit from the guaranteed price impact.

What Is a ‘Back-Run’ and How Does It Differ from a Sandwich Attack?
How Can Oracle Price Feeds Be Exploited in a Derivatives Front-Running Attack?
What Is the Key Vulnerability That Sandwich Attacks Exploit on Automated Market Makers (AMMs)?
Explain the ‘Sandwich Attack’ as a Specific Form of Mempool Front-Running