Step 1: Prepare Your Uniswap V2 Config
Your config controls what pools, chains, and contracts your indexer will track. Here's the relevant part for Uniswap V2:
{
"type": "uniswap-v2",
"chainId": 43111,
"toBlock": 0,
"protocols": [
{
"name": "weth-usdc.e",
"contractAddress": "0xaf6ed58980b5a0732423469dd9f3f69d9dc6dab5",
"fromBlock": 865348,
"pricingStrategy": "coingecko",
"token0": {
"coingeckoId": "weth",
"decimals": 18
},
"token1": {
"coingeckoId": "usd-coin",
"decimals": 6
},
"preferredTokenCoingeckoId": "token1"
}
// ...add more pools as needed
]
}
What does each field mean?
-
type: "uniswap-v2" — Tells the system this is a Uniswap V2 protocol.
-
chainId: 43111 — The EVM chain ID (Avalanche Fuji testnet in this case).
-
toBlock: 0 — The latest block to index (0 means "keep syncing to latest").
-
protocols: An array of pool configs. Each object describes a Uniswap V2 pool to index:
name
: Human-readable name for the pool.contractAddress
: The pool's smart contract address.fromBlock
: The first block to start indexing for this pool.pricingStrategy
: How to price the tokens (e.g., "coingecko").token0/token1
: Metadata for each token in the pool (Coingecko ID, decimals).preferredTokenCoingeckoId
: Which token to use as the price reference.
You can add as many pools as you want to the protocols array.