Query editor
with pools as (select * from query_4971818where blockchain = 'base' and version = '4'),price as (select * from (select pr.*, row_number() over (partition by pr.blockchain, contract_address order by timestamp desc) as rnfrom prices.latest prjoin pools poon po.blockchain = pr.blockchain and (pr.contract_address = po.token_1_address or pr.contract_address = po.token_0_address)) where rn = 1),swaps as (select a.contract_address, a.evt_tx_hash, a.evt_block_time, a.evt_index, a.evt_block_number, a.id, a.sqrtPriceX96, currency0, currency1, -a.amount0 as amount0, -a.amount1 as amount1FROM uniswap_v4_base.poolmanager_evt_swap aleft join uniswap_v4_base.PoolManager_evt_Initialize bon a.id = b.idjoin pools pon p.pool_address = a.id and b.id = p.pool_address),latest_swap_per_ml as (SELECTml.id as pool_id,ml.evt_block_number as ml_block,ml.evt_index as ml_index,ml.evt_tx_hash as ml_tx,s.sqrtPriceX96,s.currency0,s.currency1,ROW_NUMBER() OVER (PARTITION BY ml.id, ml.evt_block_number, ml.evt_indexORDER BY s.evt_block_number DESC, s.evt_index DESC) as rnFROM uniswap_v4_base.PoolManager_evt_ModifyLiquidity mlJOIN swaps sON s.id = ml.idAND (s.evt_block_number < ml.evt_block_numberOR (s.evt_block_number = ml.evt_block_number AND s.evt_index < ml.evt_index))),latest_swap AS (SELECT * FROM latest_swap_per_ml WHERE rn = 1),modify_liquidity AS (SELECT