#[repr(u8)]
pub enum TransferFeeInstruction { InitializeTransferFeeConfig { transfer_fee_config_authority: COption<Pubkey>, withdraw_withheld_authority: COption<Pubkey>, transfer_fee_basis_points: u16, maximum_fee: u64, }, TransferCheckedWithFee { amount: u64, decimals: u8, fee: u64, }, WithdrawWithheldTokensFromMint, WithdrawWithheldTokensFromAccounts { num_token_accounts: u8, }, HarvestWithheldTokensToMint, SetTransferFee { transfer_fee_basis_points: u16, maximum_fee: u64, }, }
Expand description

Transfer Fee extension instructions

Variants§

§

InitializeTransferFeeConfig

Fields

§transfer_fee_config_authority: COption<Pubkey>

Pubkey that may update the fees

§withdraw_withheld_authority: COption<Pubkey>

Withdraw instructions must be signed by this key

§transfer_fee_basis_points: u16

Amount of transfer collected as fees, expressed as basis points of the transfer amount

§maximum_fee: u64

Maximum fee assessed on transfers

Initialize the transfer fee on a new mint.

Fails if the mint has already been initialized, so must be called before InitializeMint.

The mint must have exactly enough space allocated for the base mint (82 bytes), plus 83 bytes of padding, 1 byte reserved for the account type, then space required for this extension, plus any others.

Accounts expected by this instruction:

  1. [writable] The mint to initialize.
§

TransferCheckedWithFee

Fields

§amount: u64

The amount of tokens to transfer.

§decimals: u8

Expected number of base 10 digits to the right of the decimal place.

§fee: u64

Expected fee assessed on this transfer, calculated off-chain based on the transfer_fee_basis_points and maximum_fee of the mint.

Transfer, providing expected mint information and fees

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The source account. Must include the TransferFeeAmount extension.
  2. [] The token mint. Must include the TransferFeeConfig extension.
  3. [writable] The destination account. Must include the TransferFeeAmount extension.
  4. [signer] The source account’s owner/delegate.
  • Multisignature owner/delegate
  1. [writable] The source account.
  2. [] The token mint.
  3. [writable] The destination account.
  4. [] The source account’s multisignature owner/delegate.
  5. ..4+M [signer] M signer accounts.
§

WithdrawWithheldTokensFromMint

Transfer all withheld tokens in the mint to an account. Signed by the mint’s withdraw withheld tokens authority.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [writable] The token mint. Must include the TransferFeeConfig extension.
  2. [writable] The fee receiver account. Must include the TransferFeeAmount extension associated with the provided mint.
  3. [signer] The mint’s withdraw_withheld_authority.
  • Multisignature owner/delegate
  1. [writable] The token mint.
  2. [writable] The destination account.
  3. [] The mint’s multisig withdraw_withheld_authority.
  4. ..3+M [signer] M signer accounts.
§

WithdrawWithheldTokensFromAccounts

Fields

§num_token_accounts: u8

Number of token accounts harvested

Transfer all withheld tokens to an account. Signed by the mint’s withdraw withheld tokens authority.

Accounts expected by this instruction:

  • Single owner/delegate
  1. [] The token mint. Must include the TransferFeeConfig extension.
  2. [writable] The fee receiver account. Must include the TransferFeeAmount extension and be associated with the provided mint.
  3. [signer] The mint’s withdraw_withheld_authority.
  4. ..3+N [writable] The source accounts to withdraw from.
  • Multisignature owner/delegate
  1. [] The token mint.
  2. [writable] The destination account.
  3. [] The mint’s multisig withdraw_withheld_authority.
  4. ..3+M [signer] M signer accounts. 3+M+1. ..3+M+N [writable] The source accounts to withdraw from.
§

HarvestWithheldTokensToMint

Permissionless instruction to transfer all withheld tokens to the mint.

Succeeds for frozen accounts.

Accounts provided should include the TransferFeeAmount extension. If not, the account is skipped.

Accounts expected by this instruction:

  1. [writable] The mint.
  2. ..1+N [writable] The source accounts to harvest from.
§

SetTransferFee

Fields

§transfer_fee_basis_points: u16

Amount of transfer collected as fees, expressed as basis points of the transfer amount

§maximum_fee: u64

Maximum fee assessed on transfers

Set transfer fee. Only supported for mints that include the TransferFeeConfig extension.

Accounts expected by this instruction:

  • Single authority
  1. [writable] The mint.
  2. [signer] The mint’s fee account owner.
  • Multisignature authority
  1. [writable] The mint.
  2. [] The mint’s multisignature fee account owner.
  3. ..2+M [signer] M signer accounts.

Implementations§

source§

impl TransferFeeInstruction

source

pub fn unpack(input: &[u8]) -> Result<(Self, &[u8]), ProgramError>

Unpacks a byte buffer into a TransferFeeInstruction

source

pub fn pack(&self, buffer: &mut Vec<u8>)

Packs a TransferFeeInstruction into a byte buffer.

Trait Implementations§

source§

impl Clone for TransferFeeInstruction

source§

fn clone(&self) -> TransferFeeInstruction

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 Debug for TransferFeeInstruction

source§

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

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

impl PartialEq for TransferFeeInstruction

source§

fn eq(&self, other: &TransferFeeInstruction) -> 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 Copy for TransferFeeInstruction

source§

impl StructuralPartialEq for TransferFeeInstruction

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> AbiExample for T

§

default fn example() -> T

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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