Query editor
withconstants as (select{{pool_address_l1}} as poolAddress) --,fee_tier as (selectcast(fee as double) / 1e6 as feeTierfromuniswap_v3_ethereum.Factory_evt_PoolCreated,constantswherepool = 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_ethereum.Pair_evt_Swap,constants,fee_tierwherecontract_address = poolAddressand evt_block_time > --now() --- interval '{{display_range_in_days_l1}}' day --- interval '{{rolling_days_l1}}' day --- interval '1' day) --,-- The last trade time in a dayclosing_times as (selectdate_trunc('day', time) as time,max(time) as cTimefromswap_evt0group by1