Query editor
withP as( SELECT * from prices.usd_latest),A as( select date(evt_block_time) as day, "to" as address ,"from" as bridge, contract_address, 0-cast(value as double)/1e6 as amount from evms.erc20_transfers union allselect date(evt_block_time) as day, "from" as address ,"to" as bridge, contract_address, cast(value as double)/1e6 as amount from evms.erc20_transfers ),B as( select day, a.contract_address, b.symbol,case when b.symbol in ('USDC','USDT','WBTC') then b.symbol else 'altcoins' end as cate,case when b.symbol in ('USDC','USDT') then sum(b.price*amount)when b.symbol in ('WBTC') then sum(b.price*amount/1e2) else sum(b.price*amount/1e12) end as valuefrom A as ajoin P as b on a.contract_address = b.contract_addresswhere bridge = 0x57891966931Eb4Bb6FB81430E6cE0A03AAbDe063group by 1,2,3,4order by day desc ),PE as( SELECT price from prices.usd_latest where symbol = 'ETH' and blockchain is null),AE as( select date(block_time) as day, "to" as address ,"from" as bridge, call_type, 0-cast(value as double)/1e18 as amount from ethereum.traces where success = true union allselect date(block_time) as day, "from" as address ,"to" as bridge, call_type, cast(value as double)/1e18 as amount from ethereum.traces where success = true),BE as( select day, 0x as contract_address, 'ETH' as symbol, 'ETH' as cate, sum(amount * (select * from PE) ) as valuefrom AEwhere bridge = 0x49048044D57e1C92A77f79988d21Fa8fAF74E97eand (call_type is null or call_type NOT IN ('delegatecall', 'callcode', 'staticcall') )group by 1,2,3,4order by day desc),D as( select * from BE-- union all select * from B)select * from Dwhere day >= date('2023-03-01')