boomer77stablecoins supply
    Updated 2021-09-06
    with supply as (select date, currency, sum(balance_usd) as Total_Supply_USD, sum(balance) as Total_Supply
    from terra.daily_balances
    where currency != 'LUNA'
    and date >= CURRENT_DATE - 190
    group by 1,2),

    price as (select date_trunc('day', block_timestamp) as blockday, currency, symbol, avg(price_usd) as price
    from terra.oracle_prices
    where blockday >= CURRENT_DATE - 190
    group by 1,2,3)

    select a.date, a.currency, a.total_supply, b.price, (a.total_supply*b.price) as Total_Supply_USD
    from supply a
    join price b on a.date = b.blockday and a.currency = b.symbol
    Run a query to Download Data