Backtesting Framework A Guide for Crypto Traders
Build a backtesting framework that works for DeFi. Learn core components, on-chain challenges like gas and MEV, and how to test strategies before you trade.

May 20, 2026
Wallet Finder

May 17, 2026

You swap a mid-cap token on a DEX. The quoted price looks fine. The transaction confirms. You receive fewer tokens than expected, and it wasn't because you misread the pool. Someone saw your order before it landed, traded around it, and turned your urgency into their profit.
That's the lived version of mev protection. For most traders, MEV stops being an abstract protocol topic the first time a clean setup produces a dirty fill.
The reason this matters is scale, not theory. By May 2023, roughly 625,000 ETH of cumulative MEV had been extracted on Ethereum, worth about $1.2 billion at the time, according to Milk Road's MEV guide. On March 11, 2023 alone, about 5,100 ETH of MEV was extracted versus about 2,600 ETH in transaction-fee revenue that day, which shows how extraction can overtake ordinary user fees on busy days. If you trade on-chain and care about execution, that's not background noise. It's part of your cost structure.
Most traders blame bad fills on volatility, thin liquidity, or loose slippage settings. Sometimes that's right. Often it isn't.
A common pattern looks like this: you submit a swap large enough to move price, your transaction sits just long enough to be observed, and bots react before inclusion. They don't need to guess what you're doing. If your order is visible in the public mempool, they can inspect direction, size, and the slippage room you've allowed.
That's why bot activity feels like a hidden tax. You don't get a line item that says “you were sandwiched.” You just see a weaker fill, a failed transaction, or both.
Public transaction visibility is the opening. The bot's edge comes from seeing your signed transaction before it becomes final. In practice, that turns your trade into a signal.
If you trade actively, latency matters too. Fast routing doesn't solve every execution problem, but it changes how much time adversarial actors have to react. For traders who want to think about that side of execution, this breakdown of latency in crypto trading patterns is worth reviewing.
Practical rule: If your order is visible before inclusion, assume someone is trying to monetize it.
The broad takeaway is simple. MEV isn't a niche issue for whales, protocol teams, or searchers. It affects any trader whose order size, route, token pair, or timing creates visible edge for someone else.
The cost lands in a few familiar ways:
Traders who treat mev protection as optional usually learn the lesson by paying for it first.
Maximal Extractable Value, or MEV, is the value someone can extract by controlling transaction ordering, insertion, or exclusion before a block is finalized. For a trader, the easiest mental model is this: the mempool is a public waiting room, but it also acts like a live auction for transaction priority and information.

When you sign a swap and broadcast it publicly, it doesn't jump straight into a finalized block. It waits. During that window, anyone watching can analyze it.
That matters because many DeFi trades are predictable once visible. A large buy can move a pool. A liquidation can pay a bounty. An arbitrage gap can close after one known trade executes. Public visibility turns pending transactions into tradable signals.
Three groups matter most in the MEV pipeline:
From a trader's perspective, the distinction matters less than the flow. Searchers identify the opportunity. Builders package it. Validators include it.
The key point isn't that your transaction exists. The key point is that other actors can react to it before it settles.
MEV isn't just a bug that appeared because bots got clever. It emerges anywhere transaction ordering has economic value and pending order flow is visible. DEX swaps, arbitrage paths, liquidations, NFT mints, and governance actions can all create that value.
That's also why “just pay more gas” isn't a real defense. Higher priority may help in some cases, but it doesn't remove the information leak. If the market can see your intent and your tolerance, someone may still route around you.
For practical trading, this is the important framing:
Once you think about MEV this way, mev protection stops looking like a wallet feature and starts looking like execution infrastructure.
The attacks that hit traders most often are simple once you strip away the jargon. They all come down to one thing: someone sees your pending transaction and trades around it.

This is the one most traders have felt, even if they didn't label it correctly.
Your order becomes the filling in the sandwich. The bot's first trade worsens your entry, and the second trade closes its profit.
This hurts most when you trade size into thinner pools or when your slippage setting gives the attacker room to operate.
Frontrunning is more general. The bot cuts ahead because your transaction reveals profitable information.
A simple sequence:
The result isn't always a classic sandwich. Sometimes the bot just captures the opportunity before you do.
Backrunning happens after your transaction rather than before it. The bot lets your trade execute, then trades immediately after to exploit the conditions your transaction created.
That can include:
Backrunning isn't always directly harmful in the same way a sandwich is, but it still means your transaction created extractable value for someone else.
Here's a visual explainer that shows the mechanics in a more concrete format:
On lending protocols, liquidations are another major MEV arena. When a borrower crosses the threshold, bots race to be first to execute the liquidation and claim the economic reward.
For normal traders, the main lesson is indirect but important. If your strategy interacts with volatile collateral, magnified positions, or distressed positions, you're trading in a part of DeFi where bots are already highly optimized.
You won't always identify the exact mechanism from your wallet screen, but there are common clues:
If a route exposes your order before inclusion, assume searchers are testing whether your transaction can be turned into their trade.
That's why mev protection has to be judged by execution outcomes, not just by whether a wallet says “protected.”
Not all defenses solve the same problem. Some hide your transaction. Some change who sees it. Some move protection into protocol design. If you trade regularly, you need to know what each mechanism does and where it falls short.
The cleanest user-side defense is to stop your signed transaction from entering the public mempool at all. Private relay systems from providers such as Flashbots and Tatum route transactions directly to builders, which removes the observability that enables frontrunning and sandwiching. Tatum says this path can be up to 2 seconds faster during congestion, with direct propagation to builders rather than broad public broadcast.
This is why private routing is the default recommendation for many swaps. It attacks the problem at the source: if bots can't inspect the transaction in advance, they can't react to the contents in the usual way.
But private routing isn't a magic button. It can reduce attack surface without guaranteeing the best final fill.
A benchmark study submitted 273 transactions across four private MEV-protection RPCs and found that MEV Blocker, Blink, and Flashbots each executed at rates above 90%, while Merkle executed at 74%, according to the arXiv benchmark on private MEV-protection RPCs. The same study reported net average price difference figures in blocks for the tested services, and found the difference between MEV Blocker and Flashbots was statistically significant at the 10% level.
That matters because the practical question isn't “was my order hidden?” It's “did I get a better trade outcome?”
Wallet-side privacy helps, but stronger designs push protection deeper into infrastructure. Shutter's Rolling Shutter moves MEV resistance into rollup sequencing by committing to ordering while transactions are still encrypted. The sequencer can't inspect contents and then reorder after decryption without creating conflicting commitments, as described in Shutter's Rolling Shutter announcement.
That approach is harder to bypass because it changes the ordering layer itself, not just the route a wallet uses.
| Mechanism | How It Works | Best For | Key Trade-off |
|---|---|---|---|
| Private relays | Sends signed transactions directly to builders instead of the public mempool | Large swaps, time-sensitive DeFi actions | Better privacy, but not always the best settlement price |
| Private mempools via RPC | Uses a protected RPC endpoint to keep order details from public bot watchers | Everyday wallet trading on supported chains | Depends on provider quality and routing outcomes |
| DEX-native protected routing | Aggregator or DEX handles routing with built-in protection logic | Retail users who want easier defaults | Less control over path selection and execution policy |
| Transaction bundling | Packages dependent actions together for controlled inclusion | Power users, arbitrage, multi-step DeFi flows | More setup complexity and less flexibility mid-flight |
| Encrypted ordering or sequencer designs | Commits or orders transactions while encrypted | Protocols, rollups, high-value ecosystems | Harder to deploy and depends on network architecture |
| Chain-specific leader-aware routing | Chooses safer validator or leader paths in real time | Fast chains where ordering risk is leader-specific | More operational complexity than a simple private/public toggle |
What works in practice: hide intent when possible, then measure actual fill quality instead of assuming protection equals improvement.
The best mev protection setup is the one you'll use on every meaningful trade. Keep it simple enough to become default behavior, then tighten it based on your results.

