CartanGroupmonthly volume and count and users
    Updated 2024-01-16
    with
    saber as (
    select
    date_trunc('month', BLOCK_TIMESTAMP) as month,
    SWAP_FROM_AMOUNT,
    SWAP_FROM_MINT,
    SWAP_TO_AMOUNT,
    SWAP_TO_MINT,
    SWAPPER,
    TX_ID
    from
    solana.defi.fact_swaps
    where
    SWAP_PROGRAM = 'Saber Router'
    ),
    price as (
    select
    date_trunc('month', RECORDED_HOUR) as month,
    SYMBOL,
    TOKEN_ADDRESS,
    avg(CLOSE) as usd_price
    from
    solana.price.ez_token_prices_hourly
    group by
    1,
    2,
    3
    )
    select
    saber.month,
    sum(SWAP_FROM_AMOUNT * usd_price) as volume,
    avg(SWAP_FROM_AMOUNT * usd_price) as avg,
    count(distinct SWAPPER) as user,
    count(distinct TX_ID) as count,
    sum(volume) over (
    order by
    QueryRunArchived: QueryRun has been archived