From 2ce7808135b959f0382abb1948f9616b94a0b566 Mon Sep 17 00:00:00 2001 From: ysq Date: Mon, 10 Nov 2025 16:44:18 +0800 Subject: [PATCH] feat: update GasFeeStrategy API calls with data size parameters --- README.md | 2 +- README_CN.md | 2 +- examples/address_lookup/src/main.rs | 2 +- examples/bonk_copy_trading/src/main.rs | 2 +- examples/bonk_sniper_trading/src/main.rs | 2 +- examples/cli_trading/src/main.rs | 20 +++++++++---------- examples/gas_fee_strategy/src/main.rs | 7 ++++++- .../src/main.rs | 2 +- examples/middleware_system/src/main.rs | 2 +- examples/nonce_cache/src/main.rs | 2 +- examples/pumpfun_copy_trading/src/main.rs | 2 +- examples/pumpfun_sniper_trading/src/main.rs | 2 +- examples/pumpswap_direct_trading/src/main.rs | 2 +- examples/pumpswap_trading/src/main.rs | 2 +- examples/raydium_amm_v4_trading/src/main.rs | 2 +- examples/raydium_cpmm_trading/src/main.rs | 2 +- examples/seed_trading/src/main.rs | 2 +- 17 files changed, 31 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index ed84f13..096d499 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ For detailed information about Gas Fee Strategy, see the [Gas Fee Strategy Refer // Create GasFeeStrategy instance let gas_fee_strategy = GasFeeStrategy::new(); // Set global strategy -gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); +gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); ``` #### 3. Build Trading Parameters diff --git a/README_CN.md b/README_CN.md index d0e54b4..5606898 100755 --- a/README_CN.md +++ b/README_CN.md @@ -146,7 +146,7 @@ let client = SolanaTrade::new(Arc::new(payer), trade_config).await; // 创建 GasFeeStrategy 实例 let gas_fee_strategy = GasFeeStrategy::new(); // 设置全局策略 -gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); +gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); ``` #### 3. 构建交易参数 diff --git a/examples/address_lookup/src/main.rs b/examples/address_lookup/src/main.rs index a2d8d9b..5af43b1 100644 --- a/examples/address_lookup/src/main.rs +++ b/examples/address_lookup/src/main.rs @@ -125,7 +125,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul fetch_address_lookup_table_account(&client.rpc, &lookup_table_key).await.ok(); let gas_fee_strategy = GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from PumpFun..."); diff --git a/examples/bonk_copy_trading/src/main.rs b/examples/bonk_copy_trading/src/main.rs index 9b0a62b..7bc38c0 100644 --- a/examples/bonk_copy_trading/src/main.rs +++ b/examples/bonk_copy_trading/src/main.rs @@ -125,7 +125,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()> let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from Bonk..."); diff --git a/examples/bonk_sniper_trading/src/main.rs b/examples/bonk_sniper_trading/src/main.rs index ea3cf3a..5ac165d 100644 --- a/examples/bonk_sniper_trading/src/main.rs +++ b/examples/bonk_sniper_trading/src/main.rs @@ -95,7 +95,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult< let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let token_type = if trade_info.quote_token_mint == sol_trade_sdk::constants::USD1_TOKEN_ACCOUNT { diff --git a/examples/cli_trading/src/main.rs b/examples/cli_trading/src/main.rs index 40006fc..531a268 100644 --- a/examples/cli_trading/src/main.rs +++ b/examples/cli_trading/src/main.rs @@ -615,7 +615,7 @@ async fn handle_buy_pumpfun( let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let buy_params = TradeBuyParams { dex_type: DexType::PumpFun, @@ -669,7 +669,7 @@ async fn handle_buy_pumpswap( let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let buy_params = TradeBuyParams { dex_type: DexType::PumpSwap, @@ -722,7 +722,7 @@ async fn handle_buy_bonk( let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let buy_params = TradeBuyParams { dex_type: DexType::Bonk, @@ -779,7 +779,7 @@ async fn handle_buy_raydium_v4( let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let buy_params = TradeBuyParams { dex_type: DexType::RaydiumAmmV4, @@ -836,7 +836,7 @@ async fn handle_buy_raydium_cpmm( let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let buy_params = TradeBuyParams { dex_type: DexType::RaydiumCpmm, @@ -1003,7 +1003,7 @@ async fn handle_sell_pumpfun( let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let sell_params = TradeSellParams { dex_type: DexType::PumpFun, @@ -1061,7 +1061,7 @@ async fn handle_sell_pumpswap( let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let sell_params = TradeSellParams { dex_type: DexType::PumpSwap, @@ -1118,7 +1118,7 @@ async fn handle_sell_bonk( let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let sell_params = TradeSellParams { dex_type: DexType::Bonk, @@ -1178,7 +1178,7 @@ async fn handle_sell_raydium_v4( let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let sell_params = TradeSellParams { dex_type: DexType::RaydiumAmmV4, @@ -1238,7 +1238,7 @@ async fn handle_sell_raydium_cpmm( let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let sell_params = TradeSellParams { dex_type: DexType::RaydiumCpmm, diff --git a/examples/gas_fee_strategy/src/main.rs b/examples/gas_fee_strategy/src/main.rs index 3ba62a9..f085d03 100644 --- a/examples/gas_fee_strategy/src/main.rs +++ b/examples/gas_fee_strategy/src/main.rs @@ -12,7 +12,7 @@ async fn main() { // Set global strategy println!("1. Set global strategy"); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Print all strategies println!("\n2. Print all strategies"); @@ -30,6 +30,8 @@ async fn main() { 500000, // cu_price 0.0, // buy_tip 0.0, // sell_tip + 256 * 1024, + 0, ); // Add high-low fee strategy for SwqosType::Jito on Buy @@ -42,6 +44,7 @@ async fn main() { 10 * 1_000_000, // high cu_price 0.001, // low tip 0.1, // high tip + 0, ); // Print all strategies @@ -56,6 +59,8 @@ async fn main() { 500000, // cu_price 0.0001, // buy_tip 0.0001, // sell_tip + 256 * 1024, + 0, ); // Print all strategies diff --git a/examples/meteora_damm_v2_direct_trading/src/main.rs b/examples/meteora_damm_v2_direct_trading/src/main.rs index d2e1664..cae7e46 100644 --- a/examples/meteora_damm_v2_direct_trading/src/main.rs +++ b/examples/meteora_damm_v2_direct_trading/src/main.rs @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { let mint_pubkey = Pubkey::from_str("PRVT6TB7uss3FrUd2D9xs2zqDBsa3GbMJMwCQsgmeta").unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from Metaora Damm V2..."); diff --git a/examples/middleware_system/src/main.rs b/examples/middleware_system/src/main.rs index b6eb4af..a57d782 100644 --- a/examples/middleware_system/src/main.rs +++ b/examples/middleware_system/src/main.rs @@ -81,7 +81,7 @@ async fn test_middleware() -> AnyResult<()> { let pool_address = Pubkey::from_str("539m4mVWt6iduB6W8rDGPMarzNCMesuqY5eUTiiYHAgR")?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let buy_params = sol_trade_sdk::TradeBuyParams { dex_type: DexType::PumpSwap, diff --git a/examples/nonce_cache/src/main.rs b/examples/nonce_cache/src/main.rs index db6ca43..836d176 100644 --- a/examples/nonce_cache/src/main.rs +++ b/examples/nonce_cache/src/main.rs @@ -125,7 +125,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul let durable_nonce = fetch_nonce_info(&client.rpc, nonce_account_str).await; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from PumpFun..."); diff --git a/examples/pumpfun_copy_trading/src/main.rs b/examples/pumpfun_copy_trading/src/main.rs index 08b4cfc..520d668 100644 --- a/examples/pumpfun_copy_trading/src/main.rs +++ b/examples/pumpfun_copy_trading/src/main.rs @@ -121,7 +121,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from PumpFun..."); diff --git a/examples/pumpfun_sniper_trading/src/main.rs b/examples/pumpfun_sniper_trading/src/main.rs index 018de5e..a3960e7 100644 --- a/examples/pumpfun_sniper_trading/src/main.rs +++ b/examples/pumpfun_sniper_trading/src/main.rs @@ -89,7 +89,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from PumpFun..."); diff --git a/examples/pumpswap_direct_trading/src/main.rs b/examples/pumpswap_direct_trading/src/main.rs index 432277d..fac1297 100644 --- a/examples/pumpswap_direct_trading/src/main.rs +++ b/examples/pumpswap_direct_trading/src/main.rs @@ -23,7 +23,7 @@ async fn main() -> Result<(), Box> { let mint_pubkey = Pubkey::from_str("pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn").unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from PumpSwap..."); diff --git a/examples/pumpswap_trading/src/main.rs b/examples/pumpswap_trading/src/main.rs index 0f8615c..d80c9cf 100644 --- a/examples/pumpswap_trading/src/main.rs +++ b/examples/pumpswap_trading/src/main.rs @@ -195,7 +195,7 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) - let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let is_sol = params.base_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT || params.quote_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT; diff --git a/examples/raydium_amm_v4_trading/src/main.rs b/examples/raydium_amm_v4_trading/src/main.rs index 9772662..b70c6fa 100644 --- a/examples/raydium_amm_v4_trading/src/main.rs +++ b/examples/raydium_amm_v4_trading/src/main.rs @@ -140,7 +140,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent) ); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from Raydium_amm_v4..."); diff --git a/examples/raydium_cpmm_trading/src/main.rs b/examples/raydium_cpmm_trading/src/main.rs index 5201df8..4d95373 100644 --- a/examples/raydium_cpmm_trading/src/main.rs +++ b/examples/raydium_cpmm_trading/src/main.rs @@ -130,7 +130,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) -> let recent_blockhash = client.rpc.get_latest_blockhash().await?; let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); let buy_params = RaydiumCpmmParams::from_pool_address_by_rpc(&client.rpc, &trade_info.pool_state).await?; diff --git a/examples/seed_trading/src/main.rs b/examples/seed_trading/src/main.rs index 2c8e302..59c9b9c 100644 --- a/examples/seed_trading/src/main.rs +++ b/examples/seed_trading/src/main.rs @@ -22,7 +22,7 @@ async fn main() -> Result<(), Box> { let mint_pubkey = Pubkey::from_str("2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv").unwrap(); let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new(); - gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001); + gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001, 256 * 1024, 0); // Buy tokens println!("Buying tokens from PumpSwap...");