Author: Shisijun
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 technical 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, allowing it to create more advanced financial products.
1.DEX mainstream architecture
Currently, DEX is flourishing in the Ethereum ecosystem. There are many different design modes for DEX, each of which has its own advantages and disadvantages in terms of functionality, scalability and decentralization.
Depending on the different transaction mechanisms, DEX can be divided into two categories (as shown below).
![](https://img.jinse.cn/7258740_image3.png)
1.1. DEX based on order book
The order book is essentially a matching algorithm that automatically searches for buy orders and sell orders that have not been signed in various markets, and the trading platform system will automatically match these buy orders and sell orders. Applicable to scenarios that require efficient price matching and flexible trading strategies. In short, there are two sources of liquidity in the order book: traders and market makers.
Extended reading: "A Brief Analysis: Order Book Model and Automated Market Making AMM" (See Appendix)
1.2. Automated Market Maker (AMM)
Automated Market Maker (AMM) is 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 the k value. 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, you can expand the reading: "UniswapX Research Report (Part 1): Summarizing the V1-3 Development Link, Interpreting the Principle Innovation and Challenges of the Next Generation of DEX"
1.3 What value does DEX have?
![](https://img.jinse.cn/7258741_image3.png)
[Data source: THE BLOCK]
According to CoinGecKo's statistics, as of July 9, 2024, there are about 835 known DEX exchanges, with a total 24-hour trading volume of US$8.35 billion, of which the monthly visits reached 320 million times.
By trading volume, the three largest decentralized exchanges 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 DEX's 24-hour trading volume compared to this time in 2023 is 315% (2 billion in 2023), and the year-on-year growth rate of trading volume is 166% (120 million in 2023). Obviously, the market has a great demand for decentralized trading platforms.
Because decentralized exchanges (DEX) use deterministic smart contracts for transactions, there is no intervention from centralized third parties. This transparent operation mode is in sharp contrast to traditional financial markets.
For example, in 2022, FTX, one of the largest cryptocurrency trading platforms at the time, went bankrupt in a series of declines due to the misappropriation of user funds, triggering widespread market shocks.
In addition, DEX improves 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 is also accompanied by some risks, which include but are not limited to the following aspects:
Smart contract risk: 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 public and transparent nature of on-chain transactions, arbitrageurs or MEV robots may preempt transactions and obtain the value of 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: Because transactions are conducted on-chain, DEX transaction costs can be high, and the costs will be 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 money after attracting a large amount of investor funds. At present, the risks of Rug Pull can be roughly divided into three categories:
This scam caused heavy losses to investors and the value of the project instantly returned 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 lot of funds, Chef Nomi, the anonymous founder of SushiSwap, 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, the incident caused huge losses and psychological shock to investors.
3. The problem of extending from Bancor to DEX
If we talk about who is the first project to eat the crab of AMM, we have to mention Bancor. It is a bit pitiful to say that it did not receive widespread attention before the DeFi boom, so many people mistakenly believe that AMM was invented by Uniswap.
Nowadays, with the launch of Bancor V2, although V2 introduces innovative designs such as the oracle providing the latest price and updating the token pool ratio according to the oracle price, it still has some shortcomings.
Although the introduction of the oracle can provide more accurate price information, it also brings implementation challenges. For example, if there is no corresponding trading pair price on the centralized trading platform, this creates a chicken or egg problem. In addition, the reliability and security of the oracle are also worthy of attention. The oracle may become the target of attack, leading to price manipulation and other security issues.
Although the dynamic pool mode can update the proportion of the token pool according to the oracle price, in the case of high market volatility, liquidity providers (LP) may face greater risk of loss. The greater the market volatility, the more serious the LP's impermanent loss 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. The untimely or inaccurate update of the oracle price may cause LP to lose money in price fluctuations.
Although Bancor V2 has introduced many innovative designs, its complexity has also increased 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. ArtexSwap's DEX implementation
The ArtexSwap platform operates similarly to Uniswap, but with enhanced security through the use of Artela EVM++'s own functions.
4.1 Artela's scalability mechanism
First of all, in order to better understand the underlying environment of ArtexSwap, let's 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.
Extended reading: "V God's full text interpretation: The next stop of Web3.0 infrastructure is "encapsulation or extension"? ” (See Appendix)
From the perspective of performance, it is to improve the execution efficiency of EVM. We all know that EVM is a serial virtual machine environment. Compared with today's 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 solve whether there are conflicts between things executed at the same time?
Use a parallel execution strategy with predictive optimistic execution, assuming that there is no conflict between transactions in the initial state, and each transaction records the modification but does not immediately finalize it.
After the transaction is executed, verify whether there is a conflict, and re-execute if there is.
Prediction is to analyze historical transaction data through AI models, predict transaction dependencies, optimize execution order, and reduce conflicts and repeated 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?
Use asynchronous preloading technology to solve the input and output (I/O) bottleneck caused by state access.
Before the transaction is executed, Artela pre-loads the required state data from slow storage (such as hard disk) to fast storage (such as memory) through the prediction model. This pre-loading and caching data technology enables multiple processors or execution threads to access 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 is responsible for fast processing operations, without retaining 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 node supports horizontal expansion, and the network can automatically adjust the scale of computing nodes according to the current load or demand. This expansion process is coordinated by the elastic 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.
When facing peak transactions, the DEX network can also respond calmly like the elastic expansion of Web2.
It is worth mentioning that as a solution for horizontally expanding blockchain performance, the premise of elastic block space is "parallelization of transactions". Only after the parallelization of transactions is increased, it is necessary to horizontally expand the machine resources of the node to improve the transaction throughput.
4.2 ArtexSwap’s DEX Security Exploration
![](https://img.jinse.cn/7258742_image3.png)
ArtexSwap has been updated to version 2.0. From the perspective of ArtexSwap’s architecture, it mainly focuses on three security aspects, namely:
How should DEX identify and prevent malicious behavior?
How to avoid users being harmed by Rug Pull during transactions?
How to prevent high slippage?
Blacklist mechanism
![](https://img.jinse.cn/7258743_image3.png)
The blacklist mechanism is a strategy that puts the focus on security first, because from a behavioral perspective, the addresses and users who 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 participating in Rug Pull or other fraudulent activities, the account will not be able to trade or add liquidity on the DEX, thereby protecting other users from potential losses.
In essence, ArtexSwap provides a C-end passive defense system with a backward focus.
Anti-Rug Mechanism
Rug Pull refers to the sudden increase in token supply or withdrawal of most of the funds in the liquidity pool by developers or large holders, resulting in a sharp drop in token prices and huge losses for investors.
This type of situation is usually accompanied by a backdoor in the contract. This step is usually a slip through the net of the Blacklist mechanism. Because the information on the blacklist is lagging behind, there are generally two situations:
1. The contract vulnerability has not been discovered.
2. Whether the blacklist is found.
Let's talk about the first one first. For those who have no direct evidence that the token contract is problematic, ArtexSwap generally adopts an optimistic mechanism to deal with it, that is, it is safe by default, but the ArtexSwap platform will always monitor any attempt to significantly increase the supply of tokens. Once such a situation is found, it will be blocked, and other users will be prevented from trading related tokens to avoid losses.
The second one relies on off-chain message communication. Aspect allows interaction and data exchange outside the blockchain when off-chain message communication is enabled. 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 are directly blocked.
Slippage mechanism
It should be clear that under the liquidity mechanism of AMM, it is a high probability event to cause losses due to high slippage. Simply put, slippage refers to the difference between the execution price of a transaction 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. 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, thereby protecting traders from losses caused by drastic price fluctuations.
5. Conclusion
Although we are not sure whether the current DEX model can support long-term growth and institutional applications, 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.
It’s just that under the current hot background of the DEX track, the narrative of derivatives seems to be able to thrive, but in the long run, DEX is the most certain demand of users, so no amount of attention is too much.