saeedmznDUST is in the Air - weekly DUST swaps
    Updated 2022-09-09
    with DUST_price as (
    select block_timestamp::date daily,
    avg(swap_to_amount/swap_from_amount) price
    from solana.fact_swaps
    where swap_from_mint = 'DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ' --DUST
    and swap_to_mint ='EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' --USDR
    and swap_from_amount > 0
    and succeeded = 'TRUE'
    group by daily
    ),
    swap_from as (
    select date_trunc(week,block_timestamp) weekly,
    count (distinct tx_id) num_swaps,
    count (distinct swapper) num_swappers,
    sum (swap_from_amount) volume ,
    sum (swap_from_amount * price ) volume_usd
    from solana.core.fact_swaps join DUST_price on daily = block_timestamp::date
    where swap_from_mint = 'DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ'
    and swap_from_amount > 0
    group by 1
    ),
    swap_to as (
    select
    date_trunc(week,block_timestamp) weekly,
    count (distinct tx_id) num_swaps,
    count (distinct swapper) num_swappers,
    sum (swap_to_amount) volume ,
    sum (swap_to_amount * price ) volume_usd
    from solana.core.fact_swaps join DUST_price on daily = block_timestamp::date
    where swap_to_mint = 'DUSTawucrTsGU8hcqRdHDCbuYhCPADMLM2VcCb8VnFnQ'
    and swap_from_amount > 0
    group by 1
    ),
    all_swaps as (
    select 'swap_to' type , weekly ,num_swaps, num_swappers , volume , volume_usd from swap_to
    UNION
    Run a query to Download Data