Sandeshluna price
    Updated 2023-03-14
    with hour_table as
    (
    select distinct(date_trunc('hour',block_timestamp)) as hour from ethereum.core.fact_transactions
    where block_timestamp >= '2022-05-28'
    )
    ,luna_price AS
    (
    select date_trunc('hour',block_timestamp) as hour,'luna' as currency, min(to_amount/(from_amount)) as price from terra.core.ez_swaps
    where to_currency='ibc/B3504E092456BA618CC28AC671A71FB08C6CA0FD0BE7C8A5B5A3E2DD933CC9E4'
    and from_currency='uluna'
    group by hour
    ),
    price as
    (
    select ht.hour, lp.price from hour_table ht left join luna_price lp
    on ht.hour=lp.hour
    order by 1 desc
    ),
    luna_usd as
    (
    select hour, coalesce(price,lag(price,1) over (order by hour asc )) as price from price )
    select hour,price, 100*(lag(price,1)over(order by hour asc)-price)/((lag(price,1)over(order by hour asc))+0.0000001) as price_diff_percent from luna_usd
    Run a query to Download Data