Skip to main content

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

NameTypeDescription
_0bytes32undefined

MAX_FEE

function MAX_FEE() external view returns (uint256)

the max mint and redeem fee in basis points Governance can change this fee

Returns

NameTypeDescription
_0uint256undefined

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

NameTypeDescription
_0uint256undefined

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

NameTypeDescription
_0contract IOracleundefined

balance

function balance() external view returns (uint256)

function from PCVDeposit that must be overriden

Returns

NameTypeDescription
_0uint256undefined

balanceReportedIn

function balanceReportedIn() external view returns (address)

returns address of token this contracts balance is reported in

Returns

NameTypeDescription
_0addressundefined

buffer

function buffer() external view returns (uint256)

the amount of action used before hitting limit

replenishes at rateLimitPerSecond per second up to bufferCap

Returns

NameTypeDescription
_0uint256undefined

bufferCap

function bufferCap() external view returns (uint256)

the cap of the buffer that can be used at once

Returns

NameTypeDescription
_0uint256undefined

bufferStored

function bufferStored() external view returns (uint256)

the buffer at the timestamp of lastBufferUsedTime

Returns

NameTypeDescription
_0uint256undefined

ceiling

function ceiling() external view returns (uint256)

the default maximum acceptable oracle price ceiling is $1.02

Returns

NameTypeDescription
_0uint256undefined

core

function core() external view returns (contract ICore)

address of the Core contract referenced

Returns

NameTypeDescription
_0contract ICoreICore implementation address

decimalsNormalizer

function decimalsNormalizer() external view returns (int256)

number of decimals to scale oracle price by, i.e. multiplying by 10^(decimalsNormalizer)

Returns

NameTypeDescription
_0int256undefined

deposit

function deposit() external nonpayable

function to receive ERC20 tokens from external contracts

doInvert

function doInvert() external view returns (bool)

Returns

NameTypeDescription
_0boolundefined

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

NameTypeDescription
_0boolundefined

floor

function floor() external view returns (uint256)

the default minimum acceptable oracle price floor is 98 cents

Returns

NameTypeDescription
_0uint256undefined

getMaxMintAmountOut

function getMaxMintAmountOut() external view returns (uint256)

the maximum mint amount out

Returns

NameTypeDescription
_0uint256undefined

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

NameTypeDescription
amountInuint256undefined

Returns

NameTypeDescription
amountFeiOutuint256undefined

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

NameTypeDescription
amountFeiInuint256undefined

Returns

NameTypeDescription
amountTokenOutuint256undefined

hasSurplus

function hasSurplus() external view returns (bool)

a flag for whether the current balance is above (true) or below (false) the reservesThreshold

Returns

NameTypeDescription
_0boolundefined

invert

function invert(Decimal.D256 price) external pure returns (struct Decimal.D256)

Parameters

NameTypeDescription
priceDecimal.D256undefined

Returns

NameTypeDescription
_0Decimal.D256undefined

isContractAdmin

function isContractAdmin(address _admin) external view returns (bool)

returns whether a given address has the admin role for this contract

Parameters

NameTypeDescription
_adminaddressundefined

Returns

NameTypeDescription
_0boolundefined

isPriceValid

function isPriceValid() external view returns (bool)

return wether the current oracle price is valid or not

Returns

NameTypeDescription
_0boolundefined

lastBufferUsedTime

function lastBufferUsedTime() external view returns (uint256)

the last time the buffer was used by the contract

Returns

NameTypeDescription
_0uint256undefined

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

NameTypeDescription
toaddressundefined
amountInuint256undefined
minAmountOutuint256undefined

Returns

NameTypeDescription
amountFeiOutuint256undefined

mintFeeBasisPoints

function mintFeeBasisPoints() external view returns (uint256)

the fee in basis points for selling asset into FEI

Returns

NameTypeDescription
_0uint256undefined

mintPaused

function mintPaused() external view returns (bool)

boolean switch that indicates whether minting is paused

Returns

NameTypeDescription
_0boolundefined

oracle

