Query editor
WITH cow_trades AS (SELECTblock_time,bytearray_substring(data, 13, 20) AS sell_token,bytearray_substring(data, 45, 20) AS buy_token,bytearray_to_uint256(bytearray_substring(data, 65, 32)) AS sell_amount_raw,bytearray_to_uint256(bytearray_substring(data, 97, 32)) AS buy_amount_rawFROM ethereum.logsWHERE contract_address = 0x9008d19f58aabd9ed0d60971565aa8510560ab41AND topic0 = keccak(to_utf8('Trade(address,address,address,uint256,uint256,uint256,bytes)'))AND block_date >= CURRENT_DATE - INTERVAL '7' DAYAND block_time >= NOW() - INTERVAL '7' DAYAND block_time < NOW()),-- CoW Swap BUYcow_buy AS (SELECTblock_time,'BUY' AS side,CAST(buy_amount_raw AS DOUBLE) / 1e18 AS ethFROM cow_tradesWHERE buy_token IN (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee)),-- CoW Swap SELLcow_sell AS (SELECTblock_time,'SELL' AS side,CAST(sell_amount_raw AS DOUBLE) / 1e18 AS ethFROM cow_tradesWHERE sell_token IN (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee)),-- DEX aggregation by transactiondex_tx AS (SELECTtx_hash,MIN(block_time) AS block_time,SUM(CASEWHEN token_bought_address IN (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0x0000000000000000000000000000000000000000)THEN token_bought_amountELSE 0END)