Skip to content
Education only · not financial, tax or legal adviceCanadian facts checked 2026-10-31 · a MITEY site
Core DeFi

DEXs and liquidity pools: how decentralized trading works

Order books vs automated market makers, the x*y=k idea with simple numbers, slippage, price impact, LP tokens and trading fees, explained for Canadians.

Blue square · intermediate8 min readFacts checked 2026-10-31
Mitey the yeti, blue-eyed with a blond tuft, holding out an open paw, with a liquidity pool
Mitey says: Before you press swap, read the minimum you will receive; it tells you more than the headline price.

Trail notes

  • A decentralized exchange (DEX) lets you swap tokens through smart contracts instead of a company holding your funds.
  • Most DEXs use automated market makers: pools of two tokens priced by a formula rather than an order book.
  • Bigger trades against smaller pools move the price more; that is price impact. Slippage is the gap between the quote and what you actually get.
  • Liquidity providers deposit tokens, receive LP tokens and earn a share of trading fees, while taking on impermanent loss and code risk.

Order books vs automated market makers

A traditional exchange uses an order book: buyers post bids, sellers post asks, and a trade happens when they match. This works well when many active traders and market makers are present, but it is expensive to run entirely on a blockchain, where every order update costs a fee.

Most DEXs instead use an automated market maker (AMM). Rather than matching you with another person, you trade against a liquidity pool, a smart contract holding two (or more) tokens. A formula decides the price based on how much of each token is in the pool. Anyone can add tokens to the pool and earn fees for doing so.

Order bookAMM liquidity pool
Who you trade withAnother trader’s orderA pool of tokens
How price is setBest matching bid and askA formula based on pool balances
Who provides liquidityMarket makers posting ordersAnyone who deposits into the pool
Main cost to youSpread and feesFees plus price impact

The constant-product idea: x × y = k

The simplest and most widely copied AMM formula is the constant product. If a pool holds x units of one token and y units of another, the contract only accepts trades that keep x × y equal to a constant, k (before fees). The price is simply the ratio of the two balances.

Example: a hypothetical pool of Token A and a dollar stablecoin
The pool holds 100 Token A and 100,000 stablecoins. k = 100 × 100,000 = 10,000,000. The spot price is 100,000 ÷ 100 = 1,000 stablecoins per Token A.
Small trade: you add 1,000 stablecoins. The pool now has 101,000 stablecoins, so Token A must fall to 10,000,000 ÷ 101,000 = 99.01. You receive about 0.99 Token A, an average price of about 1,010.
Large trade: you add 10,000 stablecoins. The pool has 110,000, so Token A falls to 10,000,000 ÷ 110,000 = 90.91. You receive about 9.09 Token A, an average price of about 1,100.
After the large trade, the pool’s spot price is 110,000 ÷ 90.91, about 1,210.
Fees are ignored here to keep the arithmetic clear; a real pool would also take a small percentage of each trade.

The pool never runs out of either token, because each extra unit costs more than the last. That is the design’s strength and its cost: the formula always offers a price, but large trades get progressively worse prices.

Arbitrage keeps the pool’s price in line with other markets. If the pool’s Token A is cheaper than elsewhere, traders buy it from the pool until the price rises back. That same process is what causes impermanent loss for liquidity providers.

DEX swap in a constant-product poolYour walletsends 100 Agets 90.66 BLiquidity pool · x × y = kBeforeA 1,000 B 1,000AfterA 1,100 B 909.34Price impact ≈ 9.3% (incl. 0.3% fee)curveHypothetical round numbers for teaching · not a real pool
How a DEX swap moves a pool's price. Worked example in a constant-product pool (x × y = k) with a 0.3% fee. Swapping 100 A into a 1,000 A / 1,000 B pool returns about 90.66 B, not 100: a 9.3% shortfall from price impact plus the fee.

See the full infographic with notes.

Price impact and slippage

People often use these terms interchangeably, but they mean different things:

  • Price impact is how much your own trade moves the pool’s price. In the example, the 1,000-stablecoin trade cost about 1% more than spot; the 10,000-stablecoin trade cost about 10% more. Impact depends on trade size relative to pool size.
  • Slippage is the difference between the price you were quoted and the price you actually got, caused by other trades landing first while yours waits to be confirmed.
  • Slippage tolerance is a setting you choose. If the final price would be worse than your tolerance allows, the trade fails instead of filling badly.
Read the minimum received

