Skip to main content

IERC7726OracleFactory

Git Source

Title: IERC7726OracleFactory

Author: OlympusDAO

Interface for deploying and managing ERC7726 clone oracles parameterized by maxAge

Functions​

createOracle​

Creates a new oracle for a specific maxAge

function createOracle(uint48 maxAge_, bytes calldata customParams_) external returns (address oracle);

Parameters

NameTypeDescription
maxAge_uint48The maximum age (in seconds) of cached prices used by the oracle
customParams_bytesOptional params for factory-specific customization

Returns

NameTypeDescription
oracleaddressThe address of the created oracle

getOracle​

Gets the oracle address for a maxAge

function getOracle(uint48 maxAge_) external view returns (address oracle);

Parameters

NameTypeDescription
maxAge_uint48The maximum age used by the oracle

Returns

NameTypeDescription
oracleaddressThe oracle address, or address(0) if not found

getOracles​

Gets all deployed oracle addresses

function getOracles() external view returns (address[] memory oracles);

Returns

NameTypeDescription
oraclesaddress[]Array of all oracle addresses

getPriceCache​

Gets the configured price cache policy

function getPriceCache() external view returns (address policy);

Returns

NameTypeDescription
policyaddressThe price cache policy address

enableOracle​

Enables a specific oracle

function enableOracle(address oracle_) external;

Parameters

NameTypeDescription
oracle_addressThe oracle address to enable

disableOracle​

Disables a specific oracle

function disableOracle(address oracle_) external;

Parameters

NameTypeDescription
oracle_addressThe oracle address to disable

isOracleEnabled​

Checks if a specific oracle is enabled

function isOracleEnabled(address oracle_) external view returns (bool enabled);

Parameters

NameTypeDescription
oracle_addressThe oracle address to check

Returns

NameTypeDescription
enabledboolTrue if the oracle is enabled, false otherwise

getOracleContext​

Checks if a factory-created oracle is enabled and returns the configured price cache

Reverts if:

  • The policy is deactivated in Kernel
  • oracle_ was not created by this factory
function getOracleContext(address oracle_) external view returns (bool enabled, address policy);

Parameters

NameTypeDescription
oracle_addressThe oracle address to check

Returns

NameTypeDescription
enabledboolTrue if the oracle is enabled, false otherwise
policyaddressThe configured price cache policy address

cachePrice​

Cache the direct pair unconditionally for the calling oracle

function cachePrice(address base_, address quote_) external;

Parameters

NameTypeDescription
base_addressThe base asset to cache
quote_addressThe quote asset to cache

cachePriceIfNecessary​

Cache the direct pair only when stale for the calling oracle's configured max age

function cachePriceIfNecessary(address base_, address quote_) external;

Parameters

NameTypeDescription
base_addressThe base asset to conditionally cache
quote_addressThe quote asset to conditionally cache

enableCreation​

Enables oracle creation

function enableCreation() external;

disableCreation​

Disables oracle creation

function disableCreation() external;

setPriceCache​

Sets the configured price cache policy

function setPriceCache(address policy_) external;

Parameters

NameTypeDescription
policy_addressThe price cache policy address

Events​

OracleCreated​

Emitted when a new oracle is created

event OracleCreated(address indexed oracle, uint48 indexed maxAge);

Parameters

NameTypeDescription
oracleaddressThe created oracle address
maxAgeuint48The max age configured for this oracle

CreationEnabled​

Emitted when oracle creation is enabled

event CreationEnabled();

CreationDisabled​

Emitted when oracle creation is disabled

event CreationDisabled();

OracleEnabled​

Emitted when an oracle is enabled

event OracleEnabled(address indexed oracle);

Parameters

NameTypeDescription
oracleaddressThe enabled oracle address

OracleDisabled​

Emitted when an oracle is disabled

event OracleDisabled(address indexed oracle);

Parameters

NameTypeDescription
oracleaddressThe disabled oracle address

PriceCacheSet​

Emitted when the price cache policy is updated

event PriceCacheSet(address indexed policy);

Parameters

NameTypeDescription
policyaddressThe updated price cache policy address

Errors​

ERC7726OracleFactory_UnsupportedModuleVersion​

Thrown when module version is not supported

error ERC7726OracleFactory_UnsupportedModuleVersion(bytes5 keycode, uint8 major, uint8 minor);

Parameters

NameTypeDescription
keycodebytes5The keycode of the module
majoruint8The major version of the module
minoruint8The minor version of the module

ERC7726OracleFactory_PolicyNotActive​

Thrown when this policy is no longer active in Kernel

error ERC7726OracleFactory_PolicyNotActive();

ERC7726OracleFactory_UnsupportedModuleInterface​

Thrown when module does not support interface

error ERC7726OracleFactory_UnsupportedModuleInterface(bytes5 keycode, bytes4 interfaceId);

Parameters

NameTypeDescription
keycodebytes5The keycode of the module
interfaceIdbytes4The interface identifier, as specified in ERC-165

ERC7726OracleFactory_CreationDisabled​

Thrown when oracle creation is disabled

error ERC7726OracleFactory_CreationDisabled();

ERC7726OracleFactory_OracleAlreadyExists​

Thrown when trying to create an oracle that already exists for maxAge

error ERC7726OracleFactory_OracleAlreadyExists(uint48 maxAge);

Parameters

NameTypeDescription
maxAgeuint48The maxAge that already has an oracle

ERC7726OracleFactory_CreationAlreadyEnabled​

Thrown when creation is already enabled

error ERC7726OracleFactory_CreationAlreadyEnabled();

ERC7726OracleFactory_CreationAlreadyDisabled​

Thrown when creation is already disabled

error ERC7726OracleFactory_CreationAlreadyDisabled();

ERC7726OracleFactory_InvalidOracle​

Thrown when an invalid oracle address is provided

error ERC7726OracleFactory_InvalidOracle(address oracle);

Parameters

NameTypeDescription
oracleaddressThe invalid oracle address

ERC7726OracleFactory_OracleAlreadyEnabled​

Thrown when an oracle is already enabled

error ERC7726OracleFactory_OracleAlreadyEnabled(address oracle);

Parameters

NameTypeDescription
oracleaddressThe already enabled oracle address

ERC7726OracleFactory_OracleAlreadyDisabled​

Thrown when an oracle is already disabled

error ERC7726OracleFactory_OracleAlreadyDisabled(address oracle);

Parameters

NameTypeDescription
oracleaddressThe already disabled oracle address

ERC7726OracleFactory_OracleDisabled​

Thrown when an oracle is disabled and attempts an operation that requires enabled state

error ERC7726OracleFactory_OracleDisabled(address oracle);

Parameters

NameTypeDescription
oracleaddressThe disabled oracle address

ERC7726OracleFactory_InvalidCustomParams​

Thrown when custom params are malformed

error ERC7726OracleFactory_InvalidCustomParams(uint256 length);

Parameters

NameTypeDescription
lengthuint256The custom params length

ERC7726OracleFactory_InvalidPriceCache​

Thrown when a price cache policy address is invalid

error ERC7726OracleFactory_InvalidPriceCache(address policy);

Parameters

NameTypeDescription
policyaddressThe invalid price cache policy address

ERC7726OracleFactory_InvalidEnableData​

Thrown when re-enable pair arrays are malformed

error ERC7726OracleFactory_InvalidEnableData(uint256 baseTokenLength, uint256 quoteTokenLength);

Parameters

NameTypeDescription
baseTokenLengthuint256The number of base tokens
quoteTokenLengthuint256The number of quote tokens