Afonso_DiazTop buyers
    Updated 2024-08-23
    with

    main as (
    select
    distinct iff(direction = 'inbound', destination_address, source_address) as user
    from near.defi.ez_bridge_activity
    where platform = 'rainbow'
    and receipt_succeeded = 1
    and block_timestamp between '{{ start_date }}' and '{{ end_date }}'
    ),

    txns as (
    select
    tx_hash,
    block_timestamp,
    nft_address,
    platform_name,
    seller_address,
    buyer_address,
    price_usd
    from near.nft.ez_nft_sales
    where buyer_address in (select user from main)
    )

    select
    buyer_address,
    count(distinct tx_hash) as transactions,
    sum(price_usd) as volume_usd,
    avg(price_usd) as average_amount_usd,
    max(price_usd) as max_amount_usd
    from txns
    group by 1
    having volume_usd > 0
    order by volume_usd desc
    limit 10
    QueryRunArchived: QueryRun has been archived