⬅️ 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, CompositeOracle, ChainlinkOracleWrapper, ConstantOracle, PCVDepositWrapper, ERC20PCVDepositWrapper, BPTLens
Events
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 |
|
DepositAdd
event DepositAdd(address,address,address)
Params
Param |
Type |
Notes |
from |
address |
|
deposit |
address indexed |
|
token |
address indexed |
|
DepositRemove
event DepositRemove(address,address)
Params
Param |
Type |
Notes |
from |
address |
|
deposit |
address indexed |
|
OracleUpdate
event OracleUpdate(address,address,address,address)
Params
Param |
Type |
Notes |
from |
address |
|
token |
address indexed |
|
oldOracle |
address indexed |
|
newOracle |
address indexed |
|
Paused
event Paused(address)
Params
Param |
Type |
Notes |
account |
address |
|
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
addDeposit
function addDeposit(address) nonpayable
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.
Params
Param |
Type |
Notes |
_deposit |
address |
: the PCVDeposit to add to the list. |
addDeposits
function addDeposits(address[]) nonpayable
adds a list of multiple PCV deposits. See addDeposit.
Params
Param |
Type |
Notes |
_deposits |
address[] |
|
core
function core() view returns(address)
address of the Core contract referenced
Returns
Param |
Type |
Notes |
|
address |
ICore implementation address |
depositToToken
function depositToToken(address) view returns(address)
Map from deposit address to token address. It is used like an indexed version of the pcvDeposits array, to check existence of a PCVdeposit in the current config.
Params
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 |
getDepositForToken
function getDepositForToken(address,uint256) view returns(address)
returns the address of deposit at index i of token _token
Params
Param |
Type |
Notes |
token |
address |
|
i |
uint256 |
|
Returns
getDepositsForToken
function getDepositsForToken(address) view returns(address[])
returns an array of the deposits holding a given token.
Params
Param |
Type |
Notes |
_token |
address |
|
Returns
Param |
Type |
Notes |
|
address[] |
|
getTokenInPcv
function getTokenInPcv(uint256) view returns(address)
returns token at index i of the array of PCV tokens
Params
Param |
Type |
Notes |
i |
uint256 |
|
Returns
getTokensInPcv
function getTokensInPcv() view returns(address[])
returns an array of the addresses of tokens held in the pcv.
Returns
Param |
Type |
Notes |
|
address[] |
|
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
isOutdated
function isOutdated() 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
isTokenInPcv
function isTokenInPcv(address) view returns(bool)
returns true if a token is held in the pcv
Params
Param |
Type |
Notes |
token |
address |
|
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.
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 signed difference between PCV and user circulating FEI. |
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.
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). |
removeDeposit
function removeDeposit(address) nonpayable
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.
Params
Param |
Type |
Notes |
_deposit |
address |
: the PCVDeposit address to remove from the list. |
removeDeposits
function removeDeposits(address[]) nonpayable
removes a list of multiple PCV deposits. See removeDeposit.
Params
Param |
Type |
Notes |
_deposits |
address[] |
|
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 |
setOracle
function setOracle(address,address) nonpayable
Set the price feed oracle (in USD) for a given asset.
Params
Param |
Type |
Notes |
_token |
address |
: the asset to add price oracle for |
_newOracle |
address |
: price feed oracle for the given asset |
setOracles
function setOracles(address[],address[]) nonpayable
adds a list of token oracles. See setOracle.
Params
Param |
Type |
Notes |
_tokens |
address[] |
|
_oracles |
address[] |
|
swapDeposit
function swapDeposit(address,address) nonpayable
Swap a PCVDeposit with a new one, for instance when a new version of a deposit (holding the same token) is deployed.
Params
Param |
Type |
Notes |
_oldDeposit |
address |
: the PCVDeposit to remove from the list. |
_newDeposit |
address |
: the PCVDeposit to add to the list. |
tokenToOracle
function tokenToOracle(address) view returns(address)
Map of oracles to use to get USD values of assets held in PCV deposits. This map is used to get the oracle address from and ERC20 address.
Params
Returns
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 all oracles required for this oracle to work that are not paused themselves.
⬅️ Contracts