How Does the Constant Product Formula ($x Y = K$) of a Basic AMM Determine Price and Spread?
The formula $x y = k$ ensures that the product of the quantities of the two tokens in the pool ($x$ and $y$) remains constant ($k$). The price is determined by the ratio of the two tokens ($y/x$).
When a trade occurs, the ratio changes, and the new price is the effective execution price. The bid-offer spread arises from the price impact and the transaction fees charged by the pool on every trade.