Query editor
with all_trades as (selectdate_trunc('{{time}}', block_time) as period,avg(amount_usd / token_bought_amount) as avg_price_usdfrom dex.tradeswhere blockchain = 'base'and token_bought_address = {{contract_address}}and amount_usd > 0and token_bought_amount > 0group by 1union allselectdate_trunc('{{time}}', block_time) as period,avg(amount_usd / token_sold_amount) as avg_price_usdfrom dex.tradeswhere blockchain = 'base'and token_sold_address = {{contract_address}}and amount_usd > 0and token_sold_amount > 0group by 1)selectperiod,avg(avg_price_usd) as price_usdfrom all_tradesgroup by periodorder by period asc