
Handle Stale Data
Why Stale Data Matters
Implementing a Staleness Check
uint256 public constant MAX_PRICE_AGE = 3600; // 1 hour — adjust per asset risk
function _getFreshPrice(bytes32 assetId) internal view returns (int256 price, int8 decimal) {
(IIfaPriceFeed.PriceFeed memory info, bool exists) = oracle.getAssetInfo(assetId);
require(exists, "Asset not supported");
require(block.timestamp - info.lastUpdateTime <= MAX_PRICE_AGE, "Oracle price stale");
return (info.price, info.decimal);
}Combining with Deviation Checks (Circuit Breaker)
Best Practices
Last updated
Was this helpful?

