Query editor
WITH deposits AS(SELECT date_trunc('day', block_time) AS deposit_time,SUM(CAST(value AS DOUBLE))/ 1e18 AS eth_depositsFROM ethereum.tracesWHERE "to" = 0x00000000219ab540356cBB839Cbe05303d7705FaAND (LOWER(call_type) NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type is null)AND successAND CAST(value AS DOUBLE) > 0AND block_time >= date('2020-11-01')GROUP BY 1),full_withdrawals AS (SELECT date_trunc('day', block_time) AS f_withdrawal_time,SUM(amount)/1e9 AS total_full_eth_withdrawalsFROM ethereum.withdrawalsWHERE CAST(amount AS DOUBLE) > 20 * 1e9GROUP BY 1),partial_withdrawals AS (SELECT date_trunc('day', block_time) AS p_withdrawal_time,SUM(amount)/1e9 AS total_partial_eth_withdrawalsFROM ethereum.withdrawalsWHERE CAST(amount AS DOUBLE) < 20 * 1e9GROUP BY 1),cum_eth_deposited AS (SELECT date_trunc('day', block_time) AS c_withdrawal_time, SUM(SUM(value)/1e18) OVER (ORDER BY date_trunc('day', block_time) RANGE UNBOUNDED PRECEDING) AS cum_deposited_ethFROM ethereum.tracesWHERE "to" = 0x00000000219ab540356cBB839Cbe05303d7705FaAND successGROUP BY 1),cum_full_withdrawals AS (SELECT date_trunc('day', block_time) AS cf_withdrawal_time,SUM(SUM(amount)/1e9) OVER (ORDER BY date_trunc('day', block_time) RANGE UNBOUNDED PRECEDING) AS cum_full_eth_withdrawalsFROM ethereum.withdrawalsWHERE CAST(amount AS DOUBLE) > 20 * 1e9GROUP BY 1)SELECT deposit_time,COALESCE(SUM(eth_deposits),0) AS deposits,-COALESCE(SUM(total_full_eth_withdrawals), 0) AS full_withdrawals,-COALESCE(SUM(total_partial_eth_withdrawals), 0) AS partial_withdrawals,COALESCE(SUM(cum_deposited_eth),0) - COALESCE(SUM(cum_full_eth_withdrawals),0) AS locked_ethFROM depositsLEFT JOIN full_withdrawals ON deposit_time = f_withdrawal_timeLEFT JOIN partial_withdrawals ON deposit_time = p_withdrawal_timeLEFT JOIN cum_eth_deposited ON deposit_time = c_withdrawal_timeLEFT JOIN cum_full_withdrawals ON deposit_time = cf_withdrawal_timeWHERE deposit_time >= date('2023-04-10')GROUP BY deposit_time;