TheCryptoUpdates
CryptoEthereum

DeGate’s Order Book Approach

An exchange is a marketplace where assets, such as commodities, stocks, and cryptocurrencies, can be bought and sold. Traders use the exchange to buy or sell assets. Traditionally, the exchange works in an order-book manner. For example, buyers place an order on the exchange specifying the type and quantity of the asset they want to buy and the maximum price they are willing to pay — a limit order. Sellers do the same. The exchange then matches the buy orders and sell orders. When a match is found, the deal is done and completes the transaction. Among decentralized exchanges (DEX), interestingly, a new type of exchange is very prevalent, the Automated Market Maker, AMM.

AMM is a DEX model that relies on liquidity pools, a container of crypto tokens, for exchanging tokens between A to B. The AMM model was invented to remove the need for a central entity to match orders and automate trading. It uses a mathematical formula to regulate the pool’s token reserve. Traders do not trade against a counterparty but a smart contract that executes the conditions of the mathematical formula. When people come to trade, the quantity of tokens in the pool changes, i.e trading token A for token B means adding A into and taking B out of the pool. A token’s price relative to the other token(s) in the pool is determined by the ratio of its quantity. That’s how the AMM quotes the price. As a trader, you can only be a taker who accepts the market price but cannot make a limit order. A pain point is that traders may suffer a front-running or sandwich attack from MEV bots, making the orders fail or result in an unfavourable price. The AMM model has gained popularity for its simplicity and efficiency in executing and settling trades in a blockchain network where there is limited capacity and high transaction costs.

An order book exchange lists all open orders for any particular trading pair. It has a matching system to match the buy and sell orders. When a buy order is matched with a sell order, a successful trade is thus made. Generally, orders are considered compatible if the highest buy price matches or exceeds the lowest sell price. On a deeper level, different exchanges employ various methods to prioritize orders for matching.

In the DEX landscape, the order book model is slow to gain adoption because of several challenges.

First, high cost in handling on-chain limit orders. Every action and order occurs with gas fees. In the end, the resulting limit order might end up unprofitable for the taker, which makes on-chain limit orders unsuitable for high-frequency trading and smaller-size orders.

Second, low order matching efficiency arises from the limited network throughput, making it unable to fulfil the needs of a high-frequency trading platform such as a centralized exchange.

Third, on-chain limit orders may lead to front-running. When a taker wants to match the maker’s order, another can front-run him/her, resulting in a failed transaction.

An order book exchange in its traditional setup comes with many technical challenges for it to be suitable in the blockchain industry. However, as the Ethereum network upgrades and scales, it will be able to support significantly higher throughput and tremendously reduce gas fees. In light of this, “make DEX order book again” becomes doable.

DeGate’s order book solution

Built with Zero-Knowledge(ZK) technology, DeGate is a decentralized order book trading protocol that keeps the order book and order matching on Layer 2 and finalizing the settlement on Layer 1 via ZK rollup. The DeGate protocol should achieve the following:

  • Ensuring ZK Rollup Data Availability
  • Handling large numbers of orders efficiently
  • Saving gas

DeGate responds to the challenges by implementing a robust ZK rollup based on zkSNARKS. It generates a ZK proof through a circuit program after processing the requests off-chain, submits them on chain, and gets proof verification through immutable open source smart contracts on chain.

A ZK-rollup order book DEX can function. However, handling a large, high-frequency order book still needs to be more efficient. Every action that requires a blockchain transaction consumes data storage. To further improve the efficiency of the matching model, DeGate has designed Batch Spot Trade, a mechanism able to intelligently bundle up and compress many transactions before adding into Layer 2 block. After which, a validity proof is generated through cryptographic means, which is then submitted to Ethereum Mainnet.

To ensure the system’s accuracy, Batch Spot Trade tracks the token balances amongst the transacted users and the matched transactions. This is elaborated in the diagram below, whereby the total sum of the 3 tokens (namely ETH, USDC, USDT) is calculated to ensure the token balance always = 0 between the total no. of users in each data bundle.

The Batch Spot Trade combines the number of users making transactions and the number of users’ aggregated orders. With this design combination, the data can thus be compressed and represented using only 83 bytes, potentially bundling up to 9x more transactions.

Thanks to the design, DeGate protocol’s gas fee is significantly reduced. How low can it go? Here is an estimation.

Using the recent numbers, assuming the gas price is 15 gwei, ETH price is 1300$:

  • Deposit 8,000–10,000 gas ( 0.156 ~ 0.195 USD)
  • Order matching 800–2,400 gas (0.015 ~ 0.047 USD)
  • Withdrawal 2,000–5,000 gas (0.039 ~ 0.098 USD)

Making a swap on Uniswap v3 occurs 120,000–200,000 gas ( 2.34 ~ 3.9 USD)

Summing up DeGate’s gas fees for a series operation, deposit — trade — withdrawal, the total cost is still 10% of Uniswap.

The result of DeGate’s design is a CEX-like trading experience in a decentralized manner:

  • Instant cancellation of pending orders which matches the cancellation speed of centralized exchanges
  • No cancellation fee for cancelling a pending order
  • No fees for maker orders — including trading and gas fees for blockchain settlement

These attributes make DeGate suitable for retail users and professional market makers who need to handle a magnitude of orders instantly.

1inch also has limit order. How does DeGate differ from it?

Both 1inch and DeGate offer the limit order feature, but the mechanism behind it is different.

Order matching mechanism

DeGate is based on an order book logic where the order matching follows the priority of:

1. Price. Start matching from the highest buy price and lowest sell price.

2. Time. If different orders require the same price, the earlier the order is made the sooner it gets fulfilled.

DeGate’s order matching operates as a classic order book. Every order has an equal chance to get filled.

1inch’s limit order does not necessarily follow this logic. In 1inch, makers submit limit orders and wait for takers to take their orders. The takers don’t need to follow a fixed logic to fulfil the orders. Instead, which order is fulfilled first depends on the profit margin they could get by taking the order. The takers must consider the order’s size, gas fees and profitability before filling the order. Essentially, it is an arbitrage-driven order matching. If an order is too small or the gas cost is too high, it may not get filled due to a lack of profitability even when the price has matched the requested price. 1inch’s limit order is suitable for large orders, not for small orders.

Gas fee

On DeGate, you don’t need to pre-authorise the gas fee when you do a post-only limit order, meaning you require that the order can only be filled as a maker’s order. Remember, makers pay no fees. And cancelling a pending order occurs with no fees. If you want to change a limit order’s price, you can cancel the open order and make a new one. All these operations are gas-less.

On 1inch, you can place gas-less orders for a selection of tokens but not all tokens. And cancelling a pending order requires a gas fee. If you want to change a limit order’s price, you need to first cancel it which requires a gas fee. Frequently changing a limit order’s price is cost-consuming, making it unsuitable for trading purposes.

What to expect

In short, DeGate aims to provide an orderbook experience similar to traditional exchanges, at similar cost, but with much higher security and decentralisation. DeGate is currently on testnet. Expect the mainnet launch by Q1 2023.

Related Articles

What is The Reason Of Coinbase Global Stock Was Down 12.2% in September

Kshitij Chitransh

Maurizio Barbieri Joins The Team of Play-To-Earn Gaming Project Liberty Gaming Guild

Mohamad Ahmad

Best Crypto Telegram Channels

John Marks