Skip to main content
The IFÁ Labs oracle contract exposes a focused set of read-only functions for querying price data. All functions are view — they cost no gas when called externally and have no side effects. This page is the complete reference for every function, struct, and enum in the contract interface.

Data Types

Before the function reference, the types returned by the contract:

PriceFeed Struct

The primary return type for all single-asset price queries.

DerivedPair Struct

The return type for cross-asset pair calculations.
The lastUpdateTime for a derived pair reflects the older of the two underlying feed timestamps — the derived price is only as fresh as its least-recently-updated component.

PairDirection Enum

Controls the direction of a derived pair calculation.

Functions

getAssetInfo

Fetches the current price feed for a single asset.
Parameters: Returns: Behaviour:
  • Returns exist = false for unrecognised asset IDs. Does not revert.
  • assetInfo fields are zero-valued when exist = false. Always check exist before using assetInfo.
  • Safe to call with any bytes32 value — will never revert on invalid input.
Example:

getAssetsInfo

Batch version of getAssetInfo. Fetches price feeds for multiple assets in a single call.
Parameters: Returns: Behaviour:
  • Results are returned in the same order as the input array.
  • Each element in exists corresponds to the same-index element in infos.
  • Does not revert if an asset ID is unrecognised — returns exists[i] = false for that element.
  • Always check exists[i] before using infos[i].
Example:
Use getAssetsInfo any time your contract needs more than one price in the same transaction. One external call is significantly cheaper than N consecutive getAssetInfo calls.

getPairbyId

Computes a derived cross-asset price for a single pair.
Parameters: Returns: Behaviour:
  • Both underlying USD feeds must exist and be non-zero. If either is missing, the function reverts.
  • Self-pairing (same asset ID for both parameters) is blocked — reverts with an error.
  • lastUpdateTime reflects the older of the two underlying feed timestamps.
Example:

getPairsbyIdForward

Batch derived pair calculation — all pairs in the forward direction.
Parameters: Returns: Array of DerivedPair structs — same order as inputs. Behaviour:
  • Input arrays must be the same length. Mismatched lengths revert with InvalidAssetIndexLength.
  • Each pair is computed independently. A failure in one pair reverts the entire call.
Example:

getPairsbyIdBackward

Batch derived pair calculation — all pairs in the backward direction.
Parameters: Returns: Array of DerivedPair structs in backward direction — asset1 priced in asset0 terms. Behaviour: Identical to getPairsbyIdForward except direction is reversed for all pairs. Same length requirement and revert behaviour apply. Example:

getPairsbyId

Batch derived pair calculation with per-pair direction control.
Parameters: Returns: Array of DerivedPair structs — each computed with its specified direction. Behaviour:
  • All three input arrays must be the same length. Mismatched lengths revert with InvalidAssetOrDirectionLength.
  • Use this function when you need a mix of forward and backward pairs in a single call.
Example:

Custom Errors

The contract uses custom errors for gas-efficient reverts. These are the errors you may encounter when calling derived pair functions: Note: getAssetInfo and getAssetsInfo do not revert on unsupported assets — they return exist = false. Only derived pair functions can revert due to missing or invalid underlying feeds.

Quick Reference


Installing the Interface

The full interface with all types, functions, and natspec documentation is available via npm:
Source: github.com/IFA-Labs/IfaPriceFeed-interface

Next Steps

Event Reference

Events emitted by the oracle contract for monitoring and indexing.

Complete Example Contract

See all functions used together in a production-ready integration.