Query editor
with pair_detail as (select -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||token0, -- || Pair token0-token1 ||token1, -- || (token0) amount0*price0/decimal0 ||date_trunc('minute', evt_block_time) as block_time, -- || (token1) amount1*price1/decimal1 这里要计算 price0, price0 = amount1*price1/decimal1/(amount0/decimals0) ||avg(amount1 / amount0) as tmp_price -- || Calculate the average price per minute. (decimals 对应两个token的精度) ||from -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||(select0x2ecba91da63c29ea80fbe7b52632ca2d1f8e5be0 as token0,-- FERC0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 as token1,-- WETHcast(amount0 as decimal(38,0))/1e18 as amount0, -- token0 decimal-cast(amount1 as decimal(38,0))/1e18 as amount1, -- token1 decimal-- (cast(amount1In as double)/1e18)/ (cast(amount0Out as double)/1e18) * 1900 as price,t1.evt_block_time,t1.evt_tx_hashfromuniswap_v3_ethereum.Pair_evt_Swap t1where t1.contract_address=0x253c06b22d4b67b675ea7d2fd48422e62c394d7e -- pair address-- and evt_tx_hash <> 0x7ddd8202037bc7230c3b6e2dceadde16343ea93c157c21c52a21813d95ea3e84 -- maybe exceptionand cast(amount0 as double) > 0-- and (t1.evt_block_time > timestamp '2023-04-29 15:00' and t1.evt_block_time < timestamp '2023-04-29 16:00')) tmpgroup by1,2,3-- union-- select -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||-- token0, -- || Pair token0-token1 ||-- token1, -- || (token0) amount0*price0/decimal0 ||-- date_trunc('minute', evt_block_time) as block_time, -- || (token1) amount1*price1/decimal1 这里要计算 price0, price0 = amount1*price1/decimal1/(amount0/decimals0) ||-- avg(amount0 / amount1) as tmp_price -- || Calculate the average price per minute. (decimals 对应两个token的精度) ||-- from -- |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||-- (-- select-- 0x2ecba91da63c29ea80fbe7b52632ca2d1f8e5be0 as token0,-- FERC-- 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 as token1,-- WETH-- -cast(amount0 as decimal(38,0))/1e18 as amount0, -- token0 decimal-- cast(amount1 as decimal(38,0))/1e18 as amount1, -- token1 decimal-- -- (cast(amount1In as double)/1e18)/ (cast(amount0Out as double)/1e18) * 1900 as price,-- t1.evt_block_time,-- t1.evt_tx_hash-- from-- uniswap_v3_ethereum.Pair_evt_Swap t1-- where t1.contract_address=0x253c06b22d4b67b675ea7d2fd48422e62c394d7e -- pair address-- -- and evt_tx_hash <> 0x7ddd8202037bc7230c3b6e2dceadde16343ea93c157c21c52a21813d95ea3e84 -- maybe exception-- and cast(amount0 as double) < 0-- -- and (t1.evt_block_time > timestamp '2023-04-29 15:00' and t1.evt_block_time < timestamp '2023-04-29 16:00')-- ) tmp-- group by-- 1,2,3),-- pair_detail as (-- select-- token0,-- token1,-- block_time,-- avg(tmp_price) as tmp_price-- from-- tmp_pair_detail-- group by