Query editor
withtrades AS (SELECTd.block_time AS time,d.tx_hash AS tx,d.project AS project,--d.project_contract_address AS pool,d.token_bought_symbol AS bought,--d.token_bought_address AS bought_address,d.token_sold_symbol AS sold,---d.token_sold_address AS sold_address,d.token_pair AS pair,d.token_bought_amount AS bought_amount,d.token_sold_amount AS sold_amount,d.amount_usd AS usd_amount,tx_from, tx_toFROM dex.trades dWHERE d.blockchain = 'sonic'AND (d.token_bought_address = 0xe5da20f15420ad15de0fa650600afc998bbe3955OR d.token_sold_address = 0xe5da20f15420ad15de0fa650600afc998bbe3955)),swapx AS (SELECTtimestamp AS time,address_32_from_hex(transaction_hash) AS tx,'swapx' AS project,output_token_symbol AS bought,input_token_symbol AS sold,pair_name AS pair,output_token_amount AS bought_amount,input_token_amount AS sold_amount,swap_amount_usd AS usd_amount,varbinary_substring(address_32_from_hex(taker_address), 13) AS tx_from,varbinary_substring(address_32_from_hex(maker_address), 13) AS tx_toFROM query_4761131WHERE (input_token_address = '0xe5da20f15420ad15de0fa650600afc998bbe3955'OR output_token_address = '0xe5da20f15420ad15de0fa650600afc998bbe3955')),aggregate AS (SELECT * FROM tradesUNION ALLSELECT * FROM swapx)SELECT *FROM aggregateORDER BY 1 DESC