diff --git a/README.md b/README.md index 000c2d3..a52706e 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { 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(params.clone()), lookup_table_key: None, wait_transaction_confirmed: true, @@ -225,7 +225,7 @@ let nextblock_config = SwqosConfig::NextBlock( - If no custom URL is provided (`None`), the system will use the default endpoint for the specified `SwqosRegion` - This allows for maximum flexibility while maintaining backward compatibility -When using multiple MEV services, you need to use `Durable Nonce`. You need to initialize a `NonceCache` class (or write your own nonce management class), get the latest `nonce` value, and use it as the `nonce_account` and `current_nonce` when trading. +When using multiple MEV services, you need to use `Durable Nonce`. You need to initialize a `NonceCache` class (or write your own nonce management class), get the latest `nonce` value, and use it as the `durable_nonce` when trading. --- diff --git a/README_CN.md b/README_CN.md index a9865e2..59f163f 100755 --- a/README_CN.md +++ b/README_CN.md @@ -148,7 +148,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { 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(params.clone()), lookup_table_key: None, wait_transaction_confirmed: true, @@ -226,7 +226,7 @@ let nextblock_config = SwqosConfig::NextBlock( - 如果没有提供自定义 URL(`None`),系统将使用指定 `SwqosRegion` 的默认端点 - 这提供了最大的灵活性,同时保持向后兼容性 -当使用多个MEV服务时,需要使用`Durable Nonce`。你需要初始化`NonceCache`类(或者自行写一个管理nonce的类),获取最新的`nonce`值,并在交易的时候将`nonce_account`和`current_nonce`填入交易参数。 +当使用多个MEV服务时,需要使用`Durable Nonce`。你需要初始化`NonceCache`类(或者自行写一个管理nonce的类),获取最新的`nonce`值,并在交易的时候将`durable_nonce`填入交易参数。 --- diff --git a/docs/ADDRESS_LOOKUP_TABLE.md b/docs/ADDRESS_LOOKUP_TABLE.md index 8d6fdae..d1e72e4 100644 --- a/docs/ADDRESS_LOOKUP_TABLE.md +++ b/docs/ADDRESS_LOOKUP_TABLE.md @@ -52,7 +52,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { mint: mint_pubkey, sol_amount: buy_sol_amount, slippage_basis_points: Some(100), - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)), lookup_table_key: Some(lookup_table_key), // Include lookup table wait_transaction_confirmed: true, diff --git a/docs/ADDRESS_LOOKUP_TABLE_CN.md b/docs/ADDRESS_LOOKUP_TABLE_CN.md index 4f9ad0f..71aaf7b 100644 --- a/docs/ADDRESS_LOOKUP_TABLE_CN.md +++ b/docs/ADDRESS_LOOKUP_TABLE_CN.md @@ -52,7 +52,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { mint: mint_pubkey, sol_amount: buy_sol_amount, slippage_basis_points: Some(100), - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(PumpFunParams::from_trade(&trade_info, None)), lookup_table_key: Some(lookup_table_key), // 包含查找表 wait_transaction_confirmed: true, diff --git a/docs/NONCE_CACHE.md b/docs/NONCE_CACHE.md index 6e14ece..735ee4a 100644 --- a/docs/NONCE_CACHE.md +++ b/docs/NONCE_CACHE.md @@ -42,15 +42,12 @@ Get the latest nonce information from RPC: NonceCache::get_instance().fetch_nonce_info_use_rpc(&client.rpc).await?; // Or manually manage nonce // NonceCache::get_instance().update_nonce_info_partial(nonce_account, current_nonce, used); -let nonce_info = NonceCache::get_instance().get_nonce_info(); -let current_nonce = nonce_info.current_nonce; -let nonce_account = nonce_info.nonce_account; -println!("Current nonce: {}", current_nonce); +let durable_nonce = NonceCache::get_durable_nonce_info(); ``` ### 3. Use Nonce in Transactions -Set nonce parameters: nonce_account and current_nonce +Set nonce parameters: durable_nonce ```rust let buy_params = sol_trade_sdk::TradeBuyParams { @@ -58,7 +55,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { mint: mint_pubkey, sol_amount: buy_sol_amount, slippage_basis_points: Some(100), - 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, @@ -66,8 +63,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { close_wsol_ata: false, create_mint_ata: true, open_seed_optimize: false, - nonce_account: nonce_account, // Set nonce account - current_nonce: Some(current_nonce), // Set nonce value + durable_nonce: Some(durable_nonce), // Set durable nonce }; // Execute transaction diff --git a/docs/NONCE_CACHE_CN.md b/docs/NONCE_CACHE_CN.md index be1d7aa..36f8b5e 100644 --- a/docs/NONCE_CACHE_CN.md +++ b/docs/NONCE_CACHE_CN.md @@ -42,15 +42,12 @@ NonceCache::get_instance().init(Some(nonce_account_str.to_string())); NonceCache::get_instance().fetch_nonce_info_use_rpc(&client.rpc).await?; // 或者手动管理nonce // NonceCache::get_instance().update_nonce_info_partial(nonce_account, current_nonce, used); -let nonce_info = NonceCache::get_instance().get_nonce_info(); -let current_nonce = nonce_info.current_nonce; -let nonce_account = nonce_info.nonce_account; -println!("Current nonce: {}", current_nonce); +let durable_nonce = NonceCache::get_durable_nonce_info(); ``` ### 3. 在交易中使用 Nonce -设置 nonce 参数:nonce_account 和 recent_nonce +设置 nonce 参数:durable_nonce ```rust let buy_params = sol_trade_sdk::TradeBuyParams { @@ -58,7 +55,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { mint: mint_pubkey, sol_amount: buy_sol_amount, slippage_basis_points: Some(100), - 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, @@ -66,8 +63,7 @@ let buy_params = sol_trade_sdk::TradeBuyParams { close_wsol_ata: false, create_mint_ata: true, open_seed_optimize: false, - nonce_account: nonce_account, // 设置 nonce 账户 - current_nonce: Some(current_nonce), // 设置 nonce 值 + durable_nonce: Some(durable_nonce), // 设置 durable nonce }; // 执行交易 diff --git a/docs/TRADING_PARAMETERS.md b/docs/TRADING_PARAMETERS.md index 86be6d3..a9df819 100644 --- a/docs/TRADING_PARAMETERS.md +++ b/docs/TRADING_PARAMETERS.md @@ -21,7 +21,7 @@ The `TradeBuyParams` struct contains all parameters required for executing buy o | `mint` | `Pubkey` | ✅ | The public key of the token mint to purchase | | `sol_amount` | `u64` | ✅ | Amount of SOL to spend (in lamports) | | `slippage_basis_points` | `Option` | ❌ | Slippage tolerance in basis points (e.g., 100 = 1%, 500 = 5%) | -| `recent_blockhash` | `Hash` | ✅ | Recent blockhash for transaction validity | +| `recent_blockhash` | `Option` | ❌ | Recent blockhash for transaction validity | | `extension_params` | `Box` | ✅ | Protocol-specific parameters (PumpFunParams, PumpSwapParams, etc.) | ### Advanced Configuration Parameters @@ -34,8 +34,7 @@ The `TradeBuyParams` struct contains all parameters required for executing buy o | `close_wsol_ata` | `bool` | ✅ | Whether to close wSOL ATA after transaction | | `create_mint_ata` | `bool` | ✅ | Whether to create token mint ATA | | `open_seed_optimize` | `bool` | ✅ | Whether to use seed optimization for reduced CU consumption | -| `nonce_account` | `Option` | ❌ | nonce account | -| `current_nonce` | `Option` | ❌ | nonce value | +| `durable_nonce` | `Option` | ❌ | Durable nonce information containing nonce account and current nonce value | ## TradeSellParams @@ -50,7 +49,7 @@ The `TradeSellParams` struct contains all parameters required for executing sell | `mint` | `Pubkey` | ✅ | The public key of the token mint to sell | | `token_amount` | `u64` | ✅ | Amount of tokens to sell (in smallest token units) | | `slippage_basis_points` | `Option` | ❌ | Slippage tolerance in basis points (e.g., 100 = 1%, 500 = 5%) | -| `recent_blockhash` | `Hash` | ✅ | Recent blockhash for transaction validity | +| `recent_blockhash` | `Option` | ❌ | Recent blockhash for transaction validity | | `with_tip` | `bool` | ✅ | Whether to include tip in the transaction | | `extension_params` | `Box` | ✅ | Protocol-specific parameters (PumpFunParams, PumpSwapParams, etc.) | @@ -63,8 +62,7 @@ The `TradeSellParams` struct contains all parameters required for executing sell | `create_wsol_ata` | `bool` | ✅ | Whether to create wSOL Associated Token Account | | `close_wsol_ata` | `bool` | ✅ | Whether to close wSOL ATA after transaction | | `open_seed_optimize` | `bool` | ✅ | Whether to use seed optimization for reduced CU consumption | -| `nonce_account` | `Option` | ❌ | nonce account | -| `current_nonce` | `Option` | ❌ | nonce value | +| `durable_nonce` | `Option` | ❌ | Durable nonce information containing nonce account and current nonce value | ## Parameter Categories @@ -102,9 +100,8 @@ These parameters enable advanced optimizations: ### 🔄 Optional Parameters -When you need to use durable nonce, you need to fill in these two parameters: -- **nonce_account**: nonce account -- **current_nonce**: nonce value +When you need to use durable nonce, you need to fill in this parameter: +- **durable_nonce**: Durable nonce information containing nonce account and current nonce value ## Important Notes diff --git a/docs/TRADING_PARAMETERS_CN.md b/docs/TRADING_PARAMETERS_CN.md index ab45e8e..de2c1a9 100644 --- a/docs/TRADING_PARAMETERS_CN.md +++ b/docs/TRADING_PARAMETERS_CN.md @@ -21,7 +21,7 @@ | `mint` | `Pubkey` | ✅ | 要购买的代币 mint 公钥 | | `sol_amount` | `u64` | ✅ | 要花费的 SOL 数量(以 lamports 为单位) | | `slippage_basis_points` | `Option` | ❌ | 滑点容忍度(基点单位,例如 100 = 1%, 500 = 5%) | -| `recent_blockhash` | `Hash` | ✅ | 用于交易有效性的最新区块哈希 | +| `recent_blockhash` | `Option` | ❌ | 用于交易有效性的最新区块哈希 | | `extension_params` | `Box` | ✅ | 协议特定参数 (PumpFunParams, PumpSwapParams 等) | ### 高级配置参数 @@ -34,8 +34,7 @@ | `close_wsol_ata` | `bool` | ✅ | 交易后是否关闭 wSOL ATA | | `create_mint_ata` | `bool` | ✅ | 是否创建代币 mint ATA | | `open_seed_optimize` | `bool` | ✅ | 是否使用 seed 优化以减少 CU 消耗 | -| `nonce_account` | `Option` | ❌ | nonce 账户 | -| `current_nonce` | `Option` | ❌ | nonce 值 | +| `durable_nonce` | `Option` | ❌ | 持久 nonce 信息,包含 nonce 账户和当前 nonce 值 | ## TradeSellParams @@ -50,7 +49,7 @@ | `mint` | `Pubkey` | ✅ | 要出售的代币 mint 公钥 | | `token_amount` | `u64` | ✅ | 要出售的代币数量(最小代币单位) | | `slippage_basis_points` | `Option` | ❌ | 滑点容忍度(基点单位,例如 100 = 1%, 500 = 5%) | -| `recent_blockhash` | `Hash` | ✅ | 用于交易有效性的最新区块哈希 | +| `recent_blockhash` | `Option` | ❌ | 用于交易有效性的最新区块哈希 | | `with_tip` | `bool` | ✅ | 交易中是否包含小费 | | `extension_params` | `Box` | ✅ | 协议特定参数 (PumpFunParams, PumpSwapParams 等) | @@ -63,8 +62,7 @@ | `create_wsol_ata` | `bool` | ✅ | 是否创建 wSOL 关联代币账户 | | `close_wsol_ata` | `bool` | ✅ | 交易后是否关闭 wSOL ATA | | `open_seed_optimize` | `bool` | ✅ | 是否使用 seed 优化以减少 CU 消耗 | -| `nonce_account` | `Option` | ❌ | nonce 账户 | -| `current_nonce` | `Option` | ❌ | nonce 值 | +| `durable_nonce` | `Option` | ❌ | 持久 nonce 信息,包含 nonce 账户和当前 nonce 值 | ## 参数分类 @@ -102,9 +100,8 @@ ### 🔄 非必填参数 -当你需要使用 durable nonce 时,需要填入这两个参数: -- **nonce_account**: nonce 账户 -- **current_nonce**: nonce 值 +当你需要使用 durable nonce 时,需要填入这个参数: +- **durable_nonce**: 持久 nonce 信息,包含 nonce 账户和当前 nonce 值 ## 重要说明 diff --git a/examples/address_lookup/src/main.rs b/examples/address_lookup/src/main.rs index 35fb1a9..5e2216e 100644 --- a/examples/address_lookup/src/main.rs +++ b/examples/address_lookup/src/main.rs @@ -152,7 +152,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: Some(lookup_table_key), // you still need to update the AddressLookupTableCache wait_transaction_confirmed: true, @@ -160,8 +160,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?; diff --git a/examples/bonk_copy_trading/src/main.rs b/examples/bonk_copy_trading/src/main.rs index 9efd22b..e80c2e1 100644 --- a/examples/bonk_copy_trading/src/main.rs +++ b/examples/bonk_copy_trading/src/main.rs @@ -140,7 +140,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()> 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(BonkParams::from_trade(trade_info.clone())), lookup_table_key: None, wait_transaction_confirmed: true, @@ -148,8 +148,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> 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?; @@ -169,7 +168,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()> mint: mint_pubkey, token_amount: amount_token, slippage_basis_points: slippage_basis_points, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(BonkParams::from_trade(trade_info.clone())), lookup_table_key: None, wait_transaction_confirmed: true, @@ -177,8 +176,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()> close_wsol_ata: true, open_seed_optimize: false, with_tip: false, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?; diff --git a/examples/bonk_sniper_trading/src/main.rs b/examples/bonk_sniper_trading/src/main.rs index a197988..acbd815 100644 --- a/examples/bonk_sniper_trading/src/main.rs +++ b/examples/bonk_sniper_trading/src/main.rs @@ -103,7 +103,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult< 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(BonkParams::from_dev_trade(trade_info.clone())), lookup_table_key: None, wait_transaction_confirmed: true, @@ -111,8 +111,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> 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?; @@ -132,7 +131,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult< mint: mint_pubkey, token_amount: amount_token, slippage_basis_points: slippage_basis_points, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(BonkParams::immediate_sell( trade_info.base_token_program, trade_info.platform_config, @@ -145,8 +144,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult< close_wsol_ata: true, open_seed_optimize: false, with_tip: false, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?; diff --git a/examples/cli_trading/src/main.rs b/examples/cli_trading/src/main.rs index cb1aae1..371a805 100644 --- a/examples/cli_trading/src/main.rs +++ b/examples/cli_trading/src/main.rs @@ -608,7 +608,7 @@ async fn handle_buy_pumpfun( mint: mint_pubkey, sol_amount: sol_lamports, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(param), lookup_table_key: None, wait_transaction_confirmed: true, @@ -616,8 +616,7 @@ async fn handle_buy_pumpfun( close_wsol_ata: false, create_mint_ata: create_mint_ata, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.buy(buy_params).await { Ok(signature) => { @@ -657,7 +656,7 @@ async fn handle_buy_pumpswap( mint: mint_pubkey, sol_amount: sol_lamports, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(param), lookup_table_key: None, wait_transaction_confirmed: true, @@ -665,8 +664,7 @@ async fn handle_buy_pumpswap( close_wsol_ata: false, create_mint_ata: create_mint_ata, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.buy(buy_params).await { Ok(signature) => { @@ -705,7 +703,7 @@ async fn handle_buy_bonk( mint: mint_pubkey, sol_amount: sol_lamports, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(param), lookup_table_key: None, wait_transaction_confirmed: true, @@ -713,8 +711,7 @@ async fn handle_buy_bonk( close_wsol_ata: false, create_mint_ata: create_mint_ata, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.buy(buy_params).await { Ok(signature) => { @@ -757,7 +754,7 @@ async fn handle_buy_raydium_v4( mint: mint_pubkey, sol_amount: sol_lamports, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(param), lookup_table_key: None, wait_transaction_confirmed: true, @@ -765,8 +762,7 @@ async fn handle_buy_raydium_v4( close_wsol_ata: false, create_mint_ata: create_mint_ata, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.buy(buy_params).await { Ok(signature) => { @@ -809,7 +805,7 @@ async fn handle_buy_raydium_cpmm( mint: mint_pubkey, sol_amount: sol_lamports, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), extension_params: Box::new(param), lookup_table_key: None, wait_transaction_confirmed: true, @@ -817,8 +813,7 @@ async fn handle_buy_raydium_cpmm( close_wsol_ata: false, create_mint_ata: create_mint_ata, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.buy(buy_params).await { Ok(signature) => { @@ -971,7 +966,7 @@ async fn handle_sell_pumpfun( mint: mint_pubkey, token_amount: amount as u64, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), with_tip: false, extension_params: Box::new(param), lookup_table_key: None, @@ -979,8 +974,7 @@ async fn handle_sell_pumpfun( create_wsol_ata: true, close_wsol_ata: false, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.sell(sell_params).await { @@ -1023,7 +1017,7 @@ async fn handle_sell_pumpswap( mint: mint_pubkey, token_amount: amount as u64, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), with_tip: false, extension_params: Box::new(param), lookup_table_key: None, @@ -1031,8 +1025,7 @@ async fn handle_sell_pumpswap( create_wsol_ata: true, close_wsol_ata: false, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.sell(sell_params).await { Ok(signature) => { @@ -1074,7 +1067,7 @@ async fn handle_sell_bonk( mint: mint_pubkey, token_amount: amount as u64, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), with_tip: false, extension_params: Box::new(param), lookup_table_key: None, @@ -1082,8 +1075,7 @@ async fn handle_sell_bonk( create_wsol_ata: true, close_wsol_ata: false, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.sell(sell_params).await { Ok(signature) => { @@ -1128,7 +1120,7 @@ async fn handle_sell_raydium_v4( mint: mint_pubkey, token_amount: amount as u64, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), with_tip: false, extension_params: Box::new(param), lookup_table_key: None, @@ -1136,8 +1128,7 @@ async fn handle_sell_raydium_v4( create_wsol_ata: true, close_wsol_ata: false, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.sell(sell_params).await { Ok(signature) => { @@ -1182,7 +1173,7 @@ async fn handle_sell_raydium_cpmm( mint: mint_pubkey, token_amount: amount as u64, slippage_basis_points: slippage, - recent_blockhash: recent_blockhash, + recent_blockhash: Some(recent_blockhash), with_tip: false, extension_params: Box::new(param), lookup_table_key: None, @@ -1190,8 +1181,7 @@ async fn handle_sell_raydium_cpmm( create_wsol_ata: true, close_wsol_ata: false, open_seed_optimize: use_seed, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; match client.sell(sell_params).await { Ok(signature) => { diff --git a/examples/middleware_system/src/main.rs b/examples/middleware_system/src/main.rs index 82f8fb5..a2f7b60 100644 --- a/examples/middleware_system/src/main.rs +++ b/examples/middleware_system/src/main.rs @@ -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"); diff --git a/examples/nonce_cache/src/main.rs b/examples/nonce_cache/src/main.rs index 3d22aa7..f55b644 100644 --- a/examples/nonce_cache/src/main.rs +++ b/examples/nonce_cache/src/main.rs @@ -125,9 +125,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul 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 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); + let durable_nonce = NonceCache::get_durable_nonce_info(); // Buy tokens println!("Buying tokens from PumpFun..."); @@ -137,7 +135,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, @@ -145,8 +143,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: nonce_account, - current_nonce: Some(current_nonce), + durable_nonce: Some(durable_nonce), }; client.buy(buy_params).await?; diff --git a/examples/pumpfun_copy_trading/src/main.rs b/examples/pumpfun_copy_trading/src/main.rs index ec0f9ef..e4f644c 100644 --- a/examples/pumpfun_copy_trading/src/main.rs +++ b/examples/pumpfun_copy_trading/src/main.rs @@ -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?; diff --git a/examples/pumpfun_sniper_trading/src/main.rs b/examples/pumpfun_sniper_trading/src/main.rs index 7a5df3d..9c5c0af 100644 --- a/examples/pumpfun_sniper_trading/src/main.rs +++ b/examples/pumpfun_sniper_trading/src/main.rs @@ -97,7 +97,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR 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_dev_trade(&trade_info, None)), lookup_table_key: None, wait_transaction_confirmed: true, @@ -105,8 +105,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR 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?; @@ -126,7 +125,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR 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::immediate_sell(trade_info.creator_vault, true)), lookup_table_key: None, @@ -134,8 +133,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR create_wsol_ata: true, close_wsol_ata: true, open_seed_optimize: false, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?; diff --git a/examples/pumpswap_direct_trading/src/main.rs b/examples/pumpswap_direct_trading/src/main.rs index 7e87cdf..883f05d 100644 --- a/examples/pumpswap_direct_trading/src/main.rs +++ b/examples/pumpswap_direct_trading/src/main.rs @@ -27,7 +27,7 @@ async fn main() -> Result<(), Box> { 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( PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?, ), @@ -37,8 +37,7 @@ async fn main() -> Result<(), Box> { 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?; @@ -56,7 +55,7 @@ async fn main() -> Result<(), Box> { 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( PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?, @@ -66,8 +65,7 @@ async fn main() -> Result<(), Box> { create_wsol_ata: true, close_wsol_ata: true, open_seed_optimize: false, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?; diff --git a/examples/pumpswap_trading/src/main.rs b/examples/pumpswap_trading/src/main.rs index c13175c..c955bf5 100644 --- a/examples/pumpswap_trading/src/main.rs +++ b/examples/pumpswap_trading/src/main.rs @@ -173,7 +173,7 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) - 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(params.clone()), lookup_table_key: None, wait_transaction_confirmed: true, @@ -181,8 +181,7 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) - 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?; @@ -204,7 +203,7 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) - 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(params.clone()), lookup_table_key: None, @@ -212,8 +211,7 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) - create_wsol_ata: true, close_wsol_ata: true, open_seed_optimize: false, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?; diff --git a/examples/raydium_amm_v4_trading/src/main.rs b/examples/raydium_amm_v4_trading/src/main.rs index 23f37f1..3ce151f 100644 --- a/examples/raydium_amm_v4_trading/src/main.rs +++ b/examples/raydium_amm_v4_trading/src/main.rs @@ -141,7 +141,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent) 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(params), lookup_table_key: None, wait_transaction_confirmed: true, @@ -149,8 +149,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent) 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?; @@ -171,7 +170,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent) 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(params), lookup_table_key: None, @@ -179,8 +178,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent) create_wsol_ata: true, close_wsol_ata: true, open_seed_optimize: false, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?; diff --git a/examples/raydium_cpmm_trading/src/main.rs b/examples/raydium_cpmm_trading/src/main.rs index 385f2d6..d75d700 100644 --- a/examples/raydium_cpmm_trading/src/main.rs +++ b/examples/raydium_cpmm_trading/src/main.rs @@ -157,7 +157,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) -> 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(buy_params), lookup_table_key: None, wait_transaction_confirmed: true, @@ -165,8 +165,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) -> 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?; @@ -189,7 +188,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) -> 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(sell_params), lookup_table_key: None, @@ -197,8 +196,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) -> create_wsol_ata: true, close_wsol_ata: true, open_seed_optimize: false, - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?; diff --git a/examples/seed_trading/src/main.rs b/examples/seed_trading/src/main.rs index c64493b..d755c4a 100644 --- a/examples/seed_trading/src/main.rs +++ b/examples/seed_trading/src/main.rs @@ -28,7 +28,7 @@ async fn main() -> Result<(), Box> { 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( PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?, ), @@ -38,8 +38,7 @@ async fn main() -> Result<(), Box> { close_wsol_ata: true, create_mint_ata: true, open_seed_optimize: true, // ❗️❗️❗️❗️ open seed optimize - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.buy(buy_params).await?; @@ -65,7 +64,7 @@ async fn main() -> Result<(), Box> { 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( PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?, @@ -75,8 +74,7 @@ async fn main() -> Result<(), Box> { create_wsol_ata: true, close_wsol_ata: true, open_seed_optimize: true, // ❗️❗️❗️❗️ open seed optimize - nonce_account: None, - current_nonce: None, + durable_nonce: None, }; client.sell(sell_params).await?;