cybergenlab[DeFi Overview] Network monthly metrics
    Updated 2024-11-16
    --Get all metrics for Top Ethereum DeFi metrics

    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 ethereum.core.fact_transactions as transactions
    left join ethereum.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 in ('defi')
    and status = 'SUCCESS'
    group by 1,2
    )

    , monthly_new_users as (
    select
    date_trunc('month', block_timestamp) as time,
    label_type as category,
    count(distinct from_address) as new_users,
    from ethereum.core.fact_transactions as transactions
    left join ethereum.core.dim_labels labels on transactions.to_address = labels.address
    where block_timestamp >= dateadd(month, -1, date_trunc('month',current_date()))
    and nonce = 0
    and block_timestamp < date_trunc('month',current_date())
    and category in ('defi')
    and status = 'SUCCESS'
    group by 1,2
    )

    , flipside_defi as (
    select
    distinct initcap(label) as project_name,
    from ethereum.core.dim_labels
    where label_type = 'defi'
    QueryRunArchived: QueryRun has been archived