Query editor
WITH flows AS (SELECT bytearray_substring(topic2, 13, 20) AS holder,CAST(bytearray_to_uint256(data) AS DOUBLE) / 1e18 AS amtFROM robinhood.logsWHERE contract_address = 0xD9d674b04A72AFfe00E06385535Eaac10B988fCaAND topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efAND bytearray_substring(topic1, 13, 20) <> 0x0000000000000000000000000000000000000000UNION ALLSELECT bytearray_substring(topic1, 13, 20) AS holder,-CAST(bytearray_to_uint256(data) AS DOUBLE) / 1e18 AS amtFROM robinhood.logsWHERE contract_address = 0xD9d674b04A72AFfe00E06385535Eaac10B988fCaAND topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efAND bytearray_substring(topic2, 13, 20) <> 0x0000000000000000000000000000000000000000)SELECT to_hex(holder) AS holder,SUM(amt) AS drill_balance_est,COUNT(*) AS transfer_countFROM flowsWHERE holder NOT IN (0x8366a39CC670B4001A1121B8F6A443A643e40951,0xEAAea1bF6778BaB1f39768f56a7BC08783E7b5F2,0x0000000000000000000000000000000000000000)GROUP BY 1HAVING SUM(amt) > 0ORDER BY 2 DESCLIMIT 50;