circle-info
This is the first version of our Documentation, it will be improved and extended soon.
Page cover

Building Fallback Strategies

While IFÁ Labs provides high-quality, specialized stablecoin price feeds, no single oracle is immune to rare delays, source issues, or chain-specific problems. Production-grade protocols should implement fallback strategies to maintain safety and availability during edge cases.

Why Fallbacks Matter

  • Resilience: Continue operations if one oracle is stale or deviates.

  • Risk Reduction: Avoid liquidations or borrowings based on bad data.

  • Best Practice: Leading DeFi protocols (e.g., Aave, Compound) use multi-oracle setups.

1. Multi-Oracle Consensus (Primary Recommendation)

Combine IFÁ Labs with a general-purpose oracle (e.g., Chainlink, Pyth) and take:

  • Median of available prices.

  • Average within bounds.

  • Primary/Secondary logic (prefer IFÁ for stablecoins, fallback to other).

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
}

2. Stale Price Fallback

Cache the last known good price with a longer tolerance:

3. Circuit Breaker + Pause

Automatically pause critical actions (e.g., borrowing, liquidations) if:

  • Primary oracle stale > threshold.

  • Deviation between oracles > X%.

4. Hybrid Onchain Monitoring

Use events or external keepers (e.g., Chainlink Automation, Gelato) to trigger fallbacks or alerts.

Example: Median of Three

For maximum robustness:

Key Tips

  • Prioritize IFÁ for stablecoins: Better coverage and tuning for your core assets.

  • Test extensively: Simulate stale scenarios on testnets.

  • Monitor actively: Use tools from the previous section.

By layering IFÁ Labs with thoughtful fallbacks, you build protocols that are secure, resilient, and ready for any condition.

Next: Cross-Chain Price Consistency, ensuring reliable pricing as IFÁ expands.

Last updated

Was this helpful?