Trace how a swap changes reserves
By the end, explain the diagram in your own words, solve the case and justify the correction.
Prerequisites : Token approvals and wallet security
Level 2 · Intermediate →Reading path · 27 / 35 · Intermediate
A liquidity pool holds assets under contract rules so users can exchange or borrow them.
The essentials
A liquidity pool holds assets under contract rules so users can exchange or borrow them. A lending pool and an automated market maker are different mechanisms. In a simple constant-product AMM, reserve quantities x and y satisfy a relationship approximated by x × y = k before fees.
How it works
Trades change reserve ratios and therefore the marginal price. A large trade relative to the pool moves that price substantially. Slippage tolerance limits the execution deterioration a user accepts; it does not promise that the displayed quote will be achieved. Arbitrage links pool prices to external markets through trading incentives.
What to watch
Liquidity providers may receive fees but face inventory changes, contract risk and token risk. Concentrated liquidity adds price-range management and can stop earning fees when out of range. High volume does not guarantee profitable liquidity provision. Compare realised fees with the value of holding the original assets and any management costs.
Understand the details
An automated market maker quotes trades using a reserve relationship rather than matching every order with another user’s limit order. In a simple constant-product model, x × y stays constant before fees as one reserve grows and the other shrinks. The marginal price changes during a trade, so the average execution price differs from the initial marginal price.
Boundaries and common mistakes
Price impact comes from the trade’s size relative to liquidity; slippage also reflects changes between quote and execution. A minimum-output condition can bound an accepted result but may cause a revert. Concentrated-liquidity and stable-swap designs use different mechanics, so this example should not be applied unchanged to every pool.
The mechanism at a glance
- Initial reserves 100 / 100
- Add 10 X
- New reserves 110 / 90.91
- Receive about 9.09 Y
Apply the lesson to a case
A fee-free pool holds 100 X and 100 Y. Add 10 X in a swap. Keep the product at 10,000 and calculate the new Y reserve and the amount of Y received. Compare with a naive expectation of 10 Y.
The new Y reserve is 10,000/110 ≈ 90.91, leaving about 9.09 for the trader. The price moves along the curve during execution. Real fees would change the calculation further. Repeat with 1 X to see how relative trade size changes price impact.
Terms in this lesson
- Liquidity pool
- Assets held under shared contract rules to support activities such as exchange or lending.
Prepare a correction note
Describe the passage and the proposed correction. This creates a local note for you to share; it sends nothing. Do not include personal or confidential information.