How to Build Your Own SCP App: A Prototype for Next-generation Blockchainless DEXs

互联网 阅读 689 2021-12-09 21:37:00

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.

How Uniswap Works

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.

The Prototype of the Next-generation DEXs

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:

  1. A user sends a quote request to a router node.
  2. The router node generates the best quote and swap path with information gathered from multiple liquidity providers.
    1. An instance of a bundle swap path: UserA transfers tokenA to lpB, lpB transfers tokenB to lpC, lpC transfers tokenC to userA.
  3. If the user agrees with the quote, he will sign the transaction. And then the route node will ask all the LP nodes involved to sign it. The quote also needs to be confirmed by the LP nodes.
  4. The router node will submit the bundle transaction to everPay for execution after it gathers all the signatures required.

Benefits of the Next Generation of DEXs:

  1. A fully distributed P2P network that cannot be disrupted or shut down. Anyone can deploy a router node or an LP node in the network;
  2. Infinite scalability. Every router node can connect with hundreds of LP nodes and provide aggregation services for tens of thousands of users. An unlimited number of router nodes can be deployed in the network.
  3. No MEV. A user will be paid exactly the same price at which he signs the bundle transaction. If any of the LP nodes fails to pay the corresponding tokens, the entire bundle transaction will be rolled back, which means it does not happen at all.
  4. Ultrahigh asset security. Since LP nodes have their own private key and assets in hand, hackers have to attack them one by one to steal their assets, which means the attack vectors are highly distributed.

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.

Conclusion

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.

免责声明:
1.资讯内容不构成投资建议,投资者应独立决策并自行承担风险
2.本文版权归属原作所有,仅代表作者本人观点,不代表本站的观点或立场
上一篇:How to Build Your Own SCP App: Decentralized News Media 下一篇:Introducing Arweave’s Tech Ecosystem (Part 3)

