Skip to main content

IPausable

Functions

paused

function paused() external returns (bool)

CollateralizationOracleWrapper

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,
uint256 _validityDuration
) public

CollateralizationOracleWrapper constructor

Parameters

NameTypeDescription
_coreaddressFei Core for reference.
_validityDurationuint256the duration after which a reading becomes outdated.

initialize

function initialize(
address _core,
address _collateralizationOracle,
uint256 _validityDuration,
uint256 _deviationThresholdBasisPoints
) public

CollateralizationOracleWrapper initializer

Parameters

NameTypeDescription
_coreaddressFei Core for reference.
_collateralizationOracleaddressthe CollateralizationOracle to inspect.
_validityDurationuint256the duration after which a reading becomes outdated.
_deviationThresholdBasisPointsuint256threshold for deviation after which
keepers should call the update() function.

setCollateralizationOracle

function setCollateralizationOracle(
address _newCollateralizationOracle
) external

set the address of the CollateralizationOracle to inspect, and to cache values from.

Parameters

NameTypeDescription
_newCollateralizationOracleaddressthe address of the new oracle.

setDeviationThresholdBasisPoints

function setDeviationThresholdBasisPoints(
uint256 _newDeviationThresholdBasisPoints
) external

set the deviation threshold in basis points, used to detect if the cached value deviated significantly from the actual fresh readings.

Parameters

NameTypeDescription
_newDeviationThresholdBasisPointsuint256the new value to set.

setValidityDuration

function setValidityDuration(
uint256 _validityDuration
) external

set the validity duration of the cached collateralization values.

Parameters

NameTypeDescription
_validityDurationuint256the new validity duration
This function will emit a DurationUpdate event from Timed.sol

setReadPauseOverride

function setReadPauseOverride(
bool _readPauseOverride
) external

set the readPauseOverride flag

Parameters

NameTypeDescription
_readPauseOverrideboolthe new flag for readPauseOverride

setCache

function setCache(
uint256 _cachedProtocolControlledValue,
uint256 _cachedUserCirculatingFei,
int256 _cachedProtocolEquity
) external

governor or admin override to directly write to the cache

used in emergencies where the underlying oracle is compromised or failing

Parameters

NameTypeDescription
_cachedProtocolControlledValueuint256
_cachedUserCirculatingFeiuint256
_cachedProtocolEquityint256

update

function update() external

update reading of the CollateralizationOracle

updateIfOutdated

function updateIfOutdated() external

this method reverts if the oracle is not outdated It is useful if the caller is incentivized for calling only when the deviation threshold or frequency has passed

_update

function _update() internal returns (bool)

_setCache

function _setCache(
uint256 _cachedProtocolControlledValue,
uint256 _cachedUserCirculatingFei,
int256 _cachedProtocolEquity
) internal

Parameters

NameTypeDescription
_cachedProtocolControlledValueuint256
_cachedUserCirculatingFeiuint256
_cachedProtocolEquityint256

isOutdated

function isOutdated() public returns (bool outdated)

read

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

Get the current collateralization ratio of the protocol, from cache.

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). |

isExceededDeviationThreshold

function isExceededDeviationThreshold() public returns (bool obsolete)

_isExceededDeviationThreshold

function _isExceededDeviationThreshold(
uint256 cached,
uint256 current
) internal returns (bool)

Parameters

NameTypeDescription
cacheduint256
currentuint256

isOutdatedOrExceededDeviationThreshold

function isOutdatedOrExceededDeviationThreshold() external returns (bool)

pcvStats

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

returns the Protocol-Controlled Value, User-circulating FEI, and Protocol Equity. If there is a fresh cached value, return it. Otherwise, call the CollateralizationOracle to get fresh data.

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 difference between PCV and user circulating FEI.
If there are more circulating FEI than $ in the PCV, equity is 0.
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.

pcvStatsCurrent

function pcvStatsCurrent() external returns (uint256 protocolControlledValue, uint256 userCirculatingFei, int256 protocolEquity, bool validityStatus)

returns the Protocol-Controlled Value, User-circulating FEI, and Protocol Equity, from an actual fresh call to the CollateralizationOracle.

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 difference between PCV and user circulating FEI.
If there are more circulating FEI than $ in the PCV, equity is 0.
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). |

_readNotPaused

function _readNotPaused() internal returns (bool)