Automated market makers: work out what a swap returns

An automated market maker uses a pricing rule and available liquidity to exchange assets. It does not promise the latest market price for every token in your order. Learn why a larger swap changes its own price and how to check the final quote.

Your task: calculate one simple swap, distinguish price impact from slippage, and check the minimum amount received.

Swap arrows and a trading screen illustrating automated market-maker pricing

A swap changes the pool you trade against

Before: 1,000 A + 1,000 B

In this imaginary fee-free constant-product pool, x × y = 1,000,000. The initial marginal price is 1 B per A. A and B are example tokens, not recommendations.

Trade: add 100 A

The A reserve rises to 1,100. To preserve the product, the B reserve becomes 1,000,000 ÷ 1,100 = 909.09. The trader receives the difference: about 90.91 B.

After: a different price

The average execution is 0.9091 B per A. The new marginal price is about 0.8264 B per A. Neither is the original 1-to-1 quote. Larger trades relative to depth move the price further.

Walkthrough: turn the model into a quote check

Identify the route

Check network, token contracts and the pools used by the router. One trade may cross several pools or split between routes. Not every DEX uses an AMM, and not every AMM uses this formula.

Read the actual costs

Compare the input, estimated output, pool fees, price impact and network cost. With a 0.3% input fee in our example, only 99.7 A enters the pricing calculation, returning about 90.66 B. Actual fees depend on the pool and version.

Set a meaningful boundary

Read minimum received and the transaction deadline where available. Slippage tolerance allows execution to differ from the quote; it does not remove the impact already in it. Check approval permissions separately and reject unexpected wallet requests.

Worked example: output is the change in reserves

1,000 − (1,000,000 ÷ 1,100)≈90.91 B

For input Δx, the fee-free output is y − k ÷ (x + Δx). The 90.91 B result is about 9.09% below the 100 B a constant 1-to-1 price would suggest. This is price impact from the trade itself. Slippage is the difference between the quoted outcome and actual execution. k is a reserve-product constraint, not the pool’s dollar value; deposits, withdrawals and retained fees can change it.

Three shortcuts that give the wrong answer

Using total TVL as depth

Concentrated liquidity operates in price ranges: a large TVL may include inactive positions. Weighted and stable-asset pools use different curves. Use the current executable route quote, not this simplified formula for every pool.

Raising tolerance to fix a poor price

A wider tolerance permits a worse result; it does not improve liquidity. Compare another route or a smaller amount, including all fees. Splitting a trade through an unchanged pool does not magically eliminate its cumulative impact.

Assuming arbitrage guarantees fairness

Traders can move pool prices toward other markets by seeking price differences. That is an incentive, not a guarantee. Thin liquidity, fees, latency and transaction ordering can leave a quote unattractive or expose it to MEV.

Try it: increase the order size

Reset the fee-free pool to 1,000 A and 1,000 B. Swap 250 A. How much B comes out, what is the average B per A, and what minimum would a 1% tolerance give on that quote?

Reveal the reasoning

New B reserve: 1,000,000 ÷ 1,250 = 800. Output: 200 B. Average: 200 ÷ 250 = 0.8 B per A. A 1% tolerance gives 198 B minimum. The trade’s 20% shortfall against the initial spot price already exists before that tolerance is applied.

Cryptocurrency wallet and keys illustrating secure access and recovery

A little groundwork goes a long way

Before your next purchase or transfer, understand who controls access, where your crypto is going and what the trade will actually cost.

Protect access to your crypto

An exchange account and a self-custody wallet need different safeguards. Protect exchange logins with a unique password and strong two-factor authentication. For self-custody, your recovery backup is what lets you restore access.

Keep recovery words offline and private. A support agent or website asking for them is a reason to stop.

See a recovery example

Your phone breaks. An exchange may help you recover your account after identity checks. A self-custody wallet cannot reset your recovery phrase. Check your wallet’s official backup instructions before relying on it.

Choose the right transfer network

The asset, token version and network must be supported at the destination. A familiar ticker or a matching address format is not enough. Read the receiving platform’s deposit instructions before selecting a withdrawal network.

Check the address, any required memo or tag, fees and minimums. Consider a small test transfer first.

See a network example

Your destination accepts USDC on Ethereum. Selecting a cheaper network at the sending exchange does not make it an Ethereum transfer. Use a network both ends support; an ordinary withdrawal does not bridge tokens.

Understand the price you pay

Trading fees are only part of the cost. The spread, available liquidity and withdrawal charges also matter. A market order prioritizes execution; a limit order controls the price but may remain unfilled or fill only partly.

Check the order preview and the amount you will receive, then compare the full cost of your intended purchase and withdrawal.

Work through a cost example

Hypothetical example: a $200 trade with a 0.1% trading fee costs $0.20 in trading fees. A separate $5 withdrawal fee brings those charges to $5.20. Spread or slippage may add more; these are not quoted exchange rates.