Files
sol-trade-sdk/src/instruction/token_account_setup.rs
T
0xfnzero 05ac079d6d release: update DEX protocol support for v4.0.9
Sync supported DEX IDLs from bitquery/solana-idl-lib, upgrade protocol builders, and keep trade submission hot paths free of RPC query calls.

Include exact-output coverage, token-account setup fixes for WSOL and stable pairs, and low-latency transaction build improvements.
2026-05-16 06:42:50 +08:00

48 lines
1.2 KiB
Rust

use solana_sdk::{instruction::Instruction, pubkey::Pubkey};
#[inline]
pub(crate) fn push_create_user_token_account(
instructions: &mut Vec<Instruction>,
payer: &Pubkey,
mint: &Pubkey,
token_program: &Pubkey,
use_seed: bool,
) {
instructions.extend(
crate::common::fast_fn::create_associated_token_account_idempotent_fast_use_seed(
payer,
payer,
mint,
token_program,
use_seed,
),
);
}
#[inline]
pub(crate) fn push_create_or_wrap_user_token_account(
instructions: &mut Vec<Instruction>,
payer: &Pubkey,
mint: &Pubkey,
token_program: &Pubkey,
amount: u64,
use_seed: bool,
) {
if *mint == crate::constants::WSOL_TOKEN_ACCOUNT {
instructions.extend(crate::trading::common::handle_wsol(payer, amount));
} else {
push_create_user_token_account(instructions, payer, mint, token_program, use_seed);
}
}
#[inline]
pub(crate) fn push_close_wsol_if_needed(
instructions: &mut Vec<Instruction>,
payer: &Pubkey,
mint: &Pubkey,
) {
if *mint == crate::constants::WSOL_TOKEN_ACCOUNT {
instructions.extend(crate::trading::common::close_wsol(payer));
}
}