Query editor
with CEX as (with days AS (select day from unnest(sequence(cast('2020-08-01' as timestamp(3)), cast(current_timestamp as timestamp(3)), interval '1' day)) as days(day)),CEX as (select 0x12d4444f96c644385d8ab355f6ddf801315b6254 as holderunion allselect 0x860caf97d5da97145004cb45a4bf458686fd90e5 as holderunion allselect 0x1c580cc549d03171b13b55074dc1658f60641c73 as holderunion allselect 0x1af23b311f203844108137d6ee399109e4981401 as holder)select day, holderfrom daysfull join CEX on 1=1),deposits as (selectDATE_TRUNC('day', evt_block_time) as day,"to" as holder,sum(amount)/1e18 as depositfrom powerpool_ethereum.CVP_evt_TransferWHERE "to" in (select holder from CEX)and "from" not in (select holder from CEX)group by 1,2),withdrawals as (selectDATE_TRUNC('day', evt_block_time) as day,"from" as holder,0-sum(amount)/1e18 as withdrawalfrom powerpool_ethereum.CVP_evt_TransferWHERE "from" in (select holder from CEX)and "to" not in (select holder from CEX)group by 1,2)selectcasewhen c.holder = 0x12d4444f96c644385d8ab355f6ddf801315b6254 then 'Uniswap_V2:CVP'when c.holder = 0x860caf97d5da97145004cb45a4bf458686fd90e5 then 'Uniswap_V3:CVP'when c.holder = 0x1c580cc549d03171b13b55074dc1658f60641c73 then 'SushiSwap:CVP'when c.holder = 0x1af23b311f203844108137d6ee399109e4981401 then 'Balancer:CVP/ETH'end as Pool,c.day,round(sum(d.deposit)) as deposit,round(sum(w.withdrawal)) as withdrawalfrom CEX cleft join deposits d on c.holder = d.holder and c.day = d.dayleft join withdrawals w on c.holder = w.holder and c.day = w.daywhere c.day > NOW() - INTERVAL '30' DAYgroup by 1, 2order by 2 desc/*