boomer77LUNA & UST Supply Accurate
    Updated 2022-05-05
    with price as (select date_trunc('day', block_timestamp) as dt, avg(price_usd) as luna_price
    from terra.oracle_prices
    where symbol = 'LUNA' and year(block_timestamp) = '2022'
    group by 1),

    luna as (select date, sum(balance) as total
    from terra.daily_balances
    where currency in ('LUNA')
    and address not in ('terra1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3nln0mh', 'terra1dp0taj85ruc299rkdvzp4z5pfg6z6swaed74e6','terra1mtwph2juhj0rvjz7dy92gvl6xvukaxu8rfv8ts',
    'terra1jgp27m8fykex4e4jtt0l7ze8q528ux2lh4zh0f', 'terra1swggaf7nw9p680q4lngs340ar24g3lecr7x9ed')
    group by 1),

    ust as (select date, sum(balance) as total
    from terra.daily_balances
    where currency in ('UST')
    and address not in ('terra1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3nln0mh', 'terra1dp0taj85ruc299rkdvzp4z5pfg6z6swaed74e6','terra1mtwph2juhj0rvjz7dy92gvl6xvukaxu8rfv8ts',
    'terra1jgp27m8fykex4e4jtt0l7ze8q528ux2lh4zh0f')
    group by 1)

    select a.dt, a.luna_price, b.total as luna_supply, c.total as ust_supply
    from price a
    left join luna b on a.dt = b.date
    left join ust c on a.dt = c.date
    Run a query to Download Data