# @switchboard-xyz/sbv2-lite

> A lightweight library to decode and parse aggregator accounts

Latest version **0.2.4** (published 2023-08-30) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.2.4 |
| Published | 2023-08-30 |
| First published | 2022-04-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.0.0 |
| Dependencies | 2 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 114 |
| Maintainers | anoushk, gallynaut, herm, vjessup, mgild, jessupjn |

## Links

- npm: https://www.npmjs.com/package/@switchboard-xyz/sbv2-lite
- Repository: https://github.com/switchboard-xyz/sbv2-solana
- Homepage: https://docs.switchboard.xyz
- Issues: https://github.com/switchboard-xyz/sbv2-solana/issues
- npm.io page: https://npm.io/package/@switchboard-xyz/sbv2-lite

## Dependencies (2)

- [big.js](https://npm.io/package/big.js.md) ^6.1.1
- [@coral-xyz/anchor](https://npm.io/package/@coral-xyz/anchor.md) ^0.28.0

## Recent versions

- 0.2.4 (latest) — 2023-08-30
- 0.2.3 — 2023-08-30
- 0.2.2 — 2023-07-31
- 0.2.1 — 2023-07-31
- 0.2.0 — 2023-07-31
- 0.1.6 — 2022-09-16
- 0.1.5 — 2022-07-11
- 0.1.4 — 2022-05-26
- 0.1.3 — 2022-05-25
- 0.1.2 — 2022-05-25
- 0.1.1 — 2022-04-22
- 0.1.0 — 2022-04-20

## README

# Switchboard V2 Lite

A lightweight library to decode and parse aggregator accounts

[![npm](https://img.shields.io/npm/v/@switchboard-xyz/sbv2-lite)](https://www.npmjs.com/package/@switchboard-xyz/sbv2-lite)&nbsp;&nbsp;
[![twitter](https://badgen.net/twitter/follow/switchboardxyz)](https://twitter.com/switchboardxyz)&nbsp;&nbsp;

## Install

```
npm i @switchboard-xyz/sbv2-lite
```

## Example

```ts
import SwitchboardProgram from "@switchboard-xyz/sbv2-lite";

//

const sbv2 = await SwitchboardProgram.loadDevnet();

// SOL_USD Aggregator https://switchboard.xyz/explorer
const solAggregator = new anchor.web3.PublicKey(
  "GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR"
);

const accountInfo = await sbv2.program.provider.connection.getAccountInfo(
  solAggregator
);
if (!accountInfo) {
  throw new Error(`failed to fetch account info`);
}

// Get latest value if its been updated in the last 300 seconds
const latestResult = sbv2.decodeLatestAggregatorValue(accountInfo, 300);
if (latestResult === null) {
  throw new Error(`failed to fetch latest result for aggregator`);
}
console.log(`latestResult: ${latestResult}`);
// latestResult: 105.673205
```

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