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

Read Latest Price

Reading the latest price from IFÁ Labs is a simple onchain view call using the getAssetInfo function. This returns the current price, scaling factor, and timestamp directly from the oracle contract.

Basic Example

import "ifapricefeed-interface/IIfaPriceFeed.sol";

contract MyProtocol {
    IIfaPriceFeed public constant oracle = IIfaPriceFeed(0xA9F17344689C2c2328F94464998db1d3e35B80dC); // Base Mainnet

    function getLatestUSDTPrice() external view returns (int256 price, int8 decimal, uint256 timestamp) {
        bytes32 assetId = 0x6ca0cef6107263f3b09a51448617b659278cff744f0e702c24a2f88c91e65a0d; // USDT/USD
        
        (IIfaPriceFeed.PriceFeed memory info, bool exists) = oracle.getAssetInfo(assetId);
        
        require(exists, "Asset not supported");
        
        return (info.price, info.decimal, info.lastUpdateTime);
    }
}

Interpreting the Returned Data

  • price (int256): The raw scaled price value.

  • decimal (int8): Negative exponent for scaling (typically -18 for stablecoins).

  • lastUpdateTime (uint256): Unix timestamp of the latest update.

Convert to Human-Readable:

For a $1.00 stablecoin with decimal = -18, expect price ≈ 1e18.

Batch Reading Multiple Prices

If your protocol needs several feeds, use the batch variant (available on supported deployments):

This saves gas compared to individual calls.

Always combine price reads with verification checks (staleness, reasonableness) in production.

Next: Learn how to Handle Stale Data effectively.

Last updated

Was this helpful?