Query editor
WITH user_monthly_activity AS (-- Get all users and their active months (supplies)SELECTminter as user_address,DATE_TRUNC('month', evt_block_time) as activity_monthFROM venus_bnb.vbep20delegate_v2_evt_mintWHERE evt_block_time >= CAST('2023-01-01' AS TIMESTAMP)UNIONSELECTminter as user_address,DATE_TRUNC('month', evt_block_time) as activity_monthFROM venus_bnb.vbnb_v2_evt_mintWHERE evt_block_time >= CAST('2023-01-01' AS TIMESTAMP)UNION-- Include borrowersSELECTborrower as user_address,DATE_TRUNC('month', evt_block_time) as activity_monthFROM venus_bnb.vbep20delegate_v2_evt_borrowWHERE evt_block_time >= CAST('2023-01-01' AS TIMESTAMP)UNIONSELECTborrower as user_address,DATE_TRUNC('month', evt_block_time) as activity_monthFROM venus_bnb.vbnb_v2_evt_borrowWHERE evt_block_time >= CAST('2023-01-01' AS TIMESTAMP)),distinct_user_months AS (SELECT DISTINCTuser_address,activity_monthFROM user_monthly_activity),user_cohorts AS (SELECTuser_address,MIN(activity_month) as first_activity_month,activity_month as current_monthFROM distinct_user_monthsGROUP BY user_address, activity_month),retention_calc AS (SELECTfirst_activity_month as cohort_month,current_month,CAST((YEAR(current_month) - YEAR(first_activity_month)) * 12 +(MONTH(current_month) - MONTH(first_activity_month)) AS INTEGER) as months_since_first,COUNT(DISTINCT user_address) as retained_usersFROM user_cohortsGROUP BY first_activity_month, current_month),cohort_sizes AS (SELECTfirst_activity_month as cohort_month,