Skip to content

feat(tycho-execution): add BopAMM executor and swap encoder#1087

Closed
tvinagre wants to merge 1 commit into
mainfrom
tl/bopamm-execution
Closed

feat(tycho-execution): add BopAMM executor and swap encoder#1087
tvinagre wants to merge 1 commit into
mainfrom
tl/bopamm-execution

Conversation

@tvinagre

Copy link
Copy Markdown
Collaborator

What

Execution support for BopAMM (Bebop's on-chain PMM): BopAMMExecutor.sol, BopAMMSwapEncoder (vm:bopamm), config entries, and tests — same structure as the FermiSwap execution files in #1034.

  • Executor: ProtocolWillDebit — the TransferManager pulls tokenIn to the router and approves the BopAmmV2 settlement (0xdB13ad0fcD134E9c48f2fDaEa8f6751a0F5349ca), which debits via allowance and sends output to the recipient param (outputToRouter = false). swap() calls settlement.swap(tokenIn, tokenOut, amountIn, 0, block.timestamp, receiver); protocol-level minAmountOut is 0 because the router enforces the user's minimum and the Dispatcher measures output via balance diff. No callbacks.
  • Encoder: packed (tokenIn, tokenOut) — 40 bytes; the settlement is an executor immutable and the traded book follows from the token pair. Ethereum-only.
  • Wiring: registry entry, Constants.sol, TychoRouterTestSetup.sol (executors 21→22), test_executor_addresses.json, deploy-executors.js.

Timestamp gate

BopAMM swaps only succeed in a block whose timestamp equals the book's committed registry update (StaleUpdate() otherwise — on-chain takers need builder bundles). Fork tests pin block 25266710 (a quote-commit block for the WETH/USDC book) and fund the maker wallet, since the venue's quote caps at the committed lane size while settlement transfers come from the maker's inventory.

Testing

  • Rust: encoder unit tests (both directions + non-Ethereum rejection) and test_single_encoding_strategy_bopamm_weth_usdc; clippy -D warnings and fmt clean.
  • Solidity: 9 executor tests (decode, transfer data, direct swap, stale revert, cross-language decode of Rust-generated calldata) + a full TychoRouter singleSwap integration test, all passing on a mainnet fork. Pre-existing TychoRouterSingleSwap suites re-run green (19/19).

Note for whoever merges second (#1034 or this)

Both PRs append the 22nd executor to the deterministic test deployment sequence, so both predict the test executor address 0xe8dc788818033232EF9772CB2e6622F1Ec8bc840. The PR that lands second must re-derive its test_executor_addresses.json entry (the executor moves to position 23) and regenerate calldata.txt.

Related: #1081 (substreams), #1082 (simulation adapter).

🤖 Generated with Claude Code

BopAMM (Bebop's on-chain PMM) settles swaps through the BopAmmV2
contract, which debits tokenIn from the caller via allowance and sends
output to the recipient param. The executor is ProtocolWillDebit with
the settlement as approval target; protocol data is the packed
(tokenIn, tokenOut) pair and the book follows from it.

The protocol-level minAmountOut is 0 (the router enforces the user's
minimum and the Dispatcher measures output via balance diff) and expiry
is block.timestamp: BopAMM quotes are only valid in the block whose
timestamp equals the book's committed registry update, so fork tests
pin block 25266710 (a quote-commit block) and fund the maker wallet.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant