adriaparcerisasSolana DeFi program Jupiter 2
    Updated 2022-07-13
    WITH
    sol_price as (
    select date_trunc('week',block_timestamp) as weeks,
    avg(swap_to_amount/swap_from_amount) as sol_price
    from solana.core.fact_swaps
    where swap_from_mint = 'So11111111111111111111111111111111111111112'
    and swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
    and block_timestamp >= CURRENT_DATE-INTERVAL '1 MONTH'
    and swap_to_amount > 0
    and swap_from_amount > 0
    group by 1
    ),
    swaps as (
    SELECT
    trunc(block_timestamp,'week') as weeks,
    swap_program as exchange,
    count(distinct swapper) as n_active_wallets,
    sum(swap_from_amount) as swapped_volume
    from solana.core.fact_swaps where block_timestamp>= CURRENT_DATE-INTERVAL '1 MONTH' and swap_program='jupiter aggregator v2'
    and swap_from_amount<1e6
    group by 1,2
    order by 1 asc
    ),
    sol as (
    SELECT
    x.weeks,
    exchange,
    n_active_wallets,
    case when sol_price>200 then swapped_volume
    else swapped_volume end as weekly_swapped_volume
    from swaps x, sol_price y
    where x.weeks = y.weeks
    order by 1 asc
    )
    SELECT * from sol
    order by 1 asc
    Run a query to Download Data