Query editor
WITHbuys AS (SELECT*FROMdex.tradesWHEREtoken_bought_address = 0x9E9FbDE7C7a83c43913BddC8779158F1368F0413),sells AS (SELECT*FROMdex.tradesWHEREtoken_sold_address = 0x9E9FbDE7C7a83c43913BddC8779158F1368F0413),all AS (SELECTtx_hash,'BUY' AS side,tx_from,amount_usd,token_bought_amount_raw / 1e18 AS token_amountFROMbuysUNION ALLSELECTtx_hash,'SELL' AS side,tx_from,-1 * amount_usd,token_sold_amount_raw / 1e18 AS token_amountFROMsells),gas_all_aggregate AS (SELECTtx_from AS wallet,SUM(gas_used) AS gas_used,SUM(amount_usd) AS net_volume_usd,SUM(ABS(amount_usd)) AS total_volume_usd,SUM(token_amount) AS net_volume,SUM(ABS(token_amount)) AS total_volumeFROMall aINNER JOIN ethereum.transactions t ON a.tx_hash = t.hashWHEREabs(amount_usd) > 10GROUP BY1),median_gas_price AS (SELECTdate_trunc('hour', block_time) AS block_time,(APPROX_PERCENTILE(gas_price, 0.5)) / 1e9 AS median_gas_price_gwei,(APPROX_PERCENTILE(gas_limit, 0.5)) / 1e9 AS median_gas_limit_gweiFROMethereum.transactionsWHERE