What Is the Formula Used by a Constant Product AMM (E.g. Uniswap V2)?
The constant product formula is $x y = k$, where $x$ and $y$ are the quantities of the two tokens in the pool, and $k$ is a constant. This formula ensures that the product of the reserves remains unchanged after a trade, meaning that as one token is bought, the price of the remaining token increases, maintaining a balance and providing continuous liquidity.