Haisenbergretention rate
    Updated 2025-03-29
    WITH daily_prices AS (
    SELECT
    date_trunc(day, hour)::date AS price_date,
    token_address,
    avg(price) AS token_price
    FROM crosschain.price.ez_prices_hourly
    WHERE date_trunc(day, hour)::date BETWEEN '{{start_date}}' AND '{{end_date}}'
    GROUP BY 1, 2
    ),

    -- Step 1: Get monthly active users
    monthly_active_users AS (
    SELECT DISTINCT
    date_trunc('month', block_timestamp) AS month,
    sender AS address
    FROM axelar.defi.ez_bridge_squid
    WHERE block_timestamp::date BETWEEN '{{start_date}}' AND '{{end_date}}'
    ),

    -- Step 2: Calculate retained users
    retained_users AS (
    SELECT
    current_month.month,
    COUNT(DISTINCT current_month.address) AS total_users,
    COUNT(DISTINCT previous_month.address) AS retained_users
    FROM
    monthly_active_users current_month
    LEFT JOIN
    monthly_active_users previous_month
    ON current_month.address = previous_month.address
    AND current_month.month = previous_month.month + INTERVAL '1 month'
    GROUP BY
    current_month.month
    )

    -- Step 3: Calculate retention rate
    Last run: 3 months ago
    MONTH
    TOTAL_USERS
    RETAINED_USERS
    RETENTION_RATE
    1
    2024-01-01 00:00:00.000700210
    2
    2024-02-01 00:00:00.00039326989114.13
    3
    2024-03-01 00:00:00.00035880620615.78
    4
    2024-04-01 00:00:00.00047520739320.6
    5
    2024-05-01 00:00:00.000460271007121.19
    6
    2024-06-01 00:00:00.00036375998021.68
    7
    2024-07-01 00:00:00.00047129997627.43
    8
    2024-08-01 00:00:00.00028853953120.22
    9
    2024-09-01 00:00:00.00020047659422.85
    10
    2024-10-01 00:00:00.00026008621030.98
    11
    2024-11-01 00:00:00.00022304531920.45
    12
    2024-12-01 00:00:00.00035350491222.02
    13
    2025-01-01 00:00:00.00028124541815.33
    14
    2025-02-01 00:00:00.00025942413914.72
    15
    2025-03-01 00:00:00.0001277024789.55
    15
    671B
    2s