MoleEdu DeFi Week: Next Generation No-Chain DEX

Moledao
2023-02-16 18:14:52
Collection
In this class, Mentor Xiong Wei explained what DEX is and its differences from traditional exchanges.

Author: Moledao

The Web3 series of courses co-hosted by Moledao and OGBC has entered the fourth week! The course notes for the second week have also been organized for everyone! The second week was DeFi week, covering topics such as DEX, next-generation non-chain DEX, stablecoins, wallets, custody, and DeFi security.

Today, let's review the "Next-Generation Non-Chain DEX" course by Mentor Xiong Wei from DeFi Week! The course recording has been uploaded to Moledao's Bilibili:

Second Week: DeFi Week | Next-Generation Non-Chain DEX

Mentor Introduction

Mentor Xiong Wei founded everVision in 2022. everVision focuses on the Arweave ecosystem, advocating for the establishment of the ecological autonomous organization PermaDAO, and jointly managing the Arweave SCP Ventures fund with Arweave officials to support the development of ecological projects. Mentor Xiong Wei is also the proposer of the Storage Consensus Paradigm (SCP) and a practitioner and evangelist of SCP WEB3 applications.

Learning Outcomes

In this class, Mentor Xiong Wei explained what DEX is and how it differs from traditional exchanges. He also introduced the traditional DEX Uniswap and explained the advantages of non-chain DEX compared to traditional DEX. He further elaborated on the principles of non-chain DEX.

01 What is DEX

1.1 What are the differences between DEX and traditional exchanges?

The main feature of DEX is censorship resistance and no fund custody. Traditional exchanges, such as the Shanghai Stock Exchange, Shenzhen Stock Exchange, and NASDAQ, are actually centralized institutions under the state for custody. In DEX, no institution will conduct fund custody; it is often locked through smart contracts. Transactions in DEX are also peer-to-peer, where users trade directly with each other or with smart contracts, with no centralized platform involved. This makes funds and personal assets very secure, as they exist on the blockchain network rather than on a server. This is a significant difference between DEX and traditional exchanges.

Before Uniswap existed, there were many protocols attempting to create DEX, but at that time, DEX did not develop well, and the user experience was very poor. The key technological iteration occurred in 2018, when Uniswap was launched and AMM emerged, allowing DEX to enter a new stage. Prior to this, DEX still used an order book model, where orders were placed on-chain or executed off-chain. This DEX experience was very poor, and liquidity was also very low. It wasn't until AMM utilized a very simple mathematical model to create an unattended DEX that the barriers to entry for DEX were truly lowered, allowing more retail investors to enter the market.

02 Traditional DEX - Uniswap

The core principle of Uniswap is the constant product curve, i.e., k=x*y. What Uniswap aims to do is keep the k value constant. In each transaction, Uniswap charges a certain fee, which causes the k value to continuously grow. Users can earn money as the k value increases.

The above image briefly explains the operation mode of Uniswap. Originally, the liquidity pool contained 100 USD and 700 CNY, with a product of 700000. When a user transfers one USD into the pool, the pool's USD becomes 101. To maintain the constant product, CNY will decrease to 693.07. The reduced 6.93 CNY will be returned to the user. The process in the image actually omits the transaction fee. In reality, Uniswap might take 0.01 CNY from this, and the k value would increase. Thus, users can earn money as the k value increases, and they do not need to worry about any matters in the pool, as everything is handled automatically by the smart contract. This greatly lowers the entry barrier for users. However, even though this trading threshold is relatively low, the on-chain transaction fees and packaging processes still result in relatively high transaction times and fees.

Uniswap

03 Advantages of Non-Chain DEX

The emergence of non-chain DEX is due to the discovery that storage facilities like Arweave can be used for new applications, and although the barriers to DEX have been lowered, they are still not user-friendly for ordinary users, such as high transaction fees. Non-chain DEX aims to solve these problems and further lower the entry barriers for users, allowing DEX to truly enter the era of large-scale applications.

