banner-(1).png
2023-10-31

Hardened over time: MEV resistance of Permaswap

Web3 is booming, and Arweave is becoming a popular infrastructure choice for developers. PermaDAO is a community where everyone can contribute to the Arweave ecosystem. It's a place to propose and tackle tasks related to Arweave, with the support and feedback of the entire community. Join PermaDAO and help shape Web3!

Author: Spike @ Contributor of PermaDAO

Translator: Spike @ Contributor of PermaDAO

Reviewer: Saiee @ Contributor of PermaDAO


1. Definition and background of MEV

MEV (Maximal Extractable Value) refers to a blockchain transaction where, due to the order of transactions and the way blocks are packaged, miners or other participants have the opportunity to obtain additional value in an unfair way. This extra value mainly comes from the adjustment of the transaction order, including the reordering of the transaction order, the pre-run and post-run of the transaction, etc.

MEV arises due to the transparency and immutability of blockchain. In the traditional financial system, the order and execution of transactions are controlled by a centralized authority, while on Ethereum, the order of execution of transactions is determined by miners. This opens up opportunities for some malicious participants to gain additional benefits by reordering transactions or selectively executing them. This means that miners can choose to package their transactions before or after other transactions to gain additional benefits. This benefit can come from pre-processing, where they execute their own transactions before executing other transactions to reap the benefit. Or it can come from the post-operation, where you execute your own trades after executing other trades and get a profit from them.

To cope with MEV's problems, several solutions have been proposed. One of the solutions is to use the randomness of the blockchain to determine the execution order of transactions to reduce the room for manipulation by miners. Another solution is to introduce new protocols and mechanisms, such as zero-knowledge proofs, to increase the privacy and security of transactions.

MEV is a growing problem in the DeFi field. Due to the open and transparent nature of DeFi applications, malicious participants can more easily exploit MEV for additional gains.

MEV's profit can come from the order in which transactions are executed, such as Front-running and Back-running, or from the visibility of transactions, such as flash lending attacks.

Alternatively, MEV can be achieved through flash loan attacks. Flash lending is a form of collateral-free lending where borrowers can borrow and return funds in the same block. Flash lending can be used to attack by malicious users, who can first borrow money in the same block, then use the borrowed funds for other operations, and finally return the loan. In this way, they can get extra benefits without paying any fees.

2. The challenges and impact of MEV

MEV (Maximal Extractable Value) has a number of implications and challenges for the DeFi ecosystem. Here are some typical aspects:

  1. Pre-operation challenge: Due to MEV, the order in which trades are executed becomes critical. Malicious users can obtain a favorable transaction execution order by performing algorithmic operations before the transaction execution, thus gaining additional revenue. This brings unfairness and instability to the DeFi ecosystem.

  2. Liquidity challenges: MEV also poses challenges for liquidity providers. As malicious users can exploit MEV for additional gains, liquidity providers may face the risk of being squeezed. They need to weigh the risks and benefits and take corresponding measures to protect their interests.

  3. Market Manipulation Challenge: MEV can be used to manipulate market prices and trading volumes. Malicious users can influence the market price and trading volume by choosing a favorable order of trade execution, thus obtaining additional gains. This brings instability and unfairness to the market.

  4. Data trustworthiness challenges: Due to MEV, the order in which trades are executed may be tampered with, leading to the trustworthiness of trading data being questioned. This brings the challenge of data trustworthiness to the DeFi ecosystem, and corresponding measures need to be taken to ensure the accuracy and integrity of data.

In response to these impacts and challenges, the DeFi ecosystem is actively exploring and implementing some countermeasures and solutions. For example, several projects are researching and developing new transaction execution sequence algorithms to reduce the impact of MEV. Meanwhile, some liquidity providers are also taking measures to protect their interests, such as by limiting the size of transactions or using dynamic fee models to cope with the risk of MEV. In addition, some regulators and industry organizations are also strengthening the supervision of the DeFi ecology to ensure the fairness and stability of the market.

2.3 Risks and impacts of MEV on users

A common MEV risk is "transaction order dependence". On Ethereum, the order in which transactions are executed is determined by miners, who can reap additional benefits by reordering transactions. For example, a user sends two transactions in a block, one to buy cryptocurrency and the other to send cryptocurrency to another address. A malicious miner can make extra profit without the user's awareness by reversing the order of the two transactions, sending the cryptocurrency to his address first and then buying the cryptocurrency later.

Another MEV risk is "information leakage". Due to the transparency of transactions, malicious miners can gain access to sensitive information in the market by observing the execution of transactions. For example, when a user tries to make a large transaction on a decentralized exchange, malicious miners can judge the user's intention by observing the execution of the transaction and manipulate in the market, thus causing losses to users.

To cope with the MEV risk, some projects and protocols have proposed some solutions. Flashbots, for example, is a project that aims to reduce the impact of MEV on users by working with miners to send users' transactions directly to miners, thus avoiding the problem of transaction order dependency. Another solution is to use zero-knowledge proofs (zk-SNARKs) to hide the details of transactions, thus preventing information leakage.

3. Countermeasures and technical solutions for MEV

MEV-bot

Miner Extractable Value (MEV) refers to the value that a miner can potentially obtain in a transaction, and Front-Running is a common method of MEV attack. To deal with this attack, several technical solutions have been proposed, one of which is the solution of front-running transaction queue.

One solution is to defend against the front-trading queue attack by introducing MEV-bot. MEV-bot is an automated program that monitors and analyzes transactions in a trade pool and takes corresponding measures when it detects a front-end trade queue attack. For example, when a transaction is detected as a potential front-trade queue attack, MEV-bot can immediately execute an adversarial transaction to protect the interests of the user.

The Application of Flash Loans

Flash loans are a technical solution widely used in DeFi that allows users to borrow and repay in the same transaction without putting up any collateral. The application scenarios of this technology are very wide and can be used in arbitrage trading, liquidity provision and risk management, among other things.

One of the use cases of flash lending is arbitrage trading. Through flash lending, users can borrow a large amount of money in a short period of time and use the money to carry out arbitrage operations. For example, a user can borrow a certain amount of tokens, sell them at a higher price, and then immediately repay them and earn an arbitrage profit. This operation can be done in an extremely short period of time to maximize profits.

However, flash lending also has certain risks, mainly caused by the uncertainty of the transaction. In order to prevent the risks in flash lending, some preventive measures have been proposed. First, smart contracts should strictly verify and control the lending behavior, ensuring that the borrowed funds can only be used for specific purposes and avoid malicious use. Secondly, the execution of transactions should be completed in the same block to prevent other transactions from interfering with the flash lending process. In addition, monitoring and analysis tools can also be used to detect and prevent potential risks.

In summary, flash lending, as a technological solution, has been widely used in DeFi. It can be used in arbitrage trading, liquidity provision and risk management, among other things. However, in order to guard against the risks in flash lending, some preventive measures need to be taken, including verification and control of lending behavior, the same block execution of transactions and the use of monitoring and analysis tools.

Privacy Protection and Application of Transaction Obfuscation Techniques

In DeFi, in order to deal with the invasion of user privacy by MEV, some privacy protection and transaction obfuscation techniques have been widely used. These technologies aim to hide users' real identities and transaction behaviors, thereby protecting users' privacy and security.

A common privacy-preserving technique is Zero-Knowledge Proofs (ZKP). With ZKP, a user can prove to a verifier that a statement is true without revealing any specific information related to the statement. In DeFi, ZKPS can be used to verify a user's fund balance, the legitimacy of a transaction, etc., while protecting the user's privacy.

Another technique to cope with MEV is transaction obfuscation. Transaction obfuscation techniques make the origin and destination of a transaction untraceable by mixing multiple transactions together. In this way, even if the MEV miner obtains the transaction information, it cannot accurately determine which transactions are the real transactions of the user. The transaction obfuscation technology can be realized by using smart contracts or special transaction protocols.

For example, Mixers are a common transaction obfuscation technique. Mixers obfuscate the true source and destination of transactions by mixing together funds from different users before redistributing them to different addresses. This way can effectively protect the privacy of users, making it impossible for MEV miners to accurately track the user's transaction behavior.

In addition to Mixers, there are other transaction obfuscation technologies, such as Tornado Cash, which has been sanctioned by the US government. All these technologies can be applied in DeFi to protect users' privacy and security and reduce the impact of MEV on users.

3.2 MEV-Guard Technology

MEV (Maximal Extractable Value) is an important problem in DeFi, which refers to miners making extra profit by reordering or selectively executing trades when they package them. To solve MEV problem, many projects and researchers have proposed various countermeasures and techniques. One common technique is MEV-Guard.

Mev-guard is a technique designed to reduce the loss of MEV to the user. It works by checking and verifying transactions before they are executed to prevent malicious miners from manipulating the order of transactions or selectively executing transactions. MEV-Guard can be implemented in the following ways:

  1. Transaction Ordering Randomization: MEV-Guard can use a randomization algorithm to order transactions, making it impossible for miners to predict the order of transactions, thus reducing their chances of manipulating the order of transactions.

  2. Transaction Execution Delay: MEV-Guard can introduce a certain delay to execute transactions in order to give other miners time to compete for the packaged transactions. This can reduce the chance of miners selectively executing transactions, thus reducing the impact of MEV.

  3. Transaction Execution Order Verification: MEV-Guard can verify the order of transaction execution to ensure that miners are not maliciously selectively executing transactions. This can be achieved by using cryptographic proofs or consensus algorithms.

4. Typical Applications and Use Cases

4.1 Uniswap and MEV

With the continuous development of blockchain technology, the application of Uniswap in DeFi (Decentralized Finance) has gradually grown, and the MEV (Maximal Extractable Value) problem has gradually become a difficult problem in the Uniswap ecosystem. In the field of DeFi, Uniswap is a very typical application, but it also faces the problem of MEV. As a decentralized exchange, Uniswap cannot avoid MEV.

A common method of MEV attack is the front-running attack, which is to obtain trading information before trading and execute trades in the trading pool at a higher price, so as to gain extra profit. This type of attack is particularly harmful for Uniswap because its trades are based on a publicly available trade pool where anyone can view and execute trades.

To combat the MEV problem, Uniswap introduced a mechanism called flash loan. Flash loans allow users to borrow and perform actions in the same transaction, which prevents others from carrying out pre-run attacks in the process. With flash loans, users can borrow money and make a transaction in the same transaction, while the funds are paid back after the transaction is completed.

For example, a user can use a flash loan to carry out an arbitrage trade on Uniswap. Users can borrow a certain amount of cryptocurrency and then use the funds to trade between different trading pairs, from which they can make a profit. Due to the characteristics of flash loans, others cannot carry out pre-run attacks in the process of the user's transaction, which guarantees the benefit of the user.

More specifically, the processing methods can be divided into the following three categories:

  1. Uniswap's solutions: flash loans and transaction delays

The first is the flash lending mechanism, which reduces the possibility of MEV attacks by replacing traditional dealmaking procedures with short-term loans on the same block chain. Secondly, Uniswap also introduces a transaction delay mechanism, that is, transactions are processed with a certain delay to prevent them from being exploited by malicious miners.

  1. DEX Aggregator and order slippage

Another way Uniswap deals with MEV issues is to reduce the impact of order slippage by using DEX aggregators. A DEX Aggregator can aggregate liquidity from multiple decentralized exchanges for better trading prices and execution. The use of DEX Aggregator can reduce the transaction cost caused by order slip, which in turn reduces the incentive for miners to utilize MEV.

  1. Uniswap V4

