Home  >  Article  >  With security as the core, another architecture of Dex from ArtexSwap

With security as the core, another architecture of Dex from ArtexSwap

WBOY
WBOYOriginal
2024-07-16 11:33:22512browse

ArtexSwap is a decentralized exchange that uses Artela EVM++ and Aspect technology to solve MEV risks and Rug Pull issues, improving transaction security and efficiency, and is suitable for decentralized trading scenarios that require high security and flexibility. .

Ethereum has been the technological home of digital currencies, global payments and applications since its inception. DEX is the cornerstone of decentralized finance (DeFi). After all, leaving DEX and 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 subject to supervision by any third-party organization, allowing it to create more advanced financial products.

1. Dex mainstream architecture

At present, DEX is blooming in the Ethereum ecosystem. DEX has many different design models, and each model has its own advantages and disadvantages in terms of functionality, scalability and decentralization.

According to different transaction mechanisms, DEX can be divided into two categories (as shown below).

With security as the core, another architecture of Dex from ArtexSwap

1.1. DEX based on order book

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 system of the trading platform will automatically match these buy and sell orders. Suitable for scenarios that require efficient price matching and flexible trading strategies. Simply put, order book liquidity comes from two sources: traders and market makers.

Extended reading: "A Brief Analysis: Order Book Model and Automated Market Making AMM" (see appendix)

1.2. Automatic Market Maker (AMM)

Automated Market Maker (AMM) is a type of pricing in DEX and liquidity determination mechanisms. Simply put, it is a market maker that provides liquid 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 away a coin, he or she needs to provide another coin to the liquidity pool to maintain the k value.

For a detailed understanding of AMM, you can read more: "UniswapX Research Report (Part 1): Summarizing the V1-3 development link and interpreting the principle innovation and challenges of the next generation of DEX"

1.3 What is the value of DEX?

With security as the core, another architecture of Dex from ArtexSwap

[数据来源:THE BLOCK]

According to the statistical results of CoinGecKo, as of July 9, 2024, there are approximately 835 known DEX exchanges, with a total 24-hour trading volume of US$8.35 billion, of which the monthly visits reached 3.2 billion times.

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 exchanges of DEX and CEX. DEX accounted for 16% of the single-day trading liquidity, and the year-on-year growth rate of DEX’s 24-hour trading volume compared to this time in 2023 was 315% (2 billion in 2023), and the transaction volume increased by 166% year-on-year (120 million times in 23). Obviously, the market has a huge demand for decentralized trading platforms.

Because decentralized exchanges (DEX) use deterministic smart contracts for transactions, there is no intervention from a centralized third party. This transparent way of operating 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 amid a series of declines due to misappropriation of user funds, triggering widespread market shocks.

In addition, DEX improves financial inclusion through a decentralized approach, and some CEX may restrict user access based on geographical location or other factors.

But in general, users only need to access the Internet and connect a compatible self-built wallet to use DEX services. This model, which does not require cumbersome registration and review, enables new users to join the platform quickly and easily, 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. These features significantly lower 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:

  1. Smart contract risk: Although blockchain technology can safely execute financial transactions, the security of smart contracts relies on the development team’s ability to Skill level and experience.
  2. Front-running risk: Due to the open and transparent nature of on-chain transactions, arbitrageurs or MEV robots may be the first to trade and capture the value of ordinary users. These bots are similar to high-frequency traders in traditional financial markets, profiting from the transactions of ordinary users by paying higher transaction fees and taking advantage of network delays.
  3. Network risk: Since transactions are conducted on-chain, DEX transaction costs can be high, and the costs will be even higher when the network is congested or down. Therefore, users are susceptible to market fluctuations.
  4. Rug Pull risk: A common and serious problem in the field of decentralized finance (DeFi). There are a large number of project parties that suddenly withdraw liquidity and run away with their funds after attracting a large amount of investor funds. The current risks of Rug Pull can be roughly divided into three categories:
  • Liquidity withdrawal
  • Developers holding a large number of tokens and or issuing additional
  • Fake projects

This scam causes investors to suffer heavy losses, and the project value is instantaneous Return to zero. This has had a significant impact on trust in the entire DeFi market.

For example, the SushiSwap incident that occurred in 2021 is a typical example. Chef Nomi, the anonymous founder of SushiSwap, suddenly sold $13 million worth of SUSHI tokens in the developer fund after the project raised a large amount of funds, triggering market panic and causing the token price to plummet.

Although Chef Nomi later returned the funds and the community took over project management, this incident caused huge losses and psychological impact on investors.

3. The problem of extending from Bancor to DEX

If we say who is the first project to eat the crab of AMM, then we have to mention Bancor. It is a bit pitiful to say that it was not widely popular before the DeFi boom. attention, so many people mistakenly believe that AMM was invented by Uniswap.

Now, with the Bancor V2 version, it was launched. Although V2 introduced innovative designs such as the oracle providing the latest price and updating the token pool proportion based on the oracle price, it still has some shortcomings.

  • Although the introduction of oracles can provide more accurate price information, it also brings implementation challenges. For example, if there is no corresponding trading pair price on a 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 machine, in the case of high market volatility, the liquidity provider (LP) may face a greater risk of loss. The greater the market volatility, the more serious the LP's impermanent losses may be, which may cause liquidity providers to withdraw funds, thus affecting the stability of the liquidity pool and trading efficiency.
  • Bancor’s design may also face counterparty risk. Although the oracle mechanism has been introduced, if market prices fluctuate violently and the oracle cannot update prices in a timely manner, liquidity providers may still face greater risks. Untimely or inaccurate oracle price updates may cause LP to lose money due to price fluctuations.

Although the Bancor V2 version introduces many innovative designs, its complexity also increases the learning and usage threshold for users. Compared with other AMM models that are simpler and easier to use, 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 enhances security by using the native functions of Artela EVM++.

4.1 Artela’s scalability mechanism

First of all, in order to better understand the underlying environment of ArtexSwap, let us first briefly talk about Artela’s underlying operating mechanism. The scalability here actually contains two meanings, namely the scalability and performance of EVM.

For scalability, Artela has introduced Aspect technology for implementation. 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 customization for dApps. Application specific extensions.

Expandable reading: "V God's full text interpretation: The next stop of Web3.0 infrastructure, is it "encapsulation or expansion"? 》(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 today’s hardware, the utilization rate of this method is very high. low, so parallel processing is particularly important.

How to solve the following problems to achieve parallel execution:

1. How to solve whether there are conflicts between things executed at the same time?

Adopts a parallel execution strategy of predictive optimistic execution, assuming that there are no conflicts between transactions in the initial state, and each transaction records modifications but is not finalized immediately.

Verify after the transaction is executed to check whether there is a conflict, and re-execute it if there is any.

Predictability is to analyze historical transaction data through AI models, predict transaction dependencies, optimize the execution sequence, and reduce conflicts and repeated executions.

In contrast, Sei and Monad rely on predefined transaction dependency files and lack the adaptive ability of Artela's AI-based dynamic prediction model, which is Artela's advantage in reducing execution conflicts

2. How to improve IO Speed, reduce waiting time for things to execute?

Adopt asynchronous preloading technology to solve the input and output (I/O) bottleneck caused by state access.

Artela pre-loads the required state data from slow storage (such as hard disk) to fast storage (such as memory) through a predictive model before the transaction is executed. This early loading and caching of data technology enables multiple processors or execution threads to access it simultaneously, improving execution parallelism and efficiency.

3. How to solve the problem of data expansion during data writing and increased pressure on database processing?

Artela combines a variety of traditional data processing technologies to develop a parallel storage system to improve the efficiency of parallel processing. Parallel storage systems mainly solve two problems: one is to realize parallel processing of storage, and the other is to improve the ability to efficiently record data status to the database. During the data storage process, common problems include expansion during data writing and increased database processing pressure. To this end, Artela adopts a strategy of separating State Commitment (SC) and State Storage (SS). This strategy divides storage tasks 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 saving by merging small pieces of data into large chunks, thereby not compromising performance when processing large amounts of data.

In addition, validator nodes support horizontal expansion, and the network can automatically adjust the size of computing nodes based on 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, realizing elastic block space, 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 enables the DEX network to respond calmly to the elastic expansion of Web2 when facing peak trading times.

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 when transaction parallelism is increased, nodes need to be expanded horizontally. Machine resources to improve transaction throughput.

4.2 DEX security exploration of ArtexSwap

With security as the core, another architecture of Dex from ArtexSwap

ArtexSwap has been updated to version 2.0. From the perspective of ArtexSwap’s architecture, it mainly focuses on three security aspects, namely:

  • How to identify and Prevent malicious behavior?
  • How to prevent users from being harmed by Rug Pull when trading?
  • How to prevent high slippage?

Blacklist mechanism

With security as the core, another architecture of Dex from ArtexSwap

The blacklist mechanism is a security-focused strategy, because from a behavioral perspective, the probability of addresses and users who have participated in "bad things" to commit crimes again is very high. By marking dangerous accounts, addresses and contracts, the ArtexSwap platform can conduct a priori analysis of both parties and the environment of the transaction before the transaction. The Blacklist mechanism will continue to monitor transaction activities and exclude "dangers" on the blacklist one by one. Molecule", when operation requests from blacklisted accounts are detected, these requests are automatically blocked to prevent malicious behavior from occurring.

For example, if an account is blacklisted because it has participated in a Rug Pull or other fraudulent activity, the account will not be able to trade or add liquidity on the DEX, thus protecting other users from potential losses.

Essentially, ArtexSwap provides a C-side passive defense system with a back-centered focus.

Anti-Rug Mechanism

Rug Pull means that developers or large holders suddenly increase the supply of tokens or remove 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. Entering this step is usually a fish that slips through the blacklist mechanism. Because there is a certain lag in the blacklist information, the general situation is divided into two types:

1. This contract vulnerability has not been discovered,

2. Has the blacklist been discovered?

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 is safe by default, but the ArtexSwap platform will always monitor any attempt to significantly increase the token contract. The operation of the currency supply will be blocked once such a situation is discovered, 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 conduct security checks on the token contracts on the entire DEX. Once a malicious contract is discovered, all related operations will be directly blocked.

Slippage Mechanism

It needs to be clear that under the liquidity mechanism of AMM, it is a high probability event that high slippage will cause losses. To put it simply, slippage refers to the difference between the transaction execution price and the expected price. When the market is volatile 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. One goal. The difficulty lies in the fluctuation 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 the basic environment for its operation. 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, and Artela supports AI agents, which use market status data and AI to predict the high slippage of transactions at a certain time, and combine it with the previously mentioned liquidity monitoring to obtain an estimated value. The estimated value exceeds a threshold (30% ), prevents trade execution, thereby protecting traders from losses caused by violent price fluctuations.

5. Summary

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 become an indispensable infrastructure in the cryptocurrency ecosystem.

Still saying that, 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, there is a loss of security , that is, losing everything.

It’s just that under the current background of the hot DEX track, the narrative of derivatives seems to be able to flourish for a long time. But in the long run, DEX is the most certain demand of users, so no amount of attention is too much. .

Appendix

"Brief Analysis: Order Book Model and Automated Market Making AMM"

https://mirror.xyz/coincapital.eth/jkCgaKOOtXUn2Iv47y_1npwsyC5Cm0qL3GoVhTUA-IE

"Full Text Interpretation of Buterin: Under the Web3.0 Infrastructure One stop, "encapsulation or extension"? 》https://www.blocktempo.com/is-the-next-step-for-web3-infrastructure-encapsulation-or-extension/

The above is the detailed content of With security as the core, another architecture of Dex from ArtexSwap. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn