Abolfazl_771025daily circulating supply
    Updated 2023-01-11
    with luna_price as(select
    date_trunc('day',RECORDED_HOUR) as date,
    avg(CLOSE) as price
    from crosschain.core.fact_hourly_prices
    where ID = 'terra-luna-2'
    group by 1
    ), table1 as(select
    receiver,
    sum(amount)/pow(10,4) as "volume(receive)"
    from terra.core.ez_transfers
    WHERE CURRENCY='uluna'
    group by 1
    ),table2 as(select
    sender,
    sum(amount)/pow(10,4) as "volume(sent)"
    from terra.core.ez_transfers
    WHERE CURRENCY='uluna'
    group by 1
    ), total_supply as(select
    sum("volume(receive)") as tot_supply
    from table1 a left join table2 b on a.receiver=b.sender
    where "volume(sent)" is null
    ), circulating_supply as(select
    BLOCK_TIMESTAMP::date as date,
    sum(case when from_currency='uluna' then from_amount/pow(10,6) else null end) -
    sum(case when to_currency='uluna' then from_amount/pow(10,6) else null end) as "vol",
    sum("vol") over (order by date) as cir_supply
    from terra.core.ez_swaps
    group by 1
    )
    select
    b.date,
    price,
    cir_supply,
    cir_supply * 100 / tot_supply as ratio_supply
    from total_supply a join circulating_supply b join luna_price c on b.date=c.date
    Run a query to Download Data