Flashbots Protect vs Public Mempool: MEV Protection Explained
Flashbots Protect vs public mempool: how private order flow blocks sandwich bots and front-running, and when public broadcast is still the smarter call.
{"excerpt":"Flashbots Protect vs public mempool: how private order flow blocks sandwich bots and front-running, and when public broadcast is still the smarter call.","tags":["MEV","Flashbots","Ethereum","Trading Bots","Smart Contracts"],"cover":"crosshair","content":"A trade sent to the public mempool on Ethereum sits in plaintext for anywhere from a few hundred milliseconds to several seconds before a block includes it. During that window every searcher running a mempool scanner can see your exact swap — token in, token out, amount, slippage tolerance — and simulate a sandwich against it before you're confirmed. Flashbots Protect exists to close that window. It routes your transaction straight to block builders instead of the public p2p network, so the only parties who ever see it are the ones building the block it lands in.\n\nThis matters for anyone running an EVM trading bot, not just retail swappers clicking through a DEX front end. If you're operating a market-making strategy, a liquidation bot, or anything that touches AMM pools with real size, mempool visibility is a direct tax on your PnL. The question isn't whether private order flow helps — it does — it's when the tradeoffs (inclusion latency, builder dependency, opt-in revert behavior) are worth it.\n\n## How the public mempool actually exposes you\n\nWhen you broadcast a standard transaction, it propagates through Ethereum's gossip network to thousands of nodes, including the mempool-scanning infrastructure run by every serious MEV searcher. A sandwich bot watching for large swaps does roughly this:\n\n1. Detects your pending swap via a mempool subscription (eth_newPendingTransactionFilter or a direct node feed).\n2. Simulates the price impact of your trade against the pool's current reserves.\n3. Front-runs with a buy, lets your trade execute at the worse price, then back-runs with a sell — both bracketing yours in the same block via a higher gas bid or a direct builder relationship.\n\nThe profit the attacker extracts is bounded almost entirely by your slippage tolerance. Set 0.5% slippage on a $50k swap in a mid-liquidity pool and you've effectively posted a bounty for anyone willing to sandwich it. This is why teams building anything beyond toy bots eventually have to treat mempool exposure as a first-class risk, the same way they'd treat a smart contract vulnerability — worth a proper smart contract audit mindset applied to execution infrastructure, not just Solidity code.\n\n## What Flashbots Protect actually changes\n\nProtect is a free RPC endpoint (https://rpc.flashbots.net) that you point your wallet or bot at instead of a public node. Transactions sent through it skip the p2p mempool entirely and go directly to Flashbots' block builder (and, depending on configuration, a small set of additional trusted builders). A few concrete mechanics worth knowing:\n\n- Revert protection is on by default. If your transaction would revert, it's simply not included and you don't pay gas. This alone eliminates a whole class of failed-swap losses that hit public mempool users.\n- No mempool leakage means no generalized frontrunning. Searchers can't see your transaction to react to it, because it never reaches the network layer they're monitoring.\n- Inclusion isn't guaranteed on the next block. Because you're relying on a smaller set of builders rather than the entire validator set racing to include your transaction, inclusion can lag by a block or two versus a well-priced public transaction during quiet periods.\n- You can still get backrun. Protect stops front-running and sandwiching in the classic sense, but a builder can technically still see your transaction pre-inclusion and construct profitable backruns within the same bundle unless you're using stricter builder policies or a private RPC with explicit no-backrun guarantees.\n\nHere's the practical switch for an ethers.js bot:\n\njavascript\nimport { JsonRpcProvider } from \"ethers\";\n\n// public mempool — visible to every searcher\nconst publicProvider = new JsonRpcProvider(\"https://eth.llamarpc.com\");\n\n// private order flow via Flashbots Protect\nconst protectProvider = new JsonRpcProvider(\"https://rpc.flashbots.net\");\n\n// same transaction object, different exposure profile\nconst tx = await wallet.connect(protectProvider).sendTransaction(swapTx);\n\n\nThat's the entire integration cost for basic protection. The harder part is deciding when the latency tradeoff is acceptable for your strategy — which is exactly the kind of execution-path decision worth working through in a strategy consultation before you've already lost a few thousand dollars to sandwiches in production.\n\n## Comparison\n\n| Dimension | Public Mempool | Flashbots Protect |\n|---|---|---|\n| Sandwich attack exposure | High — visible to all searchers | Near-zero for front-running |\n| Failed-tx gas cost | Paid even on revert | Not charged (revert protection) |\n| Inclusion speed | Fast, competitive gas auction | Slightly slower, builder-dependent |\n| Backrun exposure | Yes | Possible, but no front-run sandwich |
| Cost to integrate | None (default RPC) | Swap RPC endpoint, ~zero code |
| Best for | Small trades, low-liquidity pools where MEV isn't worth targeting | Any swap over a few thousand dollars, bot-driven execution, liquidations |
| Chain support | All EVM chains | Ethereum mainnet primarily (some L2 support via other private RPCs) |
Where this fits with the rest of your execution stack
MEV protection isn't unique to Ethereum, and the underlying principle — get your transaction to the block producer without broadcasting it publicly — shows up everywhere. On Solana, the equivalent pattern is submitting through Jito bundles instead of the standard public RPC to avoid the exact same class of sandwich risk in a different execution environment. If you're running cross-chain infrastructure, it's worth designing your order-routing layer once and swapping the private-relay endpoint per chain rather than bolting on protection per bot.\n\nRoute selection matters too. A bot that's already comparing Jupiter's aggregated routing against direct Raydium pool execution on Solana should apply the same scrutiny on EVM chains — the DEX aggregator you route through and the RPC you broadcast on are two separate attack surfaces, and optimizing one without the other leaves money on the table. Teams that get this wrong usually find out during a code review and audit engagement, not before.\n\n## Which to pick, and when\n\nUse the public mempool only for trades where MEV extraction isn't economically worth an attacker's time — sub-$500 swaps in deep-liquidity pools, or transactions where you've already got tight slippage and don't care about a block or two of inclusion delay. For anything else — bot-driven swaps, liquidations, arbitrage legs, or any trade where slippage tolerance has to be wider than 0.3% to reliably land — route through Flashbots Protect or an equivalent private RPC by default. The revert-protection alone pays for the switch on a bot that fires hundreds of transactions a day, before you even count the sandwiches you stop leaking to.\n\nIf you're building or hardening a market-making or liquidation bot and want the execution path reviewed end to end, our Hyperliquid market maker team has run this exact private-order-flow migration on live capital."}
Need a bot like this built?
We design, build and run trading bots on Solana, Hyperliquid and Polymarket.
Start a projectMore from the blog
Public vs Paid RPC: How to Run a Fair Benchmark
A fair comparison of public and paid RPC endpoints must account for quotas, workload, freshness and support guarantees.
Read articleRPC Benchmark Percentiles Explained: p50, p95 and p99
Why averages hide the latency spikes that break trading bots, wallets and production blockchain applications.
Read articleHyperliquid REST vs WebSocket Benchmark: What to Measure
A benchmark plan for Hyperliquid market data that separates request latency from streaming freshness and recovery.
Read article