Skip to content

Commit 26e742a

Browse files
authored
docs(middleware): wsteth data streams comments (#900)
* docs: timestamp checks * docs: typo * docs: returned value * docs: timestamp * docs: formatting
1 parent 5b027c2 commit 26e742a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/OracleMiddleware/oracles/ChainlinkDataStreamsOracle.sol

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ abstract contract ChainlinkDataStreamsOracle is IOracleMiddlewareErrors, IChainl
1616
/// @notice The address of the Chainlink proxy verifier contract.
1717
IVerifierProxy internal immutable PROXY_VERIFIER;
1818

19-
/// @notice The ID of the Chainlink data streams.
19+
/**
20+
* @notice The ID of the Chainlink data streams.
21+
* @dev Any data streams are standardized to 18 decimals.
22+
*/
2023
bytes32 internal immutable STREAM_ID;
2124

2225
/// @notice The report version.
@@ -61,7 +64,7 @@ abstract contract ChainlinkDataStreamsOracle is IOracleMiddlewareErrors, IChainl
6164
* If zero, then we accept all recent prices.
6265
* @param targetLimit The most recent timestamp a price can have.
6366
* Can be zero if `targetTimestamp` is zero.
64-
* @return formattedPrice_ The Chainlink formatted price.
67+
* @return formattedPrice_ The Chainlink formatted price with 18 decimals.
6568
*/
6669
function _getChainlinkDataStreamPrice(bytes calldata payload, uint128 targetTimestamp, uint128 targetLimit)
6770
internal
@@ -97,9 +100,17 @@ abstract contract ChainlinkDataStreamsOracle is IOracleMiddlewareErrors, IChainl
97100

98101
// Report timestamp
99102
if (targetTimestamp == 0) {
103+
// If targetTimestamp is 0, we check if the verified report's validFromTimestamp is older or equal than
104+
// the current block timestamp minus the `_dataStreamsRecentPriceDelay`. This check ensures that the price
105+
// data is considered recent enough to be valid for use, while not strictly requiring it to be the current
106+
// timestamp.
100107
if (verifiedReport.validFromTimestamp < block.timestamp - _dataStreamsRecentPriceDelay) {
101108
revert OracleMiddlewareDataStreamInvalidTimestamp();
102109
}
110+
111+
// The report is considered valid if the `targetTimestamp` is within the interval
112+
// `[validFromTimestamp,observationsTimestamp]` and the `observationsTimestamp`
113+
// does not exceed the `targetLimit`.
103114
} else if (
104115
targetTimestamp < verifiedReport.validFromTimestamp
105116
|| verifiedReport.observationsTimestamp < targetTimestamp

0 commit comments

Comments
 (0)