Lesson 0134 min
RESERVES · CURVE

Without an Order Book, the Pool Is the Counterparty

Use one swap to see how reserves move, where impact comes from, and why LPs provide depth.

ObjectivesAfter this lesson, you should be able to:
  • Explain an AMM quote with reserves and a constant product
  • Observe how size, fees, and impact interact
  • Explain why LPs earn fees while carrying inventory risk
COURSE POSITIONStep 1 of 4
  1. PREVIOUSCourse introduction
  2. CURRENTWithout an Order Book, the Pool Is the Counterparty

    Use one swap to see how reserves move, where impact comes from, and why LPs provide depth.

  3. NEXTWhy Does the Quote Get Worse?
BEFORE YOU READ

Think about these questions first.

Choose an answer before opening the explanation. You can add anything unexpected to your review list.

Q01With no posted seller, why can a pool keep trading with me?
SHORT ANSWER

LPs pre-deposit both assets and a curve turns inventory into continuous quotes. Liquidity is not infinite: as you remove one asset, each next unit becomes more expensive.

Compared with your prediction:

An order book needs another person to stand on the other side. An AMM rewrites that problem: put two assets in a public pool, then let the reserve ratio quote the next swap.

Forget “finding a counterparty”

An AMM has no best bid, no best ask, and no Alice who must be online. The pool owns both reserves and anyone can swap against the same rule. In this lab they are credits and TOKEN: 120,000 credits and 1,000 TOKEN imply a spot price near 120 credits per TOKEN.

SIMULATION ACTIVE0.30% fee
POOL 001 · CONSTANT PRODUCT

Credits / TOKEN

The pool does not wait for another order. Its reserve ratio produces the next quote.

Spot price120.00credits / TOKEN
Credits reserve120,000X
TOKEN reserve1,000Y
Fees collected0in pool
k growth0.00%vs. initial pool
Reserves in motionx · y = 120,000,000
Credits
120,000
TOKEN
1,000

Swap fees stay in the pool and slowly grow k; adding or removing liquidity also changes the reserve scale.

Coach

Start with the two reserves, then drag the swap size. Small trades stay near the spot price; large trades travel farther along the curve.

Pool events1 EVENTS
  1. 01

    Pool created: 120,000 credits + 1,000 TOKEN,initial price 120 credits / TOKEN。

ACTION HISTORYExperiment timeline
1 state snapshots

Use the slider to return to an earlier step. Continuing from there replaces the later history with a new sequence.

Initial state
View experiment records →

x · y = k is a state constraint

For a constant-product pool, the product of the reserves describes the current state:

x = 120,000 credits
y = 1,000 TOKEN
k = x · y = 120,000,000

When you buy TOKEN with credits, the pool receives X and sends out Y. The new reserves must still satisfy the constraint, so output cannot simply use the old price. The more you buy, the scarcer TOKEN becomes and the next unit costs more.

Why fees make k grow

With a 0.30% fee, a 12,000-credit input leaves 36 credits in the pool and only 11,964 credits enter the curve calculation. The trader receives less output, while the fee remains in reserves and slowly grows x · y for LPs.

Expand: how this step works
fee = amountIn × 30 / 10,000
usableIn = amountIn - fee
amountOut = reserveOut × usableIn / (reserveIn + usableIn)

reserveIn  += amountIn
reserveOut -= amountOut

The simulator uses integer units and floors every division. Production contracts also need rounding policies, minimum output, extreme-reserve checks, and reentrancy protection.

KNOWLEDGE CHECK

Why does a large swap usually execute worse than the spot price?

Read an AMM as four questions

After this experiment, ask: how much X and Y are in the pool, how far average execution moved from spot, who receives the fee, and what an LP would withdraw after the reserves move. The formula is a compressed rule; the mechanism is the asset flow between pool, trader, and LP.

LESSON RECAPComplete the exercise and knowledge check first