Learn how to use onchain data to index all Uniswap v4 pools created for coins created via Zora and Base App and load metadata including available liquidity, current prices, token information, and more
viem
for interacting with Base Chain via standard Ethereum JSON-RPC methods. It also utilizes Uniswap’s SDKs to make some calculations easier.
index.ts
)Initialize
events within a specified block range to discover newly created pools.
publicClient.getContractEvents()
to fetch pool initialization eventsSTART_BLOCK_NUMBER
and END_BLOCK_NUMBER
for your needsviem
s watchContractEvent
insteadutils.ts
)WETH
. In the future, USDC
pairing will also be used. Tokens created directly via the Zora app do not pair with WETH
or USDC
- so we use this as a way of identifying and tagging if the coin came from Zora or Base App.
liquidity
amount we loaded previously for a pool, we utilize Uniswap’s SDK to do some math and get human-friendly versions of how much of each token is available in the pool as total liquidity.
viem
, but you can adapt it for other data sources:
Subgraphs: If you’re already using The Graph Protocol, modify the event fetching logic to query a Uniswap V4 subgraph instead of making direct RPC calls. Replace the getContractEvents
call with GraphQL queries.
Indexing Services: For projects using third-party indexing services with their own APIs, substitute their event APIs while maintaining the same pool key extraction logic.
Real-time Monitoring: Convert from batch processing to real-time by setting up WebSocket subscriptions to new block events and processing pools as they’re created.
id
: Unique pool identifier hashkey
: Complete pool key object with currencies, fee, tickSpacing, and hookscurrency0/currency1.name
: Human-readable token namecurrency0/currency1.symbol
: Token symbol (e.g., “USDC”, “WETH”)currency0/currency1.decimals
: Token decimal places for formattingcurrency0/currency1.address
: Contract addresssqrtPriceX96
: Current pool price in Uniswap’s sqrt formattick
: Current tick (logarithmic price representation)currency0Price
: Price of currency0 in terms of currency1currency1Price
: Price of currency1 in terms of currency0currency0PriceHumanReadable
: Formatted price stringcurrency1PriceHumanReadable
: Formatted price stringliquidity
: Total pool liquidity in Uniswap’s internal formatliquidityCurrency0
: Amount of currency0 in the pool (raw)liquidityCurrency1
: Amount of currency1 in the pool (raw)liquidityCurrency0HumanReadable
: Formatted amount with symbolliquidityCurrency1HumanReadable
: Formatted amount with symbolcoinType
: Type of Zora token (“ZORA_CREATOR_COIN” or “ZORA_V4_COIN”)appType
: Application ecosystem (“ZORA” or “TBA”)RPC_URL
: Base chain RPC endpoint (required)START_BLOCK_NUMBER
and END_BLOCK_NUMBER
in index.ts
to scan different ranges or implement continuous monitoring.
TBA_PAIRINGS
array to modify which base tokens indicate Base App classification.