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

Function Reference

The IFÁ Labs price oracle contract exposes a simple, efficient set of view functions for reading price data onchain. All functions are view (read-only) and can be called without gas from other contracts or offchain.

Core Structs

struct PriceFeed {
    int256 price;          // Scaled price value (positive for valid feeds)
    int8 decimal;          // Negative exponent (typically -18 for stablecoins)
    uint64 lastUpdateTime; // Timestamp of the last update
}

enum PairDirection {
    Forward,
    Backward
}

struct DerivedPair {
    // Details for derived pairs (e.g., asset0/asset1 quotes)
    // Includes derived price, decimal, timestamp, etc.
}

Functions

getAssetInfo(bytes32 _assetIndex)

Fetches price information for a single asset.

  • Inputs: bytes32 _assetIndex (asset ID)

  • Outputs:

    • PriceFeed memory assetInfo

    • bool exist (true if the asset is supported and has data)

Most commonly used for single asset lookups.

getAssetsInfo(bytes32[] calldata _assetIndexes)

Batch version for multiple assets (gas-efficient).

  • Inputs: bytes32[] calldata _assetIndexes

  • Outputs:

    • PriceFeed[] memory infos

    • bool[] memory exists

Derived Pair Functions

For calculating quotes between two assets (e.g., CNGN/USDT via USD intermediates):

  • getPairbyId(bytes32 _assetIndex0, bytes32 _assetIndex1, PairDirection _direction)

    • Single pair with specified direction.

  • getPairsbyIdForward(bytes32[] calldata _assetIndexes0, bytes32[] calldata _assetsIndexes1)

    • Batch forward direction.

  • getPairsbyIdBackward(bytes32[] calldata _assetIndexes0, bytes32[] calldata _assetsIndexes1)

    • Batch backward direction.

  • getPairsbyId(bytes32[] calldata _assetIndexes0, bytes32[] calldata _assetsIndexes1, PairDirection[] calldata _directions)

    • Batch with per-pair direction control.

Outputs: DerivedPair or array thereof.

These enable cross-asset pricing without requiring direct feeds.

Usage Notes

  • All functions are safe to call — non-existent assets return exist = false.

  • No events are emitted on reads (updates emit internal events for monitoring).

  • Use the official ifapricefeed-interface package for full type safety.

Next: Check the Event Reference for monitoring price updates.

Last updated

Was this helpful?