Skip to main content

degenbot_simulation/
lib.rs

1//! The simulation engine — the in-process revm EVM handle + its DB stack.
2//!
3//! ADR-019 D4/D7 (decision R — strategy/engine separation): this crate owns
4//! the **engine** (`BlockSimHandle`, the layered DB, `apply_simulation_overrides`,
5//! `AccessListCollector`, `WarmCodeCache`). The **strategy** — the 7-call
6//! pre/post-balance bundle, `compute_priority_fee`, `decode_balance`,
7//! `SimResult`, `dispatch_profitable_results`, `SimulateContext`,
8//! `SimulatePath`, `FailBuckets`, the calldata builders — relocated to the
9//! `degenbot-arbitrage` crate, which drives the borrowed `&mut evm`
10//! the engine exposes via [`BlockSimHandle::evm_mut`].
11//!
12//! # Standalone-Rust consumer
13//!
14//! `cargo add degenbot-simulation` reaches the in-process engine surface with
15//! zero `pyo3` dependency (ADR-005 standalone-core).
16
17// Solidity/EVM identifiers (balanceOf, stateDiff, ERC6909, WETH9, PoolManager,
18// …) are ubiquitous in this crate's docs; allow the pedantic doc-markdown lint
19// to match the peer core crates.
20#![expect(clippy::doc_markdown)]
21
22/// The in-process revm engine + its DB stack (the EVM handle, overrides,
23/// AL collector, warm cache). The settlement-arbitrage strategy relocated to
24/// `degenbot-arbitrage` (ADR-019 D4/D7, decision R).
25pub mod sim;
26
27/// The executor grammar harness (UQOAHA): deploy the real `cmd_executor` +
28/// synthesized pools into a fresh revm `CacheDB`, run a path's
29/// [`encode_cmd_stream`](degenbot_executor::composers::encode_cmd_stream)
30/// payload through `execute()`, and report whether it executes + which pools
31/// it touched. The missing third correctness tool — byte parity can't prove
32/// runtime behavior, and live sim needs a captured mainnet path. See
33/// [`harness`](crate::harness) for the API.
34pub mod harness;
35
36/// Contract-agnostic in-process revm **fixture driver** — deploy a pinned
37/// contract artifact, run staged calls, seed storage slots, drive a call,
38/// classify the verdict (Revert vs Halt), and read back output + logs. The
39/// shared spine of the tier-3 on-chain oracles and any per-contract (user)
40/// investigation harness. See [`oracle`] for the API.
41pub mod oracle;
42
43pub use oracle::{
44    call_bytes, decode_error_string, deploy, load_foundry_creation_bytecode, native_balance_of,
45    new_fixture_evm, parse_foundry_creation_bytecode, read_address, seed_slots, selector,
46    set_code_size_limits, set_disable_nonce_check, set_native_balance, transact, FixtureEvm,
47    TxSpec, Verdict,
48};
49// Re-export the engine surface at the crate root for ergonomic access + for
50// the strategy crate (`degenbot-arbitrage`) + the PyO3 wrapper. The
51// strategy value types (`SimResult`, `SimulateContext`, `FailBuckets`, …)
52// now live in `degenbot-arbitrage`.
53pub use sim::evm::{
54    apply_simulation_overrides, divergence_probe, emit_access_list_from_state, AccessListCollector,
55    BaseFeeSource, BlockEvm, BlockSimHandle, BotStateDb, CallFrame, CallTrace, CallTraceHandle,
56    CallTraceInspector, CapturedSwap, CountingFrameDb, FrameOutcome, FrameRpcCounter,
57    ProductionBlockDb, ReplayFrameError, ReplayOutcome, ReplayStatus, ReplayableTx, ScratchBlock,
58    ScratchDb, ScratchEvm, SimInspector, SimulationOverrideParams, StorageMemo,
59    SwapEventCaptureHandle, SwapEventCaptureInspector, SwapFamily, WarmCodeCache,
60    WarmCodeCacheInner, WARM_CODE_CACHE_TTL_BLOCKS,
61};