emirprince95aUST-UST LP on LOOP
    Updated 2022-01-25
    with
    mints as (select date_trunc('hour', block_timestamp) as hour_ts, sum(event_attributes:share/pow(10,6)) as ust_aust_LP_amount from terra.msg_events
    where event_attributes:"0_contract_address" = 'terra123neekasfmvcs4wa70cgw3j3uvwzqacdz2we03' --aust-ust lp sc
    and event_type = 'wasm'
    and event_attributes:"2_action" = 'mint'
    and tx_status = 'SUCCEEDED'
    group by date_trunc('hour', block_timestamp)
    ),
    burns as(
    select date_trunc('hour', block_timestamp) as hour_ts, sum(event_attributes:withdrawn_share/pow(10,6)) as ust_aust_LP_amount from terra.msg_events
    where event_attributes:"1_contract_address" = 'terra123neekasfmvcs4wa70cgw3j3uvwzqacdz2we03' --aust-ust lp sc
    and event_type = 'wasm'
    and event_attributes:"3_action" = 'burn'
    and tx_status = 'SUCCEEDED'
    group by date_trunc('hour', block_timestamp)
    ),

    net_sum as (select b.hour_ts as hourly_timestamp,
    (m.ust_aust_LP_amount-b.ust_aust_LP_amount) as amount_lp_existing
    from mints m join burns b on b.hour_ts=m.hour_ts
    order by hourly_timestamp)

    select *, sum(amount_lp_existing) over (Order By hourly_timestamp ) as cumulative_lp_amount
    from net_sum

    Run a query to Download Data