Query editor
WITH bot_attacks AS (SELECTt."from",t.hash,t.priority_fee_per_gas,gas.tx_fee_usdFROM ethereum.transactions tLEFT JOIN gas.fees gasON t.hash = gas.tx_hashAND gas.blockchain = 'ethereum'AND gas.block_time >= CURRENT_TIMESTAMP - INTERVAL '24' HOURWHERE t.block_time >= CURRENT_TIMESTAMP - INTERVAL '24' HOURAND t.priority_fee_per_gas > 100000000000),dex_attacks AS (SELECTLEAST(token_bought_symbol, token_sold_symbol) || ' - ' || GREATEST(token_bought_symbol, token_sold_symbol) as pair,COUNT(*) as attack_countFROM dex.tradesWHERE blockchain = 'ethereum'AND block_time >= CURRENT_TIMESTAMP - INTERVAL '24' HOURAND tx_hash IN (SELECT hash FROM bot_attacks)GROUP BY LEAST(token_bought_symbol, token_sold_symbol) || ' - ' || GREATEST(token_bought_symbol, token_sold_symbol)ORDER BY attack_count DESCLIMIT 1)SELECTCOUNT(*) as "Total Bot Attacks",SUM(CAST(COALESCE(tx_fee_usd, 0) AS DOUBLE)) as "Total Damage (USD)",COUNT(DISTINCT "from") as "Active Bot Count",COALESCE((SELECT pair FROM dex_attacks), 'Unknown') as "Most Targeted Pair",MAX(CAST(COALESCE(priority_fee_per_gas, 0) AS DOUBLE) / 1e9) as "Peak Tip (Gwei)",AVG(CAST(COALESCE(priority_fee_per_gas, 0) AS DOUBLE) / 1e9) as "Avg Tip (Gwei)"FROM bot_attacks