आर्टेक्सस्वैप से डेक्स की एक और वास्तुकला
ArtexSwap is a decentralized exchange that uses Artela EVM++ and Aspect technology to solve MEV risks and Rug Pull problems, improve transaction security and efficiency, and is suitable for decentralized trading scenarios that require high security and flexibility.
Since the birth of Ethereum, it has been the technological home of digital currency, global payments and applications. DEX is the cornerstone of decentralized finance (DeFi). After all, without DEX, DeFi can be said to be just empty talk. As a platform running on the blockchain, it runs direct transactions between users and is not regulated by any third-party institutions, which allows it to create more advanced financial products.
1. Dex mainstream architecture
At present, DEX is flourishing in the Ethereum ecosystem. There are many different design patterns for DEX, each of which has its own advantages and disadvantages in terms of functionality, scalability, and decentralization. According to the different transaction mechanisms, DEX can be divided into two categories (as shown below).
1.1. Order book based DEX
The order book is essentially a matching algorithm that automatically searches for buy and sell orders that have not yet been signed in various markets. The trading platform system will automatically match these buy and sell orders. It is suitable for scenarios that require efficient price matching and flexible trading strategies. In short, the liquidity of the order book comes from two sources: traders and market makers. For more information, please visit: A Brief Analysis: Order Book Model and Automated Market Making AMM (see Appendix)
1.2. Automated Market Maker (AMM)
Automated market makers (AMMs) are a pricing and liquidity determination mechanism in DEX. Simply put, market makers provide liquidity assets (two assets) to the liquidity pool. The product of the reserves in the liquidity pool is maintained at a value of k. When a user takes a coin, he needs to provide another coin to the liquidity pool to maintain this k value.
For a detailed understanding of AMM, please read: UniswapX Research Report (Part 1): Summarizing the V1-3 Development Link and Interpreting the Principle Innovation and Challenges of the Next Generation DEX
1.3 What value does DEX have?
According to CoinGecKos statistics, as of July 9, 2024, there are approximately 835 known DEX exchanges, with a total 24-hour trading volume of US$8.35 billion and 320 million monthly visits.
The 3 largest decentralized exchanges by trading volume are BabyDogeSwap, Uniswap V3 (Ethereum), and Orca.
We calculated the 24-hour trading volume of the top three DEX and CEX exchanges. DEX accounts for 16% of the daily trading liquidity, and the year-on-year growth rate of DEXs 24-hour trading volume compared to this time in 2023 is 315% (2 billion in 2023), and the trading volume increased by 166% year-on-year (120 million times in 2023). It is obvious that the market demand for decentralized trading platforms is huge.
Since decentralized exchanges (DEX) use deterministic smart contracts to conduct transactions without the intervention of a centralized third party, this transparent operation is in stark contrast to traditional financial markets.
For example, in 2022, FTX, one of the largest cryptocurrency trading platforms at the time, went bankrupt during a series of declines due to the misappropriation of user funds, triggering widespread market shocks.
Additionally, DEXs improve financial inclusion through decentralization, and some CEXs may restrict user access based on geographic location or other factors.
But in general, users only need to access the Internet and connect to a compatible self-built wallet to use DEX services. This model without cumbersome registration and review enables new users to join the platform quickly and conveniently, improving the user experience.
2. Main risks of DEX
Decentralized exchanges (DEX) can ensure the execution of transactions, improve transparency, and can be accessed without permission, which significantly lowers the threshold for trading and providing liquidity. However, DEX also comes with some risks, including but not limited to the following aspects:
-
Smart contract risks: Although blockchain technology can safely execute financial transactions, the security of smart contracts depends on the technical level and experience of the development team.
-
Front-running risk: Due to the open and transparent nature of on-chain transactions, arbitrageurs or MEV robots may preempt transactions and extract value from ordinary users. These robots are similar to high-frequency traders in traditional financial markets, profiting from ordinary users transactions by paying higher transaction fees and taking advantage of network delays.
-
Network risk: Since transactions are conducted on-chain, DEX transaction costs can be high, and they are even higher when the network is congested or down. Therefore, users are vulnerable to market fluctuations.
-
Rug Pull Risk: A common and serious problem in the field of decentralized finance (DeFi), there are a large number of projects that suddenly withdraw liquidity and run away with the funds after attracting a large amount of investor funds. Currently, the risks of Rug Pull can be roughly divided into three categories:
-
Liquidity Withdrawal
-
Developers hold a large number of tokens and/or issue additional tokens
-
Fake Projects
This scam caused heavy losses to investors, and the value of the project instantly dropped to zero. This has had a significant impact on the trust of the entire DeFi market. For example, the SushiSwap incident in 2021 is a typical example. After the project raised a large amount of funds, the anonymous founder of SushiSwap, Chef Nomi, suddenly sold $13 million worth of SUSHI tokens in the developer fund, causing market panic and causing the token price to plummet. Although Chef Nomi later returned the funds and the community took over the project management, this incident caused huge losses and psychological shock to investors.
3. Issues extending from Bancor to DEX
If we talk about who was the first project to try AMM, we have to mention Bancor. It’s a bit pitiful to say that it did not receive widespread attention before the DeFi craze, so many people mistakenly believed that AMM was invented by Uniswap.
Today, with the launch of Bancor V2, although V2 introduces innovative designs such as oracles providing the latest prices and updating the token pool ratio based on oracle prices, it still has some shortcomings.
-
Although the introduction of oracles can provide more accurate price information, it also brings challenges in implementation. For example, if there is no corresponding trading pair price on the centralized trading platform, this creates a chicken-and-egg problem. In addition, the reliability and security of oracles are also worthy of attention. Oracles may become targets of attacks, leading to price manipulation and other security issues.
-
Although the dynamic pool model can update the proportion of the token pool according to the price of the oracle, liquidity providers (LPs) may face greater risk of loss in the case of high market volatility. The greater the market volatility, the more serious the impermanent loss of LPs may be, which may cause liquidity providers to withdraw funds, thereby affecting the stability and trading efficiency of the liquidity pool.
-
Bancor’s design may also face counterparty risk. Although the oracle mechanism has been introduced, if the market price fluctuates violently and the oracle cannot update the price in time, the liquidity provider may still face greater risks. If the oracle price is not updated in time or inaccurately, it may cause LP to lose money in price fluctuations.
Although Bancor V2 introduces many innovative designs, its complexity also increases the learning and usage threshold for users. Compared with other simpler and easier-to-use AMM models, Bancor may require users to have more professional knowledge and technical background to fully understand and utilize its new features. This may limit its user growth and market acceptance.
4. DEX implementation of ArtexSwap
The ArtexSwap platform operates similarly to Uniswap, but with enhanced security through the use of Artela EVM++’s native capabilities.
4.1 Artela’s scalability mechanism
First of all, in order to better understand the underlying environment of ArtexSwap, let us briefly talk about the underlying operating mechanism of Artela. The scalability here actually contains two meanings, namely the scalability and performance of EVM.
For scalability, Artela introduced Aspect technology to implement it. This technology supports developers to create on-chain custom programs in the WebAssembly (WASM) environment. These programs can collaborate with EVM to provide high-performance customized application-specific extensions for dApp.
For more information, please visit: Vitalik Buterin’s full text: The next step for Web3.0 infrastructure: “Encapsulation or extension”? (see Appendix)
From a performance perspective, it is to improve the execution efficiency of EVM. We all know that EVM is a serial virtual machine environment. Compared with todays hardware, the utilization rate of this method is very low, so parallel processing is particularly important.
To achieve parallel execution, how to solve the following problems:
1. How to resolve conflicts between things executed at the same time?
A parallel execution strategy using predictive optimistic execution is adopted, assuming that there is no conflict between transactions in the initial state, and each transaction records the modification but is not finalized immediately.
After the transaction is executed, it is verified to check whether there is any conflict. If so, it is re-executed.
Predictiveness is the use of AI models to analyze historical transaction data, predict transaction dependencies, optimize execution order, and reduce conflicts and duplicate executions.
In contrast, Sei and Monad rely on predefined transaction dependency files and lack the adaptive capabilities of Artela’s AI-based dynamic prediction model, which is Artela’s advantage in reducing execution conflicts.
2. How to increase the speed of IO and reduce the waiting time for transaction execution?
Asynchronous preloading technology is used to solve the input and output (I/O) bottleneck caused by state access. Before the transaction is executed, Artela preloads the required state data from slow storage (such as hard disk) to fast storage (such as memory) through a predictive model. This preloading and caching data technology enables multiple processors or execution threads to access it simultaneously, improving the parallelism and efficiency of execution.
3. How to solve the problem of data expansion during writing and increased pressure on database processing?
Artela has developed a parallel storage system by combining a variety of traditional data processing technologies to improve the efficiency of parallel processing. The parallel storage system mainly solves two problems: one is to realize the parallel processing of storage, and the other is to improve the ability to efficiently record data status to the database. In the process of data storage, common problems include data expansion when writing and increased database processing pressure. To this end, Artela adopts a strategy of separating state commitment (SC) from state storage (SS). This strategy divides the storage task into two parts: one part is responsible for fast processing operations and does not retain complex data structures to save space and reduce data duplication; the other part records all detailed data information. In addition, Artela reduces the complexity of data preservation by merging small blocks of data into large blocks, so as not to affect performance when processing large amounts of data.
In addition, the validator nodes support horizontal expansion, and the network can automatically adjust the size of computing nodes according to the current load or demand. This expansion process is coordinated by the elasticity protocol to ensure sufficient computing resources in the consensus network.
Through elastic computing, the computing power of network nodes can be expanded, and elastic block space is realized, allowing independent block space to be applied for according to demand, which not only meets the expansion needs of public block space, but also ensures performance and stability.
This allows the DEX network to respond calmly to peak transactions like the elastic expansion of Web2.
It is worth mentioning that as a solution for horizontally expanding blockchain performance, elastic block space is based on the premise that transactions can be parallelized . Only after the transaction parallelism is improved, it is necessary to horizontally expand the nodes machine resources to improve transaction throughput. 4.2 ArtexSwaps DEX Security Exploration
4.2 ArtexSwap’s DEX Security Exploration
ArtexSwap has been updated to version 2.0. From the perspective of ArtexSwap’s architecture, it mainly focuses on three security aspects, namely:
-
How can DEX identify and prevent malicious behavior?
-
How to avoid being harmed by Rug Pull during transactions?
-
How to prevent high slippage?
Blacklist Mechanism
The blacklist mechanism is a strategy that puts the focus on security first, because from a behavioral perspective, addresses and users that have participated in bad things are very likely to commit crimes again. By marking accounts, addresses and contracts with dangerous labels, the ArtexSwap platform can conduct a priori analysis of both parties and the environment of the transaction before the transaction. The Blacklist mechanism will continuously monitor transaction activities and eliminate the dangerous elements on the blacklist one by one. When operation requests from blacklisted accounts are detected, these requests will be automatically blocked to prevent malicious behavior.
For example, if an account is blacklisted for having participated in rug pulls or other fraudulent activity, that account will not be able to trade or add liquidity on the DEX, thereby protecting other users from potential losses.
संक्षेप में, ArtexSwap provides a C-end passive defense system with a rear-end focus.
Anti-Rug Mechanism
Rug Pull refers to the situation where developers or large holders suddenly increase the token supply or withdraw most of the funds in the liquidity pool, causing the token price to plummet and investors to suffer huge losses.
This type of situation is usually accompanied by a backdoor in the contract. If the contract reaches this step, it is usually a fish that slips through the blacklist mechanism. Because the blacklist information has a certain lag, there are generally two situations:
-
This contract vulnerability has not been discovered.
-
Did you find any blacklist?
Let’s talk about the first one first. When there is no direct evidence that the token contract is problematic, ArtexSwap generally adopts an optimistic mechanism to deal with it, that is, it assumes that it is safe, but the ArtexSwap platform will always monitor any attempts to significantly increase the token supply. Once such a situation is discovered, it will be blocked, and at the same time other users will be prevented from trading related tokens to avoid losses.
The second method relies on off-chain message communication. When off-chain message communication is enabled, Aspect allows interaction and data exchange outside the blockchain. This allows ArtexSwap to obtain the addresses of relevant malicious contracts from third-party information sources in real time, and then perform security checks on the token contracts on the entire DEX. Once a malicious contract is found, all related operations will be directly blocked.
Slippage Mechanism
It should be made clear that under the liquidity mechanism of AMM, it is highly likely that high slippage will lead to losses. Simply put, slippage refers to the difference between the transaction execution price and the expected price. When the market fluctuates greatly or liquidity is insufficient, slippage will become significant. This is a mechanism problem.
Obviously, the prevention of Slippage is a predictive problem. It is not difficult to solve the problem of insufficient liquidity. The contract of the ArtexSwap platform only needs to monitor the liquidity pool in real time to achieve this goal. The difficulty lies in the volatility of the market, because the market is an external event information. The first thing that comes to mind is to access the oracle to obtain the market status. In order to achieve this, ArtexSwap needs to use its basic operating environment. Artela supports Aspect technology. ArtexSwap uses this to create a dApp on the chain. The dApp can interact with third-party oracles to obtain market fluctuations. Artela supports AI agents, which predict the high slippage of transactions at a certain moment through market status data and AI, and combine the liquidity monitoring mentioned above to obtain an estimated value. When the estimate exceeds a threshold (30%), the transaction is blocked from being executed, thereby protecting traders from losses caused by drastic price fluctuations.
5. Summary
Although we are unsure whether the current DEX model can support long-term growth and institutional adoption, it is foreseeable that DEX will continue to be an indispensable infrastructure in the cryptocurrency ecosystem.
Again, behind every successful scam, there may be a user who stops using Web3, and the DEX ecosystem will have nowhere to go without any new users, so for DEX, losing security means losing everything .
However, under the current hot background of DEX track, the narrative of derivatives seems to be able to flourish. But in the long run, DEX is the most certain demand of users, so no amount of attention is too much.
परिशिष्ट
《Brief Analysis: Order Book Model and Automated Market Making AMM》
This article is sourced from the internet: Another architecture of Dex from ArtexSwap