HosseinUntitled Query
    Updated 2022-12-08
    with prices as (
    select block_timestamp::date as day,
    swap_from_mint as mint,
    median (swap_to_amount/swap_from_amount) as price_usd
    from solana.fact_swaps
    where swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDav','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')
    and swap_to_amount > 0
    and swap_from_amount > 0
    and succeeded = 1
    group by 1, 2
    )

    select
    swapper "Swapper",
    count(distinct a.tx_id) "Swaps Count",
    sum(price_usd * swap_from_amount) "Volume (USD)",
    avg(price_usd * swap_from_amount) "Average Volume (USD)",
    median(price_usd * swap_from_amount) "Median Amount (USD)"
    from solana.core.fact_swaps a
    join prices c on a.block_timestamp::Date = c.day and a.swap_from_mint = c.mint
    join crosschain.core.dim_asset_metadata b
    on a.swap_from_mint = b.token_address
    where a.block_timestamp >= current_date - interval '2 weeks'
    and swap_program = 'raydium v4'
    and platform = 'solana'
    and a.succeeded = 1
    group by 1
    having "Volume (USD)" > 0
    order by 3 desc
    limit 10
    Run a query to Download Data