BlockTrackerUsers Distribution by active days
    Updated 2025-03-05
    with users as (
    SELECT
    block_timestamp,
    origin_from_address,
    tx_hash,
    min(block_timestamp) over (partition by origin_from_address) as initial_timestamp,
    max(block_timestamp) over (partition by origin_from_address) as last_timestamp
    FROM {{chain}}.core.ez_decoded_event_logs
    where block_timestamp::date >= '2022-10-01'
    and event_name IN ('LiFiGenericSwapCompleted','LiFiTransferStarted')
    ),
    transactions as (
    select
    origin_from_address,
    count(DISTINCT date_trunc('day', block_timestamp)) as n_days,
    count(DISTINCT date_trunc('week', block_timestamp)) as n_weeks,
    count(DISTINCT date_trunc('month', block_timestamp)) as n_months,
    count(DISTINCT tx_hash) as n_txns
    from users
    group by origin_from_address
    ),
    total_user_count as (
    select
    count(distinct origin_from_address) as total_users
    from transactions
    ),
    user_counts as (
    select
    t.origin_from_address,
    t.n_days,
    t.n_weeks,
    t.n_months,
    t.n_txns,
    tuc.total_users
    from transactions t
    cross join total_user_count tuc
    QueryRunArchived: QueryRun has been archived