John_GaltLuna and UST mints and burns
    Updated 2022-05-05
    WITH luna as (select
    date(block_timestamp) as date,
    sum(token_0_amount) as burnt_luna,
    sum(token_1_amount) as minted_ust,
    sum(burnt_luna) over (ORDER BY date) as cum_burnt_luna,
    sum(minted_ust) over (ORDER BY date) as cum_minted_ust
    from terra.swaps
    where date between dateadd(day, -90, current_date) and current_date
    and swap_pair = 'LUNA to UST'
    and tx_status = 'SUCCEEDED'
    group by date
    ),

    ust as (select
    date(block_timestamp) as date,
    sum(token_0_amount) as burnt_ust,
    sum(token_1_amount) as minted_luna,
    sum(burnt_ust) over (ORDER BY date) as cum_burnt_ust,
    sum(minted_luna) over (ORDER BY date) as cum_minted_luna
    from terra.swaps
    where date between dateadd(day, -90, current_date) and current_date
    and swap_pair = 'UST to LUNA'
    and tx_status = 'SUCCEEDED'
    group by date
    ),

    final as (select luna.date, burnt_ust, burnt_luna, minted_ust, minted_luna,
    minted_ust - burnt_ust as net_minted_ust,
    burnt_luna - minted_luna as net_burnt_luna,
    sum(net_minted_ust) over (order by luna.date) as cum_ust_mint,
    sum(net_burnt_luna) over (order by luna.date) as cum_luna_burn
    from luna
    left outer join ust on luna.date = ust.date
    order by date
    )

    Run a query to Download Data