OracleRegistry
Last updated
Last updated
Inherits: IOracleRegistry, Auth2Step, ERC165
Canonical registry for ERC-7726-compatible price oracles Registry itself conforms to ERC-7726 (exposes getQuote
) Owner seeds initial oracles on deploy; every subsequent oracle must be scheduled, then committed ≥ ORACLE_UPDATE_DELAY
seconds later. A user (or its owner) may temporarily override with the pending oracle until the commit executes, enabling instant adoption if desired. Owner may disable any active oracle; getQuote
then reverts unless a user override is in place
Mandatory delay (seconds) before a scheduled oracle can be committed
uint256 public immutable ORACLE_UPDATE_DELAY;
Registry mapping: base → quote → oracle data
mapping(address base => mapping(address quote => OracleData oracleData)) internal _oracles;
Per‑vault oracle overrides: user → base → quote → oracle
mapping(address user => mapping(address base => mapping(address quote => IOracle))) public oracleOverrides;
modifier requiresUserAuth(address user);
constructor(address initialOwner, Authority initialAuthority, uint256 oracleUpdateDelay)
Auth2Step(initialOwner, initialAuthority);
Adds an oracle for the provided base and quote assets
MUST REVERT if not called by the authorized address
function addOracle(address base, address quote, IOracle oracle) external requiresAuth;
Parameters
base
address
Base asset address
quote
address
Quote asset address
oracle
IOracle
Oracle to add
Schedules an oracle update for the base/quote asset pair The update process is a two-step process: first, the new oracle data is set using this function; second, the update is committed using the commitOracleUpdate function
MUST REVERT if not called by the authorized address
function scheduleOracleUpdate(address base, address quote, IOracle oracle) external requiresAuth;
Parameters
base
address
Base asset address
quote
address
Quote asset address
oracle
IOracle
Oracle to schedule
Commits the oracle update for the base/quote asset pair Can be called by anyone after the update process is initiated using scheduleOracleUpdate
and the update delay has passed
MUST REVERT if the update is not initiated
function commitOracleUpdate(address base, address quote) external;
Parameters
base
address
Base asset address
quote
address
Quote asset address
Cancels the scheduled update for the base/quote asset pair
MUST REVERT if not called by the authorized address
function cancelScheduledOracleUpdate(address base, address quote) external requiresAuth;
Parameters
base
address
Base asset address
quote
address
Quote asset address
Disables the oracle for the base/quote asset pair
Performs a soft delete to forbid calling addOracle
with the same base and quote assets and avoid front-running attack
function disableOracle(address base, address quote, IOracle oracle) external requiresAuth;
Parameters
base
address
Base asset address
quote
address
Quote asset address
oracle
IOracle
Oracle that is to be disabled
Allows a user to accept the pending oracle for a given base/quote pair during the delay period Can be called by the user to use the new oracle early
MUST REVERT if the caller is not the user or its owner
function acceptPendingOracle(address base, address quote, address user, IOracle oracle)
external
requiresUserAuth(user);
Parameters
base
address
Base asset address
quote
address
Quote asset address
user
address
Vault that is accepting the pending oracle
oracle
IOracle
Oracle that is to be accepted
Allows a user to remove the oracle override for a given base/quote pair
MUST REVERT if the caller is not the user or its owner
function removeOracleOverride(address base, address quote, address user) external requiresUserAuth(user);
Parameters
base
address
Base asset address
quote
address
Quote asset address
user
address
The vault address removing the override
Returns the value of baseAmount
of base
in quote
terms
MUST round down towards 0 MUST revert with OracleUnsupportedPair
if not capable to provide data for the specified base
and quote
pair MUST revert with OracleUntrustedData
if not capable to provide data within a degree of confidence publicly specified
function getQuote(uint256 baseAmount, address base, address quote) external view virtual returns (uint256);
Parameters
baseAmount
uint256
The amount of base
to convert
base
address
The asset that the user needs to know the value for
quote
address
The asset in which the user needs to value the base
Returns
<none>
uint256
quoteAmount The value of baseAmount
of base
in quote
terms
Returns the value of the base asset in terms of the quote asset with using the provided oracle data for the provided user (respects user-specific overrides)
function getQuoteForUser(uint256 baseAmount, address base, address quote, address user)
external
view
virtual
returns (uint256);
Parameters
baseAmount
uint256
Amount of base asset
base
address
Base asset address
quote
address
Quote asset address
user
address
Vault address
Returns
<none>
uint256
value of the base asset in terms of the quote asset
Return oracle metadata for base/quote
function getOracleData(address base, address quote) external view virtual returns (OracleData memory);
Parameters
base
address
Base asset address
quote
address
Quote asset address
Returns
<none>
OracleData
data Oracle data
See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId) public view override returns (bool);
Get the oracle for a user
Returns the current oracle if active or deprecated with no override reverts if the oracle is disabled and no override is set
function _getOracleForVault(address user, address base, address quote) internal view returns (IOracle);
Parameters
user
address
The user address to get the oracle for
base
address
The base token address
quote
address
The quote token address
Returns
<none>
IOracle
The oracle instance for the given pair
Validate that an oracle can convert one base token to a non‑zero quote token
Implicitly checks zero address because the getQuote call reverts
function _validateOracle(IOracle oracle, address base, address quote) internal view;
Parameters
oracle
IOracle
The oracle to validate
base
address
The base token address
quote
address
The quote token address
Determine the decimals of an asset
Defaults to 18 if the asset is not an ERC20
function _getDecimals(address asset) internal view returns (uint8);
Parameters
asset
address
The asset address to get decimals for
Returns
<none>
uint8
The decimals of the asset