@switchboard-xyz/common
v5.8.3
Published
common type definitions and utils for interacting with switchboard
Keywords
Readme
Install
npm i --save @switchboard-xyz/commonUsage
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);Feed Parameter Units
Raw v2 OracleFeed.maxJobRangePct values are fixed-point percentages scaled by 1e9: 1_000_000_000 means 1%. minJobResponses and minOracleSamples are unscaled counts.
Some SDK gateway helpers accept human-percent maxVariance values and scale them internally, while low-level Crossbar/gateway request bodies expect already-scaled integers. See Feed Parameter Units before copying validation values between APIs.
