#[repr(u8)]pub enum TokenWrapInstruction {
CreateMint {
idempotent: bool,
},
Wrap {
amount: u64,
},
Unwrap {
amount: u64,
},
CloseStuckEscrow,
SyncMetadataToToken2022,
SyncMetadataToSplToken,
}Expand description
Instructions supported by the Token Wrap program
Variants§
CreateMint
Create a wrapped token mint. Assumes caller has pre-funded wrapped mint and backpointer account. Supports both directions:
- spl-token to token-2022
- token-2022 to spl-token
- token-2022 to token-2022 w/ new extensions
Accounts expected by this instruction:
[w]Unallocated wrapped mint account to create (PDA), address must be:get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)[w]Unallocated wrapped backpointer account to create (PDA)get_wrapped_mint_backpointer_address(wrapped_mint_address)[]Existing unwrapped mint[]System program[]SPL Token program for wrapped mint
Wrap
Wrap tokens
Move a user’s unwrapped tokens into an escrow account and mint the same number of wrapped tokens into the provided account.
Accounts expected by this instruction:
[w]Recipient wrapped token account[w]Wrapped mint, must be initialized, address must be:get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)[]Wrapped mint authority, address must be:get_wrapped_mint_authority(wrapped_mint)[]SPL Token program for unwrapped mint[]SPL Token program for wrapped mint[w]Unwrapped token account to wrapget_wrapped_mint_authority(wrapped_mint_address)[]Unwrapped token mint[w]Escrow of unwrapped tokens, address must be anATA:get_escrow_address(unwrapped_mint, unwrapped_token_program, wrapped_token_program)[s]Transfer authority on unwrapped token account. Not required to be a signer if it’s a multisig...8+M[s](Optional) M multisig signers on unwrapped token account.
Unwrap
Unwrap tokens
Burn user wrapped tokens and transfer the same amount of unwrapped tokens from the escrow account to the provided account.
Accounts expected by this instruction:
0. [w] Escrow of unwrapped tokens, address must be an ATA:
get_escrow_address(unwrapped_mint, unwrapped_token_program, wrapped_token_program)
[w]Recipient unwrapped tokens[]Wrapped mint authority, address must be:get_wrapped_mint_authority(wrapped_mint)[]Unwrapped token mint[]SPL Token program for wrapped mint[]SPL Token program for unwrapped mint[w]Wrapped token account to unwrap[w]Wrapped mint, address must be:get_wrapped_mint_address(unwrapped_mint_address, wrapped_token_program_id)[s]Transfer authority on wrapped token account..8+M[s](Optional) M multisig signers on wrapped token account
CloseStuckEscrow
Closes a stuck escrow ATA. This is for the edge case where an
unwrapped mint with a close authority is closed and then a new mint
is created at the same address but with a different size, leaving
the escrow ATA in a bad state.
This instruction will close the old escrow ATA, returning the lamports
to the destination account. It will only work if the current escrow has
different extensions than the mint. The client is then responsible
for calling create_associated_token_account to recreate it.
Accounts expected by this instruction:
[w]Escrow account to close (ATA)[w]Destination for lamports from closed account[]Unwrapped mint[]Wrapped mint[]Wrapped mint authority (PDA)[]Token-2022 program
SyncMetadataToToken2022
This instruction copies the metadata fields from an unwrapped mint to
its wrapped mint TokenMetadata extension.
Supports (unwrapped to wrapped):
- Token-2022 to Token-2022
- SPL-token to Token-2022
If source mint is a Token-2022, it must have a MetadataPointer and the
account it points to must be provided. If source mint is an SPL-Token,
the Metaplex PDA must be provided.
If the TokenMetadata extension on the wrapped mint if not present, it
will initialize it. The client is responsible for funding the wrapped
mint account with enough lamports to cover the rent for the
additional space required by the TokenMetadata extension and/or
metadata sync.
Accounts expected by this instruction:
[w]Wrapped mint[]Wrapped mint authority PDA[]Unwrapped mint[]Token-2022 program[](Optional) Source metadata account. Required if metadata pointer indicates external account.[](Optional) Owner program. Required when metadata account is owned by a third-party program.
SyncMetadataToSplToken
This instruction copies the metadata fields from an unwrapped mint to
its wrapped mint Metaplex metadata account.
Supports (unwrapped to wrapped):
- Token-2022 to SPL-token
- SPL-token to SPL-token
This instruction will create the Metaplex metadata account if it
doesn’t exist, or update it if it does. The wrapped_mint_authority
PDA must be pre-funded with enough lamports to cover the rent for
the Metaplex metadata account’s creation or updates, as it will
act as the payer for the Metaplex program CPI.
If source mint is a Token-2022, it must have a MetadataPointer and the
account it points to must be provided. If source mint is an SPL-Token,
the Metaplex PDA must be provided.
Accounts expected by this instruction:
[w]Metaplexmetadata account[w]Wrapped mint authority (PDA)[]Wrapped SPL Token mint[]Unwrapped mint[]MetaplexToken Metadata Program[]System program[]Rent sysvar[](Optional) Source metadata account. Required if unwrapped mint is an SPL-Token or, if a Token-2022, its metadata pointer indicates an external account.[](Optional) Owner program. Required when metadata account is owned by a third-party program.
Implementations§
Source§impl TokenWrapInstruction
impl TokenWrapInstruction
Sourcepub fn unpack(input: &[u8]) -> Result<Self, ProgramError>
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError>
Unpacks a byte array into a
TokenWrapInstruction.
Trait Implementations§
Source§impl Clone for TokenWrapInstruction
impl Clone for TokenWrapInstruction
Source§fn clone(&self) -> TokenWrapInstruction
fn clone(&self) -> TokenWrapInstruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TokenWrapInstruction
impl Debug for TokenWrapInstruction
Source§impl PartialEq for TokenWrapInstruction
impl PartialEq for TokenWrapInstruction
impl StructuralPartialEq for TokenWrapInstruction
Auto Trait Implementations§
impl Freeze for TokenWrapInstruction
impl RefUnwindSafe for TokenWrapInstruction
impl Send for TokenWrapInstruction
impl Sync for TokenWrapInstruction
impl Unpin for TokenWrapInstruction
impl UnwindSafe for TokenWrapInstruction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more