For MetaMask, Rabby, or another EVM wallet, the first practical move is using a private RPC or a swap interface that routes privately by default. The exact clicks vary by wallet and provider, but the workflow is usually the same:
On Solana wallets such as Phantom, the equivalent decision is often less about a classic mempool toggle and more about which routing stack or infrastructure sits behind the transaction path.
Loose slippage creates room for extraction. Extremely tight slippage creates failed transactions. You need enough tolerance for normal market movement and route changes, but not enough to invite abuse.
A useful working rule:
There's a real trade-off here. Analysis discussed by CoW DAO found private transactions had lower on-chain revert rates, 4.2% versus 13.8% for public transactions, but private flow could still incur more slippage in the sampled comparison, which is why protected routing doesn't automatically mean a better final settlement according to CoW DAO's discussion of MEV transparency and trade-offs.
Some interfaces advertise mev protection but don't tell you what kind. You want to know whether they use private submission, solver-based execution, batch auctions, or some combination.
When reviewing a setup, check for these points:
For post-trade review and wallet-level monitoring, Wallet Finder.ai's wallet scanner protection is one example of a tool positioned around reducing front-running risk while tracking on-chain activity. That won't replace execution routing, but it fits into a broader workflow where you care about both privacy and trade analysis.
Good execution is usually a stack, not one setting.
For builders and serious operators, wallet-side mev protection is only the first layer. The stronger move is to redesign the ordering environment so adversaries never get useful visibility in the first place.
Shutter's model is the clearest example of where this is going. It integrates threshold-encryption-style protection into rollup sequencing so transactions are ordered while still encrypted, which prevents the sequencer from reordering based on transaction contents after decryption, as described in Shutter's overview of Rolling Shutter.
That changes the power balance. Instead of asking every user to route privately and hope the route holds, the network itself makes adversarial inspection harder.
Protocol-level design matters most in ecosystems with high-value order flow, latency sensitivity, and lots of composable DeFi. In those environments, user-side privacy tools help, but they still rely on local choices by wallets, frontends, and RPCs.
A stronger architecture can include:
If you're running strategies across multiple chains, the edge comes from matching protection to market structure. Ethereum-style private routing works well when public mempool visibility is the main leak. In other environments, the risk sits closer to leader behavior, sequencing policy, or venue design.
The long-term fix for MEV isn't better wallet copy. It's better market structure.
For protocol teams, that means treating MEV as an execution and fairness problem at the architecture level. For quant traders, it means routing strategy should be chain-specific and venue-specific, not ideological.
You can't judge mev protection by a toggle alone. You need to look at outcomes. If a route says “protected” but your fills still degrade, the label doesn't matter.
Start with your own transaction history on a block explorer and your trading journal. Look for repeated patterns:
That kind of review is easier when you can see wallet history, trade timing, and PnL in one place. A tool such as Wallet Finder.ai's protected wallet scanning workflow can help traders compare execution behavior across wallets they track, especially when they're trying to separate signal from anecdotal frustration.

Many Ethereum-only guides fall behind on this aspect. On Solana, the issue is increasingly less about a classic public mempool and more about which leaders or validators are handling your path. bloXroute describes infrastructure that scores current and upcoming slot leaders, identifies increased sandwich or malicious-ordering risk, and routes around those paths in its analysis of Solana's newer MEV model.
That's a different playbook. It means the right question is no longer just “did I use a private route?” Sometimes the better question is “which path did my transaction take, and was that path safe?”
If you trade across chains, your monitoring has to evolve with the chain. The bots already have.
If you trade based on on-chain wallet behavior, Wallet Finder.ai gives you a practical way to track wallets, trades, timing, and PnL across major ecosystems so you can review execution quality, spot patterns that look like hidden extraction, and make better routing decisions before the next trade.