From TradFi Order Book Exchanges To DeFi DEXs: Are DEXs On Layer 3s Possible?

zk.Link
zkLinkBlog
Published in
12 min readMay 2, 2024

--

As the financial industry progresses, the clear trend is moving from centralized entities with traditional order books to the decentralized and automated systems of DeFi DEXs. In addition, the introduction of zero-knowledge technology has marked a significant leap in this transition, providing both enhanced scalability and efficiency in making transactions on the blockchain.

zkLink, in particular, is at the forefront of this innovation by leveraging its Layer 3 solutions and zero-knowledge technology to build and integrate DEXs. Integrating DEXs with zkLink Nova’s Layer 3 facilitates a secure, scalable, and liquid trading environment — and building DEXs with zkLink Nexus allows for high-performance functionality.

From TradFi exchanges to DeFi exchanges, and now to zkLink’s Layer 3 innovations, we’re witnessing a transformative period where the principles of traditional finance are blended with the advantages of decentralized protocols in shaping the future of cryptocurrency trading and liquidity.

In this article, we’ll:

  • introduce the concept of traditional order books utilized by TradFi;
  • introduce the DEX models utilized in crypto such as order books and AMMs;
  • delve into the details of DeFi DEXs and analyze the current state of the market;
  • assess how zero-knowledge technology is being used in the space;
  • guide builders on the benefits of developing and integrating DEXs on zkLink; and
  • demonstrate how Layer 3s can take DEXs to the next level of adoption.

TradFi: Introduction To Order Books

What Is An Order Book?

An Order Book is a real-time ledger that acts as a digital marketplace for all active buy and sell orders for a specific asset on an exchange. It’s an essential tool that displays the current supply and demand levels, which allows traders to make informed decisions based on factors such as market trends and liquidity.

At its core, an order book consists of three elements: the bid side, the ask side, and the order time priority. The bid side showcases the current buy orders, reflecting what traders are willing to pay for the asset, while the ask side displays the current sell orders, indicating the prices sellers are requesting. The difference between the highest bid price and the lowest ask price is known as the spread, a key metric in market analysis. Each order has a size or amount, which refers to the total units of an asset looking to be traded at a specific price. Order time priority records the time priority of all the transactions that have been put up to ensure their timely and proper execution.

The order book plays a pivotal role in trade execution strategies. Understanding and effectively utilizing the order book is crucial for navigating the complexities of trading. There are typically three types of orders:

  1. Traders can opt for a market order, which is executed immediately at the best available price, though it may incur higher costs due to the spread. While market orders are part of the order book, they are typically executed immediately and will likely not stay in the order book for a long time.
  2. A limit order allows traders to specify a buying or selling price, potentially reducing costs by narrowing the spread, albeit at the expense of immediate execution.
  3. A stop order triggers a trade when the price reaches a predefined level, serving as a tool to protect profits or limit losses, but is subject to potential slippage in times of market volatility.

How Do Order Books Work?

An order book works by matching buy and sell orders based on their price and time priority. When a buy order and a sell order have the same price, they are matched and executed, resulting in a trade. The price at which the trade occurs is called the market price. The constant flow of these orders and their matching create a dynamic trading market.

Since an order book is a continuously updated list of buy and sell orders, it provides some valuable insights into the market. A trader can gauge the market’s supply and demand dynamics based on the orders placed.

For example, if the number of buy orders is higher, that may signal strong demand with the potential to push prices up. Alternatively, a higher number of sell orders may signal an overabundant supply with the potential to push prices down.

Another major indicator derived from the order book is depth of market (DOM). DOM is an important indicator that reflects the real-time volume of the orders. A greater depth of the market is considered more liquid and stable because the probability of price manipulation is much lower since large orders will have a smaller market price impact. DOM data can be found using the “market depth chart.” Using DOM data, one can see where the price of a security may be heading in the short term as orders are filled, updated, or canceled.

Who Uses Order Books?

