LogoLogo
  • HOOKRANK
    • Introduction
  • CORE FEATURES
    • Dashboard
      • Hook List
      • Hook Details
    • Earnings Analytics
    • Gas Spendings
    • Total Value Locked
    • Transaction Volume
  • HOOKS KNOWLEDGE
    • NoOp Hooks
  • HookRank indexing
    • Events
      • Swap
      • Initialize
      • ModifyLiquidity
    • Tracked Data
  • PUBLIC API
    • Introduction
    • Endpoints
      • /api/public/v1/uniswap/hooks/networks
        • GET
      • /api/public/v1/uniswap/hooks/currencies
        • GET
      • /api/public/v1/uniswap/hooks
        • GET
      • /api/public/v1/uniswap/hooks/{{chainId}}/{{hookAddress}}
        • GET
      • /api/public/v1/uniswap/hooks/{{chainId}}/{{hookAddress}}/contract-metadata
        • GET
  • GUIDES
    • FAQs
    • How To Provide Custom Hook Integration Data
  • EXTERNAL LINKS
    • Twitter / X
    • GitHub
    • Discord
    • Brand Kit
Powered by GitBook
On this page
  1. HookRank indexing
  2. Events

ModifyLiquidity

PreviousInitializeNextTracked Data

Last updated 2 months ago

The ModifyLiquidity event is emitted whenever a liquidity position is changed in a Uniswap V4 pool. It tracks changes in liquidity for a specific position, identified by the owner's address and the tick range (lower and upper tick boundaries). The event captures the amount of liquidity being added (positive delta) or removed (negative delta), along with the current timestamp and pool information.

Here's the event signature:

event ModifyLiquidity(
    address indexed owner,
    address indexed pool,
    int24 tickLower,
    int24 tickUpper,
    int256 liquidityDelta,
    uint256 timestamp
);

Each ModifyLiquidity event is processed by Hookrank in the following way:

  1. Load and update poolId, liquidity, tickLower, tickUpper;

  2. load both pool tokens;

  3. calculate amounts for tokens using Uniswap ;

  4. calculate total amount of liquidity modification in USD: amountUSD = amount0 * token0DerivedETH * ethPriceUSD + amount1 * token1DerivedETH * ethPriceUSD;

  5. decrement TVL by old TVL until new amounts are calculated

  6. increment txCount by 1;

  7. increment each txCount by 1;

  8. increment each totalValueLocked by token amount;

  9. increment each totalValueLockedUSD by token amount in USD;

  10. increment txCount by 1;

  11. if the new position includes the current tick, then increment liquidity by event liquidityDelta;

  12. update TVL in both tokens, ETH and USD;

  13. update gasAccumulatedByModifyLiqs and gasAccumulatedByModifyLiqsInEth by respective values from event;

  14. if liquidityDelta > 0 then increment addLiqCount by 1 else increment removeLiqCount by 1;

  15. update TVL by updated pool values;

  16. if there is a hook for the pool then update TVL: decrement by pool TVL before event and increment by TVL after event;

  17. update gasAccumulatedByModifyLiqs and gasAccumulatedByModifyLiqsInEth by respective values from event;

  18. if liquidityDelta > 0 then increment addLiqCount by 1 else increment removeLiqCount by 1;

  19. create new entity with respective values;

  20. load or create new for each tickLower and tickUpper;

  21. update for both ticks liquidityGross and liquidityNet incrementing it by liquidityDelta;

  22. update , , , with values calculated earlier;

position math
Position
PoolManager
Pool
PoolManager
Token
Token
Token
Pool
Pool
Pool
Pool
Pool
PoolManager
Hook
Hook
Hook
ModifyLiquidity
Tick
UniswapDayData
PoolDayData
PoolHourData
TokenDayData
TokenHourData