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
+2 -3
View File
@@ -89,7 +89,7 @@ async fn test_middleware() -> AnyResult<()> {
mint: mint_pubkey,
sol_amount: buy_sol_cost,
slippage_basis_points: slippage_basis_points,
recent_blockhash: recent_blockhash,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(
PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool_address).await?,
),
@@ -99,8 +99,7 @@ async fn test_middleware() -> AnyResult<()> {
close_wsol_ata: true,
create_mint_ata: true,
open_seed_optimize: false,
nonce_account: None,
current_nonce: None,
durable_nonce: None,
};
client.buy(buy_params).await?;
println!("tip: This transaction will not succeed because we're using a test account. You can modify the code to initialize the payer with your own private key");