Order books are used by a wide variety of participants in financial markets, including individual retail investors, institutional investors, market makers, and algorithmic traders. These participants rely on order books to make informed decisions on trading securities, derivatives, and other financial instruments. Examples of financial stakeholders that use order books include:

  • Retail Investors: Individual traders use order books to view the available liquidity, determine entry and exit points, and execute trades based on perceived market direction.
  • Institutional Investors: Including pension funds, mutual funds, and insurance companies, these large investors use order books to gauge market depth and liquidity, which is crucial when making large-volume trades that could impact the market price.
  • Market Makers and Liquidity Providers: These are firms or individuals who commit to buying and selling certain securities to ensure there is always a market for them, thus providing liquidity. They use order books to balance their buy and sell orders to manage their inventory effectively and minimize risk.
  • Algorithmic Traders: These traders use automated systems to interpret order book data and execute trades at high speeds. They might exploit small price discrepancies or predict short-term market movements based on changes in the order book.
  • Arbitrageurs: Traders who take advantage of price differences between different markets or derivatives use order books to identify profitable discrepancies between the bid and ask prices across different exchanges or instruments.

Examples Of How Order Books Are Used In Traditional Finance

  • Stock Exchanges: Virtually all major stock exchanges, like the New York Stock Exchange (NYSE) and NASDAQ, use electronic order books that list all outstanding orders. These are integral to their market structure, supporting both direct market access trading and algorithmic trading strategies.
  • Foreign Exchange (Forex): The Forex market, which is decentralized, uses a network of financial institutions (banks, central banks, investment managers) that provide an electronic order book for currency pairs. These order books help participants gauge market sentiment and liquidity in different currencies.
  • Futures and Options Exchanges: Exchanges like the Chicago Mercantile Exchange (CME) and the Chicago Board Options Exchange (CBOE) provide detailed order books for a variety of derivatives, including futures and options. Traders use this information to understand market dynamics and liquidity risks.
  • Bond Markets: While traditionally less transparent, electronic trading platforms for bonds like Bloomberg’s Tradebook or MarketAxess now offer electronic order books. These platforms provide better transparency for pricing and liquidity in the bond market.

These examples illustrate the ubiquity and importance of order books across different financial sectors, highlighting their role in ensuring transparent, efficient, and fair markets. Whether through direct observation or algorithmic analysis, understanding order books is crucial for anyone engaged in trading activities in financial markets.

CeFi vs DeFi: Introduction To CEX Order Books & DEX Exchange Models

Beyond traditional financial exchanges, a similar segment has emerged in the crypto and blockchain industry — Centralized Exchanges (CEXs) and Decentralized Exchanges (DEXs). CEXs began the movement of onboarding investors to the cryptocurrency industry, while DEXs have gone beyond the limitations of CEXs and become one of the largest segments within the decentralized finance (DeFi) ecosystem.

CEXs facilitate cryptocurrency trading by using order books similar to TradFi exchanges. DEXs, on the other hand, facilitate the trading of cryptocurrencies and tokens without the need for a central authority or intermediary, aligning with the core principles of DeFi, which emphasize financial services that are open, interoperable, and without centralized control.

DEXs employ various models to facilitate the trading of cryptocurrencies in a decentralized manner. Each model has its mechanism for matching and executing trades, balancing liquidity provision, and determining prices. Two prominent types of order books that have gained widespread use in the crypto space are Central Limit Order Books (CLOBs) and Automated Market Makers (AMMs).

Model 1: Central Limit Order Books (CLOBs)

Similar to the TradFi order books mentioned above, Central Limit Order Books are a traditional and well-established mechanism for matching buyers and sellers in crypto financial markets. CLOBs are at the heart of most centralized exchanges (CEXs) on the market but are also employed by a few DEXs. CLOBs operate based on a centralized order book that consolidates all the buy and sell orders, providing a clear and organized view of market liquidity. In a CLOB, participants can place various types of orders such as market orders, limit orders, and stop orders.

