Back to Learn

How the PancakeSwap AMM Works

A practical explanation of pool reserves, price impact, liquidity providers and the differences between V2, V3 and Infinity.

An automated market maker, or AMM, lets users exchange tokens against a liquidity pool instead of waiting for a matching order from another trader.

The pool holds token reserves. A formula and the pool's smart contracts determine how those reserves change during a swap. The price shown by the interface comes from that state, the trade size, fees and the route selected for the transaction.

PancakeSwap has more than one pool model, so “the PancakeSwap AMM” is a useful starting phrase rather than a single formula that describes every trade.

The basic AMM idea

Imagine a pool containing token A and token B. Traders add one token and remove the other. Liquidity providers supplied the reserves and receive pool fees according to the rules of that pool.

In a classic constant-product pool, the simplified relationship is:

reserve A × reserve B = constant

You may also see this written as x × y = k.

When a trader adds token A and removes token B, both reserves change. Because the ratio between them changes, the marginal pool price changes as well. The larger the trade compared with the pool, the more the price moves during execution.

This simple model is useful for understanding V2-style pools. It is not a complete description of concentrated-liquidity or bin-based pools.

A simplified constant-product example

Suppose a pool has 100 units of A and 10,000 units of B. Ignoring fees and rounding, the product is 1,000,000.

If someone adds 10 A, the pool would hold 110 A. To keep the product near 1,000,000, the B reserve would move to roughly 9,090.91. The trader receives roughly 909.09 B.

The starting reserve ratio suggested 100 B for each A. The average execution in this simplified trade is lower because the swap moves along the pool's price curve.

Real transactions include fees, integer rounding, route logic and live state changes. Treat the example as a mental model, not a quote calculator.

Liquidity and price impact

Price impact is the price movement caused by your trade relative to the pool's current state. Deep liquidity generally allows a larger trade with less impact than a shallow pool, all else being equal.

This is why the same token pair can produce different outputs across pools. The result can change with:

  • reserve depth or active liquidity near the current price;
  • pool fee tier;
  • protocol version and pool type;
  • intermediate routing tokens;
  • other trades before yours;
  • the amount you enter.

Our guide to DeFi liquidity explains how available liquidity affects a quote.

Price impact is not slippage

The terms are related but not identical.

Price impact describes how your own trade moves through available liquidity.

Slippage describes the difference between an expected result and the result the transaction is allowed to execute at as market state changes.

A large trade can show high price impact even if it executes exactly against the quoted pool state. A small trade can fail its slippage check if the market changes sharply before confirmation. Read slippage, price impact and gas for a fuller comparison.

Where does the AMM price come from?

The pool does not ask an external exchange for permission to set each trade price. Its smart-contract state and formula determine the on-chain result.

Arbitrageurs compare pool prices with other markets. If a profitable difference exists, their trades can move the pool toward the wider market. This process is competitive and costs gas and fees, so it is not instantaneous or guaranteed to remove every difference.

Some products also use oracles for specific functions, but an oracle does not replace the AMM curve in a conventional pool swap.

What liquidity providers receive

Liquidity providers deposit assets under the rules of a pool and receive a position representing their share or range. Fees paid by traders are allocated according to the protocol version and active-liquidity rules.

Providing liquidity has real risks:

  • token prices can move relative to one another;
  • the position can underperform simply holding the assets;
  • concentrated ranges can go out of range;
  • smart contracts can contain defects or unexpected behavior;
  • fees may not compensate for price movement or gas;
  • a token can have malicious or restrictive logic.

The official PancakeSwap liquidity documentation is the right place to confirm current pool behavior and fee details. Do not rely on a historical percentage copied into a third-party article.

PancakeSwap V2-style pools

V2-style pools use the familiar constant-product model across the full price range. LP positions are fungible shares of the pool.

This design is comparatively easy to reason about, but liquidity is spread across prices that may never be reached. A trade's execution still depends on pool depth, fee and route.

PancakeSwap V3 concentrated liquidity

V3 introduced concentrated liquidity. Liquidity providers choose price ranges where their capital is active. Concentrating liquidity around the current price can create more usable depth within that range, but it also requires range selection and monitoring.

If price moves outside the chosen range, the position can become one-sided and stop earning swap fees until it is active again. Concentrated liquidity changes LP management, not the need for traders to check price impact and minimum received.

See PancakeSwap V2 vs V3 for a version-focused comparison.

PancakeSwap Infinity

PancakeSwap Infinity extends the architecture beyond one pool formula. Its official technical overview separates accounting, pool-management logic and optional hooks.

This modular design can support different AMM types and customized behavior. Hooks may affect features such as fees, oracle logic or order handling. For users, that means the pool type and route matter. A label that says “Infinity” does not by itself tell you every execution rule.

How routing changes the final quote

A token pair may have several pools, fee tiers or protocol versions. A router can compare eligible paths and may use an intermediate token when that produces a viable result.

For example, A to C may route directly, or it may pass through B. A multi-hop route can access deeper liquidity, but it can also add pool fees and gas. The best-looking spot price is not enough. You need the amount-specific output after fees, price impact and estimated network cost.

The PancakeSwap review covers the product at a higher level. To evaluate a transaction across different liquidity venues, use the framework in how to compare liquidity routes.

Latin Link is a non-custodial aggregation interface whose routing can consider eligible sources through OpenOcean. That broader route search can be useful, but it does not guarantee the highest output. Quotes remain dynamic and depend on the amount, chain, liquidity, fees, gas, price impact and slippage.

Frequently asked questions

Does PancakeSwap use an order book?

Its AMM swaps use liquidity pools rather than a conventional central limit order book. Other product features can use different execution designs, so check the specific feature.

Who sets the price in a PancakeSwap pool?

The pool formula and current reserves or active liquidity determine the on-chain price. Trader and arbitrage activity changes that state over time.

Why does a large trade receive a worse average price?

It consumes more of the available liquidity and moves farther along the pool curve. The effect is larger in shallow pools.

Is more liquidity always safer?

No. Deeper liquidity can reduce price impact, but it does not prove that a token or smart contract is safe.

Do all PancakeSwap pools use x × y = k?

No. It is the standard simplified model for V2-style constant-product pools. V3 concentrated liquidity and Infinity pool types need different math and assumptions.

This article is educational and is not financial, legal or tax advice.

01/Next step

Compare alternatives

Review platforms by model, network, routing and use case.

View alternatives

Review the route

Compare output, gas, slippage, price impact and minimum received before signing.

How to compare routes

Check a current quote.

Latin Link can use OpenOcean routing to compare eligible sources. The route depends on the pair, network, amount and time.