ZookSolana NFT Dashboard
    Updated 2023-03-26
    -- acknowledgments: credit to degen^#6854 for starting a prior version of this query. Credit to Sam for suggesting improvements.
    with sales as(
    select
    block_timestamp,
    tx_id,
    sales_amount,
    purchaser
    from solana.dim_nft_metadata a
    join solana.fact_nft_sales b
    on a.mint = b.mint
    where contract_name = 'Bubblegoose Ballers'
    and sales_amount > 0 and BLOCK_TIMESTAMP >= '2022-01-01'
    )
    ,

    aggregate_sales as (
    Select
    block_timestamp::DATE as date,
    count(distinct(tx_id)) as nb_sales,
    min(sales_amount) as min_sales_price_sol,
    max(sales_amount) as max_sales_price_sol,
    round(avg(sales_amount),2) as avg_sales_amount_sol,
    round(sum(sales_amount),2) as sales_volume_sol
    from sales
    group by 1
    ),
    solPrice as ( -- get the daily price of solana from orca dex
    select date_trunc('day', block_timestamp) as date,
    round(sum(SWAP_FROM_AMOUNT) / sum(SWAP_TO_AMOUNT),2) as solana_price
    from solana.core.fact_swaps
    where SWAP_FROM_MINT='EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' -- usdc
    and SWAP_TO_MINT='So11111111111111111111111111111111111111112' -- sol
    and BLOCK_TIMESTAMP >= '2022-01-01'
    and SWAP_PROGRAM ='orca'
    group by 1
    Run a query to Download Data