IPegStabilityModule
Last updated
Last updated
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
mint amountChiOut
CHI to address to
for amountIn
underlying tokens
see getMintAmountOut() to pre-calculate amount out
Name | Type | Description |
---|---|---|
redeem amountChiIn
CHI for amountOut
underlying tokens and send to address to
see getRedeemAmountOut() to pre-calculate amount out
send any surplus reserves to the PCV allocation
set the mint fee vs oracle price in basis point terms
set the redemption fee vs oracle price in basis point terms
set the ideal amount of reserves for the contract to hold for redemptions
set the target for sending surplus reserves
calculate the amount of CHI out for a given amountIn
of underlying
calculate the amount of underlying out for a given amountChiIn
of CHI
the maximum mint amount out
a flag for whether the current balance is above (true) or below and equal (false) to the reservesThreshold
an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold
the ideal amount of reserves for the contract to hold for redemptions
the mint fee vs oracle price in basis point terms
the redemption fee vs oracle price in basis point terms
the underlying token exchanged for CHI
the PCV deposit target to send surplus reserves
the max mint and redeem fee in basis points
event emitted when excess PCV is allocated
event emitted when a new max fee is set
event emitted when a new mint fee is set
event emitted when a new redeem fee is set
event emitted when reservesThreshold is updated
event emitted when surplus target is updated
event emitted upon a redemption
event emitted when chi gets minted
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
to
address
amountIn
uint256
minAmountOut
uint256
to
address
amountChiIn
uint256
minAmountOut
uint256
newMintFeeBasisPoints
uint256
newRedeemFeeBasisPoints
uint256
newReservesThreshold
uint256
newTarget
contract IPCVDeposit
amountIn
uint256
amountChiIn
uint256
caller
address
amount
uint256
### MaxFeeUpdate
oldMaxFee
uint256
newMaxFee
uint256
### MintFeeUpdate
oldMintFee
uint256
newMintFee
uint256
### RedeemFeeUpdate
oldRedeemFee
uint256
newRedeemFee
uint256
### ReservesThresholdUpdate
oldReservesThreshold
uint256
newReservesThreshold
uint256
### SurplusTargetUpdate
oldTarget
contract IPCVDeposit
newTarget
contract IPCVDeposit
### Redeem
to
address
amountChiIn
uint256
amountAssetOut
uint256
### Mint
to
address
amountIn
uint256
amountChiOut
uint256