⬅️ Contracts
Fei Protocol's Collateralization Oracle
Author: eswak
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.
Mainnet implementations
Core, OptimisticTimelock, CollateralizationOracleKeeper, CollateralizationOracleGuardian, CollateralizationOracleWrapper, TribeReserveStabilizer, PCVEquityMinter, ProxyAdmin
Events
CachedValueUpdate
event CachedValueUpdate(address,uint256,uint256,int256)
Params
Param |
Type |
Notes |
from |
address |
|
protocolControlledValue |
uint256 indexed |
|
userCirculatingFei |
uint256 indexed |
|
protocolEquity |
int256 indexed |
|
CollateralizationOracleUpdate
event CollateralizationOracleUpdate(address,address,address)
Params
Param |
Type |
Notes |
from |
address |
|
oldOracleAddress |
address indexed |
|
newOracleAddress |
address indexed |
|
ContractAdminRoleUpdate
event ContractAdminRoleUpdate(bytes32,bytes32)
Params
Param |
Type |
Notes |
oldContractAdminRole |
bytes32 indexed |
|
newContractAdminRole |
bytes32 indexed |
|
CoreUpdate
event CoreUpdate(address,address)
Params
Param |
Type |
Notes |
oldCore |
address indexed |
|
newCore |
address indexed |
|
DeviationThresholdUpdate
event DeviationThresholdUpdate(address,uint256,uint256)
Params
Param |
Type |
Notes |
from |
address |
|
oldThreshold |
uint256 indexed |
|
newThreshold |
uint256 indexed |
|
DurationUpdate
event DurationUpdate(uint256,uint256)
Params
Param |
Type |
Notes |
oldDuration |
uint256 |
|
newDuration |
uint256 |
|
Paused
event Paused(address)
Params
Param |
Type |
Notes |
account |
address |
|
ReadPauseOverrideUpdate
event ReadPauseOverrideUpdate(bool)
Params
Param |
Type |
Notes |
readPauseOverride |
bool |
|
TimerReset
event TimerReset(uint256)
Params
Param |
Type |
Notes |
startTime |
uint256 |
|
Unpaused
event Unpaused(address)
Params
Param |
Type |
Notes |
account |
address |
|
Update
event Update(uint256)
Params
Param |
Type |
Notes |
_peg |
uint256 |
|
Methods
CONTRACT_ADMIN_ROLE
function CONTRACT_ADMIN_ROLE() view returns(bytes32)
a role used with a subset of governor permissions for this contract only
Returns
cachedProtocolControlledValue
function cachedProtocolControlledValue() view returns(uint256)
cached value of the Protocol Controlled Value
Returns
cachedProtocolEquity
function cachedProtocolEquity() view returns(int256)
cached value of the Protocol Equity
Returns
cachedUserCirculatingFei
function cachedUserCirculatingFei() view returns(uint256)
cached value of the User Circulating FEI
Returns
collateralizationOracle
function collateralizationOracle() view returns(address)
address of the CollateralizationOracle to memoize
Returns
core
function core() view returns(address)
address of the Core contract referenced
Returns
Param |
Type |
Notes |
|
address |
ICore implementation address |
deviationThresholdBasisPoints
function deviationThresholdBasisPoints() view returns(uint256)
deviation threshold to consider cached values outdated, in basis points (base 10_000)
Returns
duration
function duration() view returns(uint256)
the duration of the timed period
Returns
fei
function fei() view returns(address)
address of the Fei contract referenced by Core
Returns
Param |
Type |
Notes |
|
address |
IFei implementation address |
feiBalance
function feiBalance() view returns(uint256)
fei balance of contract
Returns
Param |
Type |
Notes |
|
uint256 |
fei amount held |
initialize
function initialize(address,address,uint256,uint256) nonpayable
CollateralizationOracleWrapper initializer
Params
Param |
Type |
Notes |
_core |
address |
Fei Core for reference. |
_collateralizationOracle |
address |
the CollateralizationOracle to inspect. |
_validityDuration |
uint256 |
the duration after which a reading becomes outdated. |
_deviationThresholdBasisPoints |
uint256 |
threshold for deviation after which keepers should call the update() function. |
isContractAdmin
function isContractAdmin(address) view returns(bool)
returns whether a given address has the admin role for this contract
Params
Param |
Type |
Notes |
_admin |
address |
|
Returns
isExceededDeviationThreshold
function isExceededDeviationThreshold() view returns(bool)
Returns
Param |
Type |
Notes |
obsolete |
bool |
|
isOutdated
function isOutdated() view returns(bool)
Returns
Param |
Type |
Notes |
outdated |
bool |
|
isOutdatedOrExceededDeviationThreshold
function isOutdatedOrExceededDeviationThreshold() view returns(bool)
Returns
isOvercollateralized
function isOvercollateralized() view 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.
Returns
isTimeEnded
function isTimeEnded() view returns(bool)
return true if time period has ended
Returns
isTimeStarted
function isTimeStarted() view returns(bool)
Returns
pause
function pause() nonpayable
set pausable methods to paused
paused
function paused() view returns(bool)
Returns true if the contract is paused, and false otherwise.
Returns
pcvStats
function pcvStats() view returns(uint256,uint256,int256,bool)
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.
Returns
Param |
Type |
Notes |
protocolControlledValue |
uint256 |
: the total USD value of all assets held by the protocol. |
userCirculatingFei |
uint256 |
: the number of FEI not owned by the protocol. |
protocolEquity |
int256 |
: the difference between PCV and user circulating FEI. If there are more circulating FEI than $ in the PCV, equity is 0. |
validityStatus |
bool |
: 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). |
pcvStatsCurrent
function pcvStatsCurrent() view returns(uint256,uint256,int256,bool)
returns the Protocol-Controlled Value, User-circulating FEI, and Protocol Equity, from an actual fresh call to the CollateralizationOracle.
Returns
Param |
Type |
Notes |
protocolControlledValue |
uint256 |
: the total USD value of all assets held by the protocol. |
userCirculatingFei |
uint256 |
: the number of FEI not owned by the protocol. |
protocolEquity |
int256 |
: the difference between PCV and user circulating FEI. If there are more circulating FEI than $ in the PCV, equity is 0. |
validityStatus |
bool |
: 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). |
read
function read() view returns(tuple,bool)
Get the current collateralization ratio of the protocol, from cache.
Returns
Param |
Type |
Notes |
collateralRatio |
tuple |
the current collateral ratio of the protocol. |
validityStatus |
bool |
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). |
readPauseOverride
function readPauseOverride() view returns(bool)
a flag to override pause behavior for reads
Returns
remainingTime
function remainingTime() view returns(uint256)
number of seconds remaining until time is up
Returns
Param |
Type |
Notes |
|
uint256 |
remaining |
setCache
function setCache(uint256,uint256,int256) nonpayable
governor or admin override to directly write to the cache
used in emergencies where the underlying oracle is compromised or failing
Params
Param |
Type |
Notes |
_cachedProtocolControlledValue |
uint256 |
|
_cachedUserCirculatingFei |
uint256 |
|
_cachedProtocolEquity |
int256 |
|
setCollateralizationOracle
function setCollateralizationOracle(address) nonpayable
set the address of the CollateralizationOracle to inspect, and to cache values from.
Params
Param |
Type |
Notes |
_newCollateralizationOracle |
address |
the address of the new oracle. |
setContractAdminRole
function setContractAdminRole(bytes32) nonpayable
sets a new admin role for this contract
Params
Param |
Type |
Notes |
newContractAdminRole |
bytes32 |
|
setCore
function setCore(address) nonpayable
set new Core reference address
Params
Param |
Type |
Notes |
newCore |
address |
the new core address |
setDeviationThresholdBasisPoints
function setDeviationThresholdBasisPoints(uint256) nonpayable
set the deviation threshold in basis points, used to detect if the cached value deviated significantly from the actual fresh readings.
Params
Param |
Type |
Notes |
_newDeviationThresholdBasisPoints |
uint256 |
the new value to set. |
setReadPauseOverride
function setReadPauseOverride(bool) nonpayable
set the readPauseOverride flag
Params
Param |
Type |
Notes |
_readPauseOverride |
bool |
the new flag for readPauseOverride |
setValidityDuration
function setValidityDuration(uint256) nonpayable
set the validity duration of the cached collateralization values.
Params
Param |
Type |
Notes |
_validityDuration |
uint256 |
the new validity duration This function will emit a DurationUpdate event from Timed.sol |
startTime
function startTime() view returns(uint256)
the start timestamp of the timed period
Returns
timeSinceStart
function timeSinceStart() view returns(uint256)
number of seconds since contract was initialized
will be less than or equal to duration
Returns
Param |
Type |
Notes |
|
uint256 |
timestamp |
tribe
function tribe() view returns(address)
address of the Tribe contract referenced by Core
Returns
Param |
Type |
Notes |
|
address |
IERC20 implementation address |
tribeBalance
function tribeBalance() view returns(uint256)
tribe balance of contract
Returns
Param |
Type |
Notes |
|
uint256 |
tribe amount held |
unpause
function unpause() nonpayable
set pausable methods to unpaused
update
function update() nonpayable
update reading of the CollateralizationOracle
updateIfOutdated
function updateIfOutdated() nonpayable
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
⬅️ Contracts