Skip to content

Commit 0db0d10

Browse files
committed
fix: add future price check in pyth price feed latestRoundData
1 parent 8f8b710 commit 0db0d10

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

contracts/oracles/updatable/PythPriceFeed.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ interface IPythPriceFeedExceptions {
3232

3333
/// @notice Thrown when the decimals returned by Pyth are outside sane boundaries
3434
error IncorrectPriceDecimals();
35+
36+
/// @notice Thrown when a retrieved price's publish time is too far ahead in the future
37+
error PriceTimestampTooFarAhead();
3538
}
3639

3740
/// @title Pyth price feed
@@ -67,6 +70,12 @@ contract PythPriceFeed is IUpdatablePriceFeed, IPythPriceFeedExceptions {
6770
function latestRoundData() external view override returns (uint80, int256, uint256, uint256, uint80) {
6871
PythStructs.Price memory priceData = IPyth(pyth).getPriceUnsafe(priceFeedId);
6972

73+
if ((block.timestamp < priceData.publishTime)) {
74+
if ((priceData.publishTime - block.timestamp) > MAX_DATA_TIMESTAMP_AHEAD_SECONDS) {
75+
revert PriceTimestampTooFarAhead();
76+
}
77+
}
78+
7079
int256 price = _getDecimalAdjustedPrice(priceData);
7180

7281
return (0, price, 0, priceData.publishTime, 0);

0 commit comments

Comments
 (0)