Query editor
with add_liq as (select sum(value/1e18) as total_add, contract_address,date_trunc('day', evt_block_time::date) as dtfrom bep20."BEP20_evt_Transfer"where evt_tx_hash in (select hashfrom bsc.transactionswhere "to" = '\x20a304a7d126758dfe6b243d0fc515f83bca8431'and hash in (select evt_tx_hashfrom bep20."BEP20_evt_Transfer"where "from" = '\x0000000000000000000000000000000000000000'))and "from" != '\x0000000000000000000000000000000000000000'group by 2,3),remove_liq as (select sum(value/1e18) as total_remove, contract_address,date_trunc('day', evt_block_time::date) as dtfrom bep20."BEP20_evt_Transfer"where evt_tx_hash in (select hashfrom bsc.transactionswhere "to" = '\x20a304a7d126758dfe6b243d0fc515f83bca8431'and hash in (select evt_tx_hashfrom bep20."BEP20_evt_Transfer"where "to" = '\x0000000000000000000000000000000000000000'))and "to" != '\x0000000000000000000000000000000000000000'group by 2,3),price as (select avg(price) as price, date_trunc('day', minute) as dt_price,case when contract_address = '\x4d2d32d8652058bf98c772953e1df5c5c85d9f45' then 'DAO'when contract_address = '\xb58a9d5920af6ac1a9522b0b10f55df16686d1b6' then 'FITFI'else symbolend as symbol,contract_addressfrom prices."usd"where contract_address in (select contract_address from add_liq)and minute::date >= '2022-12-01'group by 2,3,4)select sum(total_add_usd) as net_liq_add, dt,SUM(sum(total_add_usd)) OVER( ORDER BY dt ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS current_liq_usdfrom (select sum(total_add * price) as total_add_usd, symbol,dtfrom add_liq aleft join price p ona.dt = p.dt_priceand a.contract_address = p.contract_addressgroup by 2,3unionselect sum(total_remove * -price) as total_remove_usd, symbol,dt