Updated 2023-11-07
    select
    SWAPPER AS User,
    count(*) AS TX,
    sum(case when SWAP_TO_AMOUNT*B.Close is not null then SWAP_TO_AMOUNT*B.Close
    else SWAP_From_AMOUNT*C.Close end ) AS Volume,
    count(DISTINCT date_trunc('Month',BLOCK_TIMESTAMP)) AS Months,
    count(DISTINCT date_trunc('Week',BLOCK_TIMESTAMP)) AS Weeks,
    sum(case when Swap_program like 'jupiter aggregator v2' then 1 else 0 end) AS "Before V3 upgrade TX"
    from
    solana.defi.fact_swaps
    left join solana.price.ez_token_prices_hourly B on date_trunc('Hour',BLOCK_TIMESTAMP)=B.RECORDED_HOUR
    and SWAP_TO_MINT=B.TOKEN_ADDRESS
    left join solana.price.ez_token_prices_hourly C on date_trunc('Hour',BLOCK_TIMESTAMP)=C.RECORDED_HOUR
    and SWAP_FROM_MINT=C.TOKEN_ADDRESS
    where
    Swap_program like 'jupiter%'
    and swapper='{{param-name}}' group by 1


    Run a query to Download Data