Most swap screens show a “minimum received” amount based on your slippage tolerance. That number, not the headline price, is the worst outcome you have agreed to. A very wide tolerance invites bots to trade just before and after you at your expense.

Gas fees sit on top of all this. On a busy network a small swap can cost more in fees than it saves. Our guide to gas fees explains how those are set.

Becoming a liquidity provider: LP tokens and fees

To add liquidity, you deposit both tokens in the pool’s current ratio. In return you receive LP tokens, a receipt that represents your share of the pool. When you withdraw, you return the LP tokens and receive your share of whatever the pool holds at that moment, which may be a different mix from what you put in.

Each trade pays a fee, a small percentage set by the pool, that stays in the pool and grows the value behind each LP token. Some pools also pay extra reward tokens; we cover that in liquidity mining.

Example: your share of fees in a hypothetical pool
You provide 2% of a pool’s liquidity.
Over a month the pool handles 5,000,000 dollars of trades at a 0.30% fee: 15,000 dollars in fees.
Your 2% share is 300 dollars, before gas, and before any impermanent loss from price changes.

LP tokens are themselves tokens. They can be lost, stolen or approved to the wrong contract, and treating them carelessly is a common way people lose a position. See wallet approvals and signing.

Risks and the Canadian angle

  • Fake tokens: anyone can create a pool for a token with a familiar name. Always confirm the contract address.
  • Thin pools: low liquidity means heavy price impact and easier manipulation.
  • Impermanent loss: providers can end up worse off than simply holding.
  • Smart contract risk: the pool and any router you use are code that can fail.
  • Front-running: bots can see pending trades and position around them.
Swaps are dispositions

The CRA lists trading one crypto-asset for another as a disposition, so each swap can create a capital gain or loss, or business income, depending on your situation. As of 2026-10-30, the CRA has published no DeFi-specific guidance on liquidity pools or LP tokens. Keep records of every swap, deposit and withdrawal. See crypto dispositions and record keeping.

If you would rather trade through a registered intermediary, our CEX vs DEX comparison sets out the trade-offs side by side.

Your checklist

Questions people ask

What is a liquidity pool?

A liquidity pool is a smart contract holding two or more tokens that traders swap against. A formula sets the price from the pool’s balances, and the people who deposited the tokens earn a share of the trading fees.

What does x*y=k mean?

It is the constant-product rule used by many automated market makers: the pool’s two token balances multiplied together must stay the same after a trade, before fees, so buying one token makes it progressively more expensive.

What is the difference between slippage and price impact?

Price impact is how much your own trade moves the pool’s price, based on its size versus the pool. Slippage is the extra difference caused by other trades executing before yours is confirmed.

Is swapping tokens on a DEX taxable in Canada?

It can be. The CRA treats trading one crypto-asset for another as a disposition, which may produce a capital gain or loss or business income. As of 2026-10-30 the CRA has no DeFi-specific guidance on liquidity pools.

Sources and dates

  • Decentralized finance (DeFi) — ethereum.orgreference
    No date shown on page · checked 2026-10-31. Overview of DeFi building blocks on Ethereum.
  • Gas and fees — ethereum.orgreference
    No date shown on page · checked 2026-10-31. How transaction fees (gas) work on Ethereum.
  • Introduction to smart contracts — ethereum.orgreference
    No date shown on page · checked 2026-10-31. What a smart contract is and how it executes.
  • Understanding crypto-assets and your tax obligations — Canada Revenue Agencyin force
    No date shown on page · checked 2026-10-30. Defines crypto-assets; lists dispositions (sell, trade, barter, gift, gamble) and acquisitions including mining/staking rewards.
  • Reporting income from crypto-asset transactions — Canada Revenue Agencyin force
    Page date 2025-12-02 · checked 2026-10-30. Business income vs capital gains is case by case; lists business indicators; crypto-to-crypto trades are dispositions; half of a capital gain is taxable.
  • Keeping books and records of crypto-assets for tax filing — Canada Revenue Agencyin force
    Page date 2025-11-10 · checked 2026-10-30. What to record per transaction, wallet addresses, yearly balances; export platform history; keep records at least six years.

Education only. Nothing on this page is financial, investment, tax or legal advice, or a recommendation to buy, sell, stake, lend or borrow any crypto-asset. Crypto-assets can lose some or all of their value and are not covered by CDIC. Canadian rules change: check the dated sources above and talk to a qualified professional about your situation. Full disclaimer.