From 49843d8a2061220706260cf0eabd042cfeaa1f5f Mon Sep 17 00:00:00 2001 From: 0xfnzero <0xfnzero@users.noreply.github.com> Date: Fri, 8 May 2026 23:23:39 +0800 Subject: [PATCH] fix(pump): default token program to legacy SPL Token instead of Token-2022 The `effective_pump_mint_token_program` helper was defaulting to TOKEN_PROGRAM_2022 when `token_program` was Pubkey::default(), causing Anchor error 0xbbf (account owned by wrong program) for all legacy PumpFun coins whose ATAs are owned by the original Token Program. Fall back to TOKEN_PROGRAM (legacy) when no explicit token program is provided. Token-2022 must be set explicitly for create_v2 coins. Co-Authored-By: Claude Opus 4.7 --- src/instruction/pumpfun.rs | 2 +- src/trading/core/params/pumpfun.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/instruction/pumpfun.rs b/src/instruction/pumpfun.rs index 31b493b..6f33a75 100644 --- a/src/instruction/pumpfun.rs +++ b/src/instruction/pumpfun.rs @@ -34,7 +34,7 @@ use solana_sdk::{instruction::Instruction, pubkey::Pubkey, signer::Signer}; fn effective_pump_mint_token_program(protocol_params: &PumpFunParams) -> Pubkey { let tp = protocol_params.token_program; if tp == Pubkey::default() { - TOKEN_PROGRAM_2022 + crate::constants::TOKEN_PROGRAM // legacy SPL Token — safe default; Token-2022 must be explicit } else { tp } diff --git a/src/trading/core/params/pumpfun.rs b/src/trading/core/params/pumpfun.rs index 2d2b7bd..1212180 100644 --- a/src/trading/core/params/pumpfun.rs +++ b/src/trading/core/params/pumpfun.rs @@ -33,7 +33,7 @@ pub struct PumpFunParams { /// `Some(PDA(["creator-vault", fee_sharing_config]))` when pump-fees `SharingConfig` is **Active**; set by `from_mint_by_rpc` / [`refresh_fee_sharing_creator_vault_from_rpc`](Self::refresh_fee_sharing_creator_vault_from_rpc). pub fee_sharing_creator_vault_if_active: Option, /// SPL Token or Token-2022 program id owning the **mint** (from gRPC / parser / cache). - /// **`Pubkey::default()`**:ix 构建时使用 SDK 默认 **Token-2022**(与多数 Pump.fun 新发一致);显式传入 Legacy 或 Token-2022 id 可覆盖该默认值。 + /// **`Pubkey::default()`**:ix 构建时使用 SDK 默认 **Token Program (legacy)**;create_v2 代币需显式传入 `TOKEN_PROGRAM_2022`。 pub token_program: Pubkey, /// Whether to close token account when selling, only effective during sell operations pub close_token_account_when_sell: Option,