switchboard-program

A Rust library to interact with Switchboard'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

```rust use switchboardprogram; use switchboardprogram::{ AggregatorState, RoundResult, FastRoundResultAccountData, fastparseswitchboardresult }; ... let aggregator: AggregatorState = switchboardprogram::getaggregator( switchboardfeedaccount // &AccountInfo )?; let roundresult: RoundResult = switchboardprogram::getaggregator_result( &aggregator)?;

// pub struct RoundResult { // pub numsuccess: Option, // pub numerror: Option, // pub result: Option, // pub roundopenslot: Option, // pub roundopentimestamp: Option, // pub minresponse: Option, // pub maxresponse: Option, // pub medians: Vec, // }

... // Compute conservative? Use the parse optimized result account instead:

let fastparsefeedround = FastRoundResultAccountData::deserialize( &switchboardparseoptimizedaccount.tryborrowdata()?).unwrap();

// pub struct FastRoundResultAccountData { // pub parent: [u8;32], // pub result: FastRoundResult, // } // // A precisioned decimal representation of the current aggregator result // // where result is represented as ${mantissa} / (10^${scale}) // pub struct SwitchboardDecimal { // pub mantissa: i128, // pub scale: u64 // } // pub struct FastRoundResult { // pub numsuccess: i32, // pub numerror: i32, // pub result: f64, // pub roundopenslot: u64, // pub roundopentimestamp: i64, // pub minresponse: f64, // pub maxresponse: f64, // pub decimal: SwitchboardDecimal, // }

```