messaritesting - luna rewards(05-04-22)
    Updated 2022-05-04
    -- Tarik - query from by 0xFrank https://app.flipsidecrypto.com/dashboard/terra-reward-analysis-pKMRCm

    select
    date_trunc('hour', t.block_timestamp) as date,
    sum(fl.value:amount / pow(10,6)) as event_amount,
    fl.value:denom::string as event_currency
    -- event_attributes:validator::string as validator
    from terra.transitions t
    , lateral flatten(input => event_attributes:amount) fl
    where t.transition_type = 'begin_block'
    and t.event = 'rewards'
    group by 1,3
    order by date desc
    limit 20

    --------------------
    -- Part 2
    -- issue: before oct 30 the event attributes only have luna, and after 10/30 they have various currencies
    -- it seems like each event attribute post 10/30
    SELECT * FROM terra.transitions
    where transition_type = 'end_block'
    and event = 'rewards'
    and chain_id = 'columbus-5'
    AND block_timestamp > CURRENT_DATE - 150
    limit 50

    ----------------------------------------------------
    -- Final query:
    with prices as (
    select date_trunc('hour', block_timestamp) as date,
    symbol,
    currency,
    avg(price_usd) as price
    from terra.oracle_prices
    group by 1,2,3
    ),
    Run a query to Download Data