From 3132981f8513a47f133e51dd1dba054c1d4e430c Mon Sep 17 00:00:00 2001 From: Wood Date: Sun, 23 Nov 2025 21:02:55 +0800 Subject: [PATCH] feat: add dynamic tip update methods to GasFeeStrategy - Add update_buy_tip() method to dynamically update buy tip while keeping other parameters unchanged - Add update_sell_tip() method to dynamically update sell tip while keeping other parameters unchanged - Enable simple one-line tip updates for all configured SWQOS providers - Support percentage-based dynamic tip calculation in trading bots --- src/common/gas_fee_strategy.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/common/gas_fee_strategy.rs b/src/common/gas_fee_strategy.rs index 396157c..6f2457a 100644 --- a/src/common/gas_fee_strategy.rs +++ b/src/common/gas_fee_strategy.rs @@ -317,6 +317,34 @@ impl GasFeeStrategy { self.strategies.store(Arc::new(HashMap::new())); } + /// 动态更新买入小费(保持其他参数不变) + /// Dynamically update buy tip (keep other parameters unchanged) + pub fn update_buy_tip(&self, buy_tip: f64) { + self.strategies.rcu(|current_map| { + let mut new_map = (**current_map).clone(); + for ((swqos_type, trade_type, strategy_type), value) in new_map.iter_mut() { + if *trade_type == TradeType::Buy { + value.tip = buy_tip; + } + } + Arc::new(new_map) + }); + } + + /// 动态更新卖出小费(保持其他参数不变) + /// Dynamically update sell tip (keep other parameters unchanged) + pub fn update_sell_tip(&self, sell_tip: f64) { + self.strategies.rcu(|current_map| { + let mut new_map = (**current_map).clone(); + for ((swqos_type, trade_type, strategy_type), value) in new_map.iter_mut() { + if *trade_type == TradeType::Sell { + value.tip = sell_tip; + } + } + Arc::new(new_map) + }); + } + /// 打印所有策略。 /// Print all strategies pub fn print_all_strategies(&self) {