SOLID STATE PRESS
← Back to catalog
Decentralized Exchanges and Automated Market Makers cover
Coming soon
Coming soon to Amazon
This title is in our publishing queue.
Browse available titles
Cryptocurrency & Blockchain

Decentralized Exchanges and Automated Market Makers

Liquidity Pools, the Constant Product Formula, and Impermanent Loss — A TLDR Primer

If you've heard terms like "liquidity pool," "AMM," or "impermanent loss" and had no idea what they meant — or if you're taking a course on blockchain technology and need the math to click fast — this guide is for you.

Decentralized exchanges (DEXs) like Uniswap have replaced traditional order books with a simple but powerful formula: *x × y = k*. Understanding that one equation unlocks how prices are set, how trades get executed, and why providing liquidity can be profitable — or costly. This primer walks you through all of it, step by step, with real numbers.

**What's inside:** - Why blockchains can't run traditional order books, and what automated market makers do instead - How the constant product formula prices every trade, with worked examples - How liquidity providers earn fees — and what LP tokens actually represent - The math of impermanent loss, explained with a concrete numerical walkthrough - Real risks: slippage, price impact, MEV bots, sandwich attacks, and smart contract failures - A clear-eyed look at Uniswap v3 concentrated liquidity and Curve's stableswap, so you know where the field is heading

This is not a get-rich-quick crypto pitch. It's a focused, honest explanation of how decentralized exchanges work — written for students who want to understand the mechanics, not just the hype. If you've been searching for an automated market maker explained simply, with actual math and no filler, this is the guide.

Pick it up, read it in an afternoon, and walk into your next class or project with confidence.

What you'll learn
  • Explain how a decentralized exchange (DEX) differs from a centralized exchange and from a traditional order book
  • Derive prices and trade outputs from the constant product formula x*y=k
  • Describe how liquidity providers earn fees and how LP tokens represent pool shares
  • Calculate and reason about impermanent loss, slippage, and price impact
  • Identify real risks: MEV, sandwich attacks, smart contract bugs, and rug pulls
What's inside
  1. 1. From Order Books to On-Chain Trading
    Explains what a DEX is, why centralized exchanges and traditional order books don't translate well to blockchains, and what problem AMMs were invented to solve.
  2. 2. How an Automated Market Maker Works
    Introduces liquidity pools, the constant product formula x*y=k, and walks through trade pricing with concrete numbers using Uniswap v2 as the model.
  3. 3. Liquidity Providers, LP Tokens, and Fees
    Shows how anyone can deposit a pair of tokens to become a liquidity provider, what LP tokens represent, and how the 0.3% fee accrues to providers.
  4. 4. Impermanent Loss, Slippage, and Price Impact
    Works through the math of impermanent loss with a numerical example, distinguishes slippage from price impact, and explains when LPing is actually profitable.
  5. 5. Risks: MEV, Sandwich Attacks, and Smart Contract Failure
    Surveys the real-world hazards traders and LPs face, from front-running bots to buggy or malicious contracts, with named historical examples.
  6. 6. Beyond Uniswap v2: Concentrated Liquidity and What Comes Next
    Briefly covers Curve's stableswap, Uniswap v3 concentrated liquidity, and how DEX design is still evolving — enough to orient a reader for further reading.
Published by Solid State Press
Decentralized Exchanges and Automated Market Makers cover
TLDR STUDY GUIDES

Decentralized Exchanges and Automated Market Makers

Liquidity Pools, the Constant Product Formula, and Impermanent Loss — A TLDR Primer
Solid State Press

Contents

  1. 1 From Order Books to On-Chain Trading
  2. 2 How an Automated Market Maker Works
  3. 3 Liquidity Providers, LP Tokens, and Fees
  4. 4 Impermanent Loss, Slippage, and Price Impact
  5. 5 Risks: MEV, Sandwich Attacks, and Smart Contract Failure
  6. 6 Beyond Uniswap v2: Concentrated Liquidity and What Comes Next
Chapter 1

From Order Books to On-Chain Trading

When you buy a stock on the New York Stock Exchange, a lot is happening behind the scenes that you never see. Your broker holds your money. The exchange matches your buy order against someone else's sell order. A clearinghouse settles the trade a day or two later. At every step, you are trusting an institution — your broker, the exchange, the clearinghouse — to handle your assets honestly and correctly. This is the traditional model, and it works well enough in traditional finance. In crypto, it became a problem.

A centralized exchange (CEX) like Coinbase or Binance operates on the same principle. You deposit your tokens onto the platform, and the platform controls them while you trade. The exchange runs an order book — a continuously updated list of all open buy and sell orders, sorted by price. When a buyer's price matches a seller's price, the trade executes. The platform handles custody, matching, and settlement internally, usually in a database it controls.

Custody is the catch. When your tokens sit on a centralized exchange, you do not hold them — the exchange does. "Not your keys, not your coins" is the blunt version of this principle. The exchange might get hacked (Mt. Gox, 2014: roughly 850,000 Bitcoin lost), go insolvent (FTX, 2022: billions in customer funds missing), or simply freeze withdrawals. Users of those platforms learned that "having crypto on an exchange" is not the same as holding crypto.

A decentralized exchange (DEX) attempts to fix this by executing trades directly on a blockchain, with no company in the middle holding your funds. You keep your tokens in your own wallet until the moment a trade settles. The exchange's rules are encoded in a smart contract — self-executing code that lives on the blockchain and runs exactly as written, with no human operator who can freeze your account or disappear with your money.

That sounds ideal, so why didn't developers just put a standard order book on a blockchain?

Why Order Books Break On-Chain

About This Book

If you are a college student taking a fintech, economics, or blockchain course, a self-directed learner trying to understand crypto DeFi concepts, or a high school student who has heard the words "liquidity pool" and "impermanent loss" and wants a clear explanation, this book is for you. It also works for parents, tutors, and anyone who needs a fast, honest orientation to decentralized finance.

This guide covers how decentralized exchanges work — including blockchain trading without order books — and gives you an automated market maker explained simply, from the constant product formula to slippage. It walks through a Uniswap liquidity pool beginner guide, impermanent loss explained with examples, a DeFi liquidity provider fees and risks guide, and a look at MEV, sandwich attacks, and concentrated liquidity. Concise and built around worked numbers, with no filler.

Read straight through in order — each section builds on the last. Work through the examples as you go, then test yourself with the problem set at the end.

Keep reading

You've read the first half of Chapter 1. The complete book covers 6 chapters in roughly fifteen pages — readable in one sitting.

Coming soon to Amazon