function oracle() external view returns (contract IOracle)

the oracle reference by the contract

Returns

NameTypeDescription
_0contract IOracleundefined

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

NameTypeDescription
_0boolundefined

rateLimitPerSecond

function rateLimitPerSecond() external view returns (uint256)

the rate per second for this contract

Returns

NameTypeDescription
_0uint256undefined

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

NameTypeDescription
_0Decimal.D256the 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

NameTypeDescription
toaddressundefined
amountFeiInuint256undefined
minAmountOutuint256undefined

Returns

NameTypeDescription
amountOutuint256undefined

redeemFeeBasisPoints

function redeemFeeBasisPoints() external view returns (uint256)

the fee in basis points for buying the asset for FEI

Returns

NameTypeDescription
_0uint256undefined

redeemPaused

function redeemPaused() external view returns (bool)

boolean switch that indicates whether redemptions are paused

Returns

NameTypeDescription
_0boolundefined

reservesSurplus

function reservesSurplus() external view returns (int256)

an integer representing the positive surplus or negative deficit of contract balance vs reservesThreshold

Returns

NameTypeDescription
_0int256undefined

reservesThreshold

function reservesThreshold() external view returns (uint256)

the amount of reserves to be held for redemptions

Returns

NameTypeDescription
_0uint256undefined

resistantBalanceAndVolt

function resistantBalanceAndVolt() external view returns (uint256, uint256)

override default behavior of not checking fei balance

Returns

NameTypeDescription
_0uint256undefined
_1uint256undefined

setBackupOracle

function setBackupOracle(address newBackupOracle) external nonpayable

sets the referenced backup oracle

Parameters

NameTypeDescription
newBackupOracleaddressthe new backup oracle to reference

setBufferCap

function setBufferCap(uint256 newBufferCap) external nonpayable

set the buffer cap

Parameters

NameTypeDescription
newBufferCapuint256undefined

setContractAdminRole

function setContractAdminRole(bytes32 newContractAdminRole) external nonpayable

sets a new admin role for this contract

Parameters

NameTypeDescription
newContractAdminRolebytes32undefined

setDecimalsNormalizer

function setDecimalsNormalizer(int256 newDecimalsNormalizer) external nonpayable

sets the new decimalsNormalizer

Parameters

NameTypeDescription
newDecimalsNormalizerint256the new decimalsNormalizer

setDoInvert

function setDoInvert(bool newDoInvert) external nonpayable

sets the flag for whether to invert or not

Parameters

NameTypeDescription
newDoInvertboolthe 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

NameTypeDescription
newMintFeeBasisPointsuint256undefined

setOracle

function setOracle(address newOracle) external nonpayable

sets the referenced oracle

Parameters

NameTypeDescription
newOracleaddressthe new oracle to reference

setOracleCeilingBasisPoints

function setOracleCeilingBasisPoints(uint256 newCeilingBasisPoints) external nonpayable

sets the ceiling price in BP

Parameters

NameTypeDescription
newCeilingBasisPointsuint256undefined

setOracleFloorBasisPoints

function setOracleFloorBasisPoints(uint256 newFloorBasisPoints) external nonpayable

sets the floor price in BP

Parameters

NameTypeDescription
newFloorBasisPointsuint256undefined

setRateLimitPerSecond

function setRateLimitPerSecond(uint256 newRateLimitPerSecond) external nonpayable

set the rate limit per second

Parameters

NameTypeDescription
newRateLimitPerSeconduint256undefined

setRedeemFee

function setRedeemFee(uint256 newRedeemFeeBasisPoints) external nonpayable

set the redemption fee vs oracle price in basis point terms

Parameters

NameTypeDescription
newRedeemFeeBasisPointsuint256undefined

setReservesThreshold

function setReservesThreshold(uint256 newReservesThreshold) external nonpayable

set the ideal amount of reserves for the contract to hold for redemptions

Parameters

NameTypeDescription
newReservesThresholduint256undefined

setSurplusTarget

