Query editor
withL (ybs,contract) as( values('USDe' , 0x4c9edd5852cd905f086c759e8383e09bff1e68b3),('eUSDe' , 0x90d2af7d622ca3141efa4d8f1f24d86e5974cc8f)),X as(select evt_block_time, "from" as user, "to" as pool, 0+value/1e18 as amount, contract_address from erc20_ethereum.evt_transfer union allselect evt_block_time, "to" as user, "from" as pool, 0-value/1e18 as amount, contract_address from erc20_ethereum.evt_transfer ),A as(select date_trunc('day',evt_block_time) as time, ybs, sum(amount) as amountfrom X as ajoin L as b on a.contract_address = b.contractwhere pool = 0xA62B204099277762d1669d283732dCc1B3AA96CEgroup by 1,2 ),U as( select distinct time from A ),V as( select distinct ybs from A ),T as( select time,ybs from U,V group by 1,2),B as(select a.time, a.ybs, case when amount is not null then amount else 0 end as amountfrom T as aleft join A as b on a.time = b.time and a.ybs = b.ybs )select time, ybs, amount, sum(amount) over(partition by ybs order by time) as total,rank() over(order by time desc) as rankfrom Border by 1 desc