Query editor
WITH flows AS (SELECTCASE-- DepositWHEN topic0 = 0x686cb4bac974cd11b0f8a75fc7c7764ed12cc46faaec53110f807aa802a7acb4 THEN-- Safe division by 1e6 for USDC (6 decimals)CAST(CAST(bytearray_to_uint256(bytearray_substring(data, 1, 32)) / 1000000AS BIGINT)AS DECIMAL(38,6))-- Withdrawal RequestWHEN topic0 = 0xe5c7fe3a4ffca1590f26d74c8ba8b0db69557f7f4607a2a43f82e93041611978 THEN-CAST(CAST(bytearray_to_uint256(bytearray_substring(data, 1, 32)) / 1000000AS BIGINT)AS DECIMAL(38,6))END AS signed_amount_usdFROM arbitrum.logsWHERE contract_address = 0x2df1c51e09aecf9cacb7bc98cb1742757f163df7AND topic0 IN (0x686cb4bac974cd11b0f8a75fc7c7764ed12cc46faaec53110f807aa802a7acb4,0xe5c7fe3a4ffca1590f26d74c8ba8b0db69557f7f4607a2a43f82e93041611978)AND block_time >= DATE_TRUNC('month', CURRENT_DATE - INTERVAL '12' MONTH))SELECTSUM(signed_amount_usd) AS net_flow_usdFROM flows;