WstEthOracleMiddlewareWithDataStreams

Git Source

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

NameTypeDescription
pythContractaddressThe address of the Pyth contract.
pythFeedIdbytes32The ETH/USD Pyth price feed ID for the asset.
chainlinkPriceFeedaddressThe address of the Chainlink ETH/USD price feed.
wstETHaddressThe address of the wstETH contract.
chainlinkTimeElapsedLimituint256The duration after which a Chainlink price is considered stale.
chainlinkProxyVerifierAddressaddressThe address of the Chainlink proxy verifier contract.
chainlinkStreamIdbytes32The 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

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.