Skip to content

feat: live pAMM state-override stream integration (scaffold)#1106

Draft
zizou0x wants to merge 1 commit into
mainfrom
eng-6118-titan-pamm-overrides
Draft

feat: live pAMM state-override stream integration (scaffold)#1106
zizou0x wants to merge 1 commit into
mainfrom
eng-6118-titan-pamm-overrides

Conversation

@zizou0x

@zizou0x zizou0x commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Scaffolds a generic, protocol-agnostic layer in tycho-simulation that injects live per-block VM storage overrides and block environment into pAMM pools (e.g. FermiSwap), sourced from the Titan pAMM stream. Consumers keep using ProtocolStreamBuilder unchanged; overrides are on by default with an opt-out.

Jira: ENG-6118

How it works

  • The provider maintains a live watch channel of OverrideSnapshots per protocol.
  • Each EVMPoolState for a served venue holds the receiver and reads the freshest snapshot at simulation time (get_amount_out/get_limits), so sub-block updates are reflected without a Tycho block update.
  • Storage overrides and the block environment (number/timestamp) prefer the live snapshot on conflict.

Changes

  • evm/overrides.rs (new): StateOverrideProvider trait, OverrideSnapshot, attach_live_overrides helper.
  • evm/protocol/vm/state.rs: live read-through on EVMPoolState (live_overrides field, set_live_overrides, live-aware get_overwrites and effective_block_overrides).
  • evm/decoder.rs: attaches each registered provider's channel to matching venue pools during decode.
  • evm/stream.rs: default-on auto-registration of the Titan provider, with without_titan_overrides() opt-out and with_override_provider() / titan_url().
  • evm/titan.rs (new): TitanProvider implementing the trait; WebSocket client bodies are todo!().

Status

Draft / WIP. The Titan WebSocket client (spawn, parse_message, max_lane_timestamp, venue_for_protocol) is stubbed with todo!() and lands in a follow-up. Compiles under --all-features and --no-default-features --features evm; clippy clean.

Test plan

  • Implement TitanProvider WS client and un-ignore provider tests
  • Validate live mid-block price movement against tycho-dev with FermiSwap

Add a generic, protocol-agnostic layer in tycho-simulation that injects
live per-block VM storage overrides and block environment into pAMM pools
(e.g. FermiSwap) sourced from the Titan pAMM stream.

- overrides.rs: StateOverrideProvider trait, OverrideSnapshot, and
  attach_live_overrides helper (downcasts EVMPoolState and wires a live
  watch channel into the pool).
- EVMPoolState: read-through live overrides at simulation time via a watch
  receiver; storage and block env now prefer the live snapshot.
- decoder: attaches each provider's channel to matching venue pools.
- stream builder: default-on auto-registration of the Titan provider with
  without_titan_overrides() opt-out and with_override_provider() for custom
  sources.

The Titan WebSocket client bodies (spawn/parse/timestamp resolution) are
todo!() and land in a follow-up.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant