WstEthOracleMiddlewareWithPyth
Inherits: OracleMiddlewareWithPyth
This contract is used to get the price of wstETH from the ETH price oracle.
State Variables
_wstEth
The wstETH contract.
IWstETH internal immutable _wstEth;
Functions
constructor
constructor(
address pythContract,
bytes32 pythPriceID,
address chainlinkPriceFeed,
address wstETH,
uint256 chainlinkTimeElapsedLimit
) OracleMiddlewareWithPyth(pythContract, pythPriceID, chainlinkPriceFeed, chainlinkTimeElapsedLimit);
Parameters
Name | Type | Description |
---|---|---|
pythContract | address | The address of the Pyth contract. |
pythPriceID | bytes32 | The ID of the ETH Pyth price feed. |
chainlinkPriceFeed | address | The address of the ETH Chainlink price feed. |
wstETH | address | The address of the wstETH contract. |
chainlinkTimeElapsedLimit | uint256 | The duration after which a Chainlink price is considered stale. |
parseAndValidatePrice
Parses and validates data
, returns the corresponding price data by applying ETH/wstETH ratio.
The data format is specific to the middleware and is simply forwarded from the user transaction's calldata.
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. |