Home Crypto A guide to understanding Sei Network: The first order-book-focused L1 blockchain

A guide to understanding Sei Network: The first order-book-focused L1 blockchain

0
A guide to understanding Sei Network: The first order-book-focused L1 blockchain

[ad_1]

Sei Network is the first order-book-focused L1 blockchain that offers a high throughput and low latency without sacrificing decentralization. It is specialized for trading and designed to be faster and more reliable than other types of blockchains.

Sei is built using the Cosmos SDK, the Tendermint core, and has a built-in centralized (or decentralized) limit order book (CLOB/DLOB) module that offers a heavily optimized order placement and matching engine.

A CLOB is a central limit order book where order messages are maintained and matched by a central authority. A DLOB is a decentralized limit order book where order messages are propagated and matched by a distributed network of nodes.

Central limit order-books (CLOBs) have been integral in market-making in TradFi since 2000. Every asset you trade today on the NASDAQ or other indices is filled using one. However, CLOBs in crypto have largely only existed on centralized exchanges (CEXs).

This is because bringing an orderbook on-chain is very difficult. CEXs have only been able to leverage them because they utilize Web2 infrastructure. Thing is, they’re prone to the centralization and other risks we’re familiar with that exist in Web2.

Due to this single fact of centralization, AMMs have instead become the norm in DeFi. But the thing about AMMs is that they’re inherently less efficient as CLOBs offer lower slippage, tighter spreads, and more.

Now, it is important to note that Sei Network is not the first to introduce CLOBs. Teams like @ProjectSerum have attempted to introduce on-chain CLOBs.

Serum found some success but AMMs continue to dominate DeFi and CEXs continue to dominate CLOB-based trading. This was because Serum could only be as efficient and capable as the chain it’s built on. When Solana was congested or dealing with liveness issues, so was Serum.

This is where and why Sei Network steps onto the scene. After observing Serum and its successes/shortcomings, Sei deduced that the blockchain a CLOB lives on must be purposed and optimized specifically for it.

Hence Sei became the 1st orderbook-specific L1 blockchain.

The Sei Network offers a number of advantages over other blockchains, including:

– High throughput and speed

– Liquidity

– A focus on the order book

– A comprehensive solution for trading

Sei has been optimized for speed, stability, and cost-efficiency; all things a CLOB and applications built on top of it need. It introduces novel approaches for transaction ordering, block processing, and parallelization that are specialized for exchanges. Sei-based dapps can be built on top of DLOB, and other Cosmos-based blockchains can use DLOB Sei as a shared liquidity hub.

Through the on-chain CLOB module and matching engine, Sei can provide deep liquidity and price-time-priority matching for traders and applications.

This is its edge!

Apps on Sei leverage its:

  • built-in orderbook infrastructure,
  • deep liquidity, and
  • fully decentralized matching service.

Users, on the other hand, utilize this model to precisely select the price, size, and direction of their trades (with MEV protection also).

Sei envisions itself becoming the home to a new echelon of DeFi products. Sei plans to act as the infrastructure and liquidity hub for the next generation of Cosmos ecosystem DeFi products, as it bridges the performance gap between centralized and decentralized exchanges.

For this, they chose the Cosmos SDK, Tendermint Core, and CosmWasm. In addition, the Sei network is IBC-enabled and also integrated with the wasmd module to support CosmWasm (CW) smart contracts.

As a blockchain network, Sei has a lot of moving parts. Sei unlocks an entirely new design space between the two — not general-purpose nor app-specific, but sector-specific, which enables Sei to create an environment custom-built for DEX applications.

For this article, we would be looking at seven major areas of innovation that Sei has:

  • Intelligent block propagation
  • Optimistic block processing
  • DeliverTx Parallelization
  • Endblock Parallelization
  • Native price oracles
  • Frequent batch auctioning
  • Transaction order bundling

Before we go further down this rabbit hole, let’s first understand how the Sei Network achieves consensus.

Now, to verify the validity of a transaction at the protocol level, the Sei network uses the Twin turbo consensus algorithm.

Using Twin turbo consensus, once a full node receives a transaction from a user, it must broadcast that to other nodes in the network. Full nodes will randomly gossip this transaction to other nodes in the network. Once a transaction is received by a validator, it verifies the validity of the transaction and adds that transaction to that validator’s local mempool.

So, Sei sends transaction hashes in the block proposal, allowing blocks to get reconstructed locally by validators (by looking at their mempools) rather than waiting to receive them over the network. Previously, block proposers sent blocks that contained every transaction. Validators already gossip transactions between themselves at transaction submission, so most validators already have every transaction in their local mempool.

Intelligent block propagation

With intelligent block propagation, block proposers will now send a proposal that has a hash of every transaction that is part of the block. When validators receive the block proposal, they can use transactions from their mempool to quickly reconstruct the block.

If validators don’t have all of the transactions in their local mempool, they can fall back to waiting for the contents of the entire block to arrive. This results in a ~40% increase in overall throughput.

Optimistic block processing

This is how the validators will process the block proposals. Validators will start a process concurrently to optimistically process the first block proposal they receive for any height.

If that block gets accepted by the network, then the data from the cache will get committed. If the network rejects the block, then the data from the cache will get discarded, and future rounds for that height will not use optimistic block processing.

Overall, Optimistic block processing resulted in a 33% increase in throughput. This is because the Twin-turbo consensus is helping Sei get 22k+ orders that are processed each second, all while maintaining close to 450ms block times.

During the proposed step in @Tendermint_Core, a block is proposed and disseminated to other validators. Validators then send prevote and pre-commit messages to each other to agree that this is the block they want to commit.

