Skip to content

feat(substreams): add BopAMM VM integration#1081

Closed
tvinagre wants to merge 4 commits into
mainfrom
tl/bopamm-vm-substreams
Closed

feat(substreams): add BopAMM VM integration#1081
tvinagre wants to merge 4 commits into
mainfrom
tl/bopamm-vm-substreams

Conversation

@tvinagre

@tvinagre tvinagre commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Adds an ethereum-bopamm Substreams package that indexes Bebop's BopAMM PMM as a Tycho VM protocol.

What it does

  • Discovers books (asset/USDC, one component per assetId) from the pricing module's asset-config storage writes — the contracts emit no config events.
  • Tracks the full storage + code of the settlement, pricing module, and registry contracts (fixed set, no DCI).
  • Tracks the market-maker wallet's token balances as per-book TVL (USDC duplicated across books, since inventory is shared).
  • Records per-book committed quote ts/block decoded from updateState/batchUpdateStateWithSignature calldata, and Paused/Unpaused state.
  • Deployment addresses and storage slots are passed via substreams params, so the package can target another deployment without code changes.

Pricing is a pure function of the indexed storage (no external calls, no DCI). One module per file under src/modules/; shared helpers in src/common.rs; config in src/config.rs.

Verification

  • 8 unit tests (real updateState calldata decode, bookId == assetId cross-lock, asset_config_slot keccak vs on-chain, batch decode, token-index regression, params parse). clippy -D warnings and nightly fmt clean; host + wasm32 build; substreams pack succeeds.
  • Live substreams run against mainnet over the book-creation and an active-trading range: both books created with the expected ids/tokens/attributes/creation_tx, committed_ts/block on quote updates, maker balances, and balance_owner all emitted as expected.

See HANDOVER.md for the protocol design, interfaces, storage layout, and lifecycle.

Not included (follow-ups)

  • tycho-simulation BopAMMSwapAdapter (get_amount_out) + the quote-override stream that pins block.timestamp/block.number and injects the maker balance — needed because MAX_UPDATE_AGE() == 0 (exact-timestamp gate).
  • extractors.yaml vm:bopamm entry (8 fields) — gated on releasing the spkg to S3 via release.sh ethereum-bopamm.
  • Asset delisting and maker-rotation re-seed are documented limitations.

🤖 Generated with Claude Code

tvinagre and others added 2 commits June 9, 2026 21:06
Index Bebop's BopAMM PMM as a VM protocol. Books (asset/USDC) are
discovered from the pricing module's asset-config storage writes,
since the contracts emit no config events. Tracks the full storage of
the settlement, pricing module, and registry contracts; the maker
wallet's token balances as per-book TVL; the per-book committed quote
timestamp and block decoded from updateState/batch calldata; and
pause/unpause state from the settlement.

Deployment addresses and storage slots are passed as params so the
module can target another deployment without code changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Capture the protocol design, on-chain interfaces, storage layout, the
indexing model, verification, and remaining work (simulation adapter,
quote-override stream, extractor registration).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tycho-simulation hex-decodes component ids into the adapter's bytes32
poolId (string_to_bytes32), so the previous 0x{settlement}-{assetId}
format failed before reaching any adapter. Ids are now the 32-byte
settlement (20) || assetId (12, BE) packing.

Replace the committed_ts/committed_block attributes with a single
override_block_timestamp (8-byte BE u64): tycho-simulation pins
block.timestamp from this attribute when simulating, which passes the
registry's exact-timestamp StaleUpdate() gate without a separate
quote-override stream.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ntegration test

The PrioUpdateRegistry was deployed before the test's block range, so
within range it only emits storage updates, never an account creation.
The indexer crashed with Account NotFound when applying those updates.
Add it to initialized_accounts so its account is fetched from RPC and
seeded before indexing, matching how other VM integrations bootstrap
pre-existing contracts. Verified: the protocol-testing harness now
passes test_book_discovery 1/1.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tvinagre

Copy link
Copy Markdown
Collaborator Author

Superseded by #1095, which aggregates the substreams, simulation adapter, and execution layers into one branch (reconciled against current main — FermiSwap #1034 had since merged and shares the execution wiring). Closing in favor of that PR.

@tvinagre tvinagre closed this Jun 16, 2026
@github-project-automation github-project-automation Bot moved this from Todo to Done in Tycho Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants