From 57e4c5d22188310cc21d5b44f1cc7f6cffc58b42 Mon Sep 17 00:00:00 2001 From: 0xfnzero <0xfnzero@users.noreply.github.com> Date: Fri, 22 May 2026 08:56:20 +0800 Subject: [PATCH] Fix PumpFun V2 buyback fee mutability --- Cargo.toml | 2 +- src/instruction/pumpfun.rs | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8223b5f..5fffc22 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sol-trade-sdk" -version = "4.0.11" +version = "4.0.12" edition = "2021" authors = [ "William ", diff --git a/src/instruction/pumpfun.rs b/src/instruction/pumpfun.rs index adaa3d0..49e4b47 100644 --- a/src/instruction/pumpfun.rs +++ b/src/instruction/pumpfun.rs @@ -515,7 +515,7 @@ fn build_buy_v2(params: &SwapParams) -> Result> { AccountMeta::new_readonly(accounts::ASSOCIATED_TOKEN_PROGRAM, false), fee_recipient_meta, AccountMeta::new(associated_quote_fee_recipient, false), - AccountMeta::new_readonly(buyback_fee_recipient, false), + AccountMeta::new(buyback_fee_recipient, false), AccountMeta::new(associated_quote_buyback_fee_recipient, false), AccountMeta::new(bonding_curve_addr, false), AccountMeta::new(associated_base_bonding_curve, false), @@ -705,7 +705,7 @@ fn build_sell_v2(params: &SwapParams) -> Result> { AccountMeta::new_readonly(accounts::ASSOCIATED_TOKEN_PROGRAM, false), fee_recipient_meta, AccountMeta::new(associated_quote_fee_recipient, false), - AccountMeta::new_readonly(buyback_fee_recipient, false), + AccountMeta::new(buyback_fee_recipient, false), AccountMeta::new(associated_quote_buyback_fee_recipient, false), AccountMeta::new(bonding_curve_addr, false), AccountMeta::new(associated_base_bonding_curve, false), @@ -937,6 +937,24 @@ mod tests { } } + #[test] + fn pumpfun_v2_buyback_fee_recipient_is_writable() { + let mint = pump_mint(); + let mut params = swap_params_for_buy(mint, TOKEN_PROGRAM); + params.create_output_mint_ata = false; + + let buy_ix = build_buy_v2(¶ms).unwrap().pop().unwrap(); + assert!(global_constants::BUYBACK_FEE_RECIPIENTS.contains(&buy_ix.accounts[8].pubkey)); + assert!(buy_ix.accounts[8].is_writable); + + params.trade_type = crate::swqos::TradeType::Sell; + params.input_mint = mint; + params.output_mint = crate::constants::SOL_TOKEN_ACCOUNT; + let sell_ix = build_sell_v2(¶ms).unwrap().pop().unwrap(); + assert!(global_constants::BUYBACK_FEE_RECIPIENTS.contains(&sell_ix.accounts[8].pubkey)); + assert!(sell_ix.accounts[8].is_writable); + } + #[test] fn pumpfun_v1_sell_fixed_output_uses_min_sol_directly() { let mint = pump_mint();