Query editor
with r_dai_pool as (select net_tvl, symbol, sum(net_tvl) over (partition by symbol order by dt) as total_tvl, symbol, dtfrom (select sum(total_transfer) as net_tvl, symbol, dtfrom (select sum(value/1e18) as total_transfer,case when contract_address = 0x6B175474E89094C44Da98b954EedeAC495271d0F then 'DAI'when contract_address = 0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21 then 'R'end as symbol,date_trunc('day', evt_block_time) as dtfrom erc20_ethereum.evt_Transferwhere evt_tx_hash in (select tx_hashfrom ethereum.logswhere topic0 = 0xe5ce249087ce04f05a957192435400fd97868dba0e6a4b4c049abf8af80dae78and topic1 = 0x20A61B948E33879CE7F23E535CC7BAA3BC66C5A9000000000000000000000555)and "to" = 0xBA12222222228d8Ba445958a75a0704d566BF2C8and contract_address in (0x6B175474E89094C44Da98b954EedeAC495271d0F, 0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21)group by 2,3unionselect sum(value/-1e18) as total_transfer,case when contract_address = 0x6B175474E89094C44Da98b954EedeAC495271d0F then 'DAI'when contract_address = 0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21 then 'R'end as symbol,date_trunc('day', evt_block_time) as dtfrom erc20_ethereum.evt_Transferwhere evt_tx_hash in (select tx_hashfrom ethereum.logswhere topic0 = 0xe5ce249087ce04f05a957192435400fd97868dba0e6a4b4c049abf8af80dae78and topic1 = 0x20A61B948E33879CE7F23E535CC7BAA3BC66C5A9000000000000000000000555)and "from" = 0xBA12222222228d8Ba445958a75a0704d566BF2C8and contract_address in (0x6B175474E89094C44Da98b954EedeAC495271d0F, 0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21)group by 2,3)group by 2,3)),r_bb_dai_pool as (select net_tvl, symbol, sum(net_tvl) over (partition by symbol order by dt) as total_tvl, symbol, dtfrom (select sum(total_transfer) as net_tvl, symbol, dtfrom (select sum(value/1e18) as total_transfer,case when contract_address = 0x2B218683178d029BAB6c9789b1073aA6c96E5176 then 'bb_DAI'when contract_address = 0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21 then 'R'end as symbol,date_trunc('day', evt_block_time) as dtfrom erc20_ethereum.evt_Transferwhere evt_tx_hash in (select tx_hashfrom ethereum.logswhere topic0 = 0xe5ce249087ce04f05a957192435400fd97868dba0e6a4b4c049abf8af80dae78and topic1 = 0xBF2EF8BDC2FC0F3203B3A01778E3EC5009AEEF3300000000000000000000058D)and "to" = 0xBA12222222228d8Ba445958a75a0704d566BF2C8and contract_address in (0x2B218683178d029BAB6c9789b1073aA6c96E5176, 0x183015a9bA6fF60230fdEaDc3F43b3D788b13e21)group by 2,3unionselect sum(value/-1e18) as total_transfer,