Skip to content
Liquidity poolsDeFi

Liquidity pools: the x · y = k formula

How an AMM sets prices without an order book. Simulate a swap and watch the price impact.

By SITA · Published on · 2 sources

Key points

  • A liquidity pool is a pair of token reserves held by a smart contract.
  • In a constant-product AMM, the product of reserves x · y stays equal to k: the price follows from the reserve ratio.
  • The larger a swap relative to the pool size, the higher the price impact (slippage).

SITA · Infographics

Liquidity pools: the x · y = k formula

Token A reserve (x)Token B reserve (y)x · y = kABSWAP AMOUNT (TOKEN A)150 ARECEIVED (TOKEN B)130.09 BPRICE BEFORE1 B/APRICE AFTER0.7567 B/APRICE IMPACT−13.27 %0.3% fee · k = 1,000,000
Sources: Uniswap v2 — How Uniswap works · Uniswap v2 Core whitepaper (2020)sita.re · 22 November 2026

The larger the swap relative to the pool, the stronger the price impact.

Data

Educational simulation of a constant-product pool (Uniswap v2 model, 0.3% fee). Fictional reserves.