afonsostaking reward
    Updated 2023-04-06
    with price as (
    select
    date_trunc('day', recorded_hour) as date,
    (avg(open) + avg(close)) / 2 as price
    from crosschain.core.fact_hourly_prices
    where id = 'terra-luna-2'
    group by 1
    )

    select
    date_trunc('week', block_timestamp) as "Day",
    0 as fakeField,
    sum(amount::number/1e6) as "Staking rewards $LUNA",
    sum((amount::number/1e6) * price) as "Staking rewards $"
    from terra.core.ez_transfers join price on block_timestamp::date = date
    where
    tx_succeeded = 'TRUE' and
    currency = 'uluna' and
    message_type = '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward'
    group by 1
    order by 1
    Run a query to Download Data