Skip to main content

CreateOrder

Struct CreateOrder 

Source
pub struct CreateOrder {
    pub program_id: Pubkey,
    pub owner: Pubkey,
    pub created_by: Pubkey,
    pub order_pda: Pubkey,
    pub intent_bytes: [u8; 213],
}
Expand description

Builder for a CreateOrder instruction.

intent_bytes is the canonical byte encoding (see EncodedOrderIntent). order_pda must be the canonical PDA returned by crate::pda::order::find_order_pda for the same UID; the program derives the bump itself and rejects any other address.

owner signs the instruction and must match the intent owner; this is what authenticates the order. It may be a normal user account or a PDA, the program does not check is_on_curve. A parent program that wants to create orders on behalf of its own PDA can invoke_signed into the settlement program using this instruction directly.

created_by funds the new order PDA’s rent and is recorded as the created_by address in its body. Keeping it separate from owner lets the rent cost be delegated to another account, which is handy when owner is a PDA. created_by and owner may be the same account.

The order doesn’t need to be executable for it to be created. For example, the sell token account doesn’t need to belong to the user or be an SPL token account in the first place. This is checked at execution time.

An order can exist only once: if order_pda is already initialized, the instruction reverts with AccountAlreadyInitialized. Recreating the same order is only possible after its PDA has been closed.

Wire format: [discriminator=2, ..intent bytes], 1 + EncodedOrderIntent::SIZE-bytes. Required accounts: [owner (S), created_by (W,S), order_pda (W), system_program (R)]. The system program needs to be available but doesn’t need to be at that specific position in the instruction, unlike the others.

Fields§

§program_id: Pubkey§owner: Pubkey§created_by: Pubkey§order_pda: Pubkey§intent_bytes: [u8; 213]

Trait Implementations§

Source§

impl From<CreateOrder> for Instruction

Source§

fn from(builder: CreateOrder) -> Self

Converts to this type from the input type.

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

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.