Afonso_DiazNew / Active users + Retention Rate
    Updated 8 days ago
    with

    main as (
    select
    tx_hash,
    block_timestamp,
    from_address as user,
    tx_fee,
    iff(origin_function_signature = '0xe884624b', 'GM to a Fren', 'GM') as tx_type
    from
    ink.core.fact_transactions
    where
    tx_succeeded
    and to_address = '0x9f500d075118272b3564ac6ef2c70a9067fd2d3f'
    and origin_function_signature in ('0xe884624b', '0xc0129d43')
    ),

    dayly_users as (
    select
    date_trunc('day', block_timestamp) as day,
    user,
    min(block_timestamp) over (partition by user) as first_seen
    from main
    ),

    dayly_metrics as (
    select
    day,
    count(distinct user) as active_users,
    count(distinct case when date_trunc('day', first_seen) = day then user end) as new_users,
    count(distinct case when date_trunc('day', first_seen) < day then user end) as returning_users
    from dayly_users
    group by day
    ),

    retention as (