Demonstrates factory pattern indexing — dynamically discovering and indexing contracts created by a factory contract (Uniswap V3).
- Watches UniswapV3Factory for
PoolCreatedevents - Automatically derives pool addresses and starts indexing their
Swapevents - Extracts token0/token1 addresses from the same factory event and tracks their
Transferevents - Multi-network support (Ethereum + Base)
| Contract | Discovery | Events |
|---|---|---|
| UniswapV3Factory | Static address | OwnerChanged |
| UniswapV3Pool | Derived from PoolCreated.pool |
Swap |
| UniswapV3PoolToken | Derived from PoolCreated.token0 and PoolCreated.token1 |
Transfer |
PostgreSQL + CSV
- Copy
.env.exampleto.envand configure yourDATABASE_URL - Run
docker-compose up -dto start the Postgress instance in thedocker-compose.ymlfile - Run
cargo run(defaults to starting both the indexer and GraphQL API), optionally you can add the flags:--indexer, to only index the data or--graphql,--port=<PORT>to start the GraphQL API. - You can access the GraphQL playground with your created data at http://localhost:3001/playground. Run the query in the UI:
query SwapsQuery { allSwaps(first: 10) { nodes { nodeId rindexerId contractAddress sender recipient amount0 amount1 sqrtPriceX96 liquidity tick txHash blockNumber blockTimestamp blockHash network txIndex logIndex } } }