cybergenlab[Ecosystem Overview] Network Metrics
    Updated 2024-11-17
    --Get all metrics for Top Avalanche ecosystem metrices

    with monthly_users as (
    select
    date_trunc('month', block_timestamp) as time,
    coalesce((label_type), 'other') as category,
    count(distinct from_address) as users,
    from avalanche.core.fact_transactions as transactions
    left join avalanche.core.dim_labels labels on transactions.to_address = labels.address
    where block_timestamp >= dateadd(month, -1, date_trunc('month',current_date()))
    and block_timestamp < date_trunc('month',current_date())
    and category not in ('token', 'cex', 'chadmin', 'operator', 'flotsam', 'other')
    and status = 'SUCCESS'
    group by 1,2
    )

    , monthly_new_users as (
    select
    date_trunc('month', block_timestamp) as time,
    coalesce((label_type), 'other') as category,
    count(distinct from_address) as new_users,
    from avalanche.core.fact_transactions as transactions
    left join avalanche.core.dim_labels labels on transactions.to_address = labels.address
    where block_timestamp >= dateadd(month, -1, date_trunc('month',current_date()))
    and nonce = 1
    and block_timestamp < date_trunc('month',current_date())
    and category not in ('token', 'cex', 'chadmin', 'operator', 'flotsam', 'other')
    and status = 'SUCCESS'
    group by 1,2
    )

    , defiLlama as (
    select
    livequery.live.udf_api(
    'https://api.llama.fi/v2/historicalChainTvl/Avalanche'
    ) as response
    QueryRunArchived: QueryRun has been archived