Oracle

Example code snippets to query the indexer for oracle module related data.

Using gRPC Stream

Stream oracle prices

import { IndexerGrpcOracleStream } from '@injectivelabs/sdk-ts'
import { getNetworkEndpoints, Network } from '@injectivelabs/networks'

const endpoints = getNetworkEndpoints(Network.Testnet)
const indexerGrpcOracleStream = new IndexerGrpcOracleStream(endpoints.indexer)

const streamFn = indexerGrpcOracleStream.streamOraclePrices.bind(
  indexerGrpcOracleStream,
)

const callback = (oraclePrices) => {
  console.log(oraclePrices)
}

const streamFnArgs = {
  callback,
}

streamFn(streamFnArgs)

Stream oracle prices by market

Last updated