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

Verify Price Integrity

While IFÁ Labs employs robust aggregation and security measures, no oracle is infallible. Responsible protocols always verify price data onchain before using it in critical logic (e.g., liquidations, minting, or trades).

This page covers essential checks and best practices to ensure the prices you read are fresh, valid, and reasonable.

1. Check for Asset Existence

Always confirm the asset is supported to avoid default/zero values.

(IIfaPriceFeed.PriceFeed memory info, bool exists) = feed.getAssetInfo(assetId);
require(exists, "Asset not supported by IFÁ Labs");

2. Enforce Freshness (Staleness Check)

Prices should be recent. Reject data that's too old.

uint256 MAX_STALENESS = 3600; // 1 hour — adjust based on your risk tolerance

require(info.lastUpdateTime >= block.timestamp - MAX_STALENESS, "Price is stale");

For stablecoins, you can often tolerate longer windows (e.g., 2–4 hours), but tighter thresholds reduce risk during market stress.

3. Validate Reasonableness (Circuit Breaker)

Protect against extreme deviations that could indicate manipulation or source failure.

// 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");

For non-USD pairs or volatile assets, use historical averages or multi-oracle comparisons.

4. Full Verification Example

Additional Recommendations

  • Monitor Onchain Events: Listen for price update events (if emitted) to track update frequency.

  • Multi-Oracle Fallback: In high-value protocols, combine IFÁ Labs with another oracle and use median or consensus logic.

  • Graceful Degradation: Pause critical functions if checks fail, rather than proceeding with bad data.

By implementing these simple checks, you significantly reduce risks from oracle delays, source issues, or attacks.

Next: Explore the EVM Smart Contracts Integration Guides for deeper implementation details.

Last updated

Was this helpful?