Skip to main content

IPriceConfigv2

Git Source

forge-lint: disable-start(mixed-case-function)

Interface for PriceConfigv2 policy

Policy to configure PRICEv2

Functions​

queueTimelockDelay​

Queue a timelocked change to the timelock delay

The delay update is not applied until the queued action is executed. Intended to be callable only by admin.

function queueTimelockDelay(uint48 delay_) external returns (uint64 actionId_);

Parameters

NameTypeDescription
delay_uint48The new timelock delay in seconds

Returns

NameTypeDescription
actionId_uint64The queued action ID

addAsset​

Configure a new asset on the PRICE module

See PRICEv2 for more details on caching behavior when no moving average is stored and component interface

function addAsset(
address asset_,
bool storeMovingAverage_,
bool useMovingAverage_,
uint32 movingAverageDuration_,
uint48 lastObservationTime_,
uint256[] memory observations_,
IPRICEv2.Component memory strategy_,
IPRICEv2.Component[] memory feeds_,
PriceFeedExpectation[] memory feedExpectations_
) external;

Parameters

NameTypeDescription
asset_addressThe address of the asset to add
storeMovingAverage_boolWhether to store the moving average for this asset
useMovingAverage_boolWhether to use the moving average as part of the price resolution strategy for this asset
movingAverageDuration_uint32The duration of the moving average in seconds, only used if storeMovingAverage_ is true
lastObservationTime_uint48The timestamp of the last observation
observations_uint256[]The array of observations to add - the number of observations must match the moving average duration divided by the PRICEv2 observation frequency
strategy_IPRICEv2.ComponentThe price resolution strategy to use for this asset
feeds_IPRICEv2.Component[]The array of price feeds to use for this asset
feedExpectations_PriceFeedExpectation[]Expected price and tolerance for each feed, aligned by index with feeds_

registerNonContractAsset​

Register a non-contract asset for management by the PRICE module

After registration, the address can be used as a non-contract asset identifier in PRICE

function registerNonContractAsset(address asset_) external;

Parameters

NameTypeDescription
asset_addressThe non-contract asset address to register

unregisterNonContractAsset​

Deregister a non-contract asset from management by the PRICE module

This reverts if the asset is reserved or still configured on PRICE

function unregisterNonContractAsset(address asset_) external;

Parameters

NameTypeDescription
asset_addressThe non-contract asset address to deregister

queueRemoveAsset​

Queue removal of an asset from the PRICE module

After execution, calls to PRICEv2 for the asset's price will revert.

function queueRemoveAsset(address asset_) external returns (uint64 actionId_);

Parameters

NameTypeDescription
asset_addressThe address of the asset to remove

Returns

NameTypeDescription
actionId_uint64The queued action ID

queueUpdateAsset​

Queue an atomic asset configuration update

Only updates components flagged in params_ after the queued action is executed.

See PRICEv2 for more details on the UpdateAssetParams struct

function queueUpdateAsset(
address asset_,
IPRICEv2.UpdateAssetParams memory params_,
PriceFeedExpectation[] memory feedExpectations_
) external returns (uint64 actionId_);

Parameters

NameTypeDescription
asset_addressThe address of the asset to update
params_IPRICEv2.UpdateAssetParamsUpdate parameters with flags indicating which components to update
feedExpectations_PriceFeedExpectation[]Expected price and tolerance for each feed when params_.updateFeeds is true. Must be empty otherwise.

Returns

NameTypeDescription
actionId_uint64The queued action ID

storeObservation​

Store a price observation for an asset

Calls PRICE.storeObservation(asset_) to calculate and store current price

function storeObservation(address asset_) external;

Parameters

NameTypeDescription
asset_addressThe address of asset

storeObservations​

Store the current price of all assets that track a moving average

Calls PRICE.storeObservations() to calculate and store observations

function storeObservations() external;

installSubmodule​

Install a new submodule on the designated module

function installSubmodule(address submodule_) external;

Parameters

