sbv2-solana/libraries/sbv2-lite
Conner Gallagher 1203538a0b docs: updated typedoc version
- fixes missing defined in source code references
2022-07-22 13:01:20 -06:00
..
src removed sbv2-lite anchor wallet cjs import 2022-07-11 08:57:24 -06:00
tests cleaned up package.json, tsconfig.json, and misc build configs 2022-05-25 12:38:29 -06:00
.gitignore init 2022-05-17 10:42:04 -06:00
.npmignore library build scripts cleanup 2022-05-25 15:14:48 -06:00
LICENSE cleaned up package.json, tsconfig.json, and misc build configs 2022-05-25 12:38:29 -06:00
README.md init 2022-05-17 10:42:04 -06:00
package.json docs: updated typedoc version 2022-07-22 13:01:20 -06:00
tsconfig.base.json chore(tooling): simplified tsconfig and esm builds 2022-06-17 23:43:26 -06:00
tsconfig.cjs.json chore(tooling): simplified tsconfig and esm builds 2022-06-17 23:43:26 -06:00
tsconfig.json chore(tooling): simplified tsconfig and esm builds 2022-06-17 23:43:26 -06:00

README.md

Switchboard V2 Lite

A lightweight library to decode and parse aggregator accounts

npm   twitter  

Install

npm i @switchboard-xyz/sbv2-lite

Example

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