#[repr(C)]pub struct OilPriceOracle {
pub price: u64,
pub expo: i32,
pub _pad: i32,
pub conf: u64,
pub ema: u64,
pub publish_time: i64,
pub oracle_authority: Pubkey,
}Expand description
OIL price oracle (Valiant-backed; updated by centralized authority). Price is stored as FOGO lamports per 1 OIL: fee_lamports = claimable_atomic * price * 35 / (100 * ONE_OIL).
Fields§
§price: u64Price: FOGO lamports per 1 OIL (expo applied separately for scaling; here expo is 0 for this interpretation).
expo: i32Exponent for price (e.g. -9 if price is in FOGO units with 9 decimals). Currently use price as lamports per 1 OIL, expo = 0.
_pad: i32Padding for alignment (repr(C) after i32).
conf: u64Confidence interval (optional; for future use).
ema: u64EMA price (optional; for future use).
publish_time: i64Unix timestamp when price was last updated.
Authority allowed to call SetOilOraclePrice.
Implementations§
Source§impl OilPriceOracle
impl OilPriceOracle
pub const LEN: usize
pub fn pda() -> (Pubkey, u8)
Sourcepub fn set(
&mut self,
price: u64,
expo: i32,
conf: u64,
ema: u64,
publish_time: i64,
)
pub fn set( &mut self, price: u64, expo: i32, conf: u64, ema: u64, publish_time: i64, )
Set price data (called by SetOilOraclePrice).
Sourcepub fn required_fee_lamports(&self, claimable_atomic: u64) -> u64
pub fn required_fee_lamports(&self, claimable_atomic: u64) -> u64
Required fee in lamports for a given claimable amount (atomic OIL). fee = claimable_atomic * price * 35 / (100 * ONE_OIL). Uses expo if needed; with expo=0, price is lamports per 1 OIL.
Trait Implementations§
Source§impl AccountValidation for OilPriceOracle
impl AccountValidation for OilPriceOracle
fn assert<F>(&self, condition: F) -> Result<&Self, ProgramError>
fn assert_err<F>( &self, condition: F, err: ProgramError, ) -> Result<&Self, ProgramError>
fn assert_msg<F>(&self, condition: F, msg: &str) -> Result<&Self, ProgramError>
fn assert_mut<F>(&mut self, condition: F) -> Result<&mut Self, ProgramError>
fn assert_mut_err<F>( &mut self, condition: F, err: ProgramError, ) -> Result<&mut Self, ProgramError>
fn assert_mut_msg<F>( &mut self, condition: F, msg: &str, ) -> Result<&mut Self, ProgramError>
Source§impl Clone for OilPriceOracle
impl Clone for OilPriceOracle
Source§fn clone(&self) -> OilPriceOracle
fn clone(&self) -> OilPriceOracle
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OilPriceOracle
impl Debug for OilPriceOracle
Source§impl<'de> Deserialize<'de> for OilPriceOracle
impl<'de> Deserialize<'de> for OilPriceOracle
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Discriminator for OilPriceOracle
impl Discriminator for OilPriceOracle
fn discriminator() -> u8
Source§impl PartialEq for OilPriceOracle
impl PartialEq for OilPriceOracle
Source§impl Serialize for OilPriceOracle
impl Serialize for OilPriceOracle
impl Copy for OilPriceOracle
impl Pod for OilPriceOracle
impl StructuralPartialEq for OilPriceOracle
Auto Trait Implementations§
impl Freeze for OilPriceOracle
impl RefUnwindSafe for OilPriceOracle
impl Send for OilPriceOracle
impl Sync for OilPriceOracle
impl Unpin for OilPriceOracle
impl UnwindSafe for OilPriceOracle
Blanket Implementations§
Source§impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
fn try_from_bytes(data: &[u8]) -> Result<&T, ProgramError>
fn try_from_bytes_mut(data: &mut [u8]) -> Result<&mut T, ProgramError>
Source§impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
fn try_header_from_bytes(data: &[u8]) -> Result<(&T, &[u8]), ProgramError>
fn try_header_from_bytes_mut( data: &mut [u8], ) -> Result<(&mut T, &mut [u8]), ProgramError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
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.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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