Model 2: Automated Market Makers (AMMs)

In contrast to CLOBs, Automated Market Makers have emerged as a revolutionary concept within the DeFi ecosystem and DEX segment. AMMs operate on the principles of decentralized liquidity pools, where users contribute funds to a smart contract, forming a liquidity pool that facilitates automated trading.

DEXs that utilize AMMs, such as Uniswap and SushiSwap, don’t rely on a traditional order book. Instead, trading pairs are established by liquidity providers who deposit equal values of two different assets into a pool. These liquidity pools are then used to execute trades at algorithmically determined prices based on the ratio of assets in the pool.

Among the top DEXs in Q1 2024, Uniswap, PancakeSwap, Osmosis, Curve, 1inch, Aerodrome, and Raydium are all AMMs. Therefore, the top DEX players in DeFi generally employ AMM models in their exchanges, which speaks to the preference of DeFi players to take a different approach than their CEX counterparts.

In addition, the majority of DEX trading volumes and market share lie on Ethereum and Solana. These two blockchains have emerged as the networks of choice for deploying DEXs due to their large user base, liquidity, and ecosystem.

Persisting Issues With Crypto DEXs Today

While AMM DEXs such as Uniswap hold a dominant position in the market, they possess a fundamental drawback: they’re not suited for high-frequency trading, automated transactions, or substantial trades, leading to substantial deviations in the exchange rate for larger value transactions.

However, order book exchanges are not easy to build, since the performance (transactions per second and finality) requirements for order book trades are significantly higher than on AMM designs. Decentralization is often sacrificed to increase performance — which poses traders with an unfortunate dilemma and partially explains why dYdX is leaving Ethereum and StarkEx.

One of the major problems faced is the issue of chain interoperability, which is often addressed by using bridges. However, bridging tokens from one chain to another is problematic since “most existing bridges suffer issues with user experience and/or security,” which limits the DEXs by their own bridges.

Another shortcoming that needs to be highlighted is liquidity fragmentation. Deep liquidity is a key element for order book models to ensure buy and sell prices match to fulfill trades. There are multiple reasons for liquidity fragmentation, one of which is the lack of interoperability of native stablecoins across multiple chains.

Moreover, security is another pain point for traders. Since some solutions are reliant on a Proof-of-Stake (PoS) architecture, there remains an issue of obtaining a significant amount of decentralized validators and growing the market cap of the chains’ native tokens. In addition, the previously mentioned bridges add to the security concerns.

Collectively, these issues form a substantial barrier for even the savviest traders. Multi-chain trading, for example, is quite difficult, costly, and risky, which only highlights the interoperability barriers for any other interactions.

What’s The Current Use Of ZK Technology In DEXs?

A brief market overview shows that multiple ecosystems are utilizing zero-knowledge proof technology (ZKP) in their exchange structure. ZKPs enable the verification of a statement’s truth without revealing any underlying details. In the context of DEXs, ZKPs enable traders to validate the accuracy of transactions without revealing sensitive details, ensuring a high level of privacy and security.

In the realm of DEXs, dYdX is exploring zero-knowledge technologies on top of Cosmos to enhance the scalability and privacy features of their exchange structures. Other examples of DEXs that employ zero-knowledge technology in their systems include GRVT and DeGate. However, the segment is still small due to the nascent development of ZK technology.

Nonetheless, ZK-powered order books, by leveraging ZKPs, can revolutionize DEXs. In particular, zkLink X is at the forefront of this DeFi revolution, showcasing its innovative approach to order book designs. Unlike traditional setups, zkLink X leverages ZKPs to provide a secure, private, and scalable trading environment for DEXs.

