Query editor
--Code shoutout to @KARTODWITH stable AS (SELECTcontract_address,decimals,case when symbol='PAX' then 'USDP'when symbol='UST' then 'USTC'else symbol end as symbolFROM tokens.erc20WHERE contract_address IN(0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd,0xdAC17F958D2ee523a2206206994597C13D831ec7,0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,0x4Fabb145d64652a948d72533023f6E7A623C7C53,0x8E870D67F660D95d5be530380D0eC0bd388289E1, 0x0000000000085d4780B73119b644AE5ecd22b376,0x6B175474E89094C44Da98b954EedeAC495271d0F,0x99D8a9C45b2ecA8864373A26D1459e3Dff1e17F3,0x57Ab1ec28D129707052df4dF418D58a2D46d5f51,0x674C6Ad92Fd080e4004b2312b45f796a192D27a0,0xa47c8bf37f92aBed4A126BDA807A7b7498661acD,0x853d955aCEf822Db058eb8505911ED77F175b99e,0x0C10bF8FcB7Bf5412187A595ab97a3609160b5c6, 0x5f98805A4E8be255a32880FDeC7F6728C6568bA0)union allselect 0x5aa00dce91409b58b6a1338639b9daa63eb22be7 as contract_address, 18 as decimals, 'crvUSD' as symbol),daily_change as (select day, symbol,sum(amount) as amountfrom (SELECTdate_trunc('day', evt_block_time) AS day,b.symbol,cast(value as double)/power(10,decimals)*-1 AS amountFROM erc20_ethereum.evt_Transfer aLEFT JOIN stable b ON a.contract_address = b.contract_addressWHERE a.contract_address IN (SELECT contract_address FROM stable where symbol<>'USDT' and symbol<>'USDN')AND "to" = 0x0000000000000000000000000000000000000000UNION ALLSELECTdate_trunc('day', evt_block_time) AS day,b.symbol,cast(value as double)/power(10,decimals) AS amountFROM erc20_ethereum.evt_Transfer aLEFT JOIN stable b ON a.contract_address = b.contract_addressWHERE a.contract_address IN (SELECT contract_address FROM stable where symbol<>'USDT')AND "from" = 0x0000000000000000000000000000000000000000UNION ALLSELECTdate_trunc('day', evt_block_time) AS day,b.symbol,-cast(value as double)/power(10,decimals) AS amountFROM erc20_ethereum.evt_Transfer aLEFT JOIN stable b ON a.contract_address = b.contract_addressWHERE a.contract_address IN (SELECT contract_address FROM stable where symbol='USDT')AND "to" = 0xc6cde7c39eb2f0f0095f41570af89efc2c1ea828UNION ALLSELECTdate_trunc('day', evt_block_time) AS day,b.symbol,cast(value as double)/power(10,decimals) AS amountFROM erc20_ethereum.evt_Transfer aLEFT JOIN stable b ON a.contract_address = b.contract_addressWHERE a.contract_address IN (SELECT contract_address FROM stable where symbol='USDT')AND "from" = 0xc6cde7c39eb2f0f0095f41570af89efc2c1ea828UNION allSELECT