1

I'm trying to better understand flashbots impact on frontrunning. Can anyone help me understand why this sandwich attack tx from a Flashbots bundle would pay such a high gas price? Here is a similar question but I'm specifically interested in the Flashbots aspect as I thought that would avoid the high-gas requirement.

enter image description here https://gist.github.com/j2abro/7c31b1150ff079a47cf5ff19c5699c7c

Here are the three transactions:

And here are all the flashbot transactions for the block from the Flashbots API.

Any insight appreciated!

2 Answers 2

1

As you already mentioned I found the solution in the following paper, if you are interested you really should read it! 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.

Hope I have helped you to understand it a bit better!

Have a nice day!

2

The reason for this is generally the last transaction in the bundle is the one that pays the miner tip.

Basically, anything in excess of the required gas goes to the miner. It's weird now that Type 2 transactions are the standard. You don't need to directly tip you just include it in the gas price.

I typically have an amount that is a percentage of my expected profits from the simulation, and I add that value to the base fee as a tip for the miner.

Example:

// "PRIORITY_GAS_PRICE" is a variable that I set that is effectively the miner tip.

const gasEstimates = await Promise.all(bundledTransactions.map(tx =>
    provider.estimateGas({
      ...tx,
      from: tx.from === undefined ? walletExecutor.address : tx.from
    }))
  )
  const gasEstimateTotal = gasEstimates.reduce((acc, cur) => acc.add(cur), BigNumber.from(0))
  const block = await provider.getBlock("latest");
  const gasPrice = PRIORITY_GAS_PRICE.add(block.baseFeePerGas || 0);

Good luck, let me know if you have any other questions.

--0xc0ffe3

4
  • So there are (potentially) multiple bundles in a block and it's the last tx in the bundle that pays the miner. But to clarify: it's the tipping miner that gets to specify the order of those 3 txs in the bundle, right?
    – j2abro
    Commented Jul 4, 2022 at 2:20
  • Kind of. Pre-merge the bundle was basically guaranteed to be executed at the top of the block, the first position. Since the merge, there can be multiple bundles included per block, there is a thing called "Proposer-Builder Separation (PBS)" that prevents the people who are proposing the blocks (validators, randomly chosen) from seeing the contents of the blocks, which can only be seen by the block builders. When you submit a transaction or multiple transactions to Flashbots, you send them to one or more of the available relays as a bundle, and specify the order at that point.
    – 0xc0ffe3
    Commented Sep 3, 2023 at 16:11
  • If your bundle is included, the order will be the same as you specified. These bundles are simulated prior to you submitting, and prior to being included in a block, so you won't pay for a failed transaction because it will not be included in a block. The bribe is generally paid in the last transaction so that the fee is not paid unless all transactions are included.
    – 0xc0ffe3
    Commented Sep 3, 2023 at 16:14
  • See ethereum.org/nl/roadmap/pbs for more info from the Ethereum Foundation on PBS.
    – 0xc0ffe3
    Commented Sep 3, 2023 at 16:15

Your Answer

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

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