#[repr(packed(1))]
pub struct AggregatorAccountData {
Show 36 fields pub name: [u8; 32], pub metadata: [u8; 128], pub _reserved1: [u8; 32], pub queue_pubkey: Pubkey, pub oracle_request_batch_size: u32, pub min_oracle_results: u32, pub min_job_results: u32, pub min_update_delay_seconds: u32, pub start_after: i64, pub variance_threshold: SwitchboardDecimal, pub force_report_period: i64, pub expiration: i64, pub consecutive_failure_count: u64, pub next_allowed_update_time: i64, pub is_locked: bool, pub crank_pubkey: Pubkey, pub latest_confirmed_round: AggregatorRound, pub current_round: AggregatorRound, pub job_pubkeys_data: [Pubkey; 16], pub job_hashes: [Hash; 16], pub job_pubkeys_size: u32, pub jobs_checksum: [u8; 32], pub authority: Pubkey, pub history_buffer: Pubkey, pub previous_confirmed_round_result: SwitchboardDecimal, pub previous_confirmed_round_slot: u64, pub disable_crank: bool, pub job_weights: [u8; 16], pub creation_timestamp: i64, pub resolution_mode: AggregatorResolutionMode, pub base_priority_fee: u32, pub priority_fee_bump: u32, pub priority_fee_bump_period: u32, pub max_priority_fee_multiplier: u32, pub parent_function: Pubkey, pub _ebuf: [u8; 90],
}

Fields§

§name: [u8; 32]

Name of the aggregator to store on-chain.

§metadata: [u8; 128]

Metadata of the aggregator to store on-chain.

§_reserved1: [u8; 32]

Reserved.

§queue_pubkey: Pubkey

Pubkey of the queue the aggregator belongs to.

§oracle_request_batch_size: u32

CONFIGS Number of oracles assigned to an update request.

§min_oracle_results: u32

Minimum number of oracle responses required before a round is validated.

§min_job_results: u32

Minimum number of job results before an oracle accepts a result.

§min_update_delay_seconds: u32

Minimum number of seconds required between aggregator rounds.

§start_after: i64

Unix timestamp for which no feed update will occur before.

§variance_threshold: SwitchboardDecimal

Change percentage required between a previous round and the current round. If variance percentage is not met, reject new oracle responses.

§force_report_period: i64

Number of seconds for which, even if the variance threshold is not passed, accept new responses from oracles.

§expiration: i64

Timestamp when the feed is no longer needed.

§consecutive_failure_count: u64

Counter for the number of consecutive failures before a feed is removed from a queue. If set to 0, failed feeds will remain on the queue.

§next_allowed_update_time: i64

Timestamp when the next update request will be available.

§is_locked: bool

Flag for whether an aggregators configuration is locked for editing.

§crank_pubkey: Pubkey

Optional, public key of the crank the aggregator is currently using. Event based feeds do not need a crank.

§latest_confirmed_round: AggregatorRound

Latest confirmed update request result that has been accepted as valid.

§current_round: AggregatorRound

Oracle results from the current round of update request that has not been accepted as valid yet.

§job_pubkeys_data: [Pubkey; 16]

List of public keys containing the job definitions for how data is sourced off-chain by oracles.

§job_hashes: [Hash; 16]

Used to protect against malicious RPC nodes providing incorrect task definitions to oracles before fulfillment.

§job_pubkeys_size: u32

Number of jobs assigned to an oracle.

§jobs_checksum: [u8; 32]

Used to protect against malicious RPC nodes providing incorrect task definitions to oracles before fulfillment.

§authority: Pubkey

The account delegated as the authority for making account changes.

§history_buffer: Pubkey

Optional, public key of a history buffer account storing the last N accepted results and their timestamps.

§previous_confirmed_round_result: SwitchboardDecimal

The previous confirmed round result.

§previous_confirmed_round_slot: u64

The slot when the previous confirmed round was opened.

§disable_crank: bool

Whether an aggregator is permitted to join a crank.

§job_weights: [u8; 16]

Job weights used for the weighted median of the aggregator’s assigned job accounts.

§creation_timestamp: i64

Unix timestamp when the feed was created.

§resolution_mode: AggregatorResolutionMode

Use sliding window or round based resolution NOTE: This changes result propogation in latest_round_result

§base_priority_fee: u32§priority_fee_bump: u32§priority_fee_bump_period: u32§max_priority_fee_multiplier: u32§parent_function: Pubkey§_ebuf: [u8; 90]

Reserved for future info.

Implementations§

source§

impl AggregatorAccountData

source

pub fn size() -> usize

source

pub fn new<'info>( switchboard_feed: &'info AccountInfo<'info> ) -> Result<Ref<'info, AggregatorAccountData>>

Returns the deserialized Switchboard Aggregator account

§Arguments
  • switchboard_feed - A Solana AccountInfo referencing an existing Switchboard Aggregator
§Examples
use switchboard_solana::AggregatorAccountData;

let data_feed = AggregatorAccountData::new(feed_account_info)?;
source

pub fn new_from_bytes(data: &[u8]) -> Result<&AggregatorAccountData>

Returns the deserialized Switchboard Aggregator account

§Arguments
  • data - A Solana AccountInfo’s data buffer
§Examples
use switchboard_solana::AggregatorAccountData;

let data_feed = AggregatorAccountData::new_from_bytes(feed_account_info.try_borrow_data()?)?;
source

pub fn get_result(&self) -> Result<SwitchboardDecimal>

If sufficient oracle responses, returns the latest on-chain result in SwitchboardDecimal format

§Examples
use switchboard_solana::AggregatorAccountData;
use std::convert::TryInto;

let feed_result = AggregatorAccountData::new(feed_account_info)?.get_result()?;
let decimal: f64 = feed_result.try_into()?;
source

pub fn check_confidence_interval( &self, max_confidence_interval: SwitchboardDecimal ) -> Result<()>

Check whether the confidence interval exceeds a given threshold

§Examples
use switchboard_solana::{AggregatorAccountData, SwitchboardDecimal};

let feed = AggregatorAccountData::new(feed_account_info)?;
feed.check_confidence_interval(SwitchboardDecimal::from_f64(0.80))?;
source

pub fn check_variance(&self, max_variance: Decimal) -> Result<()>

Check the variance (as a percentage difference from the max delivered oracle value) from all oracles.

source

pub fn check_staleness( &self, unix_timestamp: i64, max_staleness: i64 ) -> Result<()>

Check whether the feed has been updated in the last max_staleness seconds

§Examples
use switchboard_solana::AggregatorAccountData;

let feed = AggregatorAccountData::new(feed_account_info)?;
feed.check_staleness(clock::Clock::get().unwrap().unix_timestamp, 300)?;
source

pub fn is_expired(&self) -> Result<bool>

Trait Implementations§

source§

impl AccountDeserialize for AggregatorAccountData

source§

fn try_deserialize(buf: &mut &[u8]) -> Result<Self>

Deserializes previously initialized account data. Should fail for all uninitialized accounts, where the bytes are zeroed. Implementations should be unique to a particular account type so that one can never successfully deserialize the data of one account type into another. For example, if the SPL token program were to implement this trait, it should be impossible to deserialize a Mint account into a token Account.
source§

fn try_deserialize_unchecked(buf: &mut &[u8]) -> Result<Self>

Deserializes account data without checking the account discriminator. This should only be used on account initialization, when the bytes of the account are zeroed.
source§

impl Clone for AggregatorAccountData

source§

fn clone(&self) -> AggregatorAccountData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for AggregatorAccountData

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Discriminator for AggregatorAccountData

source§

const DISCRIMINATOR: [u8; 8] = _

§

fn discriminator() -> [u8; 8]

source§

impl Owner for AggregatorAccountData

source§

impl PartialEq for AggregatorAccountData

source§

fn eq(&self, other: &AggregatorAccountData) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryInto<AggregatorAccountData> for Option<Vec<u8>>

§

type Error = SwitchboardError

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<AggregatorAccountData, Self::Error>

Performs the conversion.
source§

impl Zeroable for AggregatorAccountData

§

fn zeroed() -> Self

source§

impl Copy for AggregatorAccountData

source§

impl Pod for AggregatorAccountData

source§

impl StructuralPartialEq for AggregatorAccountData

source§

impl ZeroCopy for AggregatorAccountData

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> AnyBitPattern for T
where T: Pod,

§

impl<T> NoUninit for T
where T: Pod,