MuzeVolume kpi
    Updated 2023-10-03
    -- forked from kpi one @ https://flipsidecrypto.xyz/edit/queries/7fbf292e-8a62-4810-9702-28de99bd9c34


    with volume as (
    select
    tx_id as transactions

    from solana.core.fact_events
    where program_id = '4MangoMjqJ2firMokCjjGgoK8d4MXcrgL7XJaL3w6fVg'
    and succeeded
    and block_timestamp >= '2023-01-01'
    ),

    prices as (
    select
    date_trunc('day', recorded_hour) as day,
    symbol,
    avg( close ) as price

    from solana.core.ez_token_prices_hourly
    group by 1,2
    ),

    final as (
    select
    substring(date_trunc('day', block_timestamp), 1, 10) as day,
    -- b.symbol,
    sum( a.amount * c.price ) as volume
    -- avg( a.amount * c.price ) as avg_volume,
    -- median( a.amount * c.price ) as median_volume,
    -- max( a.amount * c.price ) as max_volume,
    -- count( distinct a.tx_id ) as transactions,
    -- count( istinct a.tx_from ) as traders

    from solana.core.fact_transfers a
    left join solana.core.dim_tokens b on a.mint = b.token_address
    Run a query to Download Data