feat: add flexible nonce parameter support

- Add nonce_account and current_nonce to trade parameters
- Remove hardcoded NonceCache dependency from nonce_manager
- Update examples and documentation for new nonce usage
- Fix nonce documentation errors and improve clarity
This commit is contained in:
ysq
2025-09-19 18:02:11 +08:00
parent a53038855e
commit 4907aafead
26 changed files with 214 additions and 71 deletions
+7 -3
View File
@@ -119,13 +119,15 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
let client = create_solana_trade_client().await?;
let mint_pubkey = trade_info.mint;
let slippage_basis_points = Some(100);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
// Setup nonce cache
let nonce_account_str = "use_your_nonce_account_here";
NonceCache::get_instance().init(Some(nonce_account_str.to_string()));
NonceCache::get_instance().fetch_nonce_info_use_rpc(&client.rpc).await?;
let last_nonce = NonceCache::get_instance().get_nonce_info().current_nonce;
println!("Last nonce: {}", last_nonce);
let current_nonce = NonceCache::get_instance().get_nonce_info().current_nonce;
let nonce_account = NonceCache::get_instance().get_nonce_info().nonce_account;
println!("current_nonce: {}", current_nonce);
// Buy tokens
println!("Buying tokens from PumpFun...");
@@ -135,7 +137,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
mint: mint_pubkey,
sol_amount: buy_sol_amount,
slippage_basis_points: slippage_basis_points,
recent_blockhash: last_nonce,
recent_blockhash: recent_blockhash,
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
lookup_table_key: None,
wait_transaction_confirmed: true,
@@ -143,6 +145,8 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
close_wsol_ata: false,
create_mint_ata: true,
open_seed_optimize: false,
nonce_account: nonce_account,
current_nonce: Some(current_nonce),
};
client.buy(buy_params).await?;