Query editor
WITH user_actions AS (-- Unique suppliers (depositors)SELECTblock_date,owner_address AS user_address,'supplier' AS user_typeFROM evaa_ton.supplyUNION ALL-- Unique withdrawers (positive principal changes)SELECTblock_date,owner_address AS user_address,'withdrawer' AS user_typeFROM evaa_ton.withdrawWHERE user_new_principal >= 0UNION ALL-- Unique borrowers (negative principal changes)SELECTblock_date,owner_address AS user_address,'borrower' AS user_typeFROM evaa_ton.withdrawWHERE user_new_principal < 0UNION ALL-- Unique liquidated usersSELECTblock_date,owner_address AS user_address,'liquidated' AS user_typeFROM evaa_ton.liquidate),daily_counts AS (SELECTblock_date,COUNT(DISTINCT CASE WHEN user_type = 'supplier' THEN user_address END) AS unique_suppliers,COUNT(DISTINCT CASE WHEN user_type = 'withdrawer' THEN user_address END) AS unique_withdrawers,COUNT(DISTINCT CASE WHEN user_type = 'borrower' THEN user_address END) AS unique_borrowers,COUNT(DISTINCT CASE WHEN user_type = 'liquidated' THEN user_address END) AS unique_liquidated,COUNT(DISTINCT user_address) AS total_unique_usersFROM user_actionsGROUP BY block_date),cumulative_counts AS (SELECTblock_date,-- Cumulative unique countsCOUNT(DISTINCT CASE WHEN user_type = 'supplier' THEN user_address END) OVER (ORDER BY block_date) AS cumulative_suppliers,COUNT(DISTINCT CASE WHEN user_type = 'withdrawer' THEN user_address END) OVER (ORDER BY block_date) AS cumulative_withdrawers,COUNT(DISTINCT CASE WHEN user_type = 'borrower' THEN user_address END) OVER (ORDER BY block_date) AS cumulative_borrowers,COUNT(DISTINCT CASE WHEN user_type = 'liquidated' THEN user_address END) OVER (ORDER BY block_date) AS cumulative_liquidated,COUNT(DISTINCT user_address) OVER (ORDER BY block_date) AS cumulative_total_usersFROM (