Query editor
WITH eth_trades AS (SELECT -- buyblock_date,block_time,'ETH' AS chain,'BUY' AS action,token_bought_amount AS amt,amount_usd AS usd,amount_usd/token_bought_amount AS priceFROM dex.tradesWHERE token_bought_address = 0xd9ebbC7970e26B4eCeD7323b9331763E8272D011AND amount_usd IS NOT NULLUNION ALLSELECT --sellblock_date,block_time,'ETH' AS chain,'SELL' AS action,token_sold_amount AS amt,amount_usd AS usd,amount_usd/token_sold_amount AS priceFROM dex.tradesWHERE token_sold_address = 0xd9ebbC7970e26B4eCeD7323b9331763E8272D011AND amount_usd IS NOT NULL),base_trades AS (SELECT -- buyblock_date,block_time,'BASE' AS chain,'BUY' AS action,token_bought_amount AS amt,amount_usd AS usd,amount_usd/token_bought_amount AS priceFROM dex.tradesWHERE token_bought_address = 0x029a3b0532871735809A51E8653d6017eF04b6FaAND amount_usd IS NOT NULLUNION ALLSELECT --sellblock_date,block_time,'BASE' AS chain,'SELL' AS action,token_sold_amount AS amt,amount_usd AS usd,amount_usd/token_sold_amount AS priceFROM dex.tradesWHERE token_sold_address = 0x029a3b0532871735809A51E8653d6017eF04b6FaAND amount_usd IS NOT NULL),eth_daily_price AS (SELECTblock_date,action,sum(amt) AS total_amount,sum(usd) AS usd_volume,sum(usd)*0.3/100 AS fees_generated,sum(usd)/sum(amt) as avg_price