IBaseOracleMiddleware
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
Name | Type | Description |
---|---|---|
actionId | bytes32 | A unique identifier for the current action. This identifier can be used to link an Initiate call with the corresponding Validate call. |
targetTimestamp | uint128 | The target timestamp for validating the price data. For validation actions, this is the timestamp of the initiation. |
action | Types.ProtocolAction | Type of action for which the price is requested. The middleware may use this to alter the validation of the price or the returned price. |
data | bytes | The data to be used to communicate with oracles, the format varies from middleware to middleware and can be different depending on the action. |
Returns
Name | Type | Description |
---|---|---|
result_ | PriceInfo | The 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
Name | Type | Description |
---|---|---|
delay_ | uint256 | The 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
Name | Type | Description |
---|---|---|
delay_ | uint16 | The maximum delay for low-latency validation. |
getDecimals
Gets the number of decimals for the price.
function getDecimals() external view returns (uint8 decimals_);
Returns
Name | Type | Description |
---|---|---|
decimals_ | uint8 | The 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
Name | Type | Description |
---|---|---|
data | bytes | Price data for which to get the fee. |
action | Types.ProtocolAction | Type of the action for which the price is requested. |
Returns
Name | Type | Description |
---|---|---|
cost_ | uint256 | The cost of one price validation (in native token). |