OracleGuardLib
Title: OracleGuardLib
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Chainlink (https://docs.chain.link/data-feeds/l2-sequencer-feeds)
Library behind the OracleGuard facet: an opt-in L2 sequencer-uptime check and per-key WAD bounds applied on top of any IPriceOracleReader adapter. See IOracleGuard for the full semantics.
Functions
oracleGuardStorage
Returns the ERC-7201 storage struct for OracleGuard.
function oracleGuardStorage() internal pure returns (OracleGuardStorage storage $);Returns
| Name | Type | Description |
|---|---|---|
| $ | OracleGuardStorage |
__OracleGuard_init
Registers the IOracleGuard ERC-165 interface.
Must be called between preInitializer / postInitializer.
function __OracleGuard_init() internal;registerInterface
Writes true to the ERC-165 map slot for IOracleGuard.
function registerInterface() internal;guardedAnswer
Returns the oracle's WAD answer for key after the sequencer and bounds checks.
function guardedAnswer(bytes32 key) internal view returns (int256 answerWad);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | The feed identifier. |
Returns
| Name | Type | Description |
|---|---|---|
| answerWad | int256 | The checked price scaled to 1e18. |
checkSequencerUptime
Reverts unless the sequencer is up and past its grace period. No-op while no feed is set.
function checkSequencerUptime() internal view;getSequencerConfig
Returns the sequencer-uptime configuration.
function getSequencerConfig() internal view returns (address sequencerFeed, uint48 gracePeriod);Returns
| Name | Type | Description |
|---|---|---|
| sequencerFeed | address | |
| gracePeriod | uint48 |
getGuardedFeed
Returns the guard configuration of key.
function getGuardedFeed(bytes32 key) internal view returns (address oracle, int256 minAnswer, int256 maxAnswer);Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 |
Returns
| Name | Type | Description |
|---|---|---|
| oracle | address | |
| minAnswer | int256 | |
| maxAnswer | int256 |
setSequencerConfig
Sets the sequencer-uptime feed and grace period. address(0) disables the check.
Caller must hold DEFAULT_ADMIN_ROLE. A non-zero feed requires a non-zero grace period.
function setSequencerConfig(address sequencerFeed, uint48 gracePeriod) internal;Parameters
| Name | Type | Description |
|---|---|---|
| sequencerFeed | address | |
| gracePeriod | uint48 |
setGuardedFeed
Configures the oracle and WAD bounds of key.
Caller must hold DEFAULT_ADMIN_ROLE. Requires a non-zero oracle and 0 <= minAnswer <= maxAnswer.
function setGuardedFeed(bytes32 key, address oracle, int256 minAnswer, int256 maxAnswer) internal;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 | |
| oracle | address | |
| minAnswer | int256 | |
| maxAnswer | int256 |
removeGuardedFeed
Removes the guard configuration of key.
Caller must hold DEFAULT_ADMIN_ROLE.
function removeGuardedFeed(bytes32 key) internal;Parameters
| Name | Type | Description |
|---|---|---|
| key | bytes32 |