function setSurplusTarget(contract IPCVDeposit newTarget) external nonpayable

set the target for sending surplus reserves

Parameters

NameTypeDescription
newTargetcontract IPCVDepositundefined

surplusTarget

function surplusTarget() external view returns (contract IPCVDeposit)

the PCV deposit target

Returns

NameTypeDescription
_0contract IPCVDepositundefined

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

NameTypeDescription
_0contract IERC20undefined

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

NameTypeDescription
_0contract IERC20IERC20 implementation address

vconBalance

function vconBalance() external view returns (uint256)

vcon balance of contract

Returns

NameTypeDescription
_0uint256vcon amount held

volt

function volt() external view returns (contract IVolt)

address of the Fei contract referenced by Core

Returns

NameTypeDescription
_0contract IVoltIFei implementation address

voltBalance

function voltBalance() external view returns (uint256)

volt balance of contract

Returns

NameTypeDescription
_0uint256volt amount held

withdraw

function withdraw(address to, uint256 amount) external nonpayable

withdraw assets from PSM to an external address

Parameters

NameTypeDescription
toaddressundefined
amountuint256undefined

withdrawERC20

function withdrawERC20(address token, address to, uint256 amount) external nonpayable

withdraw ERC20 from the contract

Parameters

NameTypeDescription
tokenaddressaddress of the ERC20 to send
toaddressaddress destination of the ERC20
amountuint256quantity of ERC20 to send

withdrawETH

function withdrawETH(address payable to, uint256 amountOut) external nonpayable

withdraw ETH from the contract

Parameters

NameTypeDescription
toaddress payableaddress to send ETH
amountOutuint256amount of ETH to send

Events

AllocateSurplus

event AllocateSurplus(address indexed caller, uint256 amount)

event emitted when excess PCV is allocated

Parameters

NameTypeDescription
caller indexedaddressundefined
amountuint256undefined

BackupOracleUpdate

event BackupOracleUpdate(address indexed oldBackupOracle, address indexed newBackupOracle)

Parameters

NameTypeDescription
oldBackupOracle indexedaddressundefined
newBackupOracle indexedaddressundefined

BufferCapUpdate

event BufferCapUpdate(uint256 oldBufferCap, uint256 newBufferCap)

Parameters

NameTypeDescription
oldBufferCapuint256undefined
newBufferCapuint256undefined

BufferUsed

event BufferUsed(uint256 amountUsed, uint256 bufferRemaining)

Parameters

NameTypeDescription
amountUseduint256undefined
bufferRemaininguint256undefined

ContractAdminRoleUpdate

event ContractAdminRoleUpdate(bytes32 indexed oldContractAdminRole, bytes32 indexed newContractAdminRole)

Parameters

NameTypeDescription
oldContractAdminRole indexedbytes32undefined
newContractAdminRole indexedbytes32undefined

CoreUpdate

event CoreUpdate(address indexed oldCore, address indexed newCore)

Parameters

NameTypeDescription
oldCore indexedaddressundefined
newCore indexedaddressundefined

DecimalsNormalizerUpdate

event DecimalsNormalizerUpdate(int256 oldDecimalsNormalizer, int256 newDecimalsNormalizer)

Parameters

NameTypeDescription
oldDecimalsNormalizerint256undefined
newDecimalsNormalizerint256undefined

Deposit

event Deposit(address indexed _from, uint256 _amount)

Parameters

NameTypeDescription
_from indexedaddressundefined
_amountuint256undefined

InvertUpdate

event InvertUpdate(bool oldDoInvert, bool newDoInvert)

Parameters

NameTypeDescription
oldDoInvertboolundefined
newDoInvertboolundefined

MaxFeeUpdate

event MaxFeeUpdate(uint256 oldMaxFee, uint256 newMaxFee)

event emitted when a new max fee is set

Parameters

NameTypeDescription
oldMaxFeeuint256undefined
newMaxFeeuint256undefined

Mint

event Mint(address to, uint256 amountIn, uint256 amountFeiOut)

event emitted when fei gets minted

Parameters

