Updated 2024-08-05
    with

    horizon_users as (
    select
    distinct signer_id as user
    from near.horizon.fact_decoded_actions
    where receipt_succeeded = 1
    )

    select
    count(distinct tx_hash) as transactions,
    sum(price_usd) as total_volume_usd,
    avg(price_usd) as average_volume_usd,
    count(distinct iff(buyer_address in (select distinct user from horizon_users), buyer_address, null)) as buyers,
    count(distinct iff(seller_address in (select distinct user from horizon_users), seller_address, null)) as sellers
    from near.nft.ez_nft_sales
    where buyer_address in (select user from horizon_users)
    or seller_address in (select user from horizon_users)
    QueryRunArchived: QueryRun has been archived