Skip to main content

IPausable

Functions

paused

function paused() external returns (bool)

CollateralizationOracle

Reads a list of PCVDeposit that report their amount of collateral and the amount of protocol-owned FEI they manage, to deduce the protocol-wide collateralization ratio.

Functions

constructor

function constructor(
address _core,
address[] _deposits,
address[] _tokens,
address[] _oracles
) public

CollateralizationOracle constructor

Parameters

NameTypeDescription
_coreaddressFei Core for reference
_depositsaddress[]the initial list of PCV deposits
_tokensaddress[]the initial supported tokens for oracle
_oraclesaddress[]the matching set of oracles for _tokens

isTokenInPcv

function isTokenInPcv(
address token
) external returns (bool)

returns true if a token is held in the pcv

Parameters

NameTypeDescription
tokenaddress

getTokensInPcv

function getTokensInPcv() external returns (address[])

returns an array of the addresses of tokens held in the pcv.

getTokenInPcv

function getTokenInPcv(
uint256 i
) external returns (address)

returns token at index i of the array of PCV tokens

Parameters

NameTypeDescription
iuint256

getDepositsForToken

function getDepositsForToken(
address _token
) external returns (address[])

returns an array of the deposits holding a given token.

Parameters

NameTypeDescription
_tokenaddress

getDepositForToken

function getDepositForToken(
address token,
uint256 i
) external returns (address)

returns the address of deposit at index i of token _token

Parameters

NameTypeDescription
tokenaddress
iuint256

addDeposit

function addDeposit(
address _deposit
) external

Add a PCVDeposit to the list of deposits inspected by the collateralization ratio oracle. note : this function reverts if the deposit is already in the list. note : this function reverts if the deposit's token has no oracle.

Parameters

NameTypeDescription
_depositaddress: the PCVDeposit to add to the list.

addDeposits

function addDeposits(
address[] _deposits
) external

adds a list of multiple PCV deposits. See addDeposit.

Parameters

NameTypeDescription
_depositsaddress[]

_addDeposits

function _addDeposits(
address[] _deposits
) internal

Parameters

NameTypeDescription
_depositsaddress[]

_addDeposit

function _addDeposit(
address _deposit
) internal

Parameters

NameTypeDescription
_depositaddress

removeDeposit

function removeDeposit(
address _deposit
) external

Remove a PCVDeposit from the list of deposits inspected by the collateralization ratio oracle. note : this function reverts if the input deposit is not found.

Parameters

NameTypeDescription
_depositaddress: the PCVDeposit address to remove from the list.

removeDeposits

function removeDeposits(
address[] _deposits
) external

removes a list of multiple PCV deposits. See removeDeposit.

Parameters

NameTypeDescription
_depositsaddress[]

_removeDeposit

function _removeDeposit(
address _deposit
) internal

Parameters

NameTypeDescription
_depositaddress

swapDeposit

function swapDeposit(
address _oldDeposit,
address _newDeposit
) external

Swap a PCVDeposit with a new one, for instance when a new version of a deposit (holding the same token) is deployed.

Parameters

NameTypeDescription
_oldDepositaddress: the PCVDeposit to remove from the list.
_newDepositaddress: the PCVDeposit to add to the list.

setOracle

function setOracle(
address _token,
address _newOracle
) external

Set the price feed oracle (in USD) for a given asset.

Parameters

NameTypeDescription
_tokenaddress: the asset to add price oracle for
_newOracleaddress: price feed oracle for the given asset

setOracles

function setOracles(
address[] _tokens,
address[] _oracles
) public

adds a list of token oracles. See setOracle.

Parameters

NameTypeDescription
_tokensaddress[]
_oraclesaddress[]

_setOracles

function _setOracles(
address[] _tokens,
address[] _oracles
) internal

Parameters

NameTypeDescription
_tokensaddress[]
_oraclesaddress[]

_setOracle

function _setOracle(
address _token,
address _newOracle
) internal

Parameters

NameTypeDescription
_tokenaddress
_newOracleaddress

update

function update() external

update all oracles required for this oracle to work that are not paused themselves.

isOutdated

function isOutdated() external returns (bool)

read

function read() public returns (struct Decimal.D256 collateralRatio, bool validityStatus)

Get the current collateralization ratio of the protocol.

Return Values

NameTypeDescription
collateralRatiostruct Decimal.D256the current collateral ratio of the protocol.
validityStatusboolthe current oracle validity status (false if any
    of the oracles for tokens held in the PCV are invalid, or if
this contract is paused). |

pcvStats

function pcvStats() public returns (uint256 protocolControlledValue, uint256 userCirculatingFei, int256 protocolEquity, bool validityStatus)

returns the Protocol-Controlled Value, User-circulating FEI, and Protocol Equity.

Return Values

NameTypeDescription
protocolControlledValueuint256: the total USD value of all assets held
by the protocol.
userCirculatingFeiuint256: the number of FEI not owned by the protocol.
protocolEquityint256: the signed difference between PCV and user circulating FEI.
validityStatusbool: the current oracle validity status (false if any
    of the oracles for tokens held in the PCV are invalid, or if
this contract is paused). |

isOvercollateralized

function isOvercollateralized() external returns (bool)

returns true if the protocol is overcollateralized. Overcollateralization is defined as the protocol having more assets in its PCV (Protocol Controlled Value) than the circulating (user-owned) FEI, i.e. a positive Protocol Equity.

Events

DepositAdd

event DepositAdd(
address from,
address deposit,
address token
)

Parameters

NameTypeDescription
fromaddress
depositaddress
tokenaddress

DepositRemove

event DepositRemove(
address from,
address deposit
)

Parameters

NameTypeDescription
fromaddress
depositaddress

OracleUpdate

event OracleUpdate(
address from,
address token,
address oldOracle,
address newOracle
)

Parameters

NameTypeDescription
fromaddress
tokenaddress
oldOracleaddress
newOracleaddress