Skip to content
Basis Desk
DeFi · 7 min read Last reviewed September 29, 2026

How Decentralized Exchanges Work: AMMs and Liquidity Pools

Decentralized exchanges replace traditional order books with automated market makers and liquidity pools. Understanding the constant product formula, LP tokens, and impermanent loss is essential for navigating decentralized finance.

Neutral

Key points

  • Automated Market Makers (AMMs) replace traditional order books with smart contracts and mathematical formulas to execute trades.
  • Liquidity pools aggregate capital from users, who receive LP tokens representing their share of the pool and accrued trading fees.
  • The constant product formula (x * y = k) dictates asset pricing, causing the price of an asset to increase as its supply in the pool decreases.
  • Impermanent loss occurs when asset prices diverge from their deposit ratio, resulting in underperformance compared to holding the assets outside the pool.

Decentralized exchanges facilitate the trading of digital assets without intermediaries by relying on self-executing smart contracts. Instead of matching buyers and sellers through traditional order books, these platforms use automated market makers and crowdsourced liquidity pools to execute trades instantly.

The Shift from Order Books to AMMs

In traditional finance and centralized cryptocurrency platforms, trading relies on an order book model. Buyers submit bids indicating the maximum price they are willing to pay, and sellers submit asks indicating the minimum price they will accept. A centralized matching engine pairs these orders. You can read more about this architecture in our guide on how crypto exchanges work.

Replicating this model on a base-layer blockchain like Ethereum presents significant technical hurdles. Every action on a blockchain—including placing, modifying, or canceling an order—requires a transaction fee (gas) and is subject to the network's block time latency. In a volatile market, market makers must constantly update their orders, which becomes prohibitively expensive and slow on a decentralized ledger.

To solve this, decentralized finance (DeFi) developers introduced Automated Market Makers (AMMs). An AMM is a smart contract that holds reserves of two or more assets and allows users to trade against those reserves at prices determined by a hardcoded mathematical formula. There is no matching engine and no counterparty waiting on the other side of the trade. The smart contract itself acts as the counterparty, providing continuous liquidity regardless of market conditions.

Liquidity Pools and LP Tokens

For an AMM to function, it needs capital. This capital is aggregated into liquidity pools, which are smart contracts containing locked reserves of tokens. The users who deposit their assets into these pools are known as liquidity providers (LPs).

In a standard AMM model, a liquidity provider must deposit an equal value of two different assets to fund a specific trading pair. For example, to provide liquidity to an $ETH and $USDC pool, a user must deposit an equivalent dollar amount of both tokens based on the current market exchange rate.

In exchange for their deposits, the protocol issues LP tokens to the provider. These tokens act as a cryptographic receipt. They represent the provider's proportional share of the total liquidity pool. When traders swap assets through the pool, they pay a small fee (often a fraction of a percent). These fees are retained within the pool, increasing the total value of the reserves. Because the LP tokens represent a percentage claim on the pool, their underlying value grows as fees accumulate. When a provider wishes to exit, they burn their LP tokens to withdraw their original deposit plus their share of the accrued trading fees.

The Constant Product Formula

The pricing mechanism at the heart of most foundational AMMs is the constant product formula, expressed algebraically as x * y = k.

In this equation, x represents the reserve balance of the first token, y represents the reserve balance of the second token, and k is a constant value that must remain unchanged after a trade is executed (excluding the addition of trading fees).

Because k must remain constant, any increase in the supply of token x must be offset by a decrease in the supply of token y. This inverse relationship creates a hyperbolic price curve. As the supply of one token in the pool decreases, its price relative to the other token increases exponentially.

To illustrate this, consider a hypothetical liquidity pool containing 10 $ETH and 20,000 $USDC.

Assuming these are the only assets in the pool, we first calculate the constant k: 10 (ETH) * 20,000 (USDC) = 200,000 (k).

The implied price of 1 $ETH in this pool is 2,000 $USDC (20,000 / 10).

Now, assume a trader wants to buy 1 $ETH from this pool. The trader is removing 1 $ETH, meaning the new $ETH balance (x) will be 9.

To find the new $USDC balance (y) required to keep k constant, we divide k by the new $ETH balance: 200,000 / 9 = 22,222.22 $USDC.

The pool now requires 22,222.22 $USDC to maintain the constant product. Since the pool previously held 20,000 $USDC, the trader must deposit the difference: 22,222.22 - 20,000 = 2,222.22 $USDC.

The trader paid 2,222.22 $USDC for 1 $ETH. This is higher than the initial implied price of 2,000 $USDC. The difference between the expected price and the executed price is known as slippage. The constant product formula naturally enforces slippage: larger trades relative to the total size of the pool incur higher slippage, protecting the pool from being entirely drained.

Price Discovery and Arbitrage

AMMs do not have internal price feeds or order books to determine the "true" market value of an asset. The price of an asset within a liquidity pool is determined solely by the ratio of the two assets in that specific pool.

If the price of $ETH rises on external centralized exchanges, the price of $ETH inside the AMM pool remains unchanged until a trade occurs. This creates a price discrepancy.

Arbitrageurs resolve this discrepancy. If $ETH is trading at 2,100 $USDC on a centralized exchange but is still priced at 2,000 $USDC in the AMM pool, arbitrageurs will buy the cheaper $ETH from the AMM and sell it on the centralized exchange for a profit. As they buy $ETH from the AMM, they add $USDC and remove $ETH, altering the ratio. This process continues until the price inside the AMM matches the external market price. AMMs rely entirely on this profit-driven arbitrage to maintain accurate pricing.

