Query editor
WITH prices AS (SELECTDATE_TRUNC('hour', evt_block_time) AS time,cast("tokens_sold" as double) / cast("tokens_bought" as double) AS price,"tokens_bought" AS amountFROMcurvefi_ethereum.steth_swap_evt_TokenExchangeWHEREsold_id = cast(0 as int256)AND "tokens_bought" > cast(10 as uint256)UNIONSELECTDATE_TRUNC('hour', evt_block_time) AS time,cast("tokens_bought" as double)/ cast("tokens_sold" as double) AS price,"tokens_sold" AS amountFROMcurvefi_ethereum.steth_swap_evt_TokenExchangeWHEREsold_id = cast(1 as int256)AND "tokens_sold" > cast(10 as uint256))SELECTtime,SUM(cast(price as double) * CAST(amount AS DOUBLE)) / SUM(CAST(amount AS DOUBLE)) AS weight_avg_priceFROM pricesGROUP BY 1ORDER BY 1/*with prices as (select date_trunc('hour', evt_block_time) as time,"tokens_sold"/"tokens_bought" as price,"tokens_bought" as amountfrom curvefi."steth_swap_evt_TokenExchange"where sold_id = 0 and "tokens_bought" <> 0unionselect date_trunc('hour', evt_block_time) as time,"tokens_bought"/"tokens_sold" as price,"tokens_sold" as amountfrom curvefi."steth_swap_evt_TokenExchange"where sold_id = 1 and "tokens_sold" <> 0)select time,sum(price*amount)/sum(amount) as weight_avg_pricefrom pricesgroup by 1order by 1*/