feat(uniswap-v3-core): add shared indexing crate with TxDeltaIndexer trait#981
Draft
kayibal wants to merge 2 commits into
Draft
feat(uniswap-v3-core): add shared indexing crate with TxDeltaIndexer trait#981kayibal wants to merge 2 commits into
kayibal wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
d6293b5 to
640e9d9
Compare
283bcef to
ee2cd7a
Compare
Adds a native-code indexing abstraction for pending block simulation: - `TxDeltaIndexer` trait and `TxInput`/`LogInput` in tycho-common - `PendingBlockProcessor` in tycho-simulation for generating ephemeral state updates from unconfirmed transactions - `apply_deltas_ephemeral` on `TychoStreamDecoder` for read-only delta application without touching confirmed state - `build_with_pending` on `ProtocolStreamBuilder` to wire a processor alongside the live feed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a native Rust implementation of UniswapV3 as a TxDeltaIndexer: - `UniswapV3Processor` decodes pool-created, swap, mint, burn, and collect events directly from EVM logs without a Substreams package - Tick and liquidity math ported from the Uniswap V3 reference impl - Balance tracking for component token balances - Substreams module updated to use the shared block_storage helper Builds on the TxDeltaIndexer / PendingBlockProcessor infrastructure from feat/pending-block-processor. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ee2cd7a to
202d34f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extracts shared UniswapV3 indexing logic into a new
uniswap-v3-corecrate that compiles for both native and WASM targets. The substreams handlers inethereum-uniswap-v3-logs-onlybecome thin wrappers that delegate to it.Adds a
TxDeltaIndexertrait totycho-common:apply_block(block: &dto::BlockChanges)— hydrates internal state from a finalised block; the first call serves as initialisation from a full snapshot, subsequent calls apply incremental deltas.generate_deltas(txs: &[TxInput]) -> dto::BlockChanges— applies a batch of in-flight transactions against the current state and returns the aggregated protocol state deltas they would produce. Does not mutate state; repeated calls with the same transactions return identical results.The trait is designed as a native-code substitute for a Substreams package: an Ethereum block builder can feed it finalised
BlockChangesfrom the Tycho client and then callgenerate_deltasto discover how a candidate transaction bundle would alter DEX state before deciding whether to include it.UniswapV3Processorimplements the trait. It stores chain/extractor metadata, running tick and liquidity maps, and token balances.generate_deltasoperates on a clone of internal state so it is safe to call repeatedly.LogInputandTxInputare defined intycho-commonwith private fields and public constructors.The integration test streams from substreams genesis (block 12_369_621) and compares processor output against substreams ground truth across 2000 blocks using
apply_block/generate_deltas— 0 attribute mismatches, 0 balance mismatches across 136 attributes and 98 balances.Also bumps the
ethereum-uniswap-v3andethereum-uniswap-v3-logs-onlysubstreams toolchains from 1.83.0 to 1.87.0 —hashbrown 0.17(viaindexmap 2.14) requires edition 2024 which needs Cargo ≥ 1.85.