The V3 version being developed by Uniswap also has some improvements to the MEV problem. It offers more flexible liquidity management tools that give liquidity providers better control over how their funds are used.

4.2 SushiSwap and MEV

SushiSwap is a decentralized exchange platform (DEX) that improves upon and innovates upon Uniswap.

The MEV problem of SushiSwap mainly involves the order of transactions and the priority of transaction execution. In SushiSwap, the order and execution of transactions are determined by miners, which gives miners the opportunity to manipulate the transaction order to obtain additional revenue. Miners can adjust the order of transactions so that some transactions are executed before others, thereby obtaining more arbitrage opportunities.

To solve this problem, SushiSwap introduces a new mechanism called "transaction distribution". In transaction distribution, transaction fees are distributed to multiple participants, including miners, liquidity providers, and users holding SUSHI tokens. The introduction of this mechanism can reduce the incentive for miners to manipulate the order of transactions, as they cannot obtain all the transaction fees alone.

4.3 Relationship between other DeFi applications and MEV

Besides decentralized exchanges and lending platforms, there are other applications and use cases in DeFi that are closely related to MEV (Maximal Extractable Value).

A prime example is decentralized prediction markets. Prediction markets allow users to participate in the prediction of events, such as the outcome of an election, the outcome of a race, etc., by buying shares that predict the outcome. However, MEV can cause some problems in prediction markets. Due to the uncertainty of the trading order, some participants may use MEV to gain an information advantage and thus influence the prediction results. For example, a malicious participant can distort the market prediction results by trading for his own benefit while other traders have not yet executed.

To solve this problem, some prediction market platforms have taken some measures. For example, some platforms will delay the processing of trades in order to gather enough information before they are executed. Alternatively, some platforms will batch the transactions to reduce the impact of MEV on the prediction results.

Another typical example is decentralized insurance. In decentralized insurance, users can buy insurance products to protect their digital assets. However, insurance claims may be affected due to MEV. Malicious participants can use MEV to manipulate the insurance market, for example by buying an insurance product prior to an insurance claim and then selling the insurance product at a higher price when the claim is made.

To combat this problem, some decentralized insurance platforms have taken some measures. For example, some platforms review insurance claims to ensure they are legitimate. In addition, some platforms will dynamically adjust the price of insurance products to reduce the profit margin of malicious participants.

5. Permaswap's advanced anti-MEV path

Different from DEX applications based on Ethereum and other chains, Permaswap is a cross-chain DEX based on Arweave network. Specifically, its design concept is based on SCP (Storage-based consensus paradigm) and everPay, which can be regarded as the transaction module of everPay. It can also be used as a standalone DEX.

The core concept of SCP is to separate storage and computation. All computation is done off-chain, and the results are synchronized to Arweave. Therefore, there is no technical limit to the TPS of Permaswap, which only depends on the application architecture and server performance of Permaswap. In theory, the TPS of Permaswap can be comparable to the TPS of traditional payment applications of tens of thousands and billions.

Based on this, Permaswap does not have a theoretical transaction speed limit, and it is a completely real-time transaction. Each node must stay online at all times to participate in the current transaction process. Therefore, any transaction does not need to wait, and the transaction only has any state between success or failure. Thus, it can achieve 0 Gas Fee and millisecond response speed.

Because there is no long block sorting on the chain to complete the transaction, Permaswap has full MEV resistance characteristics, whether it is high-frequency trading or large-value trading, there is only slippage loss, but no MEV attack possibility.

6. Summary

This article starts with the development of MEV, gradually discusses the historical evolution of MEV, its dangers and impacts in DeFi, and points out that Permaswap can avoid MEV attacks from its original design.


🔗 More about PermaDAO :Website | Twitter | Telegram | Discord | MediumYoutube

Tagged with In MEV Permaswap

Sign up for newsletter

Sign up here to get the latest news and updates delivered directly to your inbox.