boomer77terra yield staking
    Updated 2022-01-20
    with stake as (select date, address_label_subtype, balance as staked_LUNA
    from terra.daily_balances
    where address = 'terra1fl48vsnmsdzcv85q5d2q4z5ajdha8yu3nln0mh' and currency = 'LUNA' and balance_usd > 0 and date >= '2021-01-01'),

    price as (select date_trunc('day', block_timestamp) as dt, avg(price_usd) as luna_price
    from terra.oracle_prices
    where symbol = 'LUNA'
    group by 1)
    select a.date, a.staked_LUNA, b.luna_price, (b.luna_price*a.staked_luna) as staked_usd
    from stake a
    left outer join price b on a.date = b.dt
    Run a query to Download Data