Initialize
Last updated
Last updated
The Initialize event in Uniswap V4 is emitted when a new pool is created in the PoolManager contract. It marks the initial setup of a liquidity pool between two tokens with specific parameters. When this event is emitted, it indicates that a new trading pair has been established with defined characteristics including the two tokens (currency0 and currency1), the fee tier, tick spacing, and initial price (represented as sqrtPriceX96). A unique feature of Uniswap V4 is the inclusion of hooks in pool initialization, allowing for customizable pool behavior through hook contracts. The Initialize event captures this hook address along with other pool parameters, making it a crucial event for tracking the creation and configuration of new pools in the protocol. As seen in the provided code, this event triggers various setup processes including token data initialization, price calculations, and the creation of related entities in the subgraph for analytics and tracking purposes. Event signature:
Initialize event is handled by HookRank in the following order:
Load or create new entity;
increment PoolManager poolCount
value by 1;
load or create new entity for each token in event;
load or create new entity;
increment PoolManager hookCount
value by 1;
create new entity;
calculate token prices by AMM formula and update ;