Skip to content

Instantly share code, notes, and snippets.

@dvush
Last active June 15, 2023 12:24
Show Gist options
  • Save dvush/a325716b498727e65559bd167f43ccb1 to your computer and use it in GitHub Desktop.
Save dvush/a325716b498727e65559bd167f43ccb1 to your computer and use it in GitHub Desktop.
mev_sendBundle how to

eth_sendBundle

{
  blockNumber: "0xb",
  txs: ["0xraw_tx_1", "0xraw_tx_2"],
  revertingTxHasher: ["0xtx_2_hash"]
}

mev_sendBundle

{
  version: "v0.1",
  inclusion: { block: "0xb" },
  body: [{ tx: "0xraw_tx_1" }, { tx: "0xraw_tx_2", canRevert: true }],
}

Without refund address

To send send 80% of profit made by "0xraw_tx_backrun" to the origin of tx "0xraw_tx_target"

eth_sendBundle

{
  blockNumber: "0xb",
  txs: ["0xraw_tx_target", "0xraw_tx_backrun"],
  refundPercent: 80,
}

mev_sendBundle

{
  version: "v0.1",
  inclusion: { block: "0xb" },
  body: [{ tx: "0xraw_tx_1" }, { tx: "0xraw_tx_2" }],
  validity: { refund: [{ bodyIdx: 0, percent: 80 }] },
}

With refund address

eth_sendBundle

{
  blockNumber: "0xb",
  txs: ["0xraw_tx_target", "0xraw_tx_backrun"],
  refundPercent: 80,
  refundRecipient: "0xrefund_rec",
}

mev_sendBundle

const innerBundle = {
  version: "v0.1",
  inclusion: { block: "0xb" },
  body: [{ tx: "0xraw_tx_1" }],
  validity: { refundConfig: [{ address: "0xrefund_rec", percent: 100}] }
}
{
  version: "v0.1",
  inclusion: { block: "0xb" },
  body: [{ bundle: innerBundle }, { tx: "0xraw_tx_2" }],
  validity: { refund: [{ bodyIdx: 0, percent: 80 }] },
}

backrun tx (or bundle) with hash "0xtarget_hash" using tx "0xraw_tx_backrun"

{
  version: "v0.1",
  inclusion: { block: "0xb" },
  body: [{ hash: "0xtarget_hash" }, { tx: "0xraw_tx_backrun" }],
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment