adriaparcerisasluna price change 4
    Updated 2023-01-17
    with
    t1 as (
    select trunc(block_timestamp,'day') as date,
    sum(from_amount/pow(10,from_decimal)) as volume_sold
    from terra.core.ez_swaps
    where from_currency in ('uluna') and block_timestamp>=current_date - 30
    group by 1--,2
    ),
    t2 as (
    select trunc(block_timestamp,'day') as date,
    sum(to_amount/pow(10,to_decimal)) as volume_bought
    from terra.core.ez_swaps
    where to_currency in ('uluna') and block_timestamp>=current_date - 30
    group by 1--,2
    ),
    t3 as (
    select
    trunc(recorded_hour,'day') as date,
    avg(close) as eth_price,
    LAG(eth_price,1) IGNORE NULLS OVER (ORDER BY date) as last_price,
    ((eth_price-last_price)/eth_price)*100 as eth_price_change
    from crosschain.core.fact_hourly_prices where id='terra-luna-2' and date>=current_date - 30
    group by 1
    ),
    t4 as (
    select
    t1.date,
    volume_bought,volume_sold*(-1) as volume_solds,
    volume_bought-volume_sold as net_volume,eth_price,eth_price_change
    from t1
    join t2 on t1.date=t2.date
    join t3 on t1.date=t3.date
    )
    select * from t4
    order by 1 asc
    Run a query to Download Data