keshanLuna burn UST mint
    Updated 2022-04-17
    with mint_ust as (SELECT date_trunc('day', block_timestamp) as date,
    sum(case when event_attributes:amount[0]:denom LIKE '%usd' then (event_attributes:amount[0]:amount)/1000000 end) as mint_ust_amount,
    sum(case when event_attributes:amount[0]:denom LIKE '%luna' then (event_attributes:amount[0]:amount)/1000000 end) as mint_luna_amount
    FROM terra.msg_events
    WHERE event_type = 'coinbase'
    AND msg_module = 'market'
    AND tx_status = 'SUCCEEDED'
    AND event_attributes:minter is not null
    AND (event_attributes:amount[0]:denom LIKE '%usd' or event_attributes:amount[0]:denom LIKE '%luna')
    AND date between CURRENT_DATE-61 and CURRENT_DATE-1
    GROUP BY date),
    burn_luna as (SELECT date_trunc('day', block_timestamp) as date,
    sum(case when event_attributes:amount[0]:denom LIKE '%usd' then (event_attributes:amount[0]:amount)/1000000 end) as burn_ust_amount,
    sum(case when event_attributes:amount[0]:denom LIKE '%luna' then (event_attributes:amount[0]:amount)/1000000 end) as burn_luna_amount
    FROM terra.msg_events
    WHERE event_type = 'burn'
    AND msg_module = 'market'
    AND tx_status = 'SUCCEEDED'
    AND (event_attributes:amount[0]:denom LIKE '%usd' or event_attributes:amount[0]:denom LIKE '%luna')
    AND date between CURRENT_DATE-61 and CURRENT_DATE-1
    GROUP BY date),
    ust_peg as (
    select
    date_trunc('day', block_timestamp) as date,
    avg(price_usd) as price_usd
    from terra.oracle_prices
    where symbol = 'UST'
    and block_timestamp::date >= CURRENT_DATE::date - 90
    group by date
    )

    select b.date, mint_ust_amount, mint_luna_amount, burn_ust_amount, burn_luna_amount, price_usd, 1 as usd
    from burn_luna b left join mint_ust using(date) left join ust_peg using(date)
    Run a query to Download Data