boomer77terra arb 1
    Updated 2021-12-15
    with luna as (SELECT
    date_trunc('minute', block_timestamp) AS luna_hourly,
    avg(event_attributes:exchange_rate) as luna_usd
    FROM terra.transitions
    WHERE event = 'exchange_rate_update'
    and REGEXP_REPLACE(event_attributes:denom::string,'\"','') = 'uusd'
    group by 1
    ORDER BY 1 DESC),

    bluna as (select
    date_trunc('day', block_timestamp) AS bluna_hourly,
    avg(EVENT_ATTRIBUTES:price) as bluna_usd
    from terra.msg_events
    where EVENT_ATTRIBUTES:asset::string = 'terra1kc87mu460fwkqte29rquh4hc20m54fxwtsx7gp'
    GROUP BY 1
    order by 1 desc)

    select a.luna_hourly, a.luna_usd, b.bluna_usd, (a.luna_usd - b.bluna_usd) as premium, (premium/a.luna_usd)*100 as premium_percentage, round((b.bluna_usd/a.luna_usd),5) as "blune/luna", case
    when premium_percentage >= 2.5 then 'good'
    else 'nah' end as goods
    from luna a
    left join bluna b on a.luna_hourly = b.bluna_hourly
    where bluna_usd is not null
    Run a query to Download Data