# @switchboard-xyz/common

> common type definitions and utils for interacting with switchboard

Latest version **5.8.5** (published 2026-07-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @switchboard-xyz/common
pnpm add @switchboard-xyz/common
yarn add @switchboard-xyz/common
bun add @switchboard-xyz/common
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.8.5 |
| Published | 2026-07-30 |
| First published | 2022-08-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=20 |
| Dependencies | 10 |
| Unpacked size | 4.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | mgild, jessupjn, eldios, jackswitchboard, gesarki |

## Links

- npm: https://www.npmjs.com/package/@switchboard-xyz/common
- npm.io page: https://npm.io/package/@switchboard-xyz/common

## Dependencies (10)

- [bs58](https://npm.io/package/bs58.md) ^6.0.0
- [yaml](https://npm.io/package/yaml.md) ^2.8.1
- [axios](https://npm.io/package/axios.md) ^1.9.0
- [bn.js](https://npm.io/package/bn.js.md) ^5.2.1
- [big.js](https://npm.io/package/big.js.md) ^6.2.2
- [buffer](https://npm.io/package/buffer.md) ^6.0.3
- [js-sha256](https://npm.io/package/js-sha256.md) ^0.11.0
- [decimal.js](https://npm.io/package/decimal.js.md) ^10.4.3
- [protobufjs](https://npm.io/package/protobufjs.md) ^7.4.0
- [@solana/web3.js](https://npm.io/package/@solana/web3.js.md) ^1.98.2

## Recent versions

- 5.8.5 (latest) — 2026-07-30
- 3.4.4-alpha.0 (alpha) — 2025-08-04
- 3.3.5-beta.0 (beta) — 2025-06-11
- 5.8.4 — 2026-07-28
- 5.8.3 — 2026-07-15
- 5.8.2 — 2026-05-20
- 5.8.1 — 2026-04-21
- 5.7.0 — 2026-02-11
- 5.6.1 — 2026-01-08
- 5.6.0 — 2026-01-07
- 5.5.2 — 2025-12-18
- 5.5.1 — 2025-12-08
- 5.5.0 — 2025-12-02
- 5.4.2 — 2025-12-02
- 5.4.1 — 2025-12-01
- … 199 more at https://npm.io/package/@switchboard-xyz/common/versions

## README

<div align="center">
  <a href="#">
    <img src="https://github.com/switchboard-xyz/switchboard/raw/main/website/static/img/icons/switchboard/avatar.png" />
  </a>

  <h1>@switchboard-xyz/common</h1>

  <p>Contains the OracleJob protobufs and other types and utilities shared across chains.</p>

  <p>
	<a href="https://www.npmjs.com/package/@switchboard-xyz/common">
      <img alt="NPM Badge" src="https://img.shields.io/github/package-json/v/switchboard-xyz/sbv2-core?color=red&filename=javascript%2Fcommon%2Fpackage.json&label=%40switchboard-xyz%2Fcommon&logo=npm" />
    </a>
  </p>

  <p>
    <a href="https://discord.gg/switchboardxyz">
      <img alt="Discord" src="https://img.shields.io/discord/841525135311634443?color=blueviolet&logo=discord&logoColor=white" />
    </a>
    <a href="https://twitter.com/switchboardxyz">
      <img alt="Twitter" src="https://img.shields.io/twitter/follow/switchboardxyz?label=Follow+Switchboard" />
    </a>
  </p>

  <h4>
    <strong>Npm: </strong><a href="https://www.npmjs.com/package/@switchboard-xyz/common">npmjs.com/package/@switchboard-xyz/common</a>
  </h4>
  <h4>
    <strong>Typedocs: </strong><a href="https://switchboardxyz-common.netlify.app">switchboardxyz-common.netlify.app</a>
  </h4>
</div>

## Install

```bash
npm i --save @switchboard-xyz/common
```

## Usage

### Create an OracleJob

```ts
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

```ts
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](https://docs.switchboard.xyz/custom-feeds/advanced-feed-configuration/feed-parameter-units) before copying validation values between APIs.

---
_Source: https://npm.io/package/@switchboard-xyz/common · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
