@@ -7,19 +7,19 @@ import { IUsdnProtocolTypes as Types } from "../interfaces/UsdnProtocol/IUsdnPro
77import { OracleMiddleware } from "./OracleMiddleware.sol " ;
88
99/**
10- * @title Contract to apply and return wsteth price
11- * @notice This contract is used to get the price of wsteth from the eth price oracle
10+ * @title Middleware Implementation For WstETH Price
11+ * @notice This contract is used to get the price of wstETH from the eth price oracle.
1212 */
1313contract WstEthOracleMiddleware is OracleMiddleware {
14- /// @notice wsteth instance
14+ /// @notice The wstETH contract.
1515 IWstETH internal immutable _wstEth;
1616
1717 /**
18- * @param pythContract The address of the Pyth contract
19- * @param pythPriceID The ID of the Pyth price feed
20- * @param chainlinkPriceFeed The address of the Chainlink price feed
21- * @param wstETH The address of the wstETH contract
22- * @param chainlinkTimeElapsedLimit The duration after which a Chainlink price is considered stale
18+ * @param pythContract The address of the Pyth contract.
19+ * @param pythPriceID The ID of the ETH Pyth price feed.
20+ * @param chainlinkPriceFeed The address of the ETH Chainlink price feed.
21+ * @param wstETH The address of the wstETH contract.
22+ * @param chainlinkTimeElapsedLimit The duration after which a Chainlink price is considered stale.
2323 */
2424 constructor (
2525 address pythContract ,
@@ -33,23 +33,30 @@ contract WstEthOracleMiddleware is OracleMiddleware {
3333
3434 /**
3535 * @inheritdoc OracleMiddleware
36- * @notice Parses and validates price data by applying eth/wsteth ratio
37- * @dev The data format is specific to the middleware and is simply forwarded from the user transaction's calldata
38- * Wsteth price is calculated as follows: ethPrice x stEthPerToken / 1 ether
36+ * @notice Parses and validates `data`, returns the corresponding price data by applying eth/wstETH ratio.
37+ * @dev The data format is specific to the middleware and is simply forwarded from the user transaction's calldata.
38+ * Wsteth price is calculated as follows: `ethPrice x stEthPerToken / 1 ether`.
39+ * A fee amounting to exactly {validationCost} (with the same `data` and `action`) must be sent or the transaction
40+ * will revert.
41+ * @param actionId A unique identifier for the current action. This identifier can be used to link an `Initiate`
42+ * call with the corresponding `Validate` call.
43+ * @param targetTimestamp The target timestamp for validating the price data. For validation actions, this is the
44+ * timestamp of the initiation.
45+ * @param action Type of action for which the price is requested. The middleware may use this to alter the
46+ * validation of the price or the returned price.
47+ * @param data The data to be used to communicate with oracles, the format varies from middleware to middleware and
48+ * can be different depending on the action.
49+ * @return result_ The price and timestamp as {IOracleMiddlewareTypes.PriceInfo}.
3950 */
4051 function parseAndValidatePrice (
4152 bytes32 actionId ,
4253 uint128 targetTimestamp ,
4354 Types.ProtocolAction action ,
4455 bytes calldata data
4556 ) public payable virtual override returns (PriceInfo memory ) {
46- // fetched eth price
4757 PriceInfo memory ethPrice = super .parseAndValidatePrice (actionId, targetTimestamp, action, data);
48-
49- // stEth ratio for one wstEth
5058 uint256 stEthPerToken = _wstEth.stEthPerToken ();
5159
52- // wsteth price
5360 return PriceInfo ({
5461 price: ethPrice.price * stEthPerToken / 1 ether,
5562 neutralPrice: ethPrice.neutralPrice * stEthPerToken / 1 ether,
0 commit comments