-
Notifications
You must be signed in to change notification settings - Fork 195
02StreamingIndexerOracle
Ivan Angelkoski edited this page Jun 12, 2023
·
4 revisions
Example code snippets to query the indexer for oracle module related data.
- stream oracle prices
import { IndexerGrpcOracleStream } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
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
import { IndexerGrpcOracleStream } from "@injectivelabs/sdk-ts";
import { getNetworkEndpoints, Network } from "@injectivelabs/networks";
const endpoints = getNetworkEndpoints(Network.TestnetK8s);
const indexerGrpcOracleStream = new IndexerGrpcOracleStream(endpoints.indexer);
const marketIds = ["0x..."]; /* optional param */
const streamFn = indexerGrpcOracleStream.streamOraclePricesByMarkets.bind(
indexerGrpcOracleStream
);
const callback = (oraclePrices) => {
console.log(oraclePrices);
};
const streamFnArgs = {
marketIds,
callback,
};
streamFn(streamFnArgs);
Powering the future of decentralized finance.