Skip to content

Commit 4c785dc

Browse files
committed
fix: resolve underflow issue in price validation logic
1 parent b74141f commit 4c785dc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

contracts/contracts/sapphire/CrossChainPaymaster.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ contract CrossChainPaymaster is
390390
// Validate token price
391391
if (tPrice <= 0) revert InvalidPrice(tPrice);
392392
if (tAnsweredIn < tRound) revert StalePrice(0, 0);
393-
if (tUpdated == 0 || block.timestamp - tUpdated > stalenessThreshold) revert StalePrice(tUpdated, stalenessThreshold);
393+
if (tUpdated == 0 || (block.timestamp > tUpdated && block.timestamp - tUpdated > stalenessThreshold)) revert StalePrice(tUpdated, stalenessThreshold);
394394

395395
// Get ROSE/USD price (single aggregated feed from ROFL oracle)
396396
AggregatorV3Interface roseFeed = AggregatorV3Interface(roseUsdFeed);
@@ -399,7 +399,7 @@ contract CrossChainPaymaster is
399399
// Validate ROSE price
400400
if (rPrice <= 0) revert InvalidPrice(rPrice);
401401
if (rAnsweredIn < rRound) revert StalePrice(0, 0);
402-
if (rUpdated == 0 || block.timestamp - rUpdated > stalenessThreshold) revert StalePrice(rUpdated, stalenessThreshold);
402+
if (rUpdated == 0 || (block.timestamp > rUpdated && block.timestamp - rUpdated > stalenessThreshold)) revert StalePrice(rUpdated, stalenessThreshold);
403403

404404
uint8 tokenDec = tokenDecimals[token];
405405
if (tokenDec == 0) tokenDec = 18;

0 commit comments

Comments
 (0)