您可能感兴趣

  • 解读CKB版 “闪电网络” Fiber Network:比特币可编程性扩展的另一种思路
    解读CKB版 “闪电网络” Fiber Network:比特币可编程性扩展的另一种思路

    作者:NingNing行业周期与宏观金融周期共振,加密行业正处在与 2019 年相似的整体性迷茫之中,现阶段不仅流动性枯竭,叙事貌似也在枯竭。市场不但对 VC 叙事兴趣阙如,对反 VC 的 Meme 叙事也已经疲倦。就像每次哲学危机,人们都会回归柏拉图寻找出路,当加密行业危机时,我们也需要回归比特币、回归中本聪。正如 CKB 生态 RGB++ 协议创始人 Cipher 在最新 Blog 里所阐述的,加密行业需要对以太坊 “链上计算” 的路径依赖进行反思,回归P2P经济学,让计算归于链下,让验证归于链上。因

    每日资讯 2024-09-02 12:06 1290
  • 面对NFL球员工会起诉,“退圈”的DraftKings竟主动承认NFT是证券?
    面对NFL球员工会起诉,“退圈”的DraftKings竟主动承认NFT是证券?

    作者:Zen,PANews近日,美国国家橄榄球联盟球员协会 (NFLPA) 指控数字体育娱乐和游戏公司DraftKings 逃避了其 NFT 球员许可协议的付款义务。在放弃NFT业务后,涉嫌出售未注册证券而遭到集体诉讼的DraftKings又背上了一起官司。而有趣的是,在与NFLPA的纠纷中,DraftKings的立场似乎已从反驳转变为积极承认“NFT就是证券”。放弃NFT业务:驳回集体诉讼的动议遭到否决今年7月底,Draftkings在给用户的电子邮件中表示:“经过慎重考虑,DraftKings 决定终

    每日资讯 2024-09-02 12:06 1397
  • 简析两种最新比特币智能合约实现方案:OP_NET与Arch有何区别?
    简析两种最新比特币智能合约实现方案:OP_NET与Arch有何区别?

    作者:Cookie过去半个月,OP_NET 与 Arch 这两个比特币主网上的智能合约实现方案引发了较多的讨论。有意思的事情是,OP_NET 这个名字与大家熟悉的 OP_CAT 很像,都以「OP_」开头,具有很强的、让大家认为这哥俩差不多的迷惑性。所以,在开篇要和大家先提一嘴 OP_CAT。首先,OP_CAT 是比特币操作码,从去年开始有以「量子猫」Quantum Cats,也就是「大巫师」Taproot Wizards 的创始人 Udi Wertheimer 为首的社区力量一直在呼喊要「复活」OP_CA

    每日资讯 2024-09-02 12:06 1299
  • 争议不断,以太坊正在失去“万链之王”的权威
    争议不断,以太坊正在失去“万链之王”的权威

    作者:Climber,金色财经近期围绕以太坊的话题和争议越来越多,不仅 Vitalik 本人需要下场解释观点,就连以太坊基金会也要发布公告来平息社区的质疑声。在本轮牛市周期中,以太坊的表现可谓平平。而美国以太坊现货 ETF 的通过也并未让 ETH 走势如投资者期待般爆发,相反却在币价方面越走越低。这就不免让有着「万链之王」美誉的以太坊逐渐失去投资者和社区的尊重,进而质疑起有关以太坊的方方面面。争议不断,以太坊亟需重塑权威最近一段时间以来社区成员对 Vitalik 言论观点、以太坊基金会乃至以太坊生态系统的

    每日资讯 2024-09-02 12:06 998
  • 从《黑神话:悟空》谈起,GameFi何时能取得真经?
    从《黑神话:悟空》谈起,GameFi何时能取得真经?

    作者:YBB Capital Researcher Zeke前言本文是市场垃圾时间中的一些闲聊,需要对传统游戏市场有一定程度了解。大家可以把这篇文章当作日记或者随想观看,这些只是我在游玩《黑神话:悟空》之后对GameFi的一些粗浅思考,以及对这个赛道未来的看法。一、游戏科学的九九八十一难三天全网销量破千万、Steam玩家同时在线峰值破235万、多家品牌联名周边销售爆火、国家级媒体多次采访、多个游戏取景地可凭游戏通关记录终身免费进入、86版《西游记》YouTube观看量超400万。以上,是《黑神话:悟空》上

    每日资讯 2024-09-02 12:06 689
  • Gavin Wood:如何防止女巫攻击进行有效空投?
    Gavin Wood:如何防止女巫攻击进行有效空投?

    演讲:Gavin WoodGavin 近期一直在关注的女巫攻击(civil resistance)的问题,PolkaWorld 回顾了 Gavin Wood 博士在 Polkadot Decoded 2024 上的主题演讲,想要探究 Gavin 在如何防止女巫攻击上的一些见解。什么是女巫攻击?你们可能知道,我一直在研究一些项目,我在编写灰皮书,专注于 JAM 项目,也在这个方向上做了一些代码的工作。实际上,在过去的两年时间里,我一直在思考一个非常关键的问题,这个问题在这个领域中非常重要,那就是如何防止女巫

    每日资讯 2024-09-02 12:06 1244
  • 市场热议,链抽象将成加密新叙事?
    市场热议,链抽象将成加密新叙事?

    2024年,加密货币领域的技术创新持续加速,链抽象(Chain Abstraction)逐渐成为行业内的焦点。链抽象技术的核心在于通过隐藏底层技术的复杂性,让用户能够更加便捷地在多个区块链之间进行操作。传统的区块链技术通常要求用户掌握不同链的操作流程,并需要应对跨链操作中的技术难题,这极大地吸引了新用户的进入。而链抽象的出现,则为这些问题提供了有效的解决方案,成为Web3建设不可忽视的重要一环。01、什么是链抽象及其作用链抽象能够将不同的区块链之间的差异整合在一个统一的操作界面中,使得用户只需一个账户即可

    每日资讯 2024-09-02 12:05 538
  • 今日日报|马斯克和特斯拉赢得“被指控操纵狗狗币”的诉讼;稳定币支付平台Bridge完成5800万美元融资
    今日日报|马斯克和特斯拉赢得“被指控操纵狗狗币”的诉讼;稳定币支付平台Bridge完成5800万美元融资

    今日要闻提示:马斯克和特斯拉赢得驳回指控他们操纵狗狗币的诉讼OpenAI和Anthropic已同意将其主要新AI模型在发布前共享给美国政府OKX将上线Hamster Kombat(HMSTR)现货交易X平台纽约总部将于9月13日关闭,预计将迁往得州萨尔瓦多总统布克尔成为《时代》杂志最新一期封面人物稳定币支付公司Bridge完成5800万美元融资数据:MATIC、SHIB、UNI代币头部地址持仓均超50%网龙今年上半年通过出售2.9亿元的加密货币,获利5100万元人民币监管消息美国众议院计划在9月举行多场加

    每日资讯 2024-09-02 12:05 1038