Add EVM x402 settlement extraction#250
Open
DenisCarriere wants to merge 9 commits intomainfrom
Open
Conversation
36d1231 to
bdb80a0
Compare
bdb80a0 to
740bec6
Compare
972935e to
83cef42
Compare
83cef42 to
69ed36f
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
Adds first-pass EVM x402 settlement support scoped in #249.
x402/as the protobuf event package withmap_eventsand packagedspkg/x402-v0.1.0.spkg.evm.x402.v1.Eventslike the DEX/ERC event packages:Events -> Transaction -> Log -> payment, including raw log fields and optional call metadata.evm-x402/as the database-change package that importsx402:map_eventsand emitsx402_paymentsrows.AuthorizationUsed, matching ERC-20Transfer, decodedtransferWithAuthorizationcalldata when traces are available, and facilitator attribution.x402ExactPermit2ProxySettled()/SettledWithPermit()events and joins to the immediately preceding ERC-20 transfer.evm-x402/clickhouse/with generated ClickHouse schema files, blocks/templates, a facilitator-firstx402_paymentsbase table, and aggregate materialized views..spkgartifacts for all three layers.Packages
x402-v0.1.0.spkg: normalized protobuf events.evm-x402-v0.1.0.spkg: database changes importingx402.evm-clickhouse-x402-v0.1.0.spkg: ClickHouse sink importingevm-x402.ClickHouse
x402_paymentsincludes block, transaction, log, call, and payment columns. Its sorting key is facilitator-first and recipient-second:ORDER BY (facilitator, recipient, asset, minute, timestamp, block_num, tx_index, log_index)Aggregate state tables/MVs:
state_x402_totals_by_facilitator: totals grouped by facilitator, recipient, asset, method/source/scheme.state_x402_totals_by_recipient: recipient-first totals for recipient-centric queries.state_x402_volume_by_facilitator_recipient: OHLCV-style interval buckets for payment count and volume across 1m, 5m, 10m, 30m, 1h, 4h, 1d, and 1w windows.Notes
x402:map_eventsdoes not accept params and does not apply facilitator filtering. It emits all onchain EIP-3009 settlement candidates into the database so stricter facilitator rules can be applied in ClickHouse queries.EIP-3009 payments are emitted as
confidence=heuristic. Permit2 proxy events are emitted asconfidence=high.Verification
make -C proto protogencargo check -p x402cargo test -p x402cargo check -p db-evm-x402cargo test -p db-evm-x402cargo build -p x402 --target wasm32-unknown-unknown --releasecargo build -p db-evm-x402 --target wasm32-unknown-unknown --releasemake -C evm-x402/clickhouse schemaclickhouse-local --multiquery < evm-x402/clickhouse/schema.sqlsubstreams pack x402/substreams.yaml -o spkg/x402-v0.1.0.spkgsubstreams pack evm-x402/substreams.yaml -o spkg/evm-x402-v0.1.0.spkgmake -C evm-x402/clickhouse packsubstreams info x402/substreams.yamlsubstreams info evm-x402/substreams.yamlsubstreams info evm-x402/clickhouse/substreams.yamlmake -C x402 run STOP_BLOCK=+1make -C evm-x402 run STOP_BLOCK=+1substreams-sink-noop base.substreams.pinax.network:443 evm-x402/substreams.yaml db_out -c --state-store /tmp/evm-x402-noop-state.yaml 45690000:+3Related