Skip to main content

OrderAccount

Struct OrderAccount 

Source
pub struct OrderAccount {
    pub bump: u8,
    pub cancelled: bool,
    pub amount_withdrawn: u64,
    pub amount_received: u64,
    pub created_by: Pubkey,
    pub intent: OrderIntent,
}
Expand description

Idiomatic representation of an order PDA’s body.

Fields§

§bump: u8

Canonical bump of the PDA this account lives at. Written at creation time so callers don’t need to supply it; see Self::load_from_pda.

§cancelled: bool

false = the order is still active and can be filled; true = the order has been cancelled by the owner and must not be filled.

§amount_withdrawn: u64

Cumulative amount of the sell token withdrawn for this order across settlements. Starts at zero; monotonically increases.

§amount_received: u64

Cumulative amount of the buy token received for this order across settlements. Starts at zero; monotonically increases.

§created_by: Pubkey

Account that funded the rent for this PDA. The rent is refunded here when the order is cleared.

§intent: OrderIntent

The order intent stored in this PDA.

Implementations§

Source§

impl OrderAccount

Source

pub fn load_from_pda( order_pda: &AccountView, program_id: &Address, ) -> Result<Self, ProgramError>

Load and decode the order at the given PDA, and confirm the PDA is derivable from its own data: both the UID and the bump feeding the derivation come from the stored body.

Source

pub fn is_fully_filled(&self) -> bool

Whether the order has been filled to the full amount of its exact side, so no settlement can ever fill it again.

Trait Implementations§

Source§

impl Clone for OrderAccount

Source§

fn clone(&self) -> OrderAccount

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for OrderAccount

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OrderAccount

Source§

fn default() -> OrderAccount

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

impl Eq for OrderAccount

Source§

impl From<OrderAccount> for EncodedOrderAccount

Source§

fn from(account: OrderAccount) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for OrderAccount

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for OrderAccount

Source§

impl TryFrom<&[u8]> for OrderAccount

Source§

type Error = ProgramError

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

fn try_from(bytes: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<EncodedOrderAccount> for OrderAccount

Source§

type Error = ProgramError

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

fn try_from(encoded: EncodedOrderAccount) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<[u8; 264]> for OrderAccount

Source§

type Error = ProgramError

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

fn try_from(bytes: [u8; 264]) -> Result<Self, Self::Error>

Performs the conversion.

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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

type Error = !

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>,

Source§

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.