PegStabilityModule
Functions
constructor
constructor
Parameters
Name | Type | Description |
---|---|---|
| struct PegStabilityModule.OracleParams | PSM constructor parameter struct |
| uint256 | |
| uint256 | |
| uint256 | |
| uint256 | |
| uint256 | |
| contract IERC20 | |
| contract IPCVDeposit |
pauseRedeem
set secondary pausable methods to paused
unpauseRedeem
set secondary pausable methods to unpaused
pauseMint
set secondary pausable methods to paused
unpauseMint
set secondary pausable methods to unpaused
withdraw
withdraw assets from PSM to an external address
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 |
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 |
_setMintFee
set the mint fee vs oracle price in basis point terms
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
_setRedeemFee
internal helper function to set the redemption fee
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
_setReservesThreshold
helper function to set reserves threshold
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
_setSurplusTarget
helper function to set the surplus target
Parameters
Name | Type | Description |
---|---|---|
| contract IPCVDeposit |
allocateSurplus
send any surplus reserves to the PCV allocation
deposit
function to receive ERC20 tokens from external contracts
_redeem
internal helper method to redeem chi in exchange for an external asset
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 |
_mint
internal helper method to mint chi in exchange for an external asset
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 |
redeem
function to redeem CHI for an underlying asset We do not burn Chi; this allows the contract's balance of Chi to be used before the buffer is used In practice, this helps prevent artificial cycling of mint-burn cycles and prevents a griefing vector.
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 |
mint
function to buy CHI for an underlying asset We first transfer any contract-owned chi, then mint the remaining if necessary
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 | |
| uint256 |
getMintAmountOut
calculate the amount of CHI out for a given amountIn
of underlying First get oracle price of token Then figure out how many dollars that amount in is worth by multiplying price * amount. ensure decimals are normalized if on underlying they are not 18
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
getRedeemAmountOut
calculate the amount of underlying out for a given amountChiIn
of CHI First get oracle price of token Then figure out how many dollars that amount in is worth by multiplying price * amount. ensure decimals are normalized if on underlying they are not 18
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
getMaxMintAmountOut
the maximum mint amount out
hasSurplus
a flag for whether the current balance is above (true) or below (false) the reservesThreshold
reservesSurplus
an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold
balance
function from PCVDeposit that must be overriden
balanceReportedIn
returns address of token this contracts balance is reported in
resistantBalanceAndChi
override default behavior of not checking chi balance
_getMintAmountOut
helper function to get mint amount out based on current market prices
will revert if price is outside of bounds and bounded PSM is being used
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
_getRedeemAmountOut
helper function to get redeem amount out based on current market prices
will revert if price is outside of bounds and bounded PSM is being used
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
_allocate
Allocates a portion of escrowed PCV to a target PCV deposit
Parameters
Name | Type | Description |
---|---|---|
| uint256 |
_transfer
transfer ERC20 token
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 |
_transferFrom
transfer assets from user to this contract
Parameters
Name | Type | Description |
---|---|---|
| address | |
| address | |
| uint256 |
_mintChi
mint amount of CHI to the specified user on a rate limit
Parameters
Name | Type | Description |
---|---|---|
| address | |
| uint256 |
_validatePriceRange
overriden function in the bounded PSM
Parameters
Name | Type | Description |
---|---|---|
| struct Decimal.D256 |
Events
RedemptionsPaused
event that is emitted when redemptions are paused
Parameters
Name | Type | Description |
---|---|---|
| address | |
### RedemptionsUnpaused |
event that is emitted when redemptions are unpaused
Parameters
Name | Type | Description |
---|---|---|
| address | |
### MintingPaused |
event that is emitted when minting is paused
Parameters
Name | Type | Description |
---|---|---|
| address | |
### MintingUnpaused |
event that is emitted when minting is unpaused
Parameters
Name | Type | Description |
---|---|---|
| address |
Last updated