A Super 37-Layer Sandwich Trade Including 35 Preys. And They All Have Been Taxed, Attackers Included.
Nothing Is Certain Except Death and Taxes, Even for Sandwich Attackers.
On November 3, 2022, EigenPhi detected a HUGE significant transaction: a sandwich bot sandwiched 35 consecutive swap transactions at block height 15891138 on Ethereum. Similar to the story of a whale getting sandwiched reported in August, this trade gave us another glimpse of the sandwich bots' fancy play. Whatsmore, all the victims and the attacker got taxed by the token they were using.
So let's take apart this WEIRD AND WICKED giant sandwich.
With the help of EigenTx, we can disentangle the details of the entire set of transactions more efficiently.
These transactions were all related to a long-tail asset Peth, a token that appears to have just undergone an initial token distribution campaign. Together with the front-run and back-run transactions, the thirty-seven consecutive transactions occupied 17.8% of the block space from txIndex=0 to txIndex=36. The sandwich robot made a net profit of about $1,558 from this trade.
35 Swaps Got Pinched
In this sandwich bot's activity, 35 different EOA addresses issued the 35 pinched swap transactions, and they were all buying Peth using ETH. Take the transaction with txIndex=1, for example. We show the transaction flow map and CallTrace Tree below.
In this transaction, the user behind the from address bought Peth via calling contract UniswapV2Router02's function, swapETHForExactTokens()
, in 6 steps.
Step0: The user transferred 0.05 ETH to the Router contract.
Step1-2: The Router contract calculated the amount of WETH required to swap out the least amount of Peth (4.9799 Billion) passed in by the caller through the parameter amountOut in the Input Data. It then converted the calculated result, 0.031833688541529089 ETH, into the equivalent amount of WETH.
Step3: The Router contract transferred WETH obtained in step2 to the liquidity pool of Peth-WETH, UNI-V2, for exchange. In principle, the user could receive 4.9799 Billion Peth from the swap.
Step4: But when UNI-v2 called the Peth contract's
transfer()
operation subsequently, it triggered the internal taxing process, and the Peth contract kept 5% of the transfer amount as a tax. Therefore, 248.995 Million Peth flowed back to the Peth contract.
Step5: The Peth contract transferred the remaining 4.730905 Billion Peth to the from address.
Step6: Finally, UniswapV2Router02 returned the unspent balance of 0.018166311458470911 ETH to the from address.
The other 34 Swap transactions all match the same pattern, but the amount of WETH needed to swap out the same amount of Peth grows sequentially. For example, the 35th swap transaction cost nearly 0.1 ETH to swap out 4.9 billion Peth, which is more than three times the cost of the first swap transaction.
One can speculate that these swap users may interact with Peth-related contracts through a user interface to engage in an IDO-like activity. The Peth contract internally limits the amount of Peth a buyer can purchase each time and taxes on purchases at a rate of 5%.
Sandwich Bot in Action
People snapping up this token gives sandwich bots a chance. The bot contract 0x00004ec2008200e43b243a000590d4cd46360000 successfully initiated a front-run transaction at the beginning and a back-run transaction at the end. The following is an analysis of each of these two transactions.
Front-run
In the front-run transaction, the sandwich bot from address called the bot contract and initiated a swap request directly to the UNI-V2 contract, using 1.422392045670034341 WETH in exchange for about 546.073 Billion Peth. Of this amount, 5% was still taxed by the Peth contract's internal process during the transfer operation, leaving 518.769 Billion Peth transferred to the bot contract.
Back-run
The principal paid by the bot in the front-run transaction was paid back in the back-run transaction. Since this transaction involves the reverse conversion of Peth to ETH, the Peth contract has a different internal process. Utilizing EigenTx's visualization tool and CallTrace Tree, it is easy to see what's happening here.
The core purpose of the bot is to convert the 518.769 Billion Peth obtained in the first front-run transaction back to a certain amount of ETH. As you can see from the CallTrace Tree, before executing the swap()
function of the UNI-V2 contract, it first required a call to the Peth contract's transfer()
function. However, this sell transaction was more complex than the previous 36 buy Peth transactions.
We can find the answer by digging deeper into the code of transfer()
in the Peth contract: the function sets a threshold switch on the total balance of Peth it holds, beyond which it will trigger swapBack()
and perform more procedures. While the previous 36 transactions hadn't triggered the button, the last one had.
The Peth contract performed the following six steps in executing the swapBack()
function:
UniswapV2Router02.swapExactTokensForETHSupportingFeeOnTransferTokens
The Peth contract called the UniswapV2Router02's swapExactTokensForETHSupportingFeeOnTransferTokens()
and swapped 16 Billion Peth to 0.308824031526530672 ETH.
0_0_3
It transferred 20% of obtained ETH, i.e., 0.061764806305306134 ETH, to the Peth contract's Owner address Ox1eFE27a04899f3112c914d7D828a73fB2B3DA2D1.
UniswapV2Routero2.addLiquidityETH
The Peth contract called the UniswapV2Router02's addLiquidityETH()
and transferred a total of 0.12352961261061227 ETH (40% of obtained ETH) to the Router contract. After calculation, it successfully added 4 Billion Peth and 0.072000914406550972 WETH to the UNI-V2 contract and obtained the corresponding liquidity pool token 16,937.560828873756839093 UNI-V2. The Router contract returned the unspent 0.051528698204061298 ETH to the Peth contract.
0_0_7
It transferred the remaining 0.175058310814673566 ETH to an EOA address Oxe00385dB0047e43dD044c7191434366ADOEBb286.
Peth.Transfer
The Peth contract taxed 19% of the sandwich bot's selling amount, i.e., 98.556 Billion Peth, which flowed back to the Peth contract and was credited to the Peth project's developer account and marketing account, respectively.
Peth.Transfer
The Peth contract transferred the remaining 420.203 Billion Peth of the sandwich bot to the UNI-V2 contract.
Eventually, the UNI-V2 contract executes the swap()
function to help the bot contract swap out 2.68668795884694026 WETH.
Settlement
The 35 pinched swap transactions spent a total of 1.988114 ETH to exchange for 173.1985 Billion Peth. The swap price was about 87.117 Billion Peth/ETH. The swap price in the sandwich bot's front-run transaction was about 364.714 Billion Peth/ETH. Regarding the back-run transaction, the swap price was increased to 193.089 Billion Peth/ETH. The sandwich bot could sell all of the Peth at a higher price to make a profit.
The revenue from this sandwich trade was 1.264296 ETH.
The total cost of the front-run and back-run transactions was -0.252859 ETH.
Therefore, the profit for the sandwich bot is 1.011437 ETH.
Address Glossary
Sandwich Bot's EOA Address: 0x70b4f501b02f48f943858cdb9961b9c4131f0ddd
Sandwich Bot's Contract Address: 0x00004EC2008200e43b243a000590d4Cd46360000
UniswapV2Router02: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
Uniswap V2: Peth 10 (UNI-V2): 0xb30aa2475303589314257fF8Cb10EE96fD0a1602
Peth Contract Address: 0x15420770691C6ba7cfEC17E467851445bCeB95cf
Peth Contract's Owner Address(EOA): 0x1eFE27a04899f3112c914d7D828a73fB2B3DA2D1
Peth Contract's Related Address (EOA): 0xe00385dB0047e43dD044c7191434366AD0EBb286
Click here to check out our Uniswap grant-winning research: MEV's Impact on Uniswap
Follow us via these to dig more hidden wisdom of DeFi: