1

Relating to a single uniswap pool, if I have a sell transaction on the same block as a remove liquidity transaction. Would I still be able to swap if they are removing all the liquidity? Which transaction would go first? If I have a higher maxPriorityFeePerGas say than the remove liquidity transaction would my tx get swapped/confirmed first? Who or what decides the "Position In Block"? Similar question to how do MEV bots frontend buy transactions in the pool?

Someone said to look here at the add method but bit too deep for me... https://github.com/ethereum/go-ethereum/blob/9489853321bb221694f5262772c656413be073af/core/tx_pool.go#L649

So I detect a remove liquidity event in the pool, I instantly put in a sell order that has a higher maxPriorityFeePerGas than the remove liquidity transaction but my "Position In Block" is still after than remove liquidity transaction?

Kai Chan
  • 11
  • 1
  • 1

1 Answers1

0

Generally, higher gas priced transaction comes first. But it depends on the specific block producer.

It's usually most effective for them to order transactions from higher gas price to lower. That's essentialy what the linked code does - plus few other rules like preference of lower-nonce transactions from the same sender and replacement higher gas-priced transactions with the same nonce & same sender.

But this is "just" the most used EVM client software for producing blocks - it's not used by 100% of the block producers, and these sorting parameters are not enforced on the network level (there's currently no way to enforce them).

For example MEV block producers usually order by different set of rules defined by them. It might be on a first-come first-served basis, or they can prefer some of their own transactions no matter the gas price, they can whitelist/blacklist senders, reorder transactions before the block is published to perform their own frontrunning, etc.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • You are incorrect with your facts. Most Ethereum block producing is MEV enabled, so gas fees and transaction ordering depend mostly on the fact what's more profitable for the block producer. – Mikko Ohtamaa Jul 31 '23 at 06:37
  • 1
    @MikkoOhtamaa I didn't know that - thanks for clarification. – Petr Hejda Jul 31 '23 at 07:39