Skip to main content

FinalizeSettle

Struct FinalizeSettle 

Source
pub struct FinalizeSettle<'a> {
    pub program_id: Pubkey,
    pub state_pda: Pubkey,
    pub begin_ix_index: u16,
    pub only_token_program: Option<TokenProgram>,
    pub source_buffers: &'a [Pubkey],
    pub destinations: &'a [Pubkey],
    pub mints: &'a [Option<Pubkey>],
    pub bumps: &'a [u8],
    pub amounts: &'a [u64],
}
Expand description

Builder for a FinalizeSettle instruction pushing the funds described by the parallel lists:

  • source_buffers[i] is the account the funds come from: the buffer token account of the order’s buy mint, or the native SOL buffer for an order buying native SOL,
  • destinations[i] is the account the funds go to (an order’s buy token account),
  • mints[i] is the buy mint if the push uses TransferChecked, or None for plain Transfer and for native SOL pushes, which ignore it,
  • bumps[i] is the canonical bump of source_buffers[i], so the program re-derives that PDA with one hash instead of searching,
  • amounts[i] is the amount to push, in the buy mint’s units or in lamports for a native SOL push.

This instruction comes in pair with a BeginSettle instruction. The slices are assumed to be built in parallel with the order information specified in BeginSettle. Notably, (1) the source buffer is the one corresponding to the order’s buy token, and (2) the destinations must be the buy token accounts specified in the corresponding order. The slices are assumed to have the same length but this is not enforced by the builder.

Wire format (with n total pushes): [discriminator=1][begin_ix_index: u16 LE][bump: u8 ×n][amount: u64 LE ×n]. Required accounts: [instructions_sysvar (R), state_pda (R), spl_token_program (R), token_2022_program (R)] followed, per push, by [source_buffer (W), destination (W), mint (R)]. The two token programs are the slots TokenProgram::ALL describes, there to name the programs this instruction’s pushes are issued against; the matching BeginSettle carries the ones its pulls need. A mint holding MINT_PLACEHOLDER makes the push a plain Transfer; any other mint makes it a TransferChecked.

FinalizeSettle only executes the transfers. Every push is validated by BeginSettle, which reads this instruction through introspection.

Fields§

§program_id: Pubkey§state_pda: Pubkey§begin_ix_index: u16§only_token_program: Option<TokenProgram>

The only token program this settlement’s transfers are issued against, or None to name every supported one; see TokenProgram::ALL.

§source_buffers: &'a [Pubkey]§destinations: &'a [Pubkey]§mints: &'a [Option<Pubkey>]§bumps: &'a [u8]§amounts: &'a [u64]

Trait Implementations§

Source§

impl From<FinalizeSettle<'_>> for Instruction

Source§

fn from(builder: FinalizeSettle<'_>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for FinalizeSettle<'a>

§

impl<'a> RefUnwindSafe for FinalizeSettle<'a>

§

impl<'a> Send for FinalizeSettle<'a>

§

impl<'a> Sync for FinalizeSettle<'a>

§

impl<'a> Unpin for FinalizeSettle<'a>

§

impl<'a> UnsafeUnpin for FinalizeSettle<'a>

§

impl<'a> UnwindSafe for FinalizeSettle<'a>

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.