feat(pumpfun): runtime V2 flag, buyback fee pool fix, legacy ix encoding

- Replace compile-time `pumpfun-v2` feature flag with runtime
  `TradeConfig::use_pumpfun_v2(bool)` for flexible V1/V2 switching
- Fix BUYBACK_FEE_RECIPIENTS pool: replace wrong addresses (was reusing
  standard pool + FEE_CONFIG) with official buyback pool from
  FEE_RECIPIENTS.md
- Fix legacy buy/buy_exact_sol_in ix data encoding: use 2-byte
  Option<bool> (option tag + value) matching official Pump SDK, 26 bytes
  total instead of broken 25
- Add `SwapParams.use_pumpfun_v2` field and wire through TradingClient
  buy/sell paths
- V2 instructions read `quote_mint` from `PumpFunParams` (not
  BondingCurveAccount which lacks the field)
- Fix `fetch_bonding_curve_account` to use BorshDeserialize instead of
  non-existent `decode_from_chain_account_data`
- Update all examples with `use_pumpfun_v2: false` field
- Update README with unified V1/V2 section showing both enabling methods
This commit is contained in:
0xfnzero
2026-05-09 07:15:07 +08:00
parent 0311a0b876
commit 1cc051a874
21 changed files with 841 additions and 513 deletions
+1
View File
@@ -176,6 +176,7 @@ async fn pumpfun_copy_trade_with_grpc(
gas_fee_strategy,
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
+1
View File
@@ -179,6 +179,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()>
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
+1
View File
@@ -147,6 +147,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult<
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
+5
View File
@@ -636,6 +636,7 @@ async fn handle_buy_pumpfun(
gas_fee_strategy: gas_fee_strategy,
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
match client.buy(buy_params).await {
@@ -692,6 +693,7 @@ async fn handle_buy_pumpswap(
gas_fee_strategy: gas_fee_strategy,
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
match client.buy(buy_params).await {
@@ -748,6 +750,7 @@ async fn handle_buy_bonk(
gas_fee_strategy: gas_fee_strategy,
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
match client.buy(buy_params).await {
@@ -808,6 +811,7 @@ async fn handle_buy_raydium_v4(
gas_fee_strategy: gas_fee_strategy,
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
match client.buy(buy_params).await {
@@ -869,6 +873,7 @@ async fn handle_buy_raydium_cpmm(
gas_fee_strategy: gas_fee_strategy,
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
match client.buy(buy_params).await {
@@ -51,6 +51,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
+1
View File
@@ -112,6 +112,7 @@ async fn test_middleware() -> AnyResult<()> {
gas_fee_strategy: gas_fee_strategy,
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
+1
View File
@@ -172,6 +172,7 @@ async fn pumpfun_copy_trade_with_grpc(
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
@@ -169,6 +169,7 @@ async fn pumpfun_copy_trade(e: sol_parser_sdk::core::events::PumpFunTradeEvent)
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
@@ -159,6 +159,7 @@ async fn pumpfun_sniper_trade(e: sol_parser_sdk::core::events::PumpFunTradeEvent
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
@@ -50,6 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
+1
View File
@@ -244,6 +244,7 @@ async fn pumpswap_trade_with_grpc(
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
@@ -181,6 +181,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent)
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
@@ -169,6 +169,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) ->
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;
+1
View File
@@ -50,6 +50,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
gas_fee_strategy: gas_fee_strategy.clone(),
simulate: false,
use_exact_sol_amount: None,
use_pumpfun_v2: false,
grpc_recv_us: None,
};
client.buy(buy_params).await?;