How ZK-Powered DEXs Work

  1. Zero-Knowledge Proofs: Participants in a ZK-powered order book can prove the validity of their transactions without revealing specific details about those transactions. This cryptographic technique allows users to maintain privacy while still ensuring the integrity of the trading process.
  2. Transaction Aggregation Off-Chain: Instead of processing each transaction on the blockchain individually, zk-powered order books use ZKPs to aggregate multiple transactions off-chain. This means that several transactions can be grouped into a single proof, reducing the computational load on the blockchain.
  3. Off-Chain Order Matching: The order matching process, which typically happens on-chain in traditional setups, is moved off-chain in ZK-powered order books. ZKPs are employed to validate and settle trades without disclosing sensitive information, resulting in faster and more efficient order matching.
  4. Reduced Gas Fees & Enhanced Scalability: By aggregating transactions off-chain and employing ZKPs, ZK-powered order books minimize the need for extensive on-chain computations. This leads to a significant reduction in gas fees, making transactions more cost-effective. Additionally, the off-chain order matching enhances the overall scalability of the DEX.

What Are The Benefits Of ZK Order Books & Developing An Order Book On zkLink X?

First and foremost, the unique design of zkLink X, zkLink’s application-specific scaling engine, empowers developers to build order books with the experience and liquidity of a CEX, but decentralized and non-custodial.

Here’s a simple list of the advantages of building an order book on zkLink X:

1)User-friendly: A common term, but here are the exact features:

  • Merged stablecoins from multiple chains/rollups
  • Massive multi-chain/rollup liquidity
  • Multi-chain accessibility
  • Fast finality
  • No gas cost on L2
  • Partial fulfillment and multiple pending orders

Merged stablecoins from multiple Ethereum rollups, which is also called token merge, eliminate the difference between equivalent tokens on different chains (for example: one USDC on Ethereum and one USDC on Arbitrum) by merging them into a single pair. This functionality adds to the broader massive multi-rollup liquidity, where one can trade native assets from different rollups without using any bridges. Users get access to liquidity from every connected Ethereum rollup. This enables users and builders to tap into native chain liquidity and have a smoother multi-rollup experience under one interface.

In addition, zkLink X connects to multiple Layer 2s, makes zero security compromises, and prevents deposit fraud. There are also no gas fees while trading on Layer 2s. By moving transactions off-chain to the Layer 2, users only pay low transaction fees. Also, since there’s no AMM-like rebalancing, there’s no slippage, fast finality of transactions powered by zk-batching, and greater flexibility with order types, such as partial fulfillment and multiple pending orders with up to 32 maker orders.

2)Decentralized: Core features to be decentralized:

  • Asset security with ZK-Rollups
  • Self-custodial
  • Trustless
  • Permissionless
  • No KYC
  • Validity proofs

It’s also worth highlighting enhanced users’ self-custody and protocol security. Self-custody is achieved by users controlling their accounts through a smart contract rather than simply a private key. This ensures the system is trustless and transparent, and gives users full self-custody over their assets. On the security side, zkLink X inherits the security of Ethereum by using zk-SNARK technology, thereby ensuring the security of cross-rollup transactions. Validity proofs are utilized to verify valid state transitions to a parent chain, which allows it to not compromise on security. The usage of ZKPs ensures that multi-rollup interoperability is safe and secure.

3)Builder-friendly: It’s also great for you to build with:

  • Simple High-Level APIs
  • Data Availability
  • Metamask integration
  • Application-Specific
  • Highly-Customizable

Some features will make the building experience for a decentralized order book that much better. Simple High-level APIs allow you to connect your front-end to zkLink’s simple REST-ful API, using the development language and stack of your choice. In addition, to enable your continuous development and building, zkLink X has a built-in data availability layer. You have immediate access to all the relevant on-chain data. For builders’ and users’ convenience, your ZK-powered order book will have a ready-to-go Metamask integration with more wallets coming soon.

Moreover, since one of zkLink X is app-specific, zkLink X is considerably smaller than general-purpose zk-circuits, resulting in lower computational resources and on-chain gas consumption. zkLink X offers developers a high level of customization, such as the choice of which networks to connect to, which DA layer to use, and other tailor-specific functions.

--

--

The First Aggregated Layer 3 Rollup for High Performance ZK Applications