A blockchain indexer for Uniswap V4 swap events on Arbitrum using rindexer.
This project indexes Uniswap V4 Swap events from the PoolManager contract on Arbitrum mainnet and stores them in a PostgreSQL database while streaming events to Redis.
Contract Details:
- Network: Arbitrum (Chain ID: 42161)
- Contract: PoolManager (
0x360E68faCcca8cA495c1B759Fd9EEe466db9FB32) - Events: Swap events from specific pools (ETH/USDC, WBTC/USDC, USDT/USDC)
- Docker and Docker Compose
- Arbitrum RPC endpoint (e.g., Alchemy, Infura, DRPC)
Optional (for local setup only):
- rindexer CLI installed locally
- Redis installed locally
-
Clone the repository and navigate to the project directory
-
Set up environment variables:
cp .env.example .env
-
Edit
.envfile and add your RPC endpoint:ARB_MAINNET_RPC=https://your-rpc-endpoint-here
Run everything in Docker containers:
docker compose up -dThis will start:
- PostgreSQL database
- Redis server
- Rindexer indexer
View indexer logs:
docker compose logs rindexer --followFor development with local rindexer:
-
Start only the database and Redis:
docker compose up postgres redis -d
-
Update your
.envfile for local connections:ARB_MAINNET_RPC=https://your-rpc-endpoint-here DATABASE_URL=postgresql://postgres:postgres@localhost:5432/rindexer_uniswapv4indexer REDIS_CONNECTION_URI=redis://localhost:6380
-
Run rindexer locally:
rindexer start indexer
docker compose ps# Indexer logs
docker compose logs rindexer --follow
# Database logs
docker compose logs postgres
# Redis logs
docker compose logs redis
# All services
docker compose logs --followPGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d rindexer_uniswapv4indexer# If using Docker Redis (port 6380)
redis-cli -p 6380
# If using local Redis (port 6379)
redis-cli -p 6379# Stop all services
docker compose down
# Stop specific service
docker compose stop rindexer.
├── README.md
├── docker-compose.yml # PostgreSQL container configuration
├── rindexer.yaml # Indexer configuration
├── abis/
│ └── PoolManager.abi.json # Uniswap V4 PoolManager ABI
├── .env # Environment variables
└── .env.example # Environment template
- Network: Arbitrum mainnet with rapid block polling
- Contract: Uniswap V4 PoolManager
- Events: Swap events only
- Storage: PostgreSQL backend
ARB_MAINNET_RPC: Arbitrum RPC endpoint (required)DATABASE_URL: PostgreSQL connection string (only for local setup)REDIS_CONNECTION_URI: Redis connection string (only for local setup)
- Ensure PostgreSQL container is running:
docker ps - Check container health:
docker logs uniswap_indexer_postgres - Verify connection:
PGPASSWORD=postgres psql -h localhost -p 5432 -U postgres -d rindexer_uniswapv4indexer
If you need to start fresh:
docker compose down
docker volume rm uniswapv4indexer_postgres_data
docker compose up -dIf port 5432 is already in use:
- Stop other PostgreSQL services
- Or modify the port in
docker-compose.ymland updateDATABASE_URLaccordingly
The indexer uses a no-code approach with rindexer. To modify:
- Add new events: Edit
include_eventsinrindexer.yaml - Change networks: Update
networkssection inrindexer.yaml - Modify contracts: Update contract details in
rindexer.yaml
After configuration changes, restart the indexer:
rindexer start indexer