
Building Fallback Strategies
Why Fallbacks Matter
Recommended Approaches
function getStablePrice(bytes32 assetId) external view returns (int256 price) {
(IIfaPriceFeed.PriceFeed memory ifaInfo, bool ifaExists) = ifaOracle.getAssetInfo(assetId);
(int256 chainlinkPrice, bool chainlinkFresh) = getChainlinkPrice(); // Your integration
if (ifaExists && isFresh(ifaInfo.lastUpdateTime) && isReasonable(ifaInfo.price)) {
return ifaInfo.price; // Prefer IFÁ for stablecoins
}
require(chainlinkFresh && isReasonable(chainlinkPrice), "No valid price");
return chainlinkPrice; // Fallback
}Example: Median of Three
Key Tips
Last updated
Was this helpful?

