OracleRegistry

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

State Variables

ORACLE_UPDATE_DELAY

Mandatory delay (seconds) before a scheduled oracle can be committed

uint256 public immutable ORACLE_UPDATE_DELAY;

_oracles

Registry mapping: base → quote → oracle data

mapping(address base => mapping(address quote => OracleData oracleData)) internal _oracles;

oracleOverrides

Per‑vault oracle overrides: user → base → quote → oracle

mapping(address user => mapping(address base => mapping(address quote => IOracle))) public oracleOverrides;

Functions

requiresUserAuth

modifier requiresUserAuth(address user);

constructor

constructor(address initialOwner, Authority initialAuthority, uint256 oracleUpdateDelay)
    Auth2Step(initialOwner, initialAuthority);

addOracle

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

Name
Type
Description

base

address

Base asset address

quote

address

Quote asset address

oracle

IOracle

Oracle to add

scheduleOracleUpdate

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

Name
Type
Description

base

address

Base asset address

quote

address

Quote asset address

oracle

IOracle

Oracle to schedule

commitOracleUpdate

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

Name
Type
Description

base

address

Base asset address

quote

address

Quote asset address

cancelScheduledOracleUpdate

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

Name
Type
Description

base

address

Base asset address

quote

address

Quote asset address

disableOracle

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

Name
Type
Description

base

address

Base asset address

quote

address

Quote asset address

oracle

IOracle

Oracle that is to be disabled

acceptPendingOracle

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

Name
Type
Description

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

removeOracleOverride

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

Name
Type
Description

base

address

Base asset address

quote

address

Quote asset address

user

address

The vault address removing the override

getQuote

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

Name
Type
Description

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

Name
Type
Description

<none>

uint256

quoteAmount The value of baseAmount of base in quote terms

getQuoteForUser

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

Name
Type
Description

baseAmount

uint256

Amount of base asset

base

address

Base asset address

quote

address

Quote asset address

user

address

Vault address

Returns

Name
Type
Description

<none>

uint256

value of the base asset in terms of the quote asset

getOracleData

Return oracle metadata for base/quote

function getOracleData(address base, address quote) external view virtual returns (OracleData memory);

Parameters

Name
Type
Description

base

address

Base asset address

quote

address

Quote asset address

Returns

Name
Type
Description

<none>

OracleData

data Oracle data

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId) public view override returns (bool);

_getOracleForVault

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

Name
Type
Description

user

address

The user address to get the oracle for

base

address

The base token address

quote

address

The quote token address

Returns

Name
Type
Description

<none>

IOracle

The oracle instance for the given pair

_validateOracle

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

Name
Type
Description

oracle

IOracle

The oracle to validate

base

address

The base token address

quote

address

The quote token address

_getDecimals

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

Name
Type
Description

asset

address

The asset address to get decimals for

Returns

Name
Type
Description

<none>

uint8

The decimals of the asset

Last updated