Create a realtime feed of Uniswap swaps on any chain
Write logic to collect Uniswap pool contract addresses
UniswapV3Factory
deployment address from Uniswap’s docs.We can use Mirror to watch the factory for PoolCreated()
events against the factory address; the SQL logic to do this using Goldsky’s decoded event logs schema is below.Write logic to collect trades
Swap()
events, and we can use the logic written above as a subquery to filter only for Uniswap pool events (so that we filter out other contracts that emit similar Swap()
events from our stream).We need to add STATE_TTL
hints in order to prevent all the logs from being kept.Write full pipeline configuration
Deploy pipeline
pipeline.yaml
configuration file, we can deploy from CLI with a single line of code:max(block)
in the database against a block explorer.You can speed up the backfill by upscaling the resource size (and then scale back down to an S
worker at edge). An M
pipeline caught up to edge (~600K swaps as of October 2023) in approximately 45 minutes.Create stream for other chains (or one multi-chain stream)
referenceName
and deployment addresses for each chain.