Expand description
A real-time AMM state engine built on a forked-EVM state cache
(evm_fork_cache).
evm-amm-state composes a forked-EVM state cache (evm_fork_cache) with a
set of protocol adapters into a pipeline that tracks a working set of
AMMs, cold-starts their on-chain state into the cache, keeps exact-write
protocols current straight from chain log events, and emits bounded repair
requests for protocols whose events don’t carry final storage values. Once a
pool’s quote read-set is warmed and current, swap simulations run fast and
offline against it.
The pieces, roughly in pipeline order:
adapters— per-protocol adapters (Uniswap V2, the Uniswap V3 family, Balancer V2, Solidly V2, and Curve — StableSwap/NG + CryptoSwap/Tricrypto-NG) over a singleadapters::AmmAdaptertrait. Each adapter knows how to cold-start a pool’s storage into anevm_fork_cache::cache::EvmCache, which log events to subscribe to, how to apply those events reactively, and how tosimulate_swapagainst the cached state. Theadapters::AdapterRegistrydispatches by pool key, andadapters::AmmSyncEnginedrives the resync-capable live path on top ofadapters::AmmReactiveHandlerand theevm_fork_cachereactive runtime.
See the crate’s examples/adapter_pipeline.rs for an end-to-end demo that
cold-starts a pool, subscribes to its events over a WebSocket endpoint,
applies them reactively, and simulates a swap against the live-synced state.
Re-exports§
pub use alloy_primitives;pub use evm_fork_cache;
Modules§
- adapters
- Protocol-neutral AMM adapter boundary.