Package Logo
coinranking_uniswap_v3
coinranking_uniswap_v3@v0.2.0
Total Downloads
5
Published
2 days ago
Network
mainnet mainnet
Publisher
User Avatar wouthoekstra

Readme

Uniswap V3 Block-Aggregated Swap Data Substream

Real-time block-aggregated swap data for Uniswap V3 pools on Ethereum mainnet.

Features

  • Tracks pool creation events with token addresses and decimals
  • Aggregates all swaps per pool per block
  • Provides closing prices and swap counts
  • Stateless design with no persistent stores

Output Format

The substream produces DexOutput messages containing:

  • pools_created: New pool deployments with token addresses and decimals
  • tickers: Per-pool metrics including:
    • Block-level volumes for both tokens
    • Swap count
    • Closing price (token1/token0 ratio)
    • Block number and timestamp

Usage

substreams run coinranking-uniswap-v3-v0.2.0.spkg map_uniswap_ticker_output \
  --substreams-api-token="YOUR_TOKEN" \
  --substreams-endpoint="mainnet.eth.streamingfast.io:443" \
  -s 12345678  # Start from any block

Notes

  • Prices are calculated from sqrtPriceX96 format to standard ratio
  • All Ethereum addresses include the 0x prefix
  • No stores or state management - purely block-level aggregation
  • Downstream systems handle rolling window calculations

Changelog

v0.2.0

  • BREAKING: Removed 24-hour rolling volume calculations and all stores
  • Simplified to stateless block-aggregated output only
  • Removed volume_24h_token0 and volume_24h_token1 fields from output
  • Eliminated store size limitations and potential isolation issues
  • Simplified codebase structure - all logic now in single lib.rs file

v0.1.2

  • Fixed critical bug where negative volumes could occur during the first 24 hours of processing
  • Added proper guard to prevent volume eviction before 24 hours of data has accumulated
  • This ensures each period's volume is added exactly once and subtracted exactly once

Documentation

Modules

Maps icon
Maps

map
map_uniswap_ticker_output

19cd5d3166e29efee3305fce8c35593dc41adc05
map map_uniswap_ticker_output (
blocksf.ethereum.type.v2.Block
)  -> dex.common.v1.DexOutput
substreams gui coinranking-uniswap-v3@v0.2.0 map_uniswap_ticker_output

map
uniswap:uni_v0_2_9:map_pools_created

3a5e4d92aeccd801140b7a330e3a1c0407bae58d
map uniswap:uni_v0_2_9:map_pools_created (
)  -> uniswap.types.v1.Pools

This module will loop over block transactions and detect pools created events. Once the pool created events have been detected, Pools structs will be emitted out of the module.

Try with

substreams gui substreams.yaml map_pools_created -t +1000
substreams gui coinranking-uniswap-v3@v0.2.0 uniswap:uni_v0_2_9:map_pools_created

map
uniswap:uni_v0_2_9:map_extract_data_types

9daec64c4ffe5d1cb38272f14d656b87928d2e28

Chunky module which emits multiple types of Events. Looping over every transaction to filter out Events. For some events, we have to loop over StorageChanges to be able to fetch certain changes such as liquidity increases and decreases. For more information on what the Event contains, check proto/uniswap/v1/uniswap.proto.

Try with

substreams gui substreams.yaml map_extract_data_types -t +1000
substreams gui coinranking-uniswap-v3@v0.2.0 uniswap:uni_v0_2_9:map_extract_data_types
Stores icon
Stores

store
uniswap:uni_v0_2_9:store_pools_created

3ec75d75eea4b8dfd8b515e09dca992a14f059ed
store <set,uniswap.types.v1.Pool> uniswap:uni_v0_2_9:store_pools_created (
)

This module stores the Pools emitted by the map_pools_created module. Dynamic data sources pattern for Uniswap v3 pools.

substreams gui coinranking-uniswap-v3@v0.2.0 uniswap:uni_v0_2_9:store_pools_created
Protobuf

Protobuf Docs Explorer

dex.common.v1
uniswap.types.v1