cybergenlab[DeFi Overview] Project Interactions Top 25
    Updated 2024-11-16
    -- forked from [Ecosystem Overview] Project Interactions Top 50 @ https://flipsidecrypto.xyz/studio/queries/26677bbc-9964-4117-878e-607f6b16bc5f

    -- Get Top 50 projects interacted with by users

    with interactions as (
    select
    --date_trunc('month', block_timestamp) as time,
    from_address as user_address,
    count(distinct address_name) as project_count,
    array_agg(distinct address_name) as projects
    from ethereum.core.fact_transactions
    inner join (
    select
    address,
    address_name,
    from ethereum.core.dim_labels
    where label_type in ('defi')
    and label_subtype not in ('token_contract', 'nft_token_contract')
    )
    on address = to_address
    where status = 'SUCCESS'
    and from_address not in (select distinct address from ethereum.core.dim_labels)
    and block_timestamp >= dateadd(month, -1, current_date())
    and block_timestamp < date_trunc('month', current_date())
    group by 1
    having project_count > 2
    )


    select
    p.value as "Contract",
    count(distinct user_address) as nb_addresses
    from interactions, lateral flatten(input => interactions.projects) p
    group by 1
    qualify(row_number() over (order by nb_addresses desc )) <= 25
    order by 2 desc
    QueryRunArchived: QueryRun has been archived