Decentralized applications do not have to be built on a public blockchain like Ethereum.
When we are talking about DEXs, we generally refer to smart contract programs that run on Ethereum like Uniswap. This post will describe how to build a DEX in a new way that combines the automated market-making capabilities of Uniswap and the same security properties as blockchains. Even better, the new DEX model provides nearly infinite scalability without the risk of MEV.
The concept of automated market making originates from Uniswap. Hence, a new type of DEXs cannot be built in isolation from the design philosophy behind Uniswap, that is, using the simplest algorithm in combination with a blockchain to allow every user to be a market maker in place of specialized agencies.
The overall architecture of Uniswap v3 is shown in the figure above. The smart contracts of Uniswap v3 are executed in the EVM, which is run by every geth node. Hence, the computation process of v3 is performed by thousands of nodes, which reach a consensus via the PoW mechanism.
Take a closer look at the smart contracts of Uniswap v3. What Uniswap v3 essentially does is to aggregate NFTs by using the Router. Behind each of the NFTs is a liquidity pool provided by an individual user who sets a specific bonding curve and a price range for market-making. When a user sends a quote request to a v3 smart contract, the Router will generate the current best price by performing an aggregation computation. The user will sign a transaction at that price and send it to the Uniswap contract for execution. The transaction will lead to synchronous update of multiple NFTs, ensuring that the swap functionality of Uniswap is secure and reliable for users.
Before creating a prototype, you need to learn about everPay and its bundle transaction. everPay is a blockchain-based financial infrastructure that combines Arweave and SCP. By offering real-time transfers and a verifiable ledger, everPay allows users and developers to conduct token settlement in real time.
In everPay, a bundle transaction is a type of opAction. It allows a many-to-many transfer that requires the signatures of all transfer parties. If any of the subtransactions in a bundle transaction fails, the entire bundle transaction will be rolled back. Generally speaking, a bundle transaction is a many-to-many transactional transfer functionality.
Now that you have learnt about how Uniswap v3 works, you can build a new generation of DEXs on top of the SCP basics and everPay's bundle transactions.
Firstly, the Router Contract in Uniswap v3 can be replaced by router nodes. A router node is a routing gateway node that can be deployed by anyone to collect the information of liquidity providers (LPs). Similar to the Router in v3, a router node can obtain the best price and swap path by performing aggregation computations when receiving a quote request.
Secondly, the NFTs in Uniswap v3 can be replaced by LP nodes, which are in control of a private key and an automated signature program. The LP node program will make quotations and sign bundle transactions according to the user-defined curve and price range. When an LP node starts, it will connect with router nodes and submit quote information to them. Router nodes will send valid bundle transactions to LP nodes, which will sign the ones in compliance with their own market-making rules. The successfully signed transactions will be sent back to router nodes.
Transaction process:
Benefits of the Next Generation of DEXs:
Such a network offers an optimal user experience. You only need to access the UI that connects to a router node and then sign your transaction at the price provided by the router node. Since the router node communicates with all the LP nodes that connect to it by using websocket, the transaction can be signed in seconds and then executed by everPay in real time. In addition to the high-speed transaction processing, you can also benefit from no slippage because the quote you are offered is what you finally get. In this way, you do not need to worry about any MEV extraction conducted by flashbots, which is commonly seen on Ethereum.
The only drawback is that becoming an LP needs to run a node, but there are workarounds. For example, your mobile wallet can be an LP node. As long as you set a price range and select a market-making curve on your phone, you can utilize the idle assets in your wallet for automated arbitrage. You can participate in the DEX's swap network as if you were playing online games, and the program on your phone will stay online and conduct automated market-making according to your custom rules.
As is shown in the prototype above, we can build a decentralized application without any on-chain smart contract at an extremely low cost. Such a development mode conforms to the mindset of Web2 developers. We can expect that the rise of the Web3 era will go beyond blockchains and EVM and bring out more paradigms for building Web3 applications. The SCP proves to be an excellent option for Web3 development by providing applications with the immutability and traceability of blockchains as well as the scalability of large-scale systems.