jangobuni3_lp_distribution copy
    Updated 2024-04-24
    -- forked from andreafiandro / uni3_lp_distribution @ https://flipsidecrypto.xyz/andreafiandro/q/0cNkYquR1zQl/uni3_lp_distribution



    with pool_info as (
    select
    pool_address,
    pool_name,
    block_timestamp as pool_create_time,

    tick_spacing,
    fee_percent,

    token0_address,
    token0_symbol,
    token0_decimals,

    token1_address,
    token1_symbol,
    token1_decimals

    from ethereum.uniswapv3.ez_pools
    where pool_address = lower('{{pool_address}}')
    limit 1 -- can only match exactly one pool
    ),

    mint_burn as (
    select
    lp.tick_lower,
    lp.tick_upper,
    pinfo.tick_spacing,
    case
    -- liquidity is misnomer, it's NOT new liquidity after action
    -- it's delta liquidity in that action
    when lp.action = 'INCREASE_LIQUIDITY' then lp.liquidity
    when lp.action = 'DECREASE_LIQUIDITY' then -1*lp.liquidity
    QueryRunArchived: QueryRun has been archived