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.
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.
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.
Unlike DEXs, where funds remain in users' wallets, CEXs custody user assets and manage balances through an internal ledger. This process involves:
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.
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.
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.
The Autonomous Verifiable Service (AVS) of Zex is designed to function similarly to a centralized exchange (CEX), incorporating components such as a matching engine and order books. However, key modifications have been made to enhance decentralization and security:
Integration of the Zellular Sequencer Component: This addition ensures the proper sequencing of transactions across the network.
Inclusion of the FROST Verifier Component: This component facilitates secure and efficient threshold signatures.
Removal of On-Chain Interaction Modules: Components responsible for on-chain interactions, such as the deposit handler and withdrawal manager, have been omitted to streamline operations.
The Zellular Sequencer Component is a core part of the Zex AVS architecture. It is responsible for sending unsequenced transactions to the Master Sequencer, which orders them in a consistent and deterministic manner. Once sequenced, the ordered transactions are sent back to the Zellular Sequencer Component, which passes them to the matching engine for execution. This process ensures synchronization across the network and preserves the decentralized nature of the exchange. More details about the role of the Zellular Sequencer can be found in the synchronization section of the documentation.
On-chain interactions are crucial for ensuring a secure and sufficiently decentralized exchange. To achieve this, we have developed a module called ZexProta to handle all on-chain interactions effectively. Meanwhile, the remaining off-chain functionalities of our platform are managed by a module named ZexCora, which, as mentioned, operates similarly to a centralized exchange (CEX). Before diving into the specifics of ZexProta, it is important to first understand the high-level architecture of PyFrost. We will explore this topic in greater detail in the on-chain interaction section.
Every transaction originates from one of two sources:
User transactions typically involve activities such as user registration, opening and closing orders, and sending withdrawal requests. For these transactions, users issue signatures, usually via their wallets. The ZexCora module is responsible for validating these signatures and verifying the source of the transaction to ensure it originates from an authorized user.
When a user makes a deposit to the Zex platform, the system needs to acknowledge the on-chain transfer and update the user’s balance accordingly. To handle this process in a decentralized manner, Zex employs multiple instances of observers, collectively referred to as ZexPorta. These observers issue a threshold signature using the FROST (Flexible Round-Optimized Schnorr Threshold Signatures) algorithm. This threshold signature is then verified by the FROST Verifier within ZexCora, ensuring that the deposit is valid and securely processed.
Loading...
Loading...