After the pre-commit message is sent, validators will go through each transaction in the block and execute state changes. If the proposed block does end up getting accepted (which is generally the case) then the candidate state is accepted. Otherwise, it’s discarded. Only the first proposed block per height will be optimistically processed to avoid overloading the validator.

The exact estimated improvement in latency will be min(300ms, N * T) where N is the number of transactions and T is the average latency of a single transaction. With a 1 second block time, there will be an estimated 30% decrease in latency and a 43% increase in throughput.

Full specifics around the proposal can be found at:

https://github.com/sei-protocol/sei-chain/blob/master/docs/rfc/rfc-000-optimistic-proposal-processing.md

Now, we move on to Sei’s Parallelization.

Sei has configured DeliverTx and EndBlock to parallelize transaction processing, which means that transactions are processed in more than one thread at the same time. This results in state changes for most types of transactions being applied during the DeliverTx phase, with the exception of CLOB transactions which have most of their state changes applied during the EndBlock logic.

DeliverTx Parallelization

Rather than processing transactions one at a time during DeliverTx, Sei processes them in parallel. This allows multiple transactions to be processed simultaneously, which leads to improved performance. Sei does this by maintaining a mapping of transaction message types to the keys they need to access (dependency mappings).

Sei knows which resources different types of transactions use, and concurrently runs transactions that don’t touch the same state.

Endblock Parallelization

In this innovation, Sei processes Orderbook-related transactions at the end of the block.

Using this method, two orders become independent if they don’t affect the same market in the same block. If there are dependencies between different markets, they will be defined when a smart contract is deployed. If the dependencies are defined incorrectly, then transactions to the dependent smart contract will fail.

This will allow Sei to handle more orders in the same amount of time, and will also allow Sei to charge lower gas fees. It also helps ensure price fairness and frontrunning prevention.

Native price oracles

The Sei blockchain has a native price oracle to support asset exchange rate pricing. This means that validators (participants in the Sei network) are required to provide accurate pricing information for assets in order to ensure that prices are reliable. To keep the pricing information fresh, voting windows can be configured to be as small as one block long, which results in rapid price updates.

Frequent batch auctioning

Sei’s native order matching engine uses frequent batch auctioning (FBA) to help match and fill trades. Rather than executing trades sequentially, market orders are aggregated at the end of a block and executed at the same price.

As an example, let’s say that the order-book has 2 limit sell orders,

  • one to sell 1 unit of asset ABC for $10, and
  • another to sell 1 unit of asset ABC for $11

Then two market orders to buy 1 unit of that same asset come in — what price would they get filled at?

With sequential execution, the buy order would match the sell orders equally. The first market buy would get filled at $10, and the second one would get filled at $11. Even though both market orders are in the same block, the second order gets a worse price due to its ordering in the block.

This also means that Sequential execution also allows frontrunning.

An example is if a validator sees an incoming market buy for $10 with 2% slippage on an orderbook that only has a limit sell for 1 unit of the asset at $10, so the validator places 2 orders before that incoming market order.

They insert:

  • A market order to buy the asset at $10
  • A limit order to sell it at $10.20

Since there’s no other liquidity on the orderbook, the users’ trade gets filled at $10.20 instead of $10, and the validator profits a risk-free $0.20

With Frequent batch auctioning (FBA), both market orders will get filled at the uniform clearing price of $10.50, and limit orders will get filled at their intended price of $10 and $11 respectively.

Through this mechanism, the ordering of transactions within a block doesn’t matter. Additionally, since orders are being aggregated at the end of a block, validators can’t front-run an order.

So, FBA is helpful in preventing orderbook-related frontrunning within the scope of a single block. But it won’t prevent non-orderbook related MEV (ex. related to an AMM), and multi-block frontrunning.

Competition:

Within the Cosmos, Sei faces some competition in the derivatives market. The most notable of them is dYdX.

But there might be a silver lining…

dYdX handles trades, liquidations, transfers, deleverages, and the updating of oracle pricing based on off-chain logic. This is very different from how Sei functions.

Sei tries to bring as much as possible on-chain.

Sei, if successful, has the potential to be highly disruptive inside and outside of the Cosmos. Should they be able to provide an on-chain orderbook experience that matches or surpasses that of a CEX (or dYdX), they can change the nature of on-chain trading and liquidity.

Conclusion:

Though I don’t see CLOBs killing AMMs, they could certainly overtake a good chunk of AMMs’ market share. There are some apps that depend on an orderbook that as a result have so far struggled to exist on-chain. Should these apps find success on-chain with Sei, it’s likely new builders, users, and TVL will arrive. These would be the individuals who are accustomed to the orderbook experience and wish to continue using them.

Since in TradFi CLOBs have been the norm for over two decades, many are accustomed to them. A hedge fund would be an example of this as rn, if they’re in crypto at all, they’re most likely using a CEX-based CLOB. Hence, they could explore Sei over time.

Should Sei be successful, its thesis on on-chain orderbook design will be proven correct and it will be the first mover. Similar chains with built-in CLOB modules will likely pop up over time but Sei would have the opportunity to capitalize on a first-mover advantage.

The opportunity is clear, now it’s time for the team to execute. Sei’s engineering team has years of experience in big tech as well as in crypto (more specifically in Cosmos). Some have extensive backgrounds in TradFi. So, they seem better positioned to be able to bridge the gaps between DeFi, institutions, and retail.

The Sei Network is an exciting project that has the potential to revolutionize the world of digital asset trading. Today Sei is currently in its incentivized testnet phase called the “Seinami.” Once they have advanced through all of the testnet stages, up next is the mainnet phase.

Sei’s full whitepaper can be found at:

https://github.com/sei-protocol/sei-chain/blob/master/whitepaper/Sei_Whitepaper.pdf

New to trading? Try crypto trading bots or copy trading on best crypto exchanges



[ad_2]

Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here