Query editor
WITHTransferOps as(SELECTchain,--evt_tx_hash,--evt_tx_from,--evt_tx_to,evt_block_date as time_date,eventName,--msgSender,split_part(substring(eventData, strpos(eventData,'"token\\\",\\\"value\\\":\\\"')+29), '\\\"}', 1) as token,split_part(substring(eventData, strpos(eventData,'"account\\\",\\\"value\\\":\\\"')+31), '\\\"}', 1) as account,cast(split_part(substring(eventData, strpos(eventData,'"srcChainId\\\",\\\"value\\\":')+30), '}\"', 1) as UINT256) as srcChainId,cast(split_part(substring(eventData, strpos(eventData,'"amount\\\",\\\"value\\\":')+26), '}\"', 1) as UINT256) as amountFROM gmx_v2_multichain.eventemitter_evt_eventlog1WHEREeventName IN ('MultichainTransferIn', 'MultichainTransferOut')AND evt_block_date >= timestamp '2025-09-01'),TokenPrices as(SELECTtimestamp as time_date,blockchain,contract_address,symbol,price,decimalsFROM prices.dayWHERECAST(contract_address as varchar) IN (SELECT DISTINCT token FROM TransferOps)AND timestamp >= timestamp '2025-09-01'),Chains (chainId, chainName) as ( values(0, 'Internal'),(1, 'Mainnet'),(56, 'BNB'),(8453, 'Base'),(42161, 'Internal'),(43114, 'Internal')),Final as (SELECTto.chain,to.time_date,c.chainName as srcChain,COUNT(*) as op_count,COUNT(DISTINCT to.account) as user_count,SUM(IF(to.eventName='MultichainTransferIn', amount * tp.price / pow(10,tp.decimals), 0)) as amount_in_usd,SUM(IF(to.eventName='MultichainTransferIn', 0, amount * tp.price / pow(10,tp.decimals))) * -1 as amount_out_usdFROM TransferOps toLEFT JOIN TokenPrices tp ON tp.blockchain = to.chain and tp.time_date = to.time_date AND CAST(tp.contract_address as varchar) = to.tokenLEFT JOIN Chains c on c.chainId = to.srcChainIdGROUP BY 1, 2, 3