The Cost of Providing Liquidity: Impermanent Loss

While liquidity providers earn trading fees, they also face a unique risk known as impermanent loss. This phenomenon occurs when the price of the deposited assets changes compared to when they were deposited.

Impermanent loss is defined as the difference in value between holding assets in an AMM liquidity pool versus simply holding the same assets in a standard cryptocurrency wallet.

When the price of one asset in a pool surges on external markets, arbitrageurs buy that asset from the pool, draining its supply and replacing it with the other asset. Consequently, the liquidity provider ends up holding less of the appreciating asset and more of the depreciating (or stable) asset. If the provider withdraws their liquidity at this point, the total dollar value of their assets will be lower than if they had never deposited them into the pool, even after accounting for some accrued fees.

The loss is termed "impermanent" because if the asset prices return to their exact original ratio at the time of deposit, the loss disappears. However, if the provider withdraws their assets while the prices are divergent, the loss becomes permanent. For highly volatile trading pairs, impermanent loss can frequently outpace the yield generated from trading fees.

The Evolution to Concentrated Liquidity

The standard constant product formula spreads liquidity evenly across an infinite price curve, from zero to infinity. This means the vast majority of capital in a pool is never utilized, as assets typically trade within a specific, narrower price range. This results in poor capital efficiency.

To address this, newer AMM models introduced concentrated liquidity. This architecture allows liquidity providers to allocate their capital within custom price ranges (ticks).

For example, in a stablecoin pool trading $USDC against another dollar-pegged asset, an LP can choose to provide liquidity only between the prices of $0.99 and $1.01. Because the capital is concentrated where the trading actually occurs, the LP captures a much higher share of the trading fees relative to their deposit size.

However, concentrated liquidity requires active management. If the market price moves outside the LP's chosen price range, their liquidity becomes inactive. It stops earning fees, and the LP's position is converted entirely into the less valuable asset. This increases the risk of impermanent loss and shifts the role of a liquidity provider from a passive depositor to an active market participant.

Common Misconceptions

  • DEXs have no fees: While DEXs eliminate centralized intermediaries, they are not free to use. Traders must pay network gas fees to execute the smart contract on the blockchain, as well as a swap fee that is distributed to the liquidity providers.
  • Impermanent loss means losing the initial dollar investment: Impermanent loss does not necessarily mean the fiat value of the portfolio has decreased. It strictly measures the opportunity cost—the underperformance of the liquidity pool position compared to a simple buy-and-hold strategy of the same initial assets.
  • Providing liquidity is a passive income strategy: While early AMM models allowed for passive depositing, the introduction of concentrated liquidity and the constant threat of impermanent loss mean that profitable liquidity provision requires active monitoring, rebalancing, and sophisticated risk management.

How This Connects to the Market

Decentralized exchanges and AMMs have fundamentally altered crypto market structure. By removing the need for centralized market makers, AMMs allow for permissionless listing. Anyone can create a market for a new token simply by deploying a smart contract and funding a liquidity pool. This has made DEXs the primary venue for price discovery of long-tail assets and early-stage tokens before they reach the volume required for centralized exchange listings. You can explore the differences in custody and execution in our centralized vs decentralized exchanges guide.

The growth of AMMs has also attracted significant regulatory attention. Authorities such as the US Securities and Exchange Commission (SEC) and the European Securities and Markets Authority (ESMA) are examining how traditional financial regulations apply to DeFi. A key area of regulatory focus is the distinction between the immutable smart contracts residing on the blockchain and the entities or foundations that host the front-end web interfaces used to access them. Regulators are increasingly scrutinizing whether the developers or governance token holders of these protocols act as unregistered brokers or exchanges under existing securities laws.

Questions this story raises

What is an Automated Market Maker (AMM)?
An AMM is a smart contract on a decentralized exchange that uses a mathematical formula to price assets and execute trades automatically, without needing a traditional order book or a centralized matching engine.
How do decentralized exchanges determine asset prices?
DEXs determine prices based on the ratio of assets within a specific liquidity pool. They rely on independent arbitrageurs to buy and sell assets when the internal pool price diverges from the external market price.
What are LP tokens?
LP (Liquidity Provider) tokens are cryptographic receipts issued to users who deposit assets into a liquidity pool. They represent the user's proportional claim on the pool's assets and the trading fees it generates.
What is concentrated liquidity?
Concentrated liquidity is an advanced AMM feature that allows liquidity providers to allocate their capital within a specific price range, improving capital efficiency but requiring active management to ensure the position remains in range.

References

  1. [1] Uniswap v3 Core Whitepaper — Uniswap
  2. [2] Statement on Decentralized Finance — US Securities and Exchange Commission
  3. [3] Uniswap v2 Core Whitepaper — Uniswap

Evergreen explainer written by Basis Desk's system and checked by an independent model pass for factual errors and advice language. Figures, fees and rules change — the references above are where to verify current specifics. Market figures marked "at the time of writing" come from live exchange data. Report an error: hello@basisdesk.news.

Not financial advice. Basis Desk publishes information, not recommendations. Crypto assets are volatile and you can lose what you invest.