Query editor
with tokens(contract_address, symbol, decimals) as (values(0x0000000000000000000000000000000000000000, 'ETH', 18),(0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 'USDC', 6),(0xdac17f958d2ee523a2206206994597c13d831ec7, 'USDT', 6),(0x2260fac5e5542a773aa44fbcfedf7c193bc2c599, 'WBTC', 8),(0xa49d7499271ae71cd8ab9ac515e6694c755d400c, 'MUTE', 18),(0xae78736cd615f374d3085123a210448e74fc6393, 'rETH', 18),(0x5f98805a4e8be255a32880fdec7f6728c6568ba0, 'LUSD', 18)), prices as (select if(symbol = 'WETH', 'ETH', symbol) as symbol, avg(price) as pricefrom prices.usdwhere blockchain = 'ethereum' and minute >= date_trunc('day', now())and symbol in ('WETH', 'USDC', 'USDT', 'WBTC', 'rETH', 'LUSD')group by 1unionselect 'MUTE' as symbol,avg(amount_usd/token_bought_amount) as pricefrom uniswap_v2_ethereum.tradeswhere block_time >= date_trunc('day', now())and project_contract_address = 0x0efb424c465dbd0a626359d63412838f727f2c25and token_bought_address = 0xa49d7499271ae71cd8ab9ac515e6694c755d400cgroup by 1), dws as (select evt_block_time as block_time, "from" as user,l1Token as token_address, cast(amount as double) as raw_amount,'deposit' as tx_typefrom zksync_v2_ethereum.L1ERC20Bridge_evt_DepositInitiatedunionselect evt_block_time as block_time, "to" as user,l1Token as token_address, cast(amount as double) * -1 as raw_amount,'withdraw' as tx_typefrom zksync_v2_ethereum.L1ERC20Bridge_evt_WithdrawalFinalizedunionselect block_time, bytearray_substring(data, 205, 20) as user,0x0000000000000000000000000000000000000000 as token_address,cast(bytearray_to_uint256(bytearray_substring(data, 449, 32)) as double) as raw_amount,'deposit' as tx_typefrom ethereum.logswhere block_time >= timestamp '2023-2-14 10:11'and contract_address = 0x32400084c286cf3e17e7b677ea9583e60a000324and topic0 = 0x4531cd5795773d7101c17bdeb9f5ab7f47d7056017506f937083be5d6e77a382unionselect evt_block_time as block_time, to as user,0x0000000000000000000000000000000000000000 as token_address,cast(amount as double) * -1 as raw_amount,'withdraw' as tx_typefrom zksync_ethereum.MailboxFacet_evt_EthWithdrawalFinalized), tmp1 as (select user, token_address,count(distinct token_address) as tokens_deposited,sum(if(tx_type = 'deposit', 1, 0)) as deposits,sum(if(tx_type = 'withdraw', 1, 0)) as withdraws,sum(if(tx_type = 'deposit', raw_amount, 0)) as deposit_raw_amount,sum(if(tx_type = 'withdraw', raw_amount, 0)) as withdraw_raw_amount,sum(raw_amount) as total_raw_amountfrom dws