Centralized Exchanges

This article explains how centralized exchanges work, using Bybit as an example. Binance, Coinbase, OKX, and most modern crypto exchanges operate similarly

Let’s explore how centralized exchanges function by examining the BTC/USDT spot trading pair on Bybit. This pair allows users to exchange Bitcoin (BTC) for Tether (USDT) and vice versa.

Order Types

An exchange is a service that provides two basic operations:

  • Limit Order: "I want to buy (or sell) a specific amount of an asset at a set price (or better) sometime in the future."

    • Guarantees: The execution price (you’ll get your specified price or better).

    • Doesn’t Guarantee: Execution timing or if the order will be filled.
  • Market Order says: "I want to buy (or sell) a specific amount of an asset right now at the best available price."

    • Guarantees: Immediate execution.

    • Doesn’t Guarantee: The exact price

Order Book and Trades

To implement this process exchanges maintain order books, a list of of all active limit orders waiting to be matched. Let’s walk through the process step by step, starting with an empty order book:

  1. User A places a buy limit order for 1 BTC at 96,500 USDT.

    • This is a bid (a limit order to buy).

    • The order book now looks like this:

      Price (USDT)

      Amount (BTC)

      96,500 (Bid)

      1 BTC

  2. User B places a market sell order for 0.5 BTC.

    • The exchange matches this with User A’s bid.

    • Trade: User B sells 0.5 BTC to User A at 96,500 USDT.

    • Updated order book:

      96,500 (Bid)

      0.5 BTC

  3. User C places a sell limit order for 5 BTC at 96,600 USDT.

    • This is an ask (a limit order to sell).

    • Note: Bids must be below the lowest ask (96,600), and asks must be above the highest bid (96,500), unless they’re meant to match immediately.

    • Updated order book:

      96,600 (Ask)

      5 BTC

      96,500 (Bid)

      0.5 BTC

  4. More users add orders, creating a deeper order book:

    96,700 (Ask)

    2 BTC

    96,600 (Ask)

    5 BTC

    96,500 (Bid)

    0.5 BTC

    96,400 (Bid)

    3 BTC

  5. User D places a market buy order for 6 BTC.

    • The order is filled from the lowest asks first:

      • 5 BTC at 96,600 USDT = 5 × 96,600 = 483,000 USDT.

      • 1 BTC at 96,700 USDT = 1 × 96,700 = 96,700 USDT.

      • Total Cost: 483,000 + 96,700 = 579,700 USDT.

    • Updated order book:

      96,700 (Ask)

      1 BTC

      96,500 (Bid)

      0.5 BTC

      96,400 (Bid)

      3 BTC

  6. Trades are recorded with timestamps for transparency:

    • Trade 1: 5 BTC at 96,600 USDT.

    • Trade 2: 1 BTC at 96,700 USDT.

In the trading ecosystem, users who place limit orders are often referred to as market makers or liquidity providers. These participants contribute to the market by adding depth to the order book, offering to buy or sell at specific prices, which other traders can then match. Conversely, users who place market orders are known as market takers. By executing trades immediately at the best available prices, they remove liquidity from the order book, reducing the depth of available orders.

It’s that simple! The order book continuously evolves as users place and cancel limit orders or execute market orders, driving the trading process on centralized exchanges.

Updated on