Simha Fintech Logo
DeFi7 MIN READ

How Automated Market Makers (AMMs) Work in DeFi

AMMs are the underlying mathematics that power decentralized exchanges. Learn how constant product formulas allow for continuous, permissionless liquidity without traditional order books.

S
Sarah Jenkins
Quantitative AnalystFebruary 23, 2026

If you've ever traded tokens on a Decentralized Exchange (DEX), you have interacted with an Automated Market Maker (AMM).

AMMs completely revolutionized digital asset trading by answering a critical question: *How do you facilitate a trade on a blockchain without relying on a centralized entity to match buyers and sellers?*

The Traditional Order Book Problem

In traditional finance (stocks, forex, and centralized crypto exchanges), trading relies on an Order Book.

Buyers submit "bids" specifying the highest price they are willing to pay. Sellers submit "asks" specifying the lowest price they are willing to accept. The exchange's matching engine pairs them up.

If there are no willing buyers or sellers at a given price point, the market becomes illiquid. To prevent this, traditional markets rely on professional "Market Makers"—huge financial institutions that constantly provide capital to both sides of the book to ensure it remains active.

Replicating a high-frequency order book on a public blockchain like Ethereum used to be too slow and far too expensive due to gas fees.

The AMM Solution: Liquidity Pools

AMMs solve this by replacing the order book completely.

Instead of waiting to match with another human being, you trade against a smart contract filled with tokens. This smart contract is called a Liquidity Pool.

But where do the tokens in the pool come from? Unlike traditional finance where giant institutions provide liquidity, DeFi crowdsources it. Anyone in the world can become a "Liquidity Provider" (LP) by depositing an equal value of two different tokens into the pool. In exchange, they earn a portion of the trading fees generated by users swapping against that pool.

The Constant Product Formula

So, if there is no order book and no human setting the price, how does the smart contract know what a token is worth?

Most standard AMMs (pioneered by Uniswap) use a beautifully simple mathematical algorithm called the Constant Product Formula:

`x * y = k`

  • x = The total amount of Token A in the pool.
  • y = The total amount of Token B in the pool.
  • k = A fixed constant that must remain exactly the same before and after every single trade.
  • Here is how it works in practice:

    Imagine a pool containing 10 BTC (x) and 1,000,000 USDC (y).

    The constant k = 10 * 1,000,000 = 10,000,000.

    If you want to buy 1 BTC from this pool:

  • You must extract 1 BTC, leaving 9 BTC in the pool.
  • Because k must ALWAYS remain 10,000,000, the smart contract calculates how much USDC MUST be in the pool to satisfy the equation: `9 * y = 10,000,000`.
  • The new required USDC balance (y) is roughly 1,111,111.
  • Since the pool originally had 1,000,000 USDC, you have to deposit 111,111 USDC to successfully execute the trade and extract your 1 BTC.
  • *(Note: Real AMM math is slightly more complex as it accounts for 0.3% LP fees and slippage curves, but the core mechanic is exactly as described).*

    As the ratio of tokens in the pool changes due to trades, the algorithm automatically and continuously adjusts the prices based purely on supply and demand curves, entirely removing the need for human market makers.

    Tags:DeFiAMMLiquidity PoolsDEXMath

    Keep Exploring

    More insights from the DeFi sector.