Skip to content

feat: add baseline mercury swap adapter#1076

Open
ind-igo wants to merge 39 commits into
propeller-heads:mainfrom
0xBaseline:feat/baseline-adapter
Open

feat: add baseline mercury swap adapter#1076
ind-igo wants to merge 39 commits into
propeller-heads:mainfrom
0xBaseline:feat/baseline-adapter

Conversation

@ind-igo

@ind-igo ind-igo commented Jun 9, 2026

Copy link
Copy Markdown

Integration for Baseline Markets (https://www.baseline.markets/)

Summary:

  • Indexing, simulation and execution integration for Baseline pools
  • Refreshes quote-state attributes from pool using getQuoteState rpc call

Notes:

  • Could not use VM integration due to Base rpcs not supporting debug_storageRangeAt method, so created a native integration.
  • Made one repo-level plumbing change for specifying the implementation type. This is due to the spkg option defaulting to VM implementations when you ran tycho-indexer run --spkg .... The new cli option lets testing select Custom.
  • In order to get enough state offchain to create quotes offchain, the substream package does an rpc call to the method "getQuoteState" for that specific pool. This allows us to reconstruct the amm logic with our native integration.
  • Production executor deployment is not included in this PR. The executor is validated through protocol-testing state overrides. Prod addresses can be deployed and added after review.

@zach030

zach030 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Hi! Thanks for the PR. I took a quick look at the substreams part.
I see you’re using the getQuoteState RPC call in substreams to fetch the live state. I think this can work, but it may impact indexer performance, so it’s probably worth looking for a better way.
From what I can see, tycho-simulation depends on those states right now. Would it be possible to update them by decoding events instead, like Swap, AddLiquidity, or RemoveLiquidity?
Another option would be to derive the state updates from storage diffs. That would mean digging into the contract storage layout, figuring out the slot for each state, and decoding the values from there. You can use the storage code in uniswap-v3 as a reference.

@ind-igo

ind-igo commented Jun 12, 2026

Copy link
Copy Markdown
Author

Hi! Thanks for the PR. I took a quick look at the substreams part. I see you’re using the getQuoteState RPC call in substreams to fetch the live state. I think this can work, but it may impact indexer performance, so it’s probably worth looking for a better way. From what I can see, tycho-simulation depends on those states right now. Would it be possible to update them by decoding events instead, like Swap, AddLiquidity, or RemoveLiquidity? Another option would be to derive the state updates from storage diffs. That would mean digging into the contract storage layout, figuring out the slot for each state, and decoding the values from there. You can use the storage code in uniswap-v3 as a reference.

Thanks for the review! I explored trying to do this directly from events but this was not able to reconstruct the full state of the amm. That getQuoteState was specifically added for this purpose. Is it a deadend to use the getQuoteState flow?

I will look into the storage diff method in the meantime.

@zach030

zach030 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Hi! Thanks for the PR. I took a quick look at the substreams part. I see you’re using the getQuoteState RPC call in substreams to fetch the live state. I think this can work, but it may impact indexer performance, so it’s probably worth looking for a better way. From what I can see, tycho-simulation depends on those states right now. Would it be possible to update them by decoding events instead, like Swap, AddLiquidity, or RemoveLiquidity? Another option would be to derive the state updates from storage diffs. That would mean digging into the contract storage layout, figuring out the slot for each state, and decoding the values from there. You can use the storage code in uniswap-v3 as a reference.

Thanks for the review! I explored trying to do this directly from events but this was not able to reconstruct the full state of the amm. That getQuoteState was specifically added for this purpose. Is it a deadend to use the getQuoteState flow?

I will look into the storage diff method in the meantime.

This approach should work, but it may affect indexing performance on Base. Since we can probably solve it by decoding storage diffs too, I’d prefer going with that instead.

ind-igo added 7 commits June 18, 2026 13:07
# Conflicts:
#	crates/tycho-execution/config/test_executor_addresses.json
#	crates/tycho-execution/contracts/scripts/deploy-executors.js
#	crates/tycho-execution/contracts/test/TychoRouterTestSetup.sol
#	crates/tycho-execution/contracts/test/assets/calldata.txt
#	crates/tycho-execution/src/encoding/evm/swap_encoder/swap_encoder_registry.rs
#	protocols/substreams/Cargo.toml
#	protocols/testing/run.Dockerfile
#	protocols/testing/src/state_registry.rs
@ind-igo

ind-igo commented Jun 18, 2026

Copy link
Copy Markdown
Author

@zach030 I have updated the integration to use storage slot tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants