PriceBoundPSM
contract to create a price bound DAI PSM This contract will allow swaps when the price of DAI is between 98 cents and 1.02 by default These defaults are changeable by the admin and governance by calling floor and ceiling setters setOracleFloor and setOracleCeiling
Methods
CONTRACT_ADMIN_ROLE
function CONTRACT_ADMIN_ROLE() external view returns (bytes32)
a role used with a subset of governor permissions for this contract only
Returns
Name | Type | Description |
---|
_0 | bytes32 | undefined |
MAX_FEE
function MAX_FEE() external view returns (uint256)
the max mint and redeem fee in basis points Governance can change this fee
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
MAX_RATE_LIMIT_PER_SECOND
function MAX_RATE_LIMIT_PER_SECOND() external view returns (uint256)
maximum rate limit per second governance can set for this contract
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
allocateSurplus
function allocateSurplus() external nonpayable
send any surplus reserves to the PCV allocation
backupOracle
function backupOracle() external view returns (contract IOracle)
the backup oracle reference by the contract
Returns
Name | Type | Description |
---|
_0 | contract IOracle | undefined |
balance
function balance() external view returns (uint256)
function from PCVDeposit that must be overriden
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
balanceReportedIn
function balanceReportedIn() external view returns (address)
returns address of token this contracts balance is reported in
Returns
Name | Type | Description |
---|
_0 | address | undefined |
buffer
function buffer() external view returns (uint256)
the amount of action used before hitting limit
replenishes at rateLimitPerSecond per second up to bufferCap
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
bufferCap
function bufferCap() external view returns (uint256)
the cap of the buffer that can be used at once
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
bufferStored
function bufferStored() external view returns (uint256)
the buffer at the timestamp of lastBufferUsedTime
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
ceiling
function ceiling() external view returns (uint256)
the default maximum acceptable oracle price ceiling is $1.02
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
core
function core() external view returns (contract ICore)
address of the Core contract referenced
Returns
Name | Type | Description |
---|
_0 | contract ICore | ICore implementation address |
decimalsNormalizer
function decimalsNormalizer() external view returns (int256)
number of decimals to scale oracle price by, i.e. multiplying by 10^(decimalsNormalizer)
Returns
Name | Type | Description |
---|
_0 | int256 | undefined |
deposit
function deposit() external nonpayable
function to receive ERC20 tokens from external contracts
doInvert
function doInvert() external view returns (bool)
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
doPartialAction
function doPartialAction() external view returns (bool)
a flag for whether to allow partial actions to complete if the buffer is less than amount
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
floor
function floor() external view returns (uint256)
the default minimum acceptable oracle price floor is 98 cents
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
getMaxMintAmountOut
function getMaxMintAmountOut() external view returns (uint256)
the maximum mint amount out
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
getMintAmountOut
function getMintAmountOut(uint256 amountIn) external view returns (uint256 amountFeiOut)
calculate the amount of FEI 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 |
---|
amountIn | uint256 | undefined |
Returns
Name | Type | Description |
---|
amountFeiOut | uint256 | undefined |
getRedeemAmountOut
function getRedeemAmountOut(uint256 amountFeiIn) external view returns (uint256 amountTokenOut)
calculate the amount of underlying out for a given amountFeiIn
of FEI 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 |
---|
amountFeiIn | uint256 | undefined |
Returns
Name | Type | Description |
---|
amountTokenOut | uint256 | undefined |
hasSurplus
function hasSurplus() external view returns (bool)
a flag for whether the current balance is above (true) or below (false) the reservesThreshold
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
invert
function invert(Decimal.D256 price) external pure returns (struct Decimal.D256)
Parameters
Name | Type | Description |
---|
price | Decimal.D256 | undefined |
Returns
Name | Type | Description |
---|
_0 | Decimal.D256 | undefined |
isContractAdmin
function isContractAdmin(address _admin) external view returns (bool)
returns whether a given address has the admin role for this contract
Parameters
Name | Type | Description |
---|
_admin | address | undefined |
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
isPriceValid
function isPriceValid() external view returns (bool)
return wether the current oracle price is valid or not
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
lastBufferUsedTime
function lastBufferUsedTime() external view returns (uint256)
the last time the buffer was used by the contract
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
mint
function mint(address to, uint256 amountIn, uint256 minAmountOut) external nonpayable returns (uint256 amountFeiOut)
function to buy FEI for an underlying asset We first transfer any contract-owned fei, then mint the remaining if necessary
Parameters
Name | Type | Description |
---|
to | address | undefined |
amountIn | uint256 | undefined |
minAmountOut | uint256 | undefined |
Returns
Name | Type | Description |
---|
amountFeiOut | uint256 | undefined |
mintFeeBasisPoints
function mintFeeBasisPoints() external view returns (uint256)
the fee in basis points for selling asset into FEI
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
mintPaused
function mintPaused() external view returns (bool)
boolean switch that indicates whether minting is paused
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
oracle
function oracle() external view returns (contract IOracle)
the oracle reference by the contract
Returns
Name | Type | Description |
---|
_0 | contract IOracle | undefined |
pause
function pause() external nonpayable
set pausable methods to paused
pauseMint
function pauseMint() external nonpayable
set secondary pausable methods to paused
pauseRedeem
function pauseRedeem() external nonpayable
set secondary pausable methods to paused
paused
function paused() external view returns (bool)
Returns true if the contract is paused, and false otherwise.
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
rateLimitPerSecond
function rateLimitPerSecond() external view returns (uint256)
the rate per second for this contract
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
readOracle
function readOracle() external view returns (struct Decimal.D256)
the peg price of the referenced oracle
the peg is defined as FEI per X with X being ETH, dollars, etc
Returns
Name | Type | Description |
---|
_0 | Decimal.D256 | the peg as a Decimal |
redeem
function redeem(address to, uint256 amountFeiIn, uint256 minAmountOut) external nonpayable returns (uint256 amountOut)
function to redeem FEI for an underlying asset We do not burn Fei; this allows the contract's balance of Fei 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 |
---|
to | address | undefined |
amountFeiIn | uint256 | undefined |
minAmountOut | uint256 | undefined |
Returns
Name | Type | Description |
---|
amountOut | uint256 | undefined |
redeemFeeBasisPoints
function redeemFeeBasisPoints() external view returns (uint256)
the fee in basis points for buying the asset for FEI
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
redeemPaused
function redeemPaused() external view returns (bool)
boolean switch that indicates whether redemptions are paused
Returns
Name | Type | Description |
---|
_0 | bool | undefined |
reservesSurplus
function reservesSurplus() external view returns (int256)
an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold
Returns
Name | Type | Description |
---|
_0 | int256 | undefined |
reservesThreshold
function reservesThreshold() external view returns (uint256)
the amount of reserves to be held for redemptions
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
resistantBalanceAndVolt
function resistantBalanceAndVolt() external view returns (uint256, uint256)
override default behavior of not checking fei balance
Returns
Name | Type | Description |
---|
_0 | uint256 | undefined |
_1 | uint256 | undefined |
setBackupOracle
function setBackupOracle(address newBackupOracle) external nonpayable
sets the referenced backup oracle
Parameters
Name | Type | Description |
---|
newBackupOracle | address | the new backup oracle to reference |
setBufferCap
function setBufferCap(uint256 newBufferCap) external nonpayable
set the buffer cap
Parameters
Name | Type | Description |
---|
newBufferCap | uint256 | undefined |
setContractAdminRole
function setContractAdminRole(bytes32 newContractAdminRole) external nonpayable
sets a new admin role for this contract
Parameters
Name | Type | Description |
---|
newContractAdminRole | bytes32 | undefined |
setDecimalsNormalizer
function setDecimalsNormalizer(int256 newDecimalsNormalizer) external nonpayable
sets the new decimalsNormalizer
Parameters
Name | Type | Description |
---|
newDecimalsNormalizer | int256 | the new decimalsNormalizer |
setDoInvert
function setDoInvert(bool newDoInvert) external nonpayable
sets the flag for whether to invert or not
Parameters
Name | Type | Description |
---|
newDoInvert | bool | the new flag for whether to invert |
setMintFee
function setMintFee(uint256 newMintFeeBasisPoints) external nonpayable
set the mint fee vs oracle price in basis point terms
Parameters
Name | Type | Description |
---|
newMintFeeBasisPoints | uint256 | undefined |
setOracle
function setOracle(address newOracle) external nonpayable
sets the referenced oracle
Parameters
Name | Type | Description |
---|
newOracle | address | the new oracle to reference |
setOracleCeilingBasisPoints
function setOracleCeilingBasisPoints(uint256 newCeilingBasisPoints) external nonpayable
sets the ceiling price in BP
Parameters
Name | Type | Description |
---|
newCeilingBasisPoints | uint256 | undefined |
setOracleFloorBasisPoints
function setOracleFloorBasisPoints(uint256 newFloorBasisPoints) external nonpayable
sets the floor price in BP
Parameters
Name | Type | Description |
---|
newFloorBasisPoints | uint256 | undefined |
setRateLimitPerSecond
function setRateLimitPerSecond(uint256 newRateLimitPerSecond) external nonpayable
set the rate limit per second
Parameters
Name | Type | Description |
---|
newRateLimitPerSecond | uint256 | undefined |
setRedeemFee
function setRedeemFee(uint256 newRedeemFeeBasisPoints) external nonpayable
set the redemption fee vs oracle price in basis point terms
Parameters
Name | Type | Description |
---|
newRedeemFeeBasisPoints | uint256 | undefined |
setReservesThreshold
function setReservesThreshold(uint256 newReservesThreshold) external nonpayable
set the ideal amount of reserves for the contract to hold for redemptions
Parameters
Name | Type | Description |
---|
newReservesThreshold | uint256 | undefined |
setSurplusTarget
function setSurplusTarget(contract IPCVDeposit newTarget) external nonpayable
set the target for sending surplus reserves
Parameters
Name | Type | Description |
---|
newTarget | contract IPCVDeposit | undefined |
surplusTarget
function surplusTarget() external view returns (contract IPCVDeposit)
the PCV deposit target
Returns
Name | Type | Description |
---|
_0 | contract IPCVDeposit | undefined |
underlyingToken
function underlyingToken() external view returns (contract IERC20)
the token this PSM will exchange for FEI This token will be set to WETH9 if the bonding curve accepts eth
Returns
Name | Type | Description |
---|
_0 | contract IERC20 | undefined |
unpause
function unpause() external nonpayable
set pausable methods to unpaused
unpauseMint
function unpauseMint() external nonpayable
set secondary pausable methods to unpaused
unpauseRedeem
function unpauseRedeem() external nonpayable
set secondary pausable methods to unpaused
updateOracle
function updateOracle() external nonpayable
updates the referenced oracle
vcon
function vcon() external view returns (contract IERC20)
address of the Tribe contract referenced by Core
Returns
Name | Type | Description |
---|
_0 | contract IERC20 | IERC20 implementation address |
vconBalance
function vconBalance() external view returns (uint256)
vcon balance of contract
Returns
Name | Type | Description |
---|
_0 | uint256 | vcon amount held |
volt
function volt() external view returns (contract IVolt)
address of the Fei contract referenced by Core
Returns
Name | Type | Description |
---|
_0 | contract IVolt | IFei implementation address |
voltBalance
function voltBalance() external view returns (uint256)
volt balance of contract
Returns
Name | Type | Description |
---|
_0 | uint256 | volt amount held |
withdraw
function withdraw(address to, uint256 amount) external nonpayable
withdraw assets from PSM to an external address
Parameters
Name | Type | Description |
---|
to | address | undefined |
amount | uint256 | undefined |
withdrawERC20
function withdrawERC20(address token, address to, uint256 amount) external nonpayable
withdraw ERC20 from the contract
Parameters
Name | Type | Description |
---|
token | address | address of the ERC20 to send |
to | address | address destination of the ERC20 |
amount | uint256 | quantity of ERC20 to send |
withdrawETH
function withdrawETH(address payable to, uint256 amountOut) external nonpayable
withdraw ETH from the contract
Parameters
Name | Type | Description |
---|
to | address payable | address to send ETH |
amountOut | uint256 | amount of ETH to send |
Events
AllocateSurplus
event AllocateSurplus(address indexed caller, uint256 amount)
event emitted when excess PCV is allocated
Parameters
Name | Type | Description |
---|
caller indexed | address | undefined |
amount | uint256 | undefined |
BackupOracleUpdate
event BackupOracleUpdate(address indexed oldBackupOracle, address indexed newBackupOracle)
Parameters
Name | Type | Description |
---|
oldBackupOracle indexed | address | undefined |
newBackupOracle indexed | address | undefined |
BufferCapUpdate
event BufferCapUpdate(uint256 oldBufferCap, uint256 newBufferCap)
Parameters
Name | Type | Description |
---|
oldBufferCap | uint256 | undefined |
newBufferCap | uint256 | undefined |
BufferUsed
event BufferUsed(uint256 amountUsed, uint256 bufferRemaining)
Parameters
Name | Type | Description |
---|
amountUsed | uint256 | undefined |
bufferRemaining | uint256 | undefined |
ContractAdminRoleUpdate
event ContractAdminRoleUpdate(bytes32 indexed oldContractAdminRole, bytes32 indexed newContractAdminRole)
Parameters
Name | Type | Description |
---|
oldContractAdminRole indexed | bytes32 | undefined |
newContractAdminRole indexed | bytes32 | undefined |
CoreUpdate
event CoreUpdate(address indexed oldCore, address indexed newCore)
Parameters
Name | Type | Description |
---|
oldCore indexed | address | undefined |
newCore indexed | address | undefined |
DecimalsNormalizerUpdate
event DecimalsNormalizerUpdate(int256 oldDecimalsNormalizer, int256 newDecimalsNormalizer)
Parameters
Name | Type | Description |
---|
oldDecimalsNormalizer | int256 | undefined |
newDecimalsNormalizer | int256 | undefined |
Deposit
event Deposit(address indexed _from, uint256 _amount)
Parameters
Name | Type | Description |
---|
_from indexed | address | undefined |
_amount | uint256 | undefined |
InvertUpdate
event InvertUpdate(bool oldDoInvert, bool newDoInvert)
Parameters
Name | Type | Description |
---|
oldDoInvert | bool | undefined |
newDoInvert | bool | undefined |
MaxFeeUpdate
event MaxFeeUpdate(uint256 oldMaxFee, uint256 newMaxFee)
event emitted when a new max fee is set
Parameters
Name | Type | Description |
---|
oldMaxFee | uint256 | undefined |
newMaxFee | uint256 | undefined |
Mint
event Mint(address to, uint256 amountIn, uint256 amountFeiOut)
event emitted when fei gets minted
Parameters
Name | Type | Description |
---|
to | address | undefined |
amountIn | uint256 | undefined |
amountFeiOut | uint256 | undefined |
MintFeeUpdate
event MintFeeUpdate(uint256 oldMintFee, uint256 newMintFee)
event emitted when a new mint fee is set
Parameters
Name | Type | Description |
---|
oldMintFee | uint256 | undefined |
newMintFee | uint256 | undefined |
MintingPaused
event MintingPaused(address account)
event that is emitted when minting is paused
Parameters
Name | Type | Description |
---|
account | address | undefined |
MintingUnpaused
event MintingUnpaused(address account)
event that is emitted when minting is unpaused
Parameters
Name | Type | Description |
---|
account | address | undefined |
OracleCeilingUpdate
event OracleCeilingUpdate(uint256 oldCeiling, uint256 newCeiling)
event emitted when maximum ceiling price is updated
Parameters
Name | Type | Description |
---|
oldCeiling | uint256 | undefined |
newCeiling | uint256 | undefined |
OracleFloorUpdate
event OracleFloorUpdate(uint256 oldFloor, uint256 newFloor)
event emitted when minimum floor price is updated
Parameters
Name | Type | Description |
---|
oldFloor | uint256 | undefined |
newFloor | uint256 | undefined |
OracleUpdate
event OracleUpdate(address indexed oldOracle, address indexed newOracle)
Parameters
Name | Type | Description |
---|
oldOracle indexed | address | undefined |
newOracle indexed | address | undefined |
Paused
event Paused(address account)
Parameters
Name | Type | Description |
---|
account | address | undefined |
RateLimitPerSecondUpdate
event RateLimitPerSecondUpdate(uint256 oldRateLimitPerSecond, uint256 newRateLimitPerSecond)
Parameters
Name | Type | Description |
---|
oldRateLimitPerSecond | uint256 | undefined |
newRateLimitPerSecond | uint256 | undefined |
Redeem
event Redeem(address to, uint256 amountFeiIn, uint256 amountAssetOut)
event emitted upon a redemption
Parameters
Name | Type | Description |
---|
to | address | undefined |
amountFeiIn | uint256 | undefined |
amountAssetOut | uint256 | undefined |
RedeemFeeUpdate
event RedeemFeeUpdate(uint256 oldRedeemFee, uint256 newRedeemFee)
event emitted when a new redeem fee is set
Parameters
Name | Type | Description |
---|
oldRedeemFee | uint256 | undefined |
newRedeemFee | uint256 | undefined |
RedemptionsPaused
event RedemptionsPaused(address account)
event that is emitted when redemptions are paused
Parameters
Name | Type | Description |
---|
account | address | undefined |
RedemptionsUnpaused
event RedemptionsUnpaused(address account)
event that is emitted when redemptions are unpaused
Parameters
Name | Type | Description |
---|
account | address | undefined |
ReservesThresholdUpdate
event ReservesThresholdUpdate(uint256 oldReservesThreshold, uint256 newReservesThreshold)
event emitted when reservesThreshold is updated
Parameters
Name | Type | Description |
---|
oldReservesThreshold | uint256 | undefined |
newReservesThreshold | uint256 | undefined |
SurplusTargetUpdate
event SurplusTargetUpdate(contract IPCVDeposit oldTarget, contract IPCVDeposit newTarget)
event emitted when surplus target is updated
Parameters
Name | Type | Description |
---|
oldTarget | contract IPCVDeposit | undefined |
newTarget | contract IPCVDeposit | undefined |
Unpaused
event Unpaused(address account)
Parameters
Name | Type | Description |
---|
account | address | undefined |
WithdrawERC20
event WithdrawERC20(address indexed _caller, address indexed _token, address indexed _to, uint256 _amount)
Parameters
Name | Type | Description |
---|
_caller indexed | address | undefined |
_token indexed | address | undefined |
_to indexed | address | undefined |
_amount | uint256 | undefined |
WithdrawETH
event WithdrawETH(address indexed _caller, address indexed _to, uint256 _amount)
Parameters
Name | Type | Description |
---|
_caller indexed | address | undefined |
_to indexed | address | undefined |
_amount | uint256 | undefined |
Withdrawal
event Withdrawal(address indexed _caller, address indexed _to, uint256 _amount)
Parameters
Name | Type | Description |
---|
_caller indexed | address | undefined |
_to indexed | address | undefined |
_amount | uint256 | undefined |