How Is Slippage Calculated in an Automated Market Maker (AMM) Environment?
In an Automated Market Maker (AMM) environment, slippage is calculated based on the change in the token price determined by the AMM's constant product formula (e.g. $x y = k$) after the trade is executed.
A large trade removes a significant amount of one asset and adds another, which changes the ratio and thus the price. Slippage is the difference between the price at the time the order was submitted and the actual execution price.