Query editor
WITH data AS (SELECTaddress,balanceFROM balances_ethereum.genesis_balances),p AS (SELECTDATE_TRUNC('week', minute) AS time,AVG(price) AS ETHFROM prices.usdWHERE blockchain IS NULLAND symbol = 'ETH'GROUP BY 1),transfers_from_data AS (SELECTDATE_TRUNC('week', block_time) AS time,COUNT(DISTINCT "from") AS withdrawn_addresses,SUM(CAST(value/1e18 AS double)) AS withdrawn_amountFROM ethereum.traces trWHERE "from" IN (SELECT address FROM data)AND successAND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null)GROUP BY 1),transfers_to_data AS (SELECTDATE_TRUNC('week', block_time) AS time,COUNT(DISTINCT "to") AS deposited_addresses,SUM(CAST(value/1e18 AS double)) AS deposited_amountFROM ethereum.traces trWHERE "to" IN (SELECT address FROM data)AND successAND (call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR call_type IS null)GROUP BY 1)SELECTtime,ETH AS "ETH price",deposited_addresses AS "Wallets (deposited to)",ETH * deposited_amount AS "ETH deposited to wallets",withdrawn_addresses AS "Wallets (withdrawn from)",ETH * withdrawn_amount AS "ETH withdrawn from wallets",ETH * (COALESCE(deposited_amount, 0) - COALESCE(withdrawn_amount, 0)) AS "Cum. Change",72009990 - SUM((COALESCE(withdrawn_amount, 0) - COALESCE(deposited_amount, 0))) OVER (ORDER BY time) AS balanceFROM pFULL OUTER JOIN transfers_from_data USING(time)FULL OUTER JOIN transfers_to_data USING(time)ORDER BY time DESC