Skip to main content
With your contract configured and the interface installed, reading a price is a single view call. This page covers three reading patterns: single asset, batch, and derived pairs. Use whichever fits your protocol’s needs — or combine them.

Single Asset Price

The most common pattern. Call getAssetInfo with a bytes32 asset ID and read the returned PriceFeed struct.
What each field means: Converting to a human-readable price:
For a USDT feed at peg, expect info.price1000000000000000000 (1e18) and info.decimal = -18, giving a human-readable price of $1.00.

Batch Price Read

If your protocol needs multiple prices in the same transaction — for example, valuing a multi-asset collateral basket — use getAssetsInfo. One external call is always cheaper than multiple individual calls.
The exists array is returned in the same order as the input assetIds array. Always check exists[i] before using infos[i] — a false value means that asset has no data and the corresponding PriceFeed fields will be zero.

Derived Pair Prices

Derived pairs let you price one supported asset directly against another — for example, CNGN priced in USDT terms, or BRZ priced in USDC terms — without requiring a dedicated feed for every possible combination. IFÁ Labs computes derived prices on-chain using the two underlying USD feeds as intermediates.

Single Derived Pair

Batch Derived Pairs

For protocols working across multiple cross-asset pairs:

Understanding PairDirection

Derived pairs require both assets to have active, non-stale USD feeds. If either underlying feed is stale or missing, the derived pair calculation will revert. Always ensure both feeds are healthy before calling derived pair functions in critical paths.

Reading Prices Off-Chain

For backend services, scripts, or frontend applications reading prices without executing a transaction:

Common Mistakes

These are the mistakes developers make most often when first reading from the oracle. All of them are avoidable. Not checking exists before using the price. If exists is false, info.price is 0. Using that value without checking will silently execute your logic against a zero price. Forgetting to apply the decimal scaling. info.price is not a dollar amount — it’s a scaled integer. 1000000000000000000 is $1.00, not one quintillion dollars. Always divide by 10^(-decimal) before using the value in human-facing output or fixed-point math. Casting int256 to uint256 without checking sign. Current stablecoin feeds always return positive prices, but the type is int256. Cast safely: only cast after confirming info.price > 0, or use uint256(info.price) with the understanding that negative values would underflow. Using the price without a staleness check. A returned price with exists = true is not automatically fresh. Always pair your read with a lastUpdateTime check before using the value in any logic with financial consequences. See Verify Price Integrity.

Next Steps

Handle Stale Data

Implement staleness guards and graceful degradation patterns.

Gas Optimization Tips

Reduce the gas footprint of your oracle integration.