WstEthOracleMiddlewareWithPyth

Git Source

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

NameTypeDescription
pythContractaddressThe address of the Pyth contract.
pythPriceIDbytes32The ID of the ETH Pyth price feed.
chainlinkPriceFeedaddressThe address of the ETH Chainlink price feed.
wstETHaddressThe address of the wstETH contract.
chainlinkTimeElapsedLimituint256The 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

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
<none>PriceInforesult_ The price and timestamp as PriceInfo.