refactor: simplify trading parameters API and nonce handling

- Change recent_blockhash from required to optional parameter
- Replace separate nonce_account and current_nonce with unified durable_nonce
- Update all examples and documentation to reflect API changes
- Improve nonce cache usage pattern for better developer experience

BREAKING CHANGE: TradeBuyParams and TradeSellParams API has changed
- recent_blockhash is now Option<Hash> instead of Hash
- nonce_account and current_nonce fields replaced with durable_nonce: Option<DurableNonceInfo>
This commit is contained in:
ysq
2025-09-21 21:56:17 +08:00
parent b4769749f5
commit f8891f3147
21 changed files with 89 additions and 136 deletions
+4 -6
View File
@@ -128,7 +128,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: recent_blockhash,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)),
lookup_table_key: None,
wait_transaction_confirmed: true,
@@ -136,8 +136,7 @@ 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: None,
current_nonce: None,
durable_nonce: None,
};
client.buy(buy_params).await?;
@@ -157,7 +156,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
mint: mint_pubkey,
token_amount: amount_token,
slippage_basis_points: slippage_basis_points,
recent_blockhash: recent_blockhash,
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(PumpFunParams::from_trade(&trade_info, Some(true))),
lookup_table_key: None,
@@ -165,8 +164,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
create_wsol_ata: false,
close_wsol_ata: false,
open_seed_optimize: false,
nonce_account: None,
current_nonce: None,
durable_nonce: None,
};
client.sell(sell_params).await?;