← Back to all products

Bundle Simulator

$10

Simulate Flashbots bundles against historical state before sending to builders.

📁 15 files
TypeScriptJSONMarkdown

📁 File Structure 15 files

bundle-simulator/ ├── LICENSE ├── README.md ├── package.json ├── src/ │ ├── analysis/ │ │ ├── gas-estimator.ts │ │ ├── profitability.ts │ │ └── state-diff.ts │ ├── bundle.ts │ ├── forked-provider.ts │ ├── index.ts │ ├── simulator.ts │ ├── types/ │ │ └── simulator.ts │ └── utils/ │ ├── encoding.ts │ └── logger.ts ├── test/ │ └── simulator.test.ts └── tsconfig.json

📖 Documentation Preview README excerpt

Bundle Simulator

Local simulation harness for testing MEV bundles before submission to Flashbots.

Price: $9.99 | License: MIT | Language: TypeScript


What's Inside

A complete local simulation environment for testing MEV bundles against forked mainnet state. Validate profitability, estimate gas, and compare strategies before risking real capital.

ModuleDescription
simulator.tsCore simulation engine — forks state, executes bundles, returns results
forked-provider.tsRPC provider wrapper that forks state from a live chain
bundle.tsBundle builder with fluent API for constructing transaction sets
analysis/profitability.tsProfit/loss analysis from simulation results
analysis/state-diff.tsPre/post state comparison with balance tracking
analysis/gas-estimator.tsGas usage estimation and break-even analysis
utils/encoding.tsHex encoding, calldata decoding, ETH formatting
utils/logger.tsStructured logging with configurable levels
types/simulator.tsFull type definitions for all simulation objects

Quick Start


npm install

import { BundleSimulator, BundleBuilder } from "@cryptoforge/bundle-simulator";

const sim = new BundleSimulator({
  rpcUrl: "http://localhost:8545",
  forkBlockNumber: 19_500_000,
});

const bundle = BundleBuilder.create()
  .searcher("0xYourAddress...")
  .target(19_500_001)
  .tx({ signedTx: "0x...", label: "Buy WETH on Uniswap" })
  .tx({ signedTx: "0x...", label: "Sell WETH on SushiSwap" })
  .build();

const result = await sim.simulate(bundle);

console.log("Profitable?", result.profitAnalysis.isProfitable);
console.log("Net profit:", result.profitAnalysis.netProfitEth, "ETH");
console.log("Gas used:", result.totalGasUsed.toString());
console.log("Duration:", result.simulationDurationMs, "ms");

Comparing Strategies


const bundles = [
  BundleBuilder.create()
    .searcher("0x...")
    .meta("strategy", "2-hop arb")

*... continues with setup instructions, usage examples, and more.*

📄 Code Sample .ts preview

src/bundle.ts // ═══════════════════════════════════════════════════════════════════════ // Bundle Simulator — Bundle Builder // Construct and manage MEV bundles for simulation // ═══════════════════════════════════════════════════════════════════════ import type { BundleTransaction } from "./types/simulator.js"; /** * Represents a bundle of transactions to simulate atomically. * * Bundles execute sequentially — if any transaction reverts, the * entire bundle is considered failed. */ export class Bundle { private transactions: BundleTransaction[] = []; private _searcherAddress: `0x${string}` = "0x0000000000000000000000000000000000000000"; private _targetBlock?: number; private _metadata: Record<string, unknown> = {}; /** Number of transactions in the bundle */ get size(): number { return this.transactions.length; } /** Searcher address (for profit tracking) */ get searcherAddress(): `0x${string}` { return this._searcherAddress; } /** Target block number */ get targetBlock(): number | undefined { return this._targetBlock; } /** All addresses involved in the bundle */ get involvedAddresses(): string[] { const addresses = new Set<string>(); addresses.add(this._searcherAddress); for (const tx of this.transactions) { if (tx.from) addresses.add(tx.from); if (tx.to) addresses.add(tx.to); } return Array.from(addresses); } /** Set the searcher address for profit analysis */ setSearcherAddress(address: `0x${string}`): this { this._searcherAddress = address; # ... 147 more lines ...
Buy Now — $10 Back to Products