switchboard-v2

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

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

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

let feedresult = AggregatorAccountData::new(feedaccountinfo)?.getresult()?;

let decimal: f64 = feedresult.tryinto()?; ```

Aggregator History

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

let historybuffer = AggregatorHistoryBuffer::new(historyaccountinfo)?; let currenttimestamp = Clock::get()?.unixtimestamp; let onehourago: f64 = historybuffer.lowerbound(currenttimestamp - 3600).unwrap().try_into()?; ```

VRF Account

```rust use switchboard_v2::VrfAccountData;

let vrf = VrfAccountData::new(vrfaccountinfo)?; let resultbuffer = vrf.getresult()?; let value: &[u128] = bytemuck::castslice(&resultbuffer[..]); let result = value[0] % 256000 as u128; ```