Query editor
with ankrETH_ratio as (select time, sum(price*amount)/sum(amount) as ratiofrom (select date_trunc('day', evt_block_time) as time,(cast(tokens_bought as double)/1e18)/(cast(tokens_sold as double)/1e18) as price,(cast(tokens_bought as double)/1e18) as amountfrom curvefi_ethereum.ankreth_swap_evt_TokenExchangewhere contract_address = 0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2 -- Curve Finance: ankrETH - wETH LP Pairand evt_block_time >= date('2021-02-02') -- pair createdand cast(bought_id as varchar) = '1'union allselect date_trunc('day', evt_block_time) as time,(cast(tokens_sold as double)/1e18)/(cast(tokens_bought as double)/1e18) as price,(cast(tokens_sold as double)/1e18) as amountfrom curvefi_ethereum.ankreth_swap_evt_TokenExchangewhere contract_address = 0xA96A65c051bF88B4095Ee1f2451C2A9d43F53Ae2 -- Curve Finance: ankrETH - wETH LP Pairand evt_block_time >= date('2021-02-02') -- pair createdand cast(sold_id as varchar) = '1') price_bothgroup by 1order by 1 desc),wETH_price as (select day as time, avg(price) as avg_pricefrom(select date_trunc('day', minute) as day, pricefrom prices.usd where blockchain = 'ethereum' and symbol = 'WETH') xgroup by 1order by 1 desc),ankrETH_price as (select time, ratio as token_ratio, ratio*avg_price as ankrETH_pricefrom ankrETH_ratioleft join wETH_price using (time))select *from ankrETH_priceorder by time desc