NameTypeDescription
submodule_addressThe address of the submodule to install

queueUpgradeSubmodule​

Queue an upgrade of a submodule on the PRICE module

The upgraded submodule must have the same keycode as an existing submodule that it is replacing, otherwise use installSubmodule.

function queueUpgradeSubmodule(address submodule_) external returns (uint64 actionId_);

Parameters

NameTypeDescription
submodule_addressThe address of the submodule to upgrade to

Returns

NameTypeDescription
actionId_uint64The queued action ID

queueExecOnSubmodule​

Queue an action on a PRICE submodule

The action is not performed until the queued action is executed. This is timelocked because PRICE.execOnSubmodule() can call mutable submodule functions.

This function reverts if:

  • The submodule is not installed
function queueExecOnSubmodule(bytes20 subKeycode_, bytes calldata data_) external returns (uint64 actionId_);

Parameters

NameTypeDescription
subKeycode_bytes20The bytes20 keycode of the submodule to call
data_bytesThe calldata to send to the submodule

Returns

NameTypeDescription
actionId_uint64The queued action ID

Errors​

IPriceConfigv2_UnsupportedModuleInterface​

Thrown when module does not support interface

error IPriceConfigv2_UnsupportedModuleInterface(bytes5 keycode, bytes4 interfaceId);

Parameters

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

IPriceConfigv2_UnsupportedModuleVersion​

Thrown when module version is not supported

error IPriceConfigv2_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

IPriceConfigv2_FeedExpectationCountInvalid​

Thrown when the number of feed expectations does not match the number of feeds

error IPriceConfigv2_FeedExpectationCountInvalid(address asset_, uint256 expectationCount_, uint256 feedCount_);

Parameters

NameTypeDescription
asset_addressThe address of the asset being configured
expectationCount_uint256The number of expectations provided
feedCount_uint256The number of feeds expected

IPriceConfigv2_FeedExpectationInvalid​

Thrown when a feed expectation is invalid

error IPriceConfigv2_FeedExpectationInvalid(address asset_, uint256 index_);

Parameters

NameTypeDescription
asset_addressThe address of the asset being configured
index_uint256The index of the invalid expectation

IPriceConfigv2_PriceFeedCallFailed​

Thrown when a feed cannot be queried for expectation validation

error IPriceConfigv2_PriceFeedCallFailed(address asset_, uint256 index_);

Parameters

NameTypeDescription
asset_addressThe address of the asset being configured
index_uint256The index of the feed that failed

IPriceConfigv2_PriceFeedOutOfBounds​

Thrown when a feed price is outside the configured expectation range

error IPriceConfigv2_PriceFeedOutOfBounds(
address asset_, uint256 index_, uint256 price_, uint256 lowerBound_, uint256 upperBound_
);

Parameters

NameTypeDescription
asset_addressThe address of the asset being configured
index_uint256The index of the feed that returned an out-of-bounds price
price_uint256The price returned by the feed
lowerBound_uint256The minimum accepted price
upperBound_uint256The maximum accepted price

IPriceConfigv2_SubmoduleImplementationChanged​

Thrown when a queued submodule action targets a submodule implementation that has changed since queueing

error IPriceConfigv2_SubmoduleImplementationChanged(bytes20 subKeycode, address expected, address actual);

Parameters

NameTypeDescription
subKeycodebytes20The bytes20 keycode of the queued submodule action
expectedaddressThe submodule implementation installed when the action was queued
actualaddressThe submodule implementation installed when the action was executed

Structs​

PriceFeedExpectation​

Expected price and tolerance for a configured feed

Used as a configuration-time plausibility check only. This does not prove feed identity; a different asset with a similar price can still pass within tolerance.

struct PriceFeedExpectation {
uint256 expectedPrice;
uint16 toleranceBps;
}

Properties

NameTypeDescription
expectedPriceuint256Expected feed price in PRICE output decimals
toleranceBpsuint16Allowed deviation from expected price, in basis points