This is a highly confrontational game.
Original Title: “The Way of DeFi丨A Hunt in the Dark Forest of Ethereum: Arbitrage Robot Brutally Arbitrage 130 ETH “
Written by: CodeForcer
Compilation: free and easy
In response to the recent frequent Ethereum sandwich trading (sandwich trading), the developer CodeForcer created an ERC20 bait token called “Salmonella” (Salmonella). In this way, it achieved a profit of 130 ETH within 24 hours. , And this also tells us about the antagonism of the Ethereum network Mempool Dark Forest.
The following is what CodeForcer wrote:
Those who follow the actions of the Ethereum mempool have realized the sudden rise of sandwich trading. For readers who do not understand this concept, sandwich trading is a very interesting strategy. The principle is to trade before and after the victim’s transaction. Arbitrage is achieved through the resulting slippage.
For example, when someone makes an asset transaction, the arbitrageur will buy the same asset before him (artificially raise the price of the currency), and then wait until the other party successfully buys, then the arbitrageur can make a profit after selling it again.
This strategy was very risky in the past, because Ethereum cannot guarantee the success of transactions. Mempool is a very interesting place, but it is not a safe place.
However, with the rise of MEV (miner extractable value) services such as FlashBots , this allows traders to create some “sandwich bundles” in which all 3 transactions are executed or none of them are executed. At the same time, the activities of the miner trading team are also increasing, and they directly incorporate the “sandwich bag” into the blocks they dug.
The combination of these two innovations allows sandwich traders to carry out some “risk-free” arbitrage activities, which makes many people fall into excitement.
But in fact, “risk-free” is not really risk-free.
In order to explain to you the risks of playing games in mempool, I demonstrated a new trading strategy called “Salmonella” (Salmonella‌), which involves the use of common runaway trading settings. The purpose of sandwich trading is to profit from the slippage caused by other people’s transactions, and the purpose of this strategy is to punish the exploiters.
A quick analysis of the blockchain showed that a team named “Ethermine” currently executes most of the sandwich transactions on the market. After determining the initial goal, I began to analyze their settings.
At the time of writing, the setup of Ethermine is quite basic, it relies on Uniswap router to execute transactions, and the transaction history shows that most of Ethermine’s transactions are revert transactions, and its smart contract itself also holds tokens for various failed transactions. After considering this, I set out to create my Salmonella contract.
The premise of the Salmonella contract is very simple. It is a regular ERC20 token and its behavior is exactly the same as any other ERC20 token in normal use cases. However, it has some special logic to detect when someone other than the designated owner is making a transaction. In these cases, it only returns 10% of the designated amount.
Here is the “toxic” transfer function:
function_transfer ( address sender , address recipient , uint256 amount ) internal virtual { require(sender != address(0), " ERC20 : transfer from the zero address "); require(recipient != address(0), " ERC20 : transfer to the zero address "); uint256 senderBalance =_balances [ sender ] ; require(senderBalance >= amount, " ERC20 : transfer amount exceeds balance " ); if (sender == ownerA || sender == ownerB) { _balances [ sender ] = senderBalance - amount ; _balances [ recipient ] += amount ; } else { _balances [ sender ] = senderBalance - amount ; uint256 trapAmount = (amount * 10) / 100 ; _balances [ recipient ] += trapAmount ; } emit Transfer ( sender , recipient , amount ); }
I deployed the Salmonella contract, and then set up a simple Uniswap pool containing Salmonella and Ethereum. Then, I used the binary search method to copy the detection data of the sandwich transaction and created a series of decoy transactions, so that Ethermine and other sandwich traders would think this was an interesting opportunity.
Finally, I wrote an execution architecture that allows me to quickly cancel transactions, change gas prices, and reset the status of the trap Uniswap pool.
After drinking a few cups of espresso, I started to work and issued a series of bait transactions, carefully setting the price slightly below the market gas level to keep the transaction in the mempool, but if the price starts to fall, I cancel Close the transaction.
In less than a few hours, I met the first target and plundered 68 ETH from their robot. After a few more hours, I stole another 35 ETH from their contract.
After one night, I browsed my Salmonella contract and found that my experiment had emptied another 17 sandwich trading contracts. Of course, the amount of funds was much less than Ethermine.
I continued to implement this strategy for a few days, and emptied a bunch of sandwich trading contracts along the way, but as the contract deployers adjusted their settings to better detect my toxic tokens, my alpha strategy quickly became invalid Up.
All in all, this is an interesting experiment, and I now present it to the community as a warning. Becoming a DeFi Corruptor is fun, but you must be careful when trading, because this game is highly confrontational.
See you Mempool!
Source link: www.8btc.com
Disclaimer: As a blockchain information platform, the articles published on this site only represent the author’s personal views, and have nothing to do with the position of ChainNews. The information, opinions, etc. in the article are for reference only, and are not intended as or regarded as actual investment advice.