Socket
Socket
Sign inDemoInstall

@switchboard-xyz/sbv2-lite

Package Overview
Dependencies
67
Maintainers
6
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @switchboard-xyz/sbv2-lite

A lightweight library to decode and parse aggregator accounts


Version published
Weekly downloads
2.8K
decreased by-18.14%
Maintainers
6
Install size
28.3 MB
Created
Weekly downloads
 

Readme

Source

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

FAQs

Last updated on 30 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc