How automated market makers work
The x·y=k formula and how price comes from reserves.
Educational content only — not investment advice. Independent and not affiliated with Uniswap Labs.
A decentralized exchange (DEX) lets people swap one token for another directly on a blockchain, using software instead of a company. This guide explains what that means, how it differs from a traditional exchange, and what trade-offs come with it.
If you have ever used an app to convert one currency into another, the basic idea of an exchange will feel familiar: you hand over one thing and receive another in return. A decentralized exchange, usually shortened to DEX, does something similar for blockchain tokens — but with an important difference. There is no company in the middle holding your money or deciding when your trade happens. Instead, the swap is carried out by smart contracts: small programs that live on a blockchain and run exactly as they are written.
To understand why that matters, it helps to compare a DEX with the kind of exchange most people meet first.
A centralized exchange (CEX) is run by a company. You create an account, usually verify your identity (a process often called KYC, short for "know your customer"), and deposit funds. From that moment, the company holds your tokens for you. When you place a trade, the exchange matches your order with someone else's inside its own systems, and it records the result in its private database. You are trusting that company to keep your funds safe and to let you withdraw them later.
A decentralized exchange works differently in several ways:
Self-custody means you, and only you, control the keys to your wallet. A "key" is a secret string of characters that proves ownership of your tokens. No company can move those tokens for you, but no company can recover them for you either. That control is the appeal of a DEX — and also the responsibility.
When a swap runs on a DEX, it is recorded on-chain: written permanently into the blockchain. On-chain settlement has three qualities worth understanding clearly:
Traditional exchanges keep an order book — a constantly updating list of who wants to buy and sell, and at what price. Many DEXs do away with the order book entirely. Instead, they use an automated market maker (AMM): a smart contract that holds a pool of two tokens and uses a mathematical formula to decide the swap rate, with no human matching orders. This is one of the most important ideas in how DEXs function, and it has its own article. For now, the short version is that a formula and a shared pool of tokens take the place of the buyers and sellers a traditional exchange would line up.
Uniswap is a widely cited example of a DEX. Described plainly, it is a set of smart contracts deployed on Ethereum and several other blockchains. Those contracts let people swap tokens and let others supply tokens to the shared pools the contracts draw on. Because the logic lives in public smart contracts rather than in a company's servers, anyone can inspect how it works. This blog discusses Uniswap independently for educational purposes; it is not affiliated with, endorsed by, or sponsored by Uniswap or Uniswap Labs.
Self-custody and on-chain settlement come with real downsides that are easy to overlook:
None of this is meant to alarm you — only to set expectations. A DEX hands you more control and asks for more care in return.
New here? Start with how automated market makers work, or browse the glossary.
Disclaimer: This article is educational content only. It is not investment, financial, legal, or tax advice, and not a recommendation to buy, sell, or trade any asset. Crypto involves significant risk, including total loss of funds.