Skip to content
GetProfitable
Search
Dictionary

Constant product formula

The classic AMM rule: the product of the two pool reserves stays constant through a trade, so price rises as you drain one side.

Written x times y equals k, where x and y are the two reserves. A swap adds to one side and removes from the other such that the product is unchanged, which makes the marginal price simply y divided by x. Fees are taken before the calculation, so k creeps upward over time and that growth is what pays liquidity providers.

The shape matters more than the algebra. Because the curve is a hyperbola, the pool can never be fully drained at any price, and the cost of each additional unit rises steeply. Small trades relative to the pool get near-mid prices; large ones get progressively worse.

Example: a pool holds 100 ETH and 300,000 USDC, so k is 30,000,000 and the price is 3,000. Buying 10 ETH leaves 90 ETH, so USDC must rise to 333,333, meaning you pay 33,333 for 10 ETH, an average of 3,333 and about 11% price-impact. The same 10 ETH from a pool ten times larger costs roughly 1% more than mid.

Related: amm, price-impact, liquidity-pool, concentrated-liquidity

See it drawn

Original diagrams for the ideas on this page. Illustrative, not real market data.

Bid-ask spread in an order bookSell orders stacked above buy orders with a gap between the best of each.SELLERS (asks)50.0690050.051,40050.0460050.011,10050.002,30049.99800spread = 0.03BUYERS (bids)
The bid-ask spread. Buy orders sit below, sell orders above, and the gap between the best bid (50.01) and best ask (50.04) is the spread you pay to cross. Bar length shows the size resting at each price.

Educational only, not advice. Spotted an error? Post in Site Feedback.