nitsRedemption Limit Mint ()
    Updated 2022-04-09
    with b as
    (SELECT block_id , sum(token_0_amount_usd) as amt, sum(amt) over (order by block_id) as cumulative_amt from terra.swaps
    where block_timestamp >'2021-02-10' and block_timestamp< '2021-05-23' and offer_currency = 'UST'
    and ask_currency = 'LUNA'
    and tx_status = 'SUCCEEDED'
    GROUP by 1 ),
    b_plus_36 as
    (SELECT block_id as bid, sum(token_0_amount_usd) as amt_36_blocks_later,sum(amt_36_blocks_later) over (order by bid) as cumulative_amt_36_blocks_later from terra.swaps
    where block_timestamp >'2021-02-10' and block_timestamp< '2021-05-23' and offer_currency = 'UST'
    and ask_currency = 'LUNA'
    and tx_status = 'SUCCEEDED'
    GROUP by 1 )
    , strength as
    (SELECT bid, cumulative_amt_36_blocks_later-cumulative_amt as pool_strength
    from b
    inner join b_plus_36
    on abs(block_id -bid) < 130 )
    SELECT date(block_timestamp) as day, max(pool_strength) as upper_limit from
    (SELECT block_id, block_timestamp from terra.swaps
    where block_timestamp >'2022-01-02'
    GROUP by 1,2 )
    inner join
    strength on block_id = bid
    GROUP by 1
    Run a query to Download Data