May 01, 2025

What is an Automated Market Maker?

#Basics

An automated market maker (AMM) is a type of decentralized exchange that runs on smart contracts, not order books. Traditional order books rely on buyers and sellers posting competing offers, and trades only happen when prices match. AMMs skip that back-and-forth by using code and math to price trades automatically, enabling fast, 24/7 onchain markets. AMMs can process trillions in trades — no centralized intermediaries required. And any fees are paid transparently to liquidity providers and blockchain networks.

What does an AMM do?

At a glance, automated market makers (AMMs) give people a simple, secure way to trade crypto directly on the blockchain. They’re easy to access, support a huge range of tokens, and — most importantly — they just work.

For everyday users, AMMs offer several key benefits:

  • A wide range of tokens. AMMs make it easy to trade popular tokens as well as newer or more niche ones. Anyone can create a new trading pair.

  • Prices are automated, not negotiated. AMMs set pricing for assets by following a predictable formula, which ensures transparency and consistency, even during market volatility.

  • Open to anyone, anywhere. As decentralized platforms, AMMs are globally accessible and don’t require approvals for user activity.

  • Earning fees by providing liquidity. In addition to these benefits for traders, there’s another opportunity: anyone can add an equal value of two tokens to a liquidity pool and earn a share of the trading fee.

How do AMMs work?

AMMs work by replacing the traditional order book with something called a liquidity pool, which is a smart contract that holds balances of two tokens. When someone makes a trade, they interact directly with this pool. The AMM uses a mathematical formula to update prices based on how much of each token is in the pool.

The Uniswap Protocol pioneered this AMM model. As one of the first and most trusted AMMs, it set a new standard for how decentralized exchanges could work: accessible, efficient, and always on.

Let’s break down the mechanics behind AMMs and how they make onchain trading possible.

Smart contracts and liquidity pools

At the core of every AMM is a set of smart contracts. These are self-executing programs deployed to public blockchains like Ethereum, and can power trading logic with no centralized operator required.

Instead of matching individual buyers and sellers like a traditional exchange, AMMs use liquidity pools. These are smart contracts that hold reserves of two different tokens (for example ETH and USDC), allowing users to trade against the pool directly. The more liquidity in the pool, the easier it is to make large trades with minimal price impact — which is why many DEXs emphasize having deep liquidity.

Anyone can become a liquidity provider (‘LP’) by depositing equal values of both tokens into a pool. In return, LPs typically earn a share of trading fees and other potential rewards, making liquidity provision a key part of the AMM ecosystem.

The constant product formula: x * y = k

So how do AMMs determine the price of each token in a pool without an order book?

They use a simple but powerful pricing rule called the constant product formula, expressed as: x * y = k Graph (1) Here’s what that means:

x and y represent the quantities (not market values) of each token in the pool. The total value of one token in an AMM liquidity pool always matches the value of the other, keeping the pool balanced at all times.

k is a fixed value — the product of those x and y amounts — that must remain constant after each trade. Liquidity providers set the initial value of k when they create a pool by depositing sums of two tokens in equal value. From that point on, k stays constant during trades.

Every swap slightly shifts the ratio between the two tokens, which changes the price. If someone buys ETH from a USDC/ETH pool, the supply of ETH goes down and its price goes up, all according to the formula. The trade adjusts the pool’s balances so that x * y = k remains true.

This simple equation powers a dynamic and decentralized pricing mechanism. No negotiations, no third parties, just math.

Let’s illustrate this concept with an example

Starting pool: 10 ETH and 20,000 USDC. The constant product formula is 10 × 20,000 = 200,000 (k stays constant).

At this point, 1 ETH = 2,000 USDC.

A user wants to buy 1 ETH. After the trade, 9 ETH remain in the pool. To keep k = 200,000, we solve for USDC: 200,000 ÷ 9 ≈ 22,222.22 USDC. The new USDC balance is 22,222.22.

The user adds 2,222.22 USDC (22,222.22 - 20,000), making their effective price for 1 ETH: 2,222.22 USDC.

Why does the price increase? This is called slippage. A trade changes the token balances in the pool, which alters the price. Larger trades (relative to the pool size) cause more slippage. Bigger pools have more liquidity, so prices stay steadier even for bigger trades.

What happens when you make a trade

Let’s say a user wants to swap $100 worth of USDC for ETH using an AMM-powered DEX like the Uniswap Protocol.

On the frontend, they choose USDC as their input and ETH as the token they want to receive. The app shows the current market rate — calculated in real time by the constant product formula. Once the user confirms the swap, the smart contract pulls USDC into the pool and sends back the correct amount of ETH.

Behind the scenes, the AMM rebalances the pool, adjusts prices accordingly, and updates the pool reserves — all in one seamless transaction.

The result? A fast and secure trade that doesn’t rely on third parties.

Explore the power of AMMs

When you're ready to discover the power of AMMs for yourself, start with the Uniswap Protocol: a secure, easy-to-use platform for swapping thousands of tokens directly from your wallet.

You can connect your crypto wallet to the Uniswap Web App to make your first swap, or download the Uniswap Wallet on iOS or Android for self-custody and seamless access to tokens, NFTs, and more.

Share

Sign up for research and updates from the Uniswap Labs team