AMM • DEX • Liquidity Pools • DeFi

Automatic Market Maker

An Automatic Market Maker is the smart contract mechanism that allows decentralized exchanges to price and swap tokens using liquidity pools instead of traditional order books.

What Is an Automatic Market Maker?

An Automatic Market Maker, or AMM, is one of the key components of decentralized exchanges. Traditional exchanges and many centralized digital exchanges rely on order books to match buyers and sellers. In contrast, many DEXs use AMM algorithms that allow automated trading through a mathematical pricing formula.

In practice, an AMM is a smart contract system embedded in a liquidity pool. It holds token reserves, calculates prices, executes swaps and updates pool balances according to programmed rules.

Simple idea: an AMM lets users trade with a smart contract liquidity pool instead of waiting for another trader to take the opposite side.
A

Automated

Prices are calculated by code instead of manual market makers.

L

Liquidity Pool

Trades happen against pooled token reserves.

S

Smart Contract

The swap logic runs on-chain according to protocol rules.

Order Book Exchange vs AMM-Based DEX

A traditional order book exchange records buy and sell orders. A trade happens when a buyer and seller agree on a price. In an AMM, the user trades with a liquidity pool, and the price changes automatically as pool balances change.

Feature Traditional Order Book AMM-Based DEX
Pricing Based on buy and sell orders placed by traders. Based on a mathematical formula and pool reserves.
Counterparty Another buyer or seller is needed. The trader swaps against a liquidity pool.
Liquidity Provided by market makers and order book depth. Provided by liquidity providers who deposit tokens.
Execution Managed by exchange infrastructure. Executed by smart contracts on-chain or through DeFi infrastructure.

On mobile, swipe the table horizontally if needed.

What Is a Liquidity Pool?

A liquidity pool is a smart contract that holds reserves of two or more tokens. Users called liquidity providers deposit assets into the pool. Traders then swap tokens through the pool.

In many AMMs, liquidity providers receive pool tokens or LP tokens that represent their share of the pool. They may earn part of trading fees, but they also take risks such as impermanent loss.

Liquidity providers deposit tokens
Pool holds token reserves
Traders swap against the pool
Fees and risks are shared by liquidity providers

The Constant Product Formula: x*y=k

Different DeFi protocols use different AMM formulas. Uniswap popularized the constant product formula:

Uniswap-Style AMM Formula
x × y = k

x = amount of token X in the pool
y = amount of token Y in the pool
k = constant product

The formula means the product of the two token balances should remain constant before fees and other protocol details. When one token amount decreases, the other token amount increases along a curve. This is why larger trades move the price more than smaller trades.

In a constant product AMM, price is determined by the ratio of assets inside the pool.

ETH/USDT Pool Example

The original article used an ETH/USDT example. Suppose a pool contains 10,000 ETH and 15,000,000 USDT. If ETH is valued at 1,500 USDT, both sides of the pool have equal value.

Initial Pool
x = 10,000 ETH
y = 15,000,000 USDT

k = 10,000 × 15,000,000
k = 150,000,000,000

If the amount of ETH in the pool decreases to 8,000 ETH, the amount of USDT required to maintain the constant product is:

After ETH Reserve Decreases
y = 150,000,000,000 ÷ 8,000
y = 18,750,000 USDT

Before

10,000 ETH and 15,000,000 USDT.

After

8,000 ETH and 18,750,000 USDT.

Meaning

ETH becomes scarcer in the pool, so its price rises relative to USDT.

Important

Real AMMs also include fees, rounding and protocol-specific details.

Price Impact and Slippage

AMM prices change as trades change pool balances. A small trade against a deep pool usually has low price impact. A large trade against a shallow pool can move the price significantly.

P

Price Impact

The change in pool price caused by your own trade size.

S

Slippage

The difference between expected price and final execution price.

D

Depth

Deeper liquidity pools generally reduce price impact for traders.

Practical note: before swapping, always check expected output, slippage tolerance, pool liquidity, network fees and token legitimacy.

AMM and DEX Examples

Uniswap was one of the first widely adopted decentralized AMMs that allowed anyone to create a liquidity pool and provide liquidity. Other protocols use different designs, governance models and liquidity approaches.

Uniswap

Popularized permissionless AMM pools and the constant product formula.

KyberSwap

Routes trades through liquidity sources and has used market-maker and aggregator-style mechanisms.

Balancer

Supports pools with multiple tokens and custom weights, not only 50:50 pools.

Curve

Specialized for stable assets and low-slippage swaps between similar-value tokens.

SushiSwap

Community-driven DEX ecosystem that began as an AMM fork and expanded over time.

Other AMMs

Many chains now have AMMs with different fee tiers, routing methods and liquidity models.

Risks of Using AMMs

AMMs are important DeFi tools, but users and liquidity providers must understand their risks.

Impermanent Loss

Liquidity providers may lose value compared with simply holding the assets.

Slippage

Large trades or low liquidity can result in worse execution prices.

Smart Contract Risk

Bugs, exploits or bad contract design can lead to loss of funds.

Token Risk

Fake, illiquid or malicious tokens can create serious losses.

MEV Risk

Some trades may be affected by front-running, sandwich attacks or other MEV behavior.

Protocol Risk

Protocol changes, governance decisions or liquidity migration can affect users.

Educational note: This article explains AMM mechanics. It is not financial, investment or trading advice.

Summary

  • An AMM is a smart contract mechanism for automated token trading.
  • AMMs use liquidity pools instead of traditional order books.
  • Uniswap popularized the constant product formula x*y=k.
  • Changing token reserves changes token prices inside the pool.
  • Liquidity providers may earn fees but face risks such as impermanent loss.
  • Traders should understand slippage, price impact, pool depth and token risks.

Continue Learning