Skip to content

Latest commit

 

History

History
75 lines (61 loc) · 1.97 KB

README.md

File metadata and controls

75 lines (61 loc) · 1.97 KB

@switchboard-xyz/common

Contains the OracleJob protobufs and other types and utilities shared across chains.

NPM Badge

Discord Twitter

Install

npm i --save @switchboard-xyz/common

Usage

Create an OracleJob

import { OracleJob, serializeOracleJob } from "@switchboard-xyz/common";

const oracleJob: OracleJob = serializeOracleJob({
  tasks: [
    {
      httpTask: {
        url: "https://www.binance.com/api/v3/ticker/price?symbol=BTCUSDT",
      },
    },
    {
      jsonParseTask: {
        path: "$.price",
      },
    },
    {
      multiplyTask: {
        /* Mainnet USDT/USD Feed */
        aggregatorPubkey: "ETAaeeuQBwsh9mC2gCov9WdhJENZuffRMXY2HgjCcSL9",
      },
    },
  ],
});

Simulate an OracleJob

import { simulateOracleJobs } from "@switchboard-xyz/common";

const result = await simulateOracleJobs([oracleJob]);
console.log(result);