On-Chain Arbitrage Bot: Gas Estimation and Bundle Submission
Table of Contents
Table of Contents
Share

Learn how to build on-chain arbitrage bots with Flashbots bundle submission, gas estimation, and MEV-safe execution. Build your competitive edge today.
Frequently Asked Questions
- An on-chain arbitrage bot is a system that detects price discrepancies between decentralized exchanges and executes trades atomically within a single Ethereum transaction. It consists of an off-chain engine that monitors mempools and calculates profit, and an on-chain executor contract that performs the actual swaps. Atomic execution ensures the entire trade either succeeds or reverts, eliminating partial-fill risk.
- Flashbots bundle submission works by packaging one or more signed transactions into a bundle and sending them to a block builder via the eth_sendBundle RPC method. The bundle specifies a target block number and an optional revert-protection flag. Before submission, builders simulate the bundle using eth_callBundle to verify profitability and detect reverts. Accepted bundles are included atomically without appearing in the public mempool, protecting the strategy from frontrunning.
- Gas estimation for an arbitrage bundle involves three steps. First, simulate the full transaction sequence using eth_callBundle or a multicall contract to get an accurate gas used figure. Second, add a safety buffer of 10 to 20 percent above the simulated gas to account for state changes between simulation and inclusion. Third, multiply estimated gas by the current base fee plus your target priority fee to compute total gas cost in ETH, then subtract this from gross profit to confirm the trade is still profitable after fees.
- The revertIfBlockNumberChanged pattern is a safety mechanism used in arbitrage executor contracts. The off-chain engine records the current block number before building the bundle and passes it to the executor contract as a parameter. The contract checks at execution time that the current block number still matches the expected value. If the block has advanced, the contract reverts, preventing the trade from executing in a stale block where the price opportunity no longer exists.
Don't Miss What's Next
Subscribe to newsletter
DeFi
MEV
Arbitrage
Flashbots
EVM
Smart Contracts
Get in Touch
Our team will get back to you within 24 hours.



















