3

I am currently watching into vulnerabilities and different threats for DEXes. I found some sandwich attacks or front running, that use moderate-high Gas Fees on Buy and crazy high Gas fees on the sell. Why is this so?

I mean almost the whole drain was used on fees. Furthermore why are is does the buy of the "victim" have lover fee than the actual attack?

Can someone explain that to me?

Here is an example: Contract Name: Feudalz Goldz $GOLDZ Contract Adress: 0x7be647634a942e73f8492d15ae492d867ce5245c

Buy Front Run: Buys 2.71431 $ETH to $GOLDZ GAS: 29 https://etherscan.io/tx/0x89fe9891aa8e6361914b270b0a77353ea4d7384b33e657f0afc7d0204a9eac92

Victim Buy: Buys 1 $ETH to $GOLDZ GAS: 31 https://etherscan.io/tx/0x36fb94763cbd415ed3b05def8b6488c014b255b5a106d10f80d1befe72864ec3

Sell Front Run: Sells 2.86919 worth $GOLDZ to $ETH GAS: 1,612 equvalent of 0.1516 ETH https://etherscan.io/tx/0xcceb888f77b56b72f15a6e1a720cb0d99a88e2aa7e2486b9fe47c85e7f079a4f

As I see it they drained 0.1548 and paid 0.1516 for fees what makes them earn only 0.0032. Is this correct?

1
  • I posted a similar question. My question is Flashbots specific, but I noticed a similar pattern of ascending gas prices for the sandwich, which is counterintuitive.
    – j2abro
    Apr 20, 2022 at 23:43

3 Answers 3

1

The answer is that the bribe for the entire bundle is sent with the backrun tx. This way, the bribe is only paid if all of the transactions, likely three (frontrun, victim, backrun) are included in the block.

Essentially you calculate the bribe based on the revenue from the bundle, accounting for the gas consumption of all TX's in the bundle, and tacking on the bribe to the backrun TX (which should be a portion of the revenue, but not so high that it becomes unprofitable, but also high enough that the bundle is selected by the builder and not someone elses who happens to submit the same sandwich (or similar) with a higher bribe).

Good luck, it's crazy out here.

Edit: When you submit a sandwich bundle, you aren't actually "frontrunning" the victim TX in the traditional sense of the word, ie: by paying a higher gas price in order to get your TX positioned ahead of the victim TX. You are basically plucking their TX out of the mempool and wrapping it in a buy and a sell, and then submitting that as an atomic bundle to a flashbots relay (or more than one relay) for inclusion in a block. The gas price paid for the "frontrunning" transaction doesn't really matter. What matters is the bribe that is paid for block inclusion. Obviously it has to be done before the victim TX is included in a block, but the frontrun gas price doesn't matter. Just has to be >= the base_fee_per_gas for the block it's included in.

0

The whole point of the sandwich attack is to sandwich the attacker by inserting two transactions, one before and one after.

To get in front of the attacker transaction, you need to pay more gas fees than the attacker. Once the attacker transaction is mined, you need to place sell order to make a profit.

The sandwich bots are built to make a profit. As long as there is profit, they will perform the attack.

2
  • Ok, but isn't it wasted on the sell? I mean if I would program that, I would put more on the Buy rather then the sell or am I missing something?
    – Stevie
    Apr 7, 2022 at 15:35
  • I see; I am not sure why they paid this much gas fees.
    – Emrah
    Apr 7, 2022 at 15:54
0

I found the solution in the following paper, if someone is interested here is the paper: https://pub.tik.ee.ethz.ch/students/2021-FS/BA-2021-07.pdf

Basically, there are a lot of bots trying to win the "Flashbots Auction". In the beginning, there weren't as many bots that tried to do this so there was much more profit to be made. Nowadays the profit is spent to bribe the Miners to take their transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.