maybeyonasluna_std_dev_l1
    Updated 2022-03-01
    with luna_price as (
    select
    date_trunc('hour',block_timestamp) as hour,
    'LUNA' as asset,
    median(price_usd) as usd_price
    from terra.oracle_prices
    where symbol = 'LUNA'
    group by 1,2
    ),
    eth_price as (
    select
    hour,
    symbol,
    price
    from ethereum.token_prices_hourly
    where symbol in ('WETH','WBTC')
    ),
    sol_price as (
    select
    date_trunc('hour',block_timestamp) as hour,
    'SOL' as asset,
    median(
    case when swap_from_mint = 'So11111111111111111111111111111111111111112' then swap_to_amount/swap_from_amount
    else swap_from_amount/swap_to_amount end
    ) as price
    from solana.swaps
    where swap_from_mint in (
    'So11111111111111111111111111111111111111112', --wSOL
    'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' --USDC
    )
    and swap_to_mint in (
    'So11111111111111111111111111111111111111112', --wSOL
    'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' --USDC
    )
    and swap_from_mint != swap_to_mint
    and swap_from_amount != 0
    Run a query to Download Data