driftbrake
A chain-agnostic simulation and drift-based halt guard for algorithmic trading strategies.
driftbrake pre-flight simulates transactions against local chain state, tracks simulated versus realized profit upon on-chain confirmation, and halts execution the moment realized profit drifts from prediction. It prevents simulation drift, revert bursts, and silent capital bleed across high-frequency EVM strategies. For the complete mechanism specification and formal invariant proofs, see the whitepaper.
Installation
Rust
# Optional concrete REVM simulation backend:
Python
Quickstart
Rust
use ;
let mut policy = institutional_default;
let mut history = new;
// In your execution loop: record pre-flight simulated profit vs actual confirmed profit
history.append;
match policy.evaluate
For the full end-to-end simulation loop wired to REVM, receipt polling, and local transaction broadcast, see examples/toy-arbitrage.
Python
=
=
# In your execution loop:
=
Workspace Packages
| Crate / Package | Description | Target |
|---|---|---|
driftbrake |
Facade crate re-exporting core, reconcile, receipt-poller, and journal | crates.io |
driftbrake-core |
Chain-agnostic trait boundaries (ProfitDecoder, HaltPolicy, SimEngine) |
crates.io |
driftbrake-reconcile |
Multi-guard engine (Fast/Slow drift, Revert-Burst, VWAR, Net Drawdown) | crates.io |
driftbrake-journal |
Crash-resilient binary Write-Ahead Log (WAL) with CRC32 integrity checks | crates.io |
driftbrake-receipt-poller |
Block-time-aware receipt polling and profit realization gating | crates.io |
driftbrake-revm-backend |
Concrete REVM simulation backend with bounded RPC concurrency | crates.io |
driftbrake-py |
Compiled CPython Stable ABI native module and backtest sweep engine | PyPI |
driftbrake-benchmark |
Synthetic drift generator and false-halt vs. missed-catch sweep tool | CLI / crate |
Architecture
driftbrake/
├── driftbrake/ # facade crate: re-exports core + reconcile + poller + journal
│ ├── core/ # chain-agnostic traits, zero REVM/alloy dependency
│ ├── reconcile/ # multi-guard engine (Fast/Slow, Revert-Burst, VWAR, Drawdown)
│ ├── journal/ # crash-resilient binary Write-Ahead Log (WAL) with CRC32
│ └── receipt-poller/ # confirms receipts, decodes realized profit
├── driftbrake-py/ # official Python native extension (PyO3, ABI3 Stable, pip)
├── revm-backend/ # separate, opt-in: concrete SimEngine (fork-and-simulate)
├── benchmark/ # parameter sweep & false-halt/missed-catch harness
└── examples/
└── toy-arbitrage/ # minimal 2-pool arb wired end-to-end against a testnet fork
For the module breakdown and why the guards are independently necessary, see docs/ARCHITECTURE.md.
Testing
# Run Rust workspace test suite
# Run Python integration test suite
Security
Report vulnerabilities per our security policy. This code has not been independently audited — review the reconcile and HaltPolicy logic yourself before running against real capital.
Contributing
See CONTRIBUTING.md for dev environment setup and PR guidelines.
License
Released under the MIT License.