Query editor
with steth_deposit as (selectdate_trunc('day',evt_block_time) as time,sum(cast(value as decimal(38, 0))/1e18) as amountfrom erc20_ethereum.evt_Transferwhere evt_block_number >= 11607098 --1st stETH tx in Lido treasury --11473216 treasury Createdand to = 0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c -- Lido treasuryand contract_address = 0xae7ab96520de3a18e5e111b5eaab095312d7fe84 -- stETHgroup by 1),steth_withdraw as (selectdate_trunc('day',evt_block_time) as time,sum(cast(value as decimal(38, 0))/1e18) as amountfrom erc20_ethereum.evt_Transferwhere evt_block_number >= 11607098 -- Createdand "from" = 0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c -- Lido treasuryand contract_address = 0xae7ab96520de3a18e5e111b5eaab095312d7fe84 -- stETHgroup by 1), steth_daily_balance as(select COALESCE(d.time,w.time) as time,COALESCE(d.amount,0) as daily_deposited,(-1) * COALESCE(w.amount,0) as daily_withdrawn,COALESCE(d.amount,0) - COALESCE(w.amount,0) as daily_balancefrom steth_deposit d full outer join steth_withdraw w on d.time = w.time), stETH_prices AS(SELECT distinctDATE_TRUNC('day', minute) AS time,last_value(price) over (partition by DATE_TRUNC('day', minute) ORDER BY minute range between unbounded preceding AND unbounded following) AS priceFROM prices.usdWHERE contract_address = 0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84)selectb.time,sum(daily_balance) over (order by b.time) as cumulative_balance,sum(daily_balance) over (order by b.time) * prices.price as value,sum(daily_deposited) over (order by b.time) as inflow_cumul,-sum(daily_withdrawn) over (order by b.time) as outflow_cumul,price as price,daily_deposited,daily_withdrawn,daily_balancefrom steth_daily_balance bleft join stETH_prices prices on b.time = prices.timeorder by 1