IBaseOracleMiddleware

Git Source

This interface exposes the only functions used or required by the USDN Protocol.

Any current or future implementation of the oracle middleware must be compatible with this interface without any modification.

Functions

parseAndValidatePrice

Parse and validate data and returns the corresponding price data.

The data format is specific to the middleware and is simply forwarded from the user transaction's calldata. A fee amounting to exactly validationCost (with the same data and action) must be sent or the transaction will revert.

function parseAndValidatePrice(
    bytes32 actionId,
    uint128 targetTimestamp,
    Types.ProtocolAction action,
    bytes calldata data
) external payable returns (PriceInfo memory result_);

Parameters

NameTypeDescription
actionIdbytes32A unique identifier for the current action. This identifier can be used to link an Initiate call with the corresponding Validate call.
targetTimestampuint128The target timestamp for validating the price data. For validation actions, this is the timestamp of the initiation.
actionTypes.ProtocolActionType of action for which the price is requested. The middleware may use this to alter the validation of the price or the returned price.
databytesThe data to be used to communicate with oracles, the format varies from middleware to middleware and can be different depending on the action.

Returns

NameTypeDescription
result_PriceInfoThe price and timestamp as PriceInfo.

getValidationDelay

Gets the required delay (in seconds) between the moment an action is initiated and the timestamp of the price data used to validate that action.

function getValidationDelay() external view returns (uint256 delay_);

Returns

NameTypeDescription
delay_uint256The validation delay.

getLowLatencyDelay

Gets The maximum amount of time (in seconds) after initiation during which a low-latency price oracle can be used for validation.

function getLowLatencyDelay() external view returns (uint16 delay_);

Returns

NameTypeDescription
delay_uint16The maximum delay for low-latency validation.

getDecimals

Gets the number of decimals for the price.

function getDecimals() external view returns (uint8 decimals_);

Returns

NameTypeDescription
decimals_uint8The number of decimals.

validationCost

Returns the cost of one price validation for the given action (in native token).

function validationCost(bytes calldata data, Types.ProtocolAction action) external view returns (uint256 cost_);

Parameters

NameTypeDescription
databytesPrice data for which to get the fee.
actionTypes.ProtocolActionType of the action for which the price is requested.

Returns

NameTypeDescription
cost_uint256The cost of one price validation (in native token).