Query editor
with steth_eth_price as (SELECTtime, lead(time, 1, DATE_TRUNC('day', now()) + interval '1' day) OVER ( ORDER BY time) AS next_time, sum(price*amount)/sum(amount) as price_steth_ethFROM (SELECTDATE_TRUNC('day', evt_block_time) AS time, CAST(tokens_sold AS DOUBLE) / CAST(tokens_bought AS DOUBLE) AS price, CAST(tokens_bought AS DOUBLE) AS amountFROM curvefi_ethereum.steth_swap_evt_TokenExchangeWHERE CAST(sold_id as DOUBLE) = 0and CAST(tokens_bought AS DOUBLE) <> 0union allSELECTDATE_TRUNC('day', evt_block_time) AS time, CAST(tokens_bought AS DOUBLE) / CAST(tokens_sold AS DOUBLE) AS price, CAST(tokens_sold AS DOUBLE) AS amountFROM curvefi_ethereum.steth_swap_evt_TokenExchangeWHERE CAST(sold_id as DOUBLE) = 1AND CAST(tokens_sold AS DOUBLE) <> 0) price_steth_ethGROUP BY 1)--steth_eth_price, balance as (SELECTc.time, lead(c.time, 1, now()) OVER ( ORDER BY c.time) AS next_time, c.eth_pool as amount_eth, c.steth_pool as amount_steth, p.price_steth_eth, c.steth_pool * p.price_steth_eth as amount_steth_in_eth, (c.eth_pool)/(c.eth_pool + p.price_steth_eth * c.steth_pool) as eth_steth_rate, (p.price_steth_eth * c.steth_pool) / (c.eth_pool + p.price_steth_eth * c.steth_pool) as steth_eth_rateFROM (SELECT * from query_374112) c--query_2301424) cLEFT JOIN steth_eth_price p ON date_trunc('day',c.time) >= date_trunc('day', p.time) and date_trunc('day',c.time) < date_trunc('day', p.next_time)) --balance, exchanges as (-- eth/steth exchangeselectdate_trunc('minute', evt_block_time) as time, (cast(tokens_sold as DOUBLE) / 1E18) as volume, (cast(tokens_bought as DOUBLE) / 1E18) as eth_volumefrom curvefi_ethereum.steth_swap_evt_TokenExchangewhere cast(sold_id as DOUBLE) = 1union allselectdate_trunc('minute', evt_block_time) as time, (cast(tokens_bought as DOUBLE)/1E18) as volume, (cast(tokens_sold as DOUBLE)/1E18) as eth_volumefrom curvefi_ethereum.steth_swap_evt_TokenExchangewhere cast(sold_id as DOUBLE) = 0order by 1 desc