Query editor
-- Full liquidity-event history for the cbETH/WETH (CL1) pool, used to-- reconstruct the pool's per-tick liquidity distribution over time and-- simulate price impact of a reference trade (see compute_price_impact.py).---- A CL pool's active liquidity at any moment is the running sum, over every-- Mint/Burn ever emitted, of the position's liquidity delta applied to the-- tick ranges it spans. Mint adds `amount` liquidity to [tickLower, tickUpper);-- Burn removes it. So the full Mint/Burn log is sufficient to rebuild the-- distribution as of any block.---- Output: unioned rows discriminated by `kind`:-- kind='mint': a=block_ts, b=evt_block_number, c=liquidity (amount),-- d=tickLower, e=tickUpper, f=evt_index-- kind='burn': same columns; liquidity is the amount removed (positive)-- kind='liqchk': a=block_ts, b=evt_block_number, c=on-chain active liquidity,-- d=active tick, f=evt_index -- last swap per block, recent-- window only; validates the reconstruction against on-chain---- (b, f) = (evt_block_number, evt_index) uniquely identifies an event, so the-- incremental pull can dedupe a boundary-overlapping refresh without ever-- collapsing genuinely distinct same-block same-range events.---- Dune parameters:-- {{pool_address}} -- CLPool contract address (text, 0x-prefixed)-- {{after_ts}} -- only return events strictly after this unix ts-- (0 for a full pull; last cached ts for incremental)-- {{liqchk_after_ts}} -- lower bound for the validation (swap) rowsWITH mint_rows AS (SELECT CAST(to_unixtime(evt_block_time) AS BIGINT) AS a,CAST(evt_block_number AS DOUBLE) AS b,CAST(amount AS DOUBLE) AS c,CAST(tickLower AS DOUBLE) AS d,CAST(tickUpper AS DOUBLE) AS e,CAST(evt_index AS DOUBLE) AS fFROM aerodrome_base.clpool_evt_mintWHERE contract_address = {{pool_address}}AND evt_block_time > from_unixtime({{after_ts}})),burn_rows AS (SELECT CAST(to_unixtime(evt_block_time) AS BIGINT) AS a,CAST(evt_block_number AS DOUBLE) AS b,CAST(amount AS DOUBLE) AS c,CAST(tickLower AS DOUBLE) AS d,CAST(tickUpper AS DOUBLE) AS e,CAST(evt_index AS DOUBLE) AS fFROM aerodrome_base.clpool_evt_burnWHERE contract_address = {{pool_address}}AND evt_block_time > from_unixtime({{after_ts}})),-- On-chain active liquidity + tick from the last swap in each recent block,-- for validating the reconstruction. Kept to a recent window to stay cheap.liqchk_rows AS (SELECT a, b, c, d, fFROM (SELECT CAST(to_unixtime(evt_block_time) AS BIGINT) AS a,CAST(evt_block_number AS DOUBLE) AS b,CAST(liquidity AS DOUBLE) AS c,