Aephia2023-08-09 08:08 PM
    Updated 2023-08-09
    WITH atlas_price AS (
    select
    --*
    DATE(block_timestamp) AS date,
    sum(case when (swap_from_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_from_amount
    when (swap_to_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_from_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_to_amount end) as ATLAS,
    sum(case when (swap_from_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_to_amount
    when (swap_to_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_from_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_from_amount end) as USDC,
    USDC / ATLAS as atlas_price
    from solana.core.fact_swaps
    WHERE succeeded = 'true'
    AND program_id IN ('JUP3c2Uh3WA4Ng34tw6kPd2G4C5BB21Xo36Je1s32Ph', 'JUP2jxvXaqu7NQY1GmNF4m1vodw12LVXYxbFL2uJvfo')
    AND block_timestamp > current_date-120
    group by 1
    ),

    polis_price AS (
    select
    --*
    DATE(block_timestamp) AS date,
    sum(case when (swap_from_mint = 'poLisWXnNRwC6oBu1vHiuKQzFjGL4XDSu4g9qjz9qVk' AND swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_from_amount
    when (swap_to_mint = 'poLisWXnNRwC6oBu1vHiuKQzFjGL4XDSu4g9qjz9qVk' AND swap_from_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_to_amount end) as POLIS,
    sum(case when (swap_from_mint = 'poLisWXnNRwC6oBu1vHiuKQzFjGL4XDSu4g9qjz9qVk' AND swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_to_amount
    when (swap_to_mint = 'poLisWXnNRwC6oBu1vHiuKQzFjGL4XDSu4g9qjz9qVk' AND swap_from_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
    then swap_from_amount end) as USDC,
    USDC / POLIS as polis_price
    from solana.core.fact_swaps
    Run a query to Download Data