Skip to main content

IPegStabilityModule

Volt Protocol

Fei Peg Stability Module

The Fei PSM is a contract which holds a reserve of assets in order to exchange FEI at $1 of underlying assets with a fee. mint() - buy FEI for $1 of underlying tokens redeem() - sell FEI 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

Methods

MAX_FEE

function MAX_FEE() external view returns (uint256)

the max mint and redeem fee in basis points

Returns

NameTypeDescription
_0uint256undefined

allocateSurplus

function allocateSurplus() external nonpayable

send any surplus reserves to the PCV allocation

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

Parameters

NameTypeDescription
amountInuint256undefined

Returns

NameTypeDescription
amountFeiOutuint256undefined

getRedeemAmountOut

function getRedeemAmountOut(uint256 amountFeiIn) external view returns (uint256 amountOut)

calculate the amount of underlying out for a given amountFeiIn of FEI

Parameters

NameTypeDescription
amountFeiInuint256undefined

Returns

NameTypeDescription
amountOutuint256undefined

hasSurplus

function hasSurplus() external view returns (bool)

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

Returns

NameTypeDescription
_0boolundefined

mint

function mint(address to, uint256 amountIn, uint256 minAmountOut) external nonpayable returns (uint256 amountFeiOut)

mint amountFeiOut FEI to address to for amountIn underlying tokens

see getMintAmountOut() to pre-calculate amount out

Parameters

NameTypeDescription
toaddressundefined
amountInuint256undefined
minAmountOutuint256undefined

Returns

NameTypeDescription
amountFeiOutuint256undefined

mintFeeBasisPoints

function mintFeeBasisPoints() external view returns (uint256)

the mint fee vs oracle price in basis point terms

Returns

NameTypeDescription
_0uint256undefined

redeem

function redeem(address to, uint256 amountFeiIn, uint256 minAmountOut) external nonpayable returns (uint256 amountOut)

redeem amountFeiIn FEI for amountOut underlying tokens and send to address to

see getRedeemAmountOut() to pre-calculate amount out

Parameters

NameTypeDescription
toaddressundefined
amountFeiInuint256undefined
minAmountOutuint256undefined

Returns

NameTypeDescription
amountOutuint256undefined

redeemFeeBasisPoints

function redeemFeeBasisPoints() external view returns (uint256)

the redemption fee vs oracle price in basis point terms

Returns

NameTypeDescription
_0uint256undefined

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 ideal amount of reserves for the contract to hold for redemptions

Returns

NameTypeDescription
_0uint256undefined

setMintFee

function setMintFee(uint256 newMintFeeBasisPoints) external nonpayable

set the mint fee vs oracle price in basis point terms

Parameters

NameTypeDescription
newMintFeeBasisPointsuint256undefined

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 to send surplus reserves

Returns

NameTypeDescription
_0contract IPCVDepositundefined

underlyingToken

function underlyingToken() external view returns (contract IERC20)

the underlying token exchanged for FEI

Returns

NameTypeDescription
_0contract IERC20undefined

Events

AllocateSurplus

event AllocateSurplus(address indexed caller, uint256 amount)

event emitted when excess PCV is allocated

Parameters

NameTypeDescription
caller indexedaddressundefined
amountuint256undefined

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

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

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