#[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

Unpacks a byte buffer into a TransferFeeInstruction

Packs a TransferFeeInstruction into a byte buffer.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.