
Verify Price Integrity
1. Check for Asset Existence
(IIfaPriceFeed.PriceFeed memory info, bool exists) = feed.getAssetInfo(assetId);
require(exists, "Asset not supported by IFÁ Labs");2. Enforce Freshness (Staleness Check)
uint256 MAX_STALENESS = 3600; // 1 hour — adjust based on your risk tolerance
require(info.lastUpdateTime >= block.timestamp - MAX_STALENESS, "Price is stale");3. Validate Reasonableness (Circuit Breaker)
// Example: Require price within ±5% of expected peg (1.00 USD)
int256 EXPECTED_PRICE = 1e18; // Assuming decimal = -18
uint256 MAX_DEVIATION = 500; // 5% in basis points (0.05 * 10000)
uint256 deviation = uint256(EXPECTED_PRICE > info.price ? EXPECTED_PRICE - info.price : info.price - EXPECTED_PRICE);
require(deviation <= EXPECTED_PRICE * MAX_DEVIATION / 10000, "Price deviation too high");4. Full Verification Example
Additional Recommendations
Last updated
Was this helpful?