NameTypeDescription
toaddressundefined
amountInuint256undefined
amountFeiOutuint256undefined

MintFeeUpdate

event MintFeeUpdate(uint256 oldMintFee, uint256 newMintFee)

event emitted when a new mint fee is set

Parameters

NameTypeDescription
oldMintFeeuint256undefined
newMintFeeuint256undefined

MintingPaused

event MintingPaused(address account)

event that is emitted when minting is paused

Parameters

NameTypeDescription
accountaddressundefined

MintingUnpaused

event MintingUnpaused(address account)

event that is emitted when minting is unpaused

Parameters

NameTypeDescription
accountaddressundefined

OracleCeilingUpdate

event OracleCeilingUpdate(uint256 oldCeiling, uint256 newCeiling)

event emitted when maximum ceiling price is updated

Parameters

NameTypeDescription
oldCeilinguint256undefined
newCeilinguint256undefined

OracleFloorUpdate

event OracleFloorUpdate(uint256 oldFloor, uint256 newFloor)

event emitted when minimum floor price is updated

Parameters

NameTypeDescription
oldFlooruint256undefined
newFlooruint256undefined

OracleUpdate

event OracleUpdate(address indexed oldOracle, address indexed newOracle)

Parameters

NameTypeDescription
oldOracle indexedaddressundefined
newOracle indexedaddressundefined

Paused

event Paused(address account)

Parameters

NameTypeDescription
accountaddressundefined

RateLimitPerSecondUpdate

event RateLimitPerSecondUpdate(uint256 oldRateLimitPerSecond, uint256 newRateLimitPerSecond)

Parameters

NameTypeDescription
oldRateLimitPerSeconduint256undefined
newRateLimitPerSeconduint256undefined

Redeem

event Redeem(address to, uint256 amountFeiIn, uint256 amountAssetOut)

event emitted upon a redemption

Parameters

NameTypeDescription
toaddressundefined
amountFeiInuint256undefined
amountAssetOutuint256undefined

RedeemFeeUpdate

event RedeemFeeUpdate(uint256 oldRedeemFee, uint256 newRedeemFee)

event emitted when a new redeem fee is set

Parameters

NameTypeDescription
oldRedeemFeeuint256undefined
newRedeemFeeuint256undefined

RedemptionsPaused

event RedemptionsPaused(address account)

event that is emitted when redemptions are paused

Parameters

NameTypeDescription
accountaddressundefined

RedemptionsUnpaused

event RedemptionsUnpaused(address account)

event that is emitted when redemptions are unpaused

Parameters

NameTypeDescription
accountaddressundefined

ReservesThresholdUpdate

event ReservesThresholdUpdate(uint256 oldReservesThreshold, uint256 newReservesThreshold)

event emitted when reservesThreshold is updated

Parameters

NameTypeDescription
oldReservesThresholduint256undefined
newReservesThresholduint256undefined

SurplusTargetUpdate

event SurplusTargetUpdate(contract IPCVDeposit oldTarget, contract IPCVDeposit newTarget)

event emitted when surplus target is updated

Parameters

NameTypeDescription
oldTargetcontract IPCVDepositundefined
newTargetcontract IPCVDepositundefined

Unpaused

event Unpaused(address account)

Parameters

NameTypeDescription
accountaddressundefined

WithdrawERC20

event WithdrawERC20(address indexed _caller, address indexed _token, address indexed _to, uint256 _amount)

Parameters

NameTypeDescription
_caller indexedaddressundefined
_token indexedaddressundefined
_to indexedaddressundefined
_amountuint256undefined

WithdrawETH

event WithdrawETH(address indexed _caller, address indexed _to, uint256 _amount)

Parameters

NameTypeDescription
_caller indexedaddressundefined
_to indexedaddressundefined
_amountuint256undefined

Withdrawal

event Withdrawal(address indexed _caller, address indexed _to, uint256 _amount)

Parameters

NameTypeDescription
_caller indexedaddressundefined
_to indexedaddressundefined
_amountuint256undefined