Query editor
with-- XXX not using Dune's price table-- Dune is scraping Coinpaprika's data and importing it into `prices."usd"`.-- Turns out Coinpaprika takes LQTY price from a single source: Uni v2!-- This makes it pointless to use ATM, since Uni v3 is a better approximation-- of LQTY price by now.-- d as (-- select-- DATE_TRUNC('hour', "minute") as "time",-- AVG("price") as "price"-- from prices."usd"-- where-- "contract_address" = '\x6dea81c8171d0ba574754ef6f8b412f2ed88c54d' -- LQTY-- and "minute" >= '2021-07-07'-- group by 1-- ),u2 as (selectDATE_TRUNC('hour', s."evt_block_time") as "time",SUM(e."price" * (s."amount1In" + s."amount1Out"))/ SUM(s."amount0In" + s."amount0Out") as "price"fromuniswap_v2."Pair_evt_Swap" sjoinprices."usd" eon DATE_TRUNC('minute', s."evt_block_time") = e."minute"wheres."contract_address" = '\xb13201b48b1e61593df055576964d0b3aab66ea3' and -- WETH <=> LQTY paire."contract_address" = '\xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' -- WETHand s."evt_block_time" > '2021-04-04'and e."minute" > '2021-04-04'and s."evt_block_time" < '2021-05-12'and e."minute" < '2021-05-12'group by 1),u3 as (selectDATE_TRUNC('hour', s."evt_block_time") as "time",AVG(e."price" * (s."sqrtPriceX96" / 2^96)^2) as "price"fromuniswap_v3."Pair_evt_Swap" sjoinprices."usd" eon DATE_TRUNC('minute', s."evt_block_time") = e."minute"wheres."contract_address" = '\xd1d5a4c0ea98971894772dcd6d2f1dc71083c44e' and -- WETH <=> LQTY paire."contract_address" = '\xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' -- WETHand s."evt_block_time" >= '2021-05-12'and e."minute" >= '2021-05-12'-- and s."evt_block_time" < '2021-07-07'-- and e."minute" < '2021-07-07'group by 1),u as (-- select * from d