sbv2-solana/libraries/rs
Conner Gallagher 39377b0c20 cleaned up package.json, tsconfig.json, and misc build configs
cleaned up tsconfig


wip


wip


Publish

 - @switchboard-xyz/switchboardv2-cli@0.1.22
 - @switchboard-xyz/eslint-config@0.1.0
 - @switchboard-xyz/sbv2-lite@0.1.2
 - @switchboard-xyz/sbv2-utils@0.0.14
 - @switchboard-xyz/switchboard-v2@0.0.98
 - @switchboard-xyz/v2-feed-parser@0.1.1
 - @switchboard-xyz/v2-feed-walkthrough@0.1.1
 - @switchboard-xyz/lease-observer@0.1.1
 - anchor-feed-parser@0.1.2
 - anchor-vrf-parser@0.1.2
 - spl-feed-parser@0.1.2
 - website@0.1.1

Publish


Publish

 - @switchboard-xyz/switchboardv2-cli@0.1.22
 - @switchboard-xyz/eslint-config@0.1.0
 - @switchboard-xyz/sbv2-lite@0.1.2
 - @switchboard-xyz/sbv2-utils@0.1.13
 - @switchboard-xyz/switchboard-v2@0.0.98
 - @switchboard-xyz/v2-feed-parser@0.1.1
 - @switchboard-xyz/v2-feed-walkthrough@0.1.1
 - @switchboard-xyz/lease-observer@0.1.1
 - anchor-feed-parser@0.1.1
 - anchor-vrf-parser@0.1.1
 - spl-feed-parser@0.1.1

Publish


ww
2022-05-25 12:38:29 -06:00
..
src init 2022-05-17 10:42:04 -06:00
.gitignore init 2022-05-17 10:42:04 -06:00
Cargo.toml cleaned up package.json, tsconfig.json, and misc build configs 2022-05-25 12:38:29 -06:00
LICENSE cleaned up package.json, tsconfig.json, and misc build configs 2022-05-25 12:38:29 -06:00
README.md developer doc cleanup 2022-05-20 16:45:42 -06:00

README.md

switchboard-v2

A Rust library to interact with Switchboard V2's hosted data feeds.

cargo   twitter  

Description

This package can be used to manage Switchboard data feed account parsing.

Specifically, this package will return the most recent confirmed round result from a provided data feed AccountInfo.

Usage

Aggregator

use switchboard_v2::AggregatorAccountData;
use std::convert::TryInto;

let feed_result = AggregatorAccountData::new(feed_account_info)?.get_result()?;

let decimal: f64 = feed_result.try_into()?;

Aggregator History

use switchboard_v2::AggregatorHistoryBuffer;
use std::convert::TryInto;

let history_buffer = AggregatorHistoryBuffer::new(history_account_info)?;
let current_timestamp = Clock::get()?.unix_timestamp;
let one_hour_ago: f64 = history_buffer.lower_bound(current_timestamp - 3600).unwrap().try_into()?;

VRF Account

use switchboard_v2::VrfAccountData;

let vrf = VrfAccountData::new(vrf_account_info)?;
let result_buffer = vrf.get_result()?;
if result_buffer == [0u8; 32] {
    msg!("vrf buffer empty");
    return Ok(());
}

let value: &[u128] = bytemuck::cast_slice(&result_buffer[..]);
let result = value[0] % 256000 as u128;