mariyaLUNA Price (USD) and Total UST Supply
    Updated 2022-04-26
    WITH TOTAL_UST AS (
    select
    date as ust_date,
    sum(balance) as ust_supply,
    lag(ust_supply) ignore nulls over(ORDER BY ust_date ASC) as ust_supply_prev,
    ((ust_supply - ust_supply_prev)/ust_supply)*100 as delta_percent_ust_supply
    from terra.daily_balances
    where currency = 'UST'
    group by date
    ),
    LUNA_PRICE AS ( -- LUNA PRICE, CHANGE AND PRICE VOLATILITY
    SELECT
    DATE(block_timestamp) as date,
    AVG(price_usd) as luna_price,
    lag(luna_price) ignore nulls over(ORDER BY date ASC) as luna_price_prev,
    ((luna_price - luna_price_prev)/luna_price)*100 as delta_percent_luna_price,
    ((max(price_usd)-min(price_usd))/min(price_usd))*100 as daily_percent_range_luna,
    STDDEV(price_usd) as luna_price_stddev
    FROM terra.oracle_prices
    WHERE symbol = 'LUNA'
    GROUP BY 1
    ORDER BY 1 ASC
    )
    SELECT
    ust_date,
    ust_supply,
    luna_price,
    daily_percent_range_luna,
    luna_price_stddev,
    delta_percent_ust_supply,
    delta_percent_luna_price
    FROM TOTAL_UST
    LEFT JOIN LUNA_PRICE ON ust_date = date
    WHERE ust_date > '2021-12-09'
    ORDER BY 1 DESC
    Run a query to Download Data