Skip to content
LIVE Jun 30, 2026 F&G 15 Predictions Markets Newsletter
EN ESsoon FRsoon DEsoon PTsoon
Markets
NEWS
DeFi

How Automated Market Makers Price Every DeFi Trade

Automated market makers replaced order books with a simple formula. Understanding x×y=k tells you why slippage happens and where the money in a liquidity pool actually goes.

Key takeaways

  • On a traditional exchange, buyers place bids and sellers post asks.
  • The Uniswap protocol, usd/" class="twl-coinlink">first deployed on Ethereum in late 2018, replaced the order book with a liquidity pool governed by one equation: x × y = k, where x is the quantity of…
  • Uniswap V3, launched in 2021, allowed providers to concentrate their capital within a chosen price range rather than spreading it across all prices from zero to infinity.
  • Three factors determine how much slippage you will see on a given trade.
  • The constant-product formula works well for uncorrelated assets but is inefficient for assets that are meant to trade near parity.
Not financial advice. This article discusses prices and model-based scenarios for information and education only. Crypto is volatile and you can lose money. Do your own research and read our disclaimer.

Automated market makers replaced order books with a simple formula. Understanding x×y=k tells you why slippage happens and where the money in a liquidity pool actually goes.

What an order book actually does

On a traditional exchange, buyers place bids and sellers post asks. A trade executes when the two sides agree on a price. This works well when there are thousands of active participants quoting tight spreads. In 2018, no crypto exchange could sustain that liquidity around the clock for the hundreds of tokens being launched every week. The bid-ask spread widened, takers faced huge slippage on anything beyond a handful of major pairs, and new tokens had nowhere liquid to trade at all.

The order-book model depends on professional market makers who are willing to hold inventory risk. In traditional finance, a handful of firms do this job. On-chain, nobody is reliably willing to sit at the keyboard quoting every small token twenty-four hours a day.

The constant-product formula

The Uniswap protocol, usd/" class="twl-coinlink">first deployed on Ethereum in late 2018, replaced the order book with a liquidity pool governed by one equation: x × y = k, where x is the quantity of one token in the pool, y is the quantity of the other, and k is a constant that never changes (except when liquidity is added or removed). Every trade shifts x and y such that their product remains k. The price of the asset you are buying is determined entirely by this ratio, not by any human quoting a spread.

Suppose a pool holds 10 ETH and 20,000 USDC. k equals 200,000. A buyer wants 1 ETH. After the trade, the pool must hold 11 ETH and enough USDC that 11 × y = 200,000, so y = 18,182 USDC. The buyer paid 20,000 − 18,182 = 1,818 USDC for 1 ETH, implying a price of $1,818. The larger the purchase relative to pool size, the more the ratio shifts and the worse the effective price becomes. This gap between the quoted price at the start of the transaction and the price you actually receive is called slippage.

Slippage is not a bug. It is the AMM’s mechanism for restoring a fair price signal. When the pool price drifts away from the broader market price, arbitrageurs step in, buying the cheap asset and selling the expensive one until the pool ratio reflects the external price. This is how decentralised exchanges stay roughly in sync with learn/”>learn section covers the maths of impermanent loss in plain numbers.

Concentrated liquidity (Uniswap V3)

Uniswap V3, launched in 2021, allowed providers to concentrate their capital within a chosen price range rather than spreading it across all prices from zero to infinity. A provider who believes ETH will trade between $1,500 and $2,500 can put all their capital to work within that band, earning fees as if they had deposited much more in a V2 pool. Outside the chosen range their capital earns nothing but is also not exposed to impermanent loss. The trade-off is active management: a position that falls out of range earns no fees and must be adjusted.

Concentrated liquidity has since been copied by most competing AMM protocols and now accounts for the majority of volume on the major Ethereum-based DEXs. It also introduced the concept of on-chain limit orders: a position placed entirely above the current price is effectively a sell order that executes as the market rises through the range.

Where slippage comes from in practice

