Zex Finance
  • Introduction
  • Zex Overview
    • Traditional DEXs
      • Zex vs. DEX
        • Synchronization
        • Verification
    • How CEXs Works
      • Zex vs. CEX
        • TXs Verification
        • On-chain Intraction
        • Custody and Transparency
  • Tech Architecture
    • High-level Architecture
    • Smart Contacts
    • ZexPorta
      • Deposit
      • Withdraw
      • Validators
    • ZexCora
Powered by GitBook
On this page
  • CEX Architecture: Order Books, Matching Engines, and Custodial Control
  • Core Components of a Centralized Exchange
  • How CEXs Maintain User Balances
Export as PDF
  1. Zex Overview

How CEXs Works

CEX Architecture: Order Books, Matching Engines, and Custodial Control

Centralized exchanges (CEXs) are the dominant trading platforms in the cryptocurrency market, offering high-speed trade execution, deep liquidity, and a user-friendly experience. Unlike decentralized exchanges (DEXs), CEXs maintain full control over user funds by managing balances through internal ledgers and executing trades via a centralized matching engine and order book.

Core Components of a Centralized Exchange

  1. Order Book: The Heart of Market Liquidity

    • An order book is a real-time record of buy and sell orders submitted by traders.

    • Orders are categorized into:

      • Limit Orders: Users specify a price at which they want to buy or sell an asset.

      • Market Orders: Users execute a trade immediately at the best available price.

      • Stop Orders: Orders that trigger once the asset reaches a predefined price.

    • The order book ensures price discovery and allows traders to see market depth and liquidity.

  2. Matching Engine: Executing Trades Efficiently

    • The matching engine is a high-performance system responsible for executing trades by pairing buy and sell orders.

    • It uses algorithms to:

      • Match market orders with the best available limit orders.

      • Maintain the order book by prioritizing orders based on price-time priority (earlier orders at the same price execute first).

      • Prevent anomalies such as self-trading or invalid transactions.

    • The matching engine ensures low-latency execution, processing millions of orders per second on high-frequency exchanges.

How CEXs Maintain User Balances

Unlike DEXs, where funds remain in users' wallets, CEXs custody user assets and manage balances through an internal ledger. This process involves:

  1. Deposit & Custody of User Funds

    • When a user deposits assets, the funds move to the exchange's hot wallet (for active trading) or cold wallet (for long-term storage & security).

    • The CEX updates the user’s balance on its internal database, allowing them to trade.

  2. Trade Execution and Balance Updates

    • When an order is filled, the exchange updates the buyer’s and seller’s balances internally, rather than executing transactions on-chain.

    • This system removes blockchain latency and fees, enabling faster trading.

  3. Full Custodial Control Over User Assets

    • Since the CEX manages all funds, it has full control over withdrawals, deposits, and security measures.

    • While this allows for efficient trading, it also introduces risks such as:

      • Hacks & Security Breaches: If an exchange is compromised, user funds can be stolen.

      • Operational Risks: Insolvency or mismanagement can lead to loss of assets.

      • Censorship & Freezing of Accounts: Users rely on the exchange’s policies and can be restricted from accessing funds.

PreviousVerificationNextZex vs. CEX
Overview of internal components of a CEX