Modularity and Programmability

IntelliX provides a high degree of modularity and programmability, allowing oracle developers to customize their implementations at varying levels of complexity. Developers can choose between two approaches: a declarative method, which is easier to implement, and a programmatic method for more advanced use cases requiring greater control.

IntelliX offers flexibility in how data is fetched and processed. Below are two approaches for publishing a price feed.

Declarative Approach

In the declarative approach, developers can configure key parameters like data source URLs, update frequency, and aggregation rules using a simple configuration file. This method is ideal for handling standard data sources with minimal setup.

The sample configuration below fetches price data from four cryptocurrency exchanges (Binance, Coinbase, Kraken, Bitfinex), extracts price values using a JSONPath processor and publishes the resulting data on-chain every 60 seconds. The data is published on multiple blockchain networks, including Bitlayer, BSC, and Merlin, and validated using an average-median approach.

sources:
    
    - id: binance
      type: url
      url: "https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT"
      
    - id: coinbase
      type: url
      url: "https://api.exchange.coinbase.com/products/BTC-USD/ticker"
    
    - id: kraken
      type: url
      url: "https://api.kraken.com/0/public/Ticker?pair=XBTUSD"
    
    - id: bitfinex
      type: url
      url: "https://api-pub.bitfinex.com/v2/ticker/tBTCUSD"

update_frequency: 60  # Fetches data every 60 seconds

processors:
    - type: json_path
      source: [binance, coinbase]
      path: "$.price"
      
    - type: json_path
      source: kraken
      path: "$.result.XXBTZUSD.c[0]"
    
    - type: json_path
      source: bitfinex
      path: "$[6]"
      
publishers:
    
    - type: bitlayer
      contract_address: "0x1234567890abcdef1234567890abcdef12345678"
      
    - type: bsc
      contract_address: "0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef"
      
    - type: merlin
      contract_address: "0xabcdef123456abcdef123456abcdef123456abcdef"

validators:
   type: price_avg_median
   
output_schema:
   type: "ufixed256x18"  # ABI-compatible type for a floating point

Programmatic Approach

For more complex use cases, IntelliX allows developers to programmatically define their fetching and aggregation logic, offering maximum flexibility for custom workflows, data transformations, and integrations.

In the example below, the developer manually defines how to fetch price data from multiple APIs and calculates the average price. This approach allows full customization of the data fetching and processing logic, making it ideal for more advanced or unique use cases.

The fetch() function is responsible for retrieving the latest BTC/USDT price data from multiple cryptocurrency exchange APIs. It performs the following steps:

  1. Fetch Data: Calls each API endpoint to retrieve the BTC/USDT price.

  2. Extract Prices: Extracts the price data from each API response and converts them to floats for uniformity.

  3. Return: Outputs an array of floats, where each float represents the BTC/USDT price from a specific exchange. This array is meant to be used by multiple fetchers in a distributed system setup to gather data from a range of sources.

The validate() function aggregates the data collected by multiple fetchers, using a two-step approach:

  1. Input: Takes an array of arrays as input, where each inner array is the result of a fetch() function call by a different fetcher.

  2. Median Calculation: Calculates the median of each inner array. This median represents a single fetcher’s perspective on the BTC/USDT price, helping reduce the influence of outliers within each source's collected data.

  3. Average Calculation: Averages the medians from all fetchers, producing a final aggregated value that represents a robust consensus of the BTC/USDT price across sources and fetchers.

Last updated