Implementation of a program that manages on chain accounts to mint and redeem Redeemables tokens (UXD), hedged by a delta neutral position on underlying DEXes.
when you redeem, increase the epoch_outflow_amount
when you redeem, if you epoch_outflow_amount too much, stop the redeem
when you mint, decrease the epoch_outflow_amount
when you redeem, if some time has passed since the last redeem, we allow for more redeem based on how long was elapsed (decreased the epoch_outflow_amount proportionally to how long was elapsed since last redeem)
This is an implementation for the limiting the outflows to a hardcoded amount (or BPS) per epoch (epoch time configurable)
Basically maintain a set of new controller flags, and adds some accounting in the mint/redeem router IXs
PR Combo:
TLDR of the logic basically:
epoch_outflow_amount
epoch_outflow_amount
too much, stop the redeemepoch_outflow_amount
epoch_outflow_amount
proportionally to how long was elapsed since last redeem)