WstEthOracleMiddlewareWithDataStreams
Inherits: OracleMiddlewareWithDataStreams
This contract is used to get the price of wstETH from the ETH price or the wstETH price directly.
State Variables
_wstETH
The wstETH contract.
IWstETH internal immutable _wstETH;
Functions
constructor
constructor(
address pythContract,
bytes32 pythFeedId,
address chainlinkPriceFeed,
address wstETH,
uint256 chainlinkTimeElapsedLimit,
address chainlinkProxyVerifierAddress,
bytes32 chainlinkStreamId
)
OracleMiddlewareWithDataStreams(
pythContract,
pythFeedId,
chainlinkPriceFeed,
chainlinkTimeElapsedLimit,
chainlinkProxyVerifierAddress,
chainlinkStreamId
);
Parameters
Name | Type | Description |
---|---|---|
pythContract | address | The address of the Pyth contract. |
pythFeedId | bytes32 | The ETH/USD Pyth price feed ID for the asset. |
chainlinkPriceFeed | address | The address of the Chainlink ETH/USD price feed. |
wstETH | address | The address of the wstETH contract. |
chainlinkTimeElapsedLimit | uint256 | The duration after which a Chainlink price is considered stale. |
chainlinkProxyVerifierAddress | address | The address of the Chainlink proxy verifier contract. |
chainlinkStreamId | bytes32 | The supported Chainlink wstETH/USD data stream ID. |
parseAndValidatePrice
Parses and validates data
, returns the corresponding price data,
applying ETH/wstETH ratio if the price is in ETH.
The data format is specific to the middleware and is simply forwarded from the user transaction's calldata.
If needed, the wstETH price is calculated as follows: ethPrice x stEthPerToken / 1 ether
.
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
) public payable virtual override(IBaseOracleMiddleware, CommonOracleMiddleware) returns (PriceInfo memory);
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 |
---|---|---|
<none> | PriceInfo | result_ The price and timestamp as PriceInfo. |