DeFi and Market Structure · Crypto Trading Guide

An automated market maker prices swaps from a pool’s state. Learn why your trade changes the price and why a quoted output can move before execution.

Understand the pool

An automated market maker uses a rule to quote exchanges against pooled assets. A simple constant product model uses x × y = k, where x and y are reserves. This is a teaching model associated with designs such as Uniswap v2. Other pool types and concentrated liquidity use different details, so do not apply one formula indiscriminately.

Calculate a swap without fees

Assume a fictional pool holds 100 units of token A and 10,000 units of token B. The product is 1,000,000. Adding 1,000 B raises the B reserve to 11,000, so the A reserve becomes approximately 90.9091. The trader receives about 9.0909 A. Average cost is 110 B per A, above the initial marginal ratio of 100. The trade itself moves along the pricing curve.

Separate impact and tolerance

Price impact is the effect of trade size on the pool quote. Slippage tolerance limits how much execution may differ from a reference quote under the application’s rules. A high tolerance does not improve the price. It permits a worse outcome. Fees, routing, token transfer behaviour and network charges make actual calculations more complex than the simplified example.

Inspect the transaction before signing

Check the correct token contract, network, route, allowance, minimum output and deadline. A quoted output can change before inclusion. A failed swap may still cost network fees. Compare total received value with the cost of the transaction rather than selecting a route solely because its displayed exchange rate is best. Use a small simulation or test where appropriate, but remember that a successful test does not prove a contract is safe for larger amounts.

Try it yourself

In the same pool without fees, adding 100 B makes the B reserve 10,100. Approximately how much A is received?

Show the worked answer

The new A reserve is 1,000,000 ÷ 10,100 = 99.0099, so output is about 0.9901 A.

Further reading

Educational material. Examples and rates are hypothetical, not trade recommendations. Product terms, eligibility and risks vary by venue and jurisdiction.

Continue learning