3.1 Advantages

  • Like traditional DEX, non-chain DEX is a censorship-resistant peer-to-peer network where anyone can join, deploy Router and LP nodes, and possess censorship resistance, making it impossible to be interrupted or shut down.

  • Infinite scalability. When we use Ethereum DEX, we find that the current TPS is only about 70 to 100, which cannot support large-scale applications. Non-chain DEX can provide greater scalability because much of the content is computed in an off-chain environment.

  • Flexible configuration. As mentioned earlier, Uniswap and Curve DEX choose a relatively fixed curve. These curves are written into smart contracts, so the asset custody process has a defined pricing formula. However, these formulas can incur impermanent loss risks when asset prices fluctuate. In non-chain DEX, these curves can be flexibly adjusted, thereby reducing the risk of impermanent loss.

  • No MEV. All on-chain DEXs have the risk of MEV. This is because on-chain transactions need to be packaged, and this data can be seen by bots; as long as there is any arbitrage opportunity, bots will extract the remaining value. Non-chain DEX can solve this problem.

  • Self-custody of assets. In on-chain DEX, assets are not in the user's wallet; they are often deposited into a smart contract. In new DEXs, issues such as contract audits and liquidity mining can pose certain risks, leading to the loss of deposited funds to hackers. In non-chain DEX, assets are completely self-custodied, making them relatively safe.

3.2 Comparison

Permaswap

04 Principles of Non-Chain DEX

4.1 Disadvantages of the Uniswap Model

Non-chain DEX does not adopt the curves of Uniswap or Curve but instead uses a completely new model, although the underlying principles are still consistent with Uniswap.

In the Uniswap model, calculations and settlements are conducted on-chain. The Uniswap smart contract includes the code for the Router and NFTs. The Router is a service for price aggregation and settlement. NFTs serve as proof that the trading party has deposited assets into the contract, with each NFT corresponding to a liquidity pool under the Router. When users trade, the Router aggregates all NFTs and displays the quotes on the page. After clicking to execute the trade, the transaction is sent to Ethereum for execution. The biggest problem with this model is that each transaction is redundantly executed across thousands of nodes on Ethereum, leading to inefficiency.

4.2 Features of Non-Chain DEX

In non-chain DEX, settlements are still conducted on-chain. To separate settlement from computation, on-chain settlements are streamlined into multi-to-multi atomic orders. This trading structure allows multiple users to transfer to multiple other users. Users need to sign when transferring to ensure they have sufficient funds for the transaction, while the receiving party does not need to sign, ensuring security. If any single transaction fails, the entire transaction becomes invalid.

The above image shows that non-chain DEX changes the Router into a node that operates independently and natively. NFTs are transformed into LP nodes. After this, on-chain computation gradually shifts to off-chain.

The Router is a central node that registers many LPs below it, and each LP node can also register to a Router. This forms a decentralized network without a blockchain. When users access the Router, it can generate an optimal quote for users based on LP quotes. After the user signs, the Router sends the order to the LP for signing. Finally, the order is executed on-chain. The entire aggregation, distribution, and execution can be completed in milliseconds.

LP nodes include automatic quoting programs, and the algorithms (similar to Uniswap's curves) can be set within the LP nodes. After the user signs, the LP node will verify the transaction's legality according to its own algorithm. Each LP can set its own market-making algorithm.

LPs do not need to trust the Router; they only need to verify legality according to their own algorithms. Thus, the entire system is trustless.

This model has infinite performance. Each Router can connect to an infinite number of LPs, and each Router can connect with others through protocols and share liquidity, which is an unimaginable feature in centralized exchanges. Through this model, a global non-chain DEX network with infinite performance can be constructed.

All non-chain DEX data is deployed on Arweave, making it immutable, traceable, and permanently stored.

05 Acknowledgments
Thanks to the following organizations for their support of this public welfare course!
Sponsor Support:
One Global Blockchain Centre (OGBC)
OGBC is a leading incubator for Web 3.0, collaborating with emerging cryptocurrency startups to build the infrastructure of the future. By leveraging OGBC's expertise, network, and resources in the cryptocurrency field, companies and projects can fully realize their potential and strive to develop innovative and valuable solutions for an increasing number of users in the blockchain industry. Other Partner Support: 06 About Moledao

MoleDAO is a blockchain developer community for all blockchain enthusiasts to stay updated on the latest developments in blockchain and grow with the help of experienced blockchain pioneers and innovators, contributing more innovative ideas to build the Web 3 ecosystem.

Our goal is to bring blockchain concepts to everyone and develop the blockchain ecosystem by building a community for blockchain enthusiasts to exchange ideas, providing support for blockchain projects, hosting a series of global hackathons, helping match project talents, and offering project sponsorship and guidance.

Our vision is to become a well-curated one-stop blockchain ecosystem. Whether you are a blockchain enthusiast, a blockchain developer, an institution, or an investor, you can find your suitable position at Moledao.

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
ChainCatcher Building the Web3 world with innovators