Query editor
WITHlogs_in AS ( -- depositsSELECT'0x' || substr(LOWER(to_hex(topic1)), -40) AS from_address,block_timeFROM blast.logsWHERE LOWER(to_hex(topic0)) = 'ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'AND '0x' || substr(LOWER(to_hex(topic2)), -40) = '0x87a89a15ee6fb67e53cd456d2b2b13f257cc5183'AND block_time >= TIMESTAMP '2025-01-15 00:00:00'),logs_out AS ( -- withdrawalsSELECT'0x' || substr(LOWER(to_hex(topic2)), -40) AS to_address,block_timeFROM blast.logsWHERE LOWER(to_hex(topic0)) = 'ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'AND '0x' || substr(LOWER(to_hex(topic1)), -40) = '0x87a89a15ee6fb67e53cd456d2b2b13f257cc5183'AND block_time >= TIMESTAMP '2025-01-15 00:00:00'),hourly_in AS (SELECTdate_trunc('hour', block_time) AS hour,COUNT(DISTINCT from_address) AS distinct_in_addressesFROM logs_inGROUP BY 1),cumulative_in AS (SELECThour,SUM(distinct_in_addresses) OVER (ORDER BY hour)AS cumulative_distinct_from_address_countFROM hourly_in),daily_out AS (SELECTdate_trunc('day', block_time) AS day,COUNT(DISTINCT to_address) AS distinct_out_addressesFROM logs_outGROUP BY 1)SELECTc.hour,c.cumulative_distinct_from_address_count,COALESCE(d.distinct_out_addresses, 0) AS daily_users_took_money_outFROM cumulative_in cLEFT JOIN daily_out dON d.day = date_trunc('day', c.hour)ORDER BY c.hour;