fix(pump): restore 26-byte legacy buy instruction data encoding

The refactored ix data encoder was producing 25-byte buy instructions
(1-byte track_volume), but the on-chain Pump program expects Anchor's
2-byte Option<bool> encoding (option tag + value), totaling 26 bytes.
The 1-byte shortfall caused instruction data under-read that manifested
as error 0xbbf (ConstraintOwner) for all legacy buy/buy_exact_sol_in.

Restore the 2-byte encoding: option tag (1u8) followed by the cashback
flag as the bool value, matching the pre-refactoring inline encoder.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
0xfnzero
2026-05-08 23:37:07 +08:00
co-authored by Claude Opus 4.7
parent ce8fb99626
commit b49c1c803e
2 changed files with 17 additions and 13 deletions
+4 -3
View File
@@ -12,7 +12,7 @@ use crate::{
instruction::pumpfun_ix_data::{
encode_pumpfun_buy_exact_quote_in_v2_ix_data, encode_pumpfun_buy_exact_sol_in_ix_data,
encode_pumpfun_buy_ix_data, encode_pumpfun_buy_v2_ix_data,
encode_pumpfun_sell_ix_data, encode_pumpfun_sell_v2_ix_data, TRACK_VOLUME_TRUE,
encode_pumpfun_sell_ix_data, encode_pumpfun_sell_v2_ix_data,
},
instruction::utils::pumpfun::{
accounts, get_bonding_curve_pda, get_bonding_curve_v2_pda,
@@ -230,15 +230,16 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
}
// ── Legacy buy path ──
let track_volume_val = if bonding_curve.is_cashback_coin { 1u8 } else { 0u8 };
let buy_data = if params.use_exact_sol_amount.unwrap_or(true) {
let min_tokens_out = calculate_with_slippage_sell(buy_token_amount, slippage_bp);
encode_pumpfun_buy_exact_sol_in_ix_data(
lamports_in,
min_tokens_out,
TRACK_VOLUME_TRUE,
track_volume_val,
)
} else {
encode_pumpfun_buy_ix_data(buy_token_amount, max_sol_cost, TRACK_VOLUME_TRUE)
encode_pumpfun_buy_ix_data(buy_token_amount, max_sol_cost, track_volume_val)
};
let bonding_curve_v2 = get_bonding_curve_v2_pda(&params.output_mint).ok_or_else(|| {