Query editor
withP as (select puffer_price as price from query_4925221 limit 1 ),X as(select evt_block_time, "from" as user, "to" as pool, 0+value/1e18 as amount, evt_tx_hash as hash, contract_address from erc20_ethereum.evt_transfer union allselect evt_block_time, "to" as user, "from" as pool, 0-value/1e18 as amount, evt_tx_hash as hash, contract_address from erc20_ethereum.evt_transfer ),A as(select date_trunc('week',evt_block_time) as time,sum(amount) as net_stake,sum(case when amount > 0 then amount else 0 end) as new_stake,sum(case when amount < 0 then amount else 0 end) as uns_stakefrom X as awhere contract_address = 0x4d1c297d39c5c1277964d0e3f8aa901493664530and pool = 0xa55ed5808aecdf23ae3782c1443185f5d2363ce7group by 1)select time, net_stake, new_stake, uns_stake,sum(net_stake) over(order by time) as total,sum(net_stake) over(order by time) * price as tvl,sum(net_stake) over(order by time) * price / 1e6 as tvl_countfrom A,Porder by 1 desc