ArioVolume
    Updated 2025-02-09
    -- forked from h4wk / Moonwalk Over time @ https://flipsidecrypto.xyz/h4wk/q/AiF92FtOLTBh/moonwalk-over-time

    with price as (
    select hour::date as price_date,
    token_address,
    symbol,
    avg(price) as price
    from solana.price.ez_prices_hourly
    where hour::date = CURRENT_DATE
    group by all
    UNION
    select hour::date as price_date,
    'So11111111111111111111111111111111111111111' as token_address,
    'SOL',
    avg(price) as price
    from solana.price.ez_prices_hourly
    where hour::date = CURRENT_DATE
    and token_address = 'So11111111111111111111111111111111111111112'
    group by all
    )
    select
    block_timestamp::date as date,
    sum(amount*price) as "Wagers Volume USD",
    count(DISTINCT tx_id) as "# Wagers",
    sum(sum(amount*price)) over(order by date) as "Cum. Wagers Volume",
    "Wagers Volume USD" / "# Wagers" as "Avg Wagers Volume"
    from solana.core.ez_events_decoded a
    join solana.core.fact_transfers b using (tx_id, block_timestamp)
    join price on (b.mint = token_address)
    where program_id = 'FitAFk15vtx2PBjfr7QTnefaHRx6HwajRiZMt1DdSSKU'
    and event_type in ('deposit', 'depositSol')
    and block_timestamp >= current_date - {{Past_Days}}
    and succeeded
    group by 1
    order by date desc
    QueryRunArchived: QueryRun has been archived