@@ -16,7 +16,10 @@ abstract contract ChainlinkDataStreamsOracle is IOracleMiddlewareErrors, IChainl
16
16
/// @notice The address of the Chainlink proxy verifier contract.
17
17
IVerifierProxy internal immutable PROXY_VERIFIER;
18
18
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
+ */
20
23
bytes32 internal immutable STREAM_ID;
21
24
22
25
/// @notice The report version.
@@ -61,7 +64,7 @@ abstract contract ChainlinkDataStreamsOracle is IOracleMiddlewareErrors, IChainl
61
64
* If zero, then we accept all recent prices.
62
65
* @param targetLimit The most recent timestamp a price can have.
63
66
* Can be zero if `targetTimestamp` is zero.
64
- * @return formattedPrice_ The Chainlink formatted price.
67
+ * @return formattedPrice_ The Chainlink formatted price with 18 decimals .
65
68
*/
66
69
function _getChainlinkDataStreamPrice (bytes calldata payload , uint128 targetTimestamp , uint128 targetLimit )
67
70
internal
@@ -97,9 +100,17 @@ abstract contract ChainlinkDataStreamsOracle is IOracleMiddlewareErrors, IChainl
97
100
98
101
// Report timestamp
99
102
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.
100
107
if (verifiedReport.validFromTimestamp < block .timestamp - _dataStreamsRecentPriceDelay) {
101
108
revert OracleMiddlewareDataStreamInvalidTimestamp ();
102
109
}
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`.
103
114
} else if (
104
115
targetTimestamp < verifiedReport.validFromTimestamp
105
116
|| verifiedReport.observationsTimestamp < targetTimestamp
0 commit comments