CenturionDEX
Launch App

How are token prices determined?

Last modified:

Every liquidity pool enforces a single invariant — the constant product — that fully determines prices from on-chain reserves alone:

x · y = k

When a trader sells one token into the pool and withdraws the other, the contract adjusts both balances so that their product remains equal to k. That adjustment is the price.

The Constant Product Formula

The spot price of token0 in terms of token1 at any moment is the ratio of the reserves:

price_token0 = y / x

Because x * y = k, the price is fully determined by the reserves and the invariant.

Deriving the swap output

When you sell Δx of token0 into a pool with reserves (x, y), the pool must maintain k:

(x + Δx) * (y - Δy) = k = x * y

Solving for Δy (the amount of token1 you receive):

Δy = y * Δx / (x + Δx)

This is always less than Δx * (y / x) — the "ideal" output at the spot price — because your own trade moves the price against you. This difference is the price impact.

Worked example

A pool holds 50 CTN and 100,000 USDC, so k = 50 * 100,000 = 5,000,000.

You sellYou receiveEffective priceSpot wasPrice impact
1 CTN100,000 × 1 / (50 + 1) = 1,960.78 USDC1,960.782,0001.96%
5 CTN100,000 × 5 / (50 + 5) = 9,090.91 USDC1,818.182,0009.09%
10 CTN100,000 × 10 / (50 + 10) = 16,666.67 USDC1,666.672,00016.67%
25 CTN100,000 × 25 / (50 + 25) = 33,333.33 USDC1,333.332,00033.33%

Notice how price impact accelerates as the trade size grows relative to the pool reserves. This is the fundamental tradeoff of AMMs: larger trades get progressively worse prices.

After the trade

After selling 5 CTN into the pool above:

New reserves: x = 55 CTN, y = 90,909.09 USDC
New k = 55 * 90,909.09 = 5,000,000  (unchanged)
New spot price = 90,909.09 / 55 = 1,652.89 USDC/CTN

The spot price dropped from 2,000 to 1,652.89 — the pool now offers less USDC per CTN because the CTN supply increased and the USDC supply decreased.

Adding Liquidity and k

When a liquidity provider deposits tokens, k increases. More liquidity means lower price impact for the same trade size:

Pool A: 50 CTN / 100,000 USDC (k = 5M)     → 5 CTN trade → 9.09% impact
Pool B: 500 CTN / 1,000,000 USDC (k = 500M) → 5 CTN trade → 0.99% impact

Deep liquidity therefore translates directly into better execution for traders.

From v2 to v3

In v2 every pool distributes liquidity across the full curve from price 0 to infinity. v3 lets providers concentrate capital within a chosen range, creating virtual reserves that behave as though the pool were far deeper. The mathematics change accordingly — see Concentrated Liquidity for the virtual-reserves formulas and Tick Math for on-chain price encoding.