IPegStabilityModule
The Chi PSM is a contract which holds a reserve of assets in order to exchange CHI at $1 of underlying assets with a fee. mint()
- buy CHI for $1 of underlying tokens redeem()
- sell CHI back for $1 of the same
The contract has a reservesThreshold() of underlying meant to stand ready for redemptions. Any surplus reserves can be sent into the PCV using allocateSurplus()
The contract is a PCVDeposit - to track reserves OracleRef - to determine price of underlying, and RateLimitedMinter - to stop infinite mints and related issues (but this is in the implementation due to inheritance-linearization difficulties)
Inspired by MakerDAO PSM, code written without reference
Functions
mint
mint amountChiOut
CHI to address to
for amountIn
underlying tokens
see getMintAmountOut() to pre-calculate amount out
Parameters
to
address
amountIn
uint256
minAmountOut
uint256
redeem
redeem amountChiIn
CHI for amountOut
underlying tokens and send to address to
see getRedeemAmountOut() to pre-calculate amount out
Parameters
to
address
amountChiIn
uint256
minAmountOut
uint256
allocateSurplus
send any surplus reserves to the PCV allocation
setMintFee
set the mint fee vs oracle price in basis point terms
Parameters
newMintFeeBasisPoints
uint256
setRedeemFee
set the redemption fee vs oracle price in basis point terms
Parameters
newRedeemFeeBasisPoints
uint256
setReservesThreshold
set the ideal amount of reserves for the contract to hold for redemptions
Parameters
newReservesThreshold
uint256
setSurplusTarget
set the target for sending surplus reserves
Parameters
newTarget
contract IPCVDeposit
getMintAmountOut
calculate the amount of CHI out for a given amountIn
of underlying
Parameters
amountIn
uint256
getRedeemAmountOut
calculate the amount of underlying out for a given amountChiIn
of CHI
Parameters
amountChiIn
uint256
getMaxMintAmountOut
the maximum mint amount out
hasSurplus
a flag for whether the current balance is above (true) or below and equal (false) to the reservesThreshold
reservesSurplus
an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold
reservesThreshold
the ideal amount of reserves for the contract to hold for redemptions
mintFeeBasisPoints
the mint fee vs oracle price in basis point terms
redeemFeeBasisPoints
the redemption fee vs oracle price in basis point terms
underlyingToken
the underlying token exchanged for CHI
surplusTarget
the PCV deposit target to send surplus reserves
MAX_FEE
the max mint and redeem fee in basis points
Events
AllocateSurplus
event emitted when excess PCV is allocated
Parameters
caller
address
amount
uint256
### MaxFeeUpdate
event emitted when a new max fee is set
Parameters
oldMaxFee
uint256
newMaxFee
uint256
### MintFeeUpdate
event emitted when a new mint fee is set
Parameters
oldMintFee
uint256
newMintFee
uint256
### RedeemFeeUpdate
event emitted when a new redeem fee is set
Parameters
oldRedeemFee
uint256
newRedeemFee
uint256
### ReservesThresholdUpdate
event emitted when reservesThreshold is updated
Parameters
oldReservesThreshold
uint256
newReservesThreshold
uint256
### SurplusTargetUpdate
event emitted when surplus target is updated
Parameters
oldTarget
contract IPCVDeposit
newTarget
contract IPCVDeposit
### Redeem
event emitted upon a redemption
Parameters
to
address
amountChiIn
uint256
amountAssetOut
uint256
### Mint
event emitted when chi gets minted
Parameters
to
address
amountIn
uint256
amountChiOut
uint256
Last updated