Query editor
withconstants as (select{{pool_address_op}} as poolAddress) --,fee_tier as (selectcast(fee as double) / 1e6 as feeTierfromuniswap_v3_optimism.Factory_evt_PoolCreated,constantswherepool = poolAddress-- treatment for pools created before the regenesis (ovm v1 -> ovm v2)union allselectcast(fee as double) / 1e6 as feeTierfromuniswap_v3_optimism.ovm1_pool_mapping,constantswherenewAddress = poolAddress) --,swap_evt0 as (selectevt_block_time as time,evt_tx_hash,-- Derive realized prices from amount1 / amount0case --when cast(amount0 as double) > 0and cast(amount1 as double) < 0 --then abs(cast(amount1 as double) * (1 + feeTier) / cast(amount0 as double)) --when cast(amount0 as double) < 0and cast(amount1 as double) > 0 --then abs(cast(amount1 as double) / (1 + feeTier) / cast(amount0 as double)) ---- If amount is too small, it is shown as 0. Care for that case.else power(cast(sqrtPriceX96 as double), 2) / power(2, 192)end as price,cast(amount0 as double) as amount0,cast(amount1 as double) as amount1,cast(liquidity as double) as liquidityfromuniswap_v3_optimism.Pair_evt_Swap,constants,fee_tierwherecontract_address = poolAddressand evt_block_time > --now() --- interval '{{display_range_in_days_op}}' day --- interval '{{rolling_days_opti}}' day --- interval '1' day) --,