Constant Product AMM

Algorithm

Constant Product Automated Market Makers (CPAMMs) represent a deterministic function governing token exchange, fundamentally differing from order book exchanges through reliance on a mathematical formula rather than discrete buy and sell orders. This core algorithm maintains a constant relationship between the quantities of two tokens within a liquidity pool, typically expressed as xy=k, where x and y represent the token reserves and k is a constant. Consequently, trades adjust the ratio of these reserves, impacting price discovery and introducing slippage proportional to pool size and trade magnitude. The inherent simplicity of this algorithmic approach facilitates permissionless liquidity provision and automated trading, forming a cornerstone of decentralized finance (DeFi).