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
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 |
redeem
redeem amountChiIn
CHI for amountOut
underlying tokens and send to address to
see getRedeemAmountOut() to pre-calculate amount out
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 |
allocateSurplus
send any surplus reserves to the PCV allocation
setMintFee
set the mint fee vs oracle price in basis point terms
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
setRedeemFee
set the redemption fee vs oracle price in basis point terms
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
setReservesThreshold
set the ideal amount of reserves for the contract to hold for redemptions
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
setSurplusTarget
set the target for sending surplus reserves
Parameters
Name | Type | Description |
---|---|---|
| contract IPCVDeposit |
getMintAmountOut
calculate the amount of CHI out for a given amountIn
of underlying
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
getRedeemAmountOut
calculate the amount of underlying out for a given amountChiIn
of CHI
Parameters
Name | Type | Description |
---|---|---|
| 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
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
### MaxFeeUpdate |
event emitted when a new max fee is set
Parameters
Name | Type | Description |
---|---|---|
| uint256 | |
| uint256 | |
### MintFeeUpdate |
event emitted when a new mint fee is set
Parameters
Name | Type | Description |
---|---|---|
| uint256 | |
| uint256 | |
### RedeemFeeUpdate |
event emitted when a new redeem fee is set
Parameters
Name | Type | Description |
---|---|---|
| uint256 | |
| uint256 | |
### ReservesThresholdUpdate |
event emitted when reservesThreshold is updated
Parameters
Name | Type | Description |
---|---|---|
| uint256 | |
| uint256 | |
### SurplusTargetUpdate |
event emitted when surplus target is updated
Parameters
Name | Type | Description |
---|---|---|
| contract IPCVDeposit | |
| contract IPCVDeposit | |
### Redeem |
event emitted upon a redemption
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 | |
### Mint |
event emitted when chi gets minted
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 |
Last updated