Three factors determine how much slippage you will see on a given trade. First, pool depth: a pool with $10 million in liquidity will move its price far less on a $10,000 trade than a pool with $50,000. Second, the fee tier: a 1% fee pool implies a larger spread between buy and sell. Third, whether any competing transaction executes between your submission and your confirmation — a form of value extraction known as MEV, or maximal extractable value, where bots insert their own trades ahead of yours to capture the price move your trade will cause.

Most DEX interfaces let you set a maximum slippage tolerance. If the actual slippage would exceed your limit, the transaction reverts rather than executing at the worse price. For large trades in thin pools, setting this too low means frequent reversions; setting it too high means bots can exploit the gap.

AMMs beyond the basic formula

The constant-product formula works well for uncorrelated assets but is inefficient for assets that are meant to trade near parity. Stablecoins pegged to the same currency, or liquid staking tokens priced near 1 ETH, do not need a curve that anticipates wild divergence. Curve Finance introduced a hybrid formula that is nearly flat near the peg and steepens sharply away from it, allowing far larger stablecoin trades with minimal slippage. Balancer generalized the model further to pools with more than two assets and unequal weights. Every DeFi protocol on the methodology/”>methodology section.

Frequently asked questions

What is an AMM?

An automated market maker is a smart contract that holds two (or more) assets in a pool and sets the price algorithmically, usually by keeping the product of the quantities constant. It allows instant trading without requiring a counterparty to post a matching order.

Why do I get a different price than the one shown before I confirm?

The price shown is calculated at the moment you request the quote. Between that moment and your transaction confirming on-chain, other transactions may execute, shifting the pool ratio. The difference is slippage. Setting a slippage tolerance in the interface protects against large deviations.

What is impermanent loss?

When you provide liquidity to a pool and one asset moves significantly in price relative to the other, arbitrageurs rebalance the pool against you. You end up with more of the underperforming asset and less of the outperforming one compared to simply holding both. This underperformance relative to holding is impermanent loss. It becomes a real, permanent loss when you withdraw at an unfavourable ratio.

Is providing liquidity profitable?

It depends on the fee rate, pool volume, and the degree of price divergence between the two assets. High-volume, low-volatility pairs (such as two stablecoins) tend to be more predictably profitable. High-volatility pairs carry a greater risk that impermanent loss exceeds the fees earned. There is no guaranteed return.

What is MEV?

Maximal extractable value (MEV) is profit that block producers or specialised bots can extract by reordering, inserting or censoring transactions within a block. In the context of DEX trading, it most commonly appears as “sandwich attacks,” where a bot places one trade just before yours and another just after, profiting from the price movement your trade causes.

Sources

This article is for information and education only. It does not constitute financial advice, and nothing here is a recommendation to provide liquidity or trade any asset. DeFi protocols carry smart-contract, impermanent-loss and regulatory risks. Always do your own research.

General information only — not investment advice. TheWeal is an independent crypto data and education publisher. Nothing here is a recommendation to buy or sell any asset. Crypto carries risk, including the possible loss of principal. Read our disclaimer and editorial guidelines.
Written by Marcus Tan

CONFIRM WITH AUTHOR — Marcus Tan is TheWeal's DeFi Editor, covering decentralised exchanges, lending, stablecoins, yield and the on-chain plumbing most readers never see. He has followed decentralised finance since 2018, through the first yield-farming wave, the stablecoin de-pegs, the bridge exploits and the slow institutional rediscovery of on-chain credit. Working from Hong Kong, Marcus reads contracts and dashboards as fluently as he reads price, and he treats total-value-locked, real yield and protocol revenue with the scepticism they deserve. His coverage is built on a habit of asking where a yield actually comes from — and saying so plainly when the answer is 'from the next person in'. Marcus believes the best DeFi journalism is a translation job: taking a mechanism that is genuinely complex and making it legible without making it sound safer than it is. He is candid about smart-contract and counterparty risk, and he expects TheWeal's explainers to leave readers more cautious and better informed, not more excitable.

More from Marcus Tan →