Query editor
WITHother_tokens AS (SELECTCASEWHEN token0 = 0x0d9b0790e97e3426c161580df4ee853e4a7c4607 THEN token1ELSE token0END AS other_tokenFROMquickswap_v3_polygon.algebrafactory_evt_poolWHEREtoken0 = 0x0d9b0790e97e3426c161580df4ee853e4a7c4607OR token1 = 0x0d9b0790e97e3426c161580df4ee853e4a7c4607),-- daily_explosion AS (-- SELECT-- timestamp '2022-01-01 00:00:00' + interval '4' hour * hour_number AS hour-- FROM-- UNNEST (-- sequence(-- 0,-- DATE_DIFF(-- 'hour',-- timestamp '2022-01-01 00:00:00',-- current_timestamp-- ) / 4-- )-- ) AS t (hour_number)-- ),other_prices as (selectapprox_percentile(price, 0.5) as pair_price,token,block_hourfrom(selectamount_usd / token_bought_amount as price,token_bought_address as token,date_trunc('day', block_time) as block_hourfromquickswap.tradeswheretoken_bought_address in (select*fromother_tokens)and amount_usd is not nulland blockchain = 'polygon'AND is_finite(amount_usd) -- Filter out non-finite valuesAND is_finite(token_bought_amount) -- Filter out non-finite valuesand is_finite(token_sold_amount)and is_finite( amount_usd / token_bought_amount)union allselectamount_usd / token_sold_amount as price,token_sold_address as token,date_trunc('day', block_time) as block_hourfrom