Merge commit '1be1674bf3d1ca4e1e77a7879f2991aeae53b009'

This commit is contained in:
ysq
2025-11-10 16:38:29 +08:00
3 changed files with 42 additions and 8 deletions
+23 -1
View File
@@ -21,6 +21,7 @@ pub struct GasFeeStrategyValue {
pub cu_limit: u32, pub cu_limit: u32,
pub cu_price: u64, pub cu_price: u64,
pub tip: f64, pub tip: f64,
pub data_size_limit: u32,
} }
#[derive(Clone)] #[derive(Clone)]
@@ -42,6 +43,8 @@ impl GasFeeStrategy {
cu_price: u64, cu_price: u64,
buy_tip: f64, buy_tip: f64,
sell_tip: f64, sell_tip: f64,
buy_data_size_limit: u32,
sell_data_size_limit: u32,
) { ) {
for swqos_type in SwqosType::values() { for swqos_type in SwqosType::values() {
if swqos_type.eq(&SwqosType::Default) { if swqos_type.eq(&SwqosType::Default) {
@@ -54,6 +57,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
buy_tip, buy_tip,
buy_data_size_limit,
); );
self.set( self.set(
swqos_type, swqos_type,
@@ -62,6 +66,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
sell_tip, sell_tip,
sell_data_size_limit,
); );
} }
self.set( self.set(
@@ -71,6 +76,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
0.0, 0.0,
buy_data_size_limit,
); );
self.set( self.set(
SwqosType::Default, SwqosType::Default,
@@ -79,6 +85,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
0.0, 0.0,
sell_data_size_limit,
); );
} }
@@ -93,6 +100,7 @@ impl GasFeeStrategy {
high_cu_price: u64, high_cu_price: u64,
low_tip: f64, low_tip: f64,
high_tip: f64, high_tip: f64,
data_size_limit: u32,
) { ) {
for swqos_type in swqos_types { for swqos_type in swqos_types {
self.del(*swqos_type, trade_type, GasFeeStrategyType::Normal); self.del(*swqos_type, trade_type, GasFeeStrategyType::Normal);
@@ -103,6 +111,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
high_cu_price, high_cu_price,
low_tip, low_tip,
data_size_limit,
); );
self.set( self.set(
*swqos_type, *swqos_type,
@@ -111,6 +120,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
low_cu_price, low_cu_price,
high_tip, high_tip,
data_size_limit,
); );
} }
} }
@@ -126,6 +136,7 @@ impl GasFeeStrategy {
high_cu_price: u64, high_cu_price: u64,
low_tip: f64, low_tip: f64,
high_tip: f64, high_tip: f64,
data_size_limit: u32,
) { ) {
if swqos_type.eq(&SwqosType::Default) { if swqos_type.eq(&SwqosType::Default) {
return; return;
@@ -138,6 +149,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
high_cu_price, high_cu_price,
low_tip, low_tip,
data_size_limit,
); );
self.set( self.set(
swqos_type, swqos_type,
@@ -146,6 +158,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
low_cu_price, low_cu_price,
high_tip, high_tip,
data_size_limit,
); );
} }
@@ -158,6 +171,8 @@ impl GasFeeStrategy {
cu_price: u64, cu_price: u64,
buy_tip: f64, buy_tip: f64,
sell_tip: f64, sell_tip: f64,
buy_data_size_limit: u32,
sell_data_size_limit: u32,
) { ) {
for swqos_type in swqos_types { for swqos_type in swqos_types {
self.del_all(*swqos_type, TradeType::Buy); self.del_all(*swqos_type, TradeType::Buy);
@@ -169,6 +184,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
buy_tip, buy_tip,
buy_data_size_limit,
); );
self.set( self.set(
*swqos_type, *swqos_type,
@@ -177,6 +193,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
sell_tip, sell_tip,
sell_data_size_limit,
); );
} }
} }
@@ -188,6 +205,8 @@ impl GasFeeStrategy {
cu_price: u64, cu_price: u64,
buy_tip: f64, buy_tip: f64,
sell_tip: f64, sell_tip: f64,
buy_data_size_limit: u32,
sell_data_size_limit: u32,
) { ) {
self.del_all(swqos_type, TradeType::Buy); self.del_all(swqos_type, TradeType::Buy);
self.del_all(swqos_type, TradeType::Sell); self.del_all(swqos_type, TradeType::Sell);
@@ -198,6 +217,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
buy_tip, buy_tip,
buy_data_size_limit,
); );
self.set( self.set(
swqos_type, swqos_type,
@@ -206,6 +226,7 @@ impl GasFeeStrategy {
cu_limit, cu_limit,
cu_price, cu_price,
sell_tip, sell_tip,
sell_data_size_limit,
); );
} }
@@ -217,6 +238,7 @@ impl GasFeeStrategy {
cu_limit: u32, cu_limit: u32,
cu_price: u64, cu_price: u64,
tip: f64, tip: f64,
data_size_limit: u32,
) { ) {
if strategy_type == GasFeeStrategyType::Normal { if strategy_type == GasFeeStrategyType::Normal {
self.del(swqos_type, trade_type, GasFeeStrategyType::HighTipLowCuPrice); self.del(swqos_type, trade_type, GasFeeStrategyType::HighTipLowCuPrice);
@@ -228,7 +250,7 @@ impl GasFeeStrategy {
let mut new_map = (**current_map).clone(); let mut new_map = (**current_map).clone();
new_map.insert( new_map.insert(
(swqos_type, trade_type, strategy_type), (swqos_type, trade_type, strategy_type),
GasFeeStrategyValue { cu_limit, cu_price, tip }, GasFeeStrategyValue { cu_limit, cu_price, tip, data_size_limit },
); );
Arc::new(new_map) Arc::new(new_map)
}); });
+8 -2
View File
@@ -380,7 +380,10 @@ impl SolanaTrade {
slippage_basis_points: params.slippage_basis_points, slippage_basis_points: params.slippage_basis_points,
address_lookup_table_account: params.address_lookup_table_account, address_lookup_table_account: params.address_lookup_table_account,
recent_blockhash: params.recent_blockhash, recent_blockhash: params.recent_blockhash,
data_size_limit: 256 * 1024, data_size_limit: params.gas_fee_strategy.get_strategies(TradeType::Buy)
.get(0)
.map(|(_, _, v)| v.data_size_limit)
.unwrap_or(256 * 1024),
wait_transaction_confirmed: params.wait_transaction_confirmed, wait_transaction_confirmed: params.wait_transaction_confirmed,
protocol_params: protocol_params.clone(), protocol_params: protocol_params.clone(),
open_seed_optimize: self.use_seed_optimize, // 使用全局seed优化配置 open_seed_optimize: self.use_seed_optimize, // 使用全局seed优化配置
@@ -484,7 +487,10 @@ impl SolanaTrade {
swqos_clients: self.swqos_clients.clone(), swqos_clients: self.swqos_clients.clone(),
middleware_manager: self.middleware_manager.clone(), middleware_manager: self.middleware_manager.clone(),
durable_nonce: params.durable_nonce, durable_nonce: params.durable_nonce,
data_size_limit: 0, data_size_limit: params.gas_fee_strategy.get_strategies(TradeType::Sell)
.get(0)
.map(|(_, _, v)| v.data_size_limit)
.unwrap_or(0),
create_input_mint_ata: false, create_input_mint_ata: false,
close_input_mint_ata: params.close_mint_token_ata, close_input_mint_ata: params.close_mint_token_ata,
create_output_mint_ata: params.create_output_token_ata, create_output_mint_ata: params.create_output_token_ata,
+11 -5
View File
@@ -41,14 +41,20 @@ pub fn compute_budget_instructions(
// Cache miss, generate new instructions // Cache miss, generate new instructions
let mut insts = SmallVec::<[Instruction; 3]>::new(); let mut insts = SmallVec::<[Instruction; 3]>::new();
if is_buy { // Only add data_size_limit instruction if > 0 and is_buy
if is_buy && data_size_limit > 0 {
insts.push(ComputeBudgetInstruction::set_loaded_accounts_data_size_limit(data_size_limit)); insts.push(ComputeBudgetInstruction::set_loaded_accounts_data_size_limit(data_size_limit));
} }
insts.extend([ // Only add compute unit price instruction if > 0
ComputeBudgetInstruction::set_compute_unit_price(unit_price), if unit_price > 0 {
ComputeBudgetInstruction::set_compute_unit_limit(unit_limit), insts.push(ComputeBudgetInstruction::set_compute_unit_price(unit_price));
]); }
// Only add compute unit limit instruction if > 0
if unit_limit > 0 {
insts.push(ComputeBudgetInstruction::set_compute_unit_limit(unit_limit));
}
// Store result in cache // Store result in cache
let insts_clone = insts.clone(); let insts_clone = insts.clone();