MLDZMNGASg8
    Updated 2022-11-16
    with tb1 as (select block_timestamp::date as day,
    median (swap_to_amount/swap_from_amount) as price_token
    from solana.fact_swaps
    where swap_from_mint = 'So11111111111111111111111111111111111111112'
    and swap_to_mint in ('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v','Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')
    and swap_to_amount > 0
    and swap_from_amount > 0
    and succeeded = 'TRUE'
    group by 1)

    SELECT
    block_timestamp::date as date,
    price_token,
    sum(fee/1e9) as amount,
    sum(fee*price_token/1e9) as amount_usd,
    avg(fee*price_token/1e9) as avg_usd,
    median(fee*price_token/1e9) as median_usd,
    min(fee*price_token/1e9) as min_usd,
    max(fee*price_token/1e9) as max_usd,
    amount_usd/count(distinct BLOCK_ID) as average_usd_block,
    avg(avg_usd) OVER (ORDER BY date ROWS BETWEEN 7 PRECEDING AND CURRENT ROW) as MA_7_Days,
    sum(amount_usd) over (order by date) as cum_volume

    from solana.core.fact_transactions s left join tb1 b on s.BLOCK_TIMESTAMP::date=b.day
    where BLOCK_TIMESTAMP>=CURRENT_DATE-30
    group by 1,2
    order by 1
    Run a query to Download Data