feat: upgrade to v0.5.2
This commit is contained in:
@@ -17,7 +17,7 @@ use crate::{
|
||||
|
||||
const MAX_LOADED_ACCOUNTS_DATA_SIZE_LIMIT: u32 = 256 * 1024;
|
||||
|
||||
/// 通用交易执行器实现
|
||||
/// Generic trade executor implementation
|
||||
pub struct GenericTradeExecutor {
|
||||
instruction_builder: Arc<dyn InstructionBuilder>,
|
||||
protocol_name: &'static str,
|
||||
@@ -46,8 +46,8 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
return Err(anyhow!("RPC is not set"));
|
||||
}
|
||||
let rpc = params.rpc.as_ref().unwrap().clone();
|
||||
let mut timer = TradeTimer::new("构建买入交易指令");
|
||||
// 构建指令
|
||||
let mut timer = TradeTimer::new("Building buy transaction instructions");
|
||||
// Build instructions
|
||||
let instructions = self.instruction_builder.build_buy_instructions(¶ms).await?;
|
||||
let final_instructions = match middleware_manager.clone() {
|
||||
Some(middleware_manager) => middleware_manager
|
||||
@@ -58,9 +58,9 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
)?,
|
||||
None => instructions,
|
||||
};
|
||||
timer.stage("构建rpc交易指令");
|
||||
timer.stage("Building RPC transaction instructions");
|
||||
|
||||
// 构建交易
|
||||
// Build transaction
|
||||
let transaction = build_rpc_transaction(
|
||||
params.payer.clone(),
|
||||
¶ms.priority_fee,
|
||||
@@ -73,13 +73,13 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
true,
|
||||
)
|
||||
.await?;
|
||||
timer.stage("rpc提交确认");
|
||||
timer.stage("RPC submission confirmation");
|
||||
|
||||
// 发送交易
|
||||
// Send transaction
|
||||
if params.wait_transaction_confirmed {
|
||||
rpc.send_and_confirm_transaction(&transaction).await?;
|
||||
} else {
|
||||
// 异步发送交易
|
||||
// Send transaction asynchronously
|
||||
rpc.send_transaction(&transaction).await?;
|
||||
}
|
||||
timer.finish();
|
||||
@@ -95,9 +95,9 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
if params.data_size_limit == 0 {
|
||||
params.data_size_limit = MAX_LOADED_ACCOUNTS_DATA_SIZE_LIMIT;
|
||||
}
|
||||
let timer = TradeTimer::new("构建买入交易指令");
|
||||
let timer = TradeTimer::new("Building buy transaction instructions");
|
||||
|
||||
// 验证参数 - 转换为BuyParams进行验证
|
||||
// Validate parameters - convert to BuyParams for validation
|
||||
let buy_params = BuyParams {
|
||||
rpc: params.rpc,
|
||||
payer: params.payer.clone(),
|
||||
@@ -112,7 +112,7 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
protocol_params: params.protocol_params.clone(),
|
||||
};
|
||||
|
||||
// 构建指令
|
||||
// Build instructions
|
||||
let instructions = self.instruction_builder.build_buy_instructions(&buy_params).await?;
|
||||
let final_instructions = match middleware_manager.clone() {
|
||||
Some(middleware_manager) => middleware_manager
|
||||
@@ -126,7 +126,7 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
|
||||
timer.finish();
|
||||
|
||||
// 并行执行交易
|
||||
// Execute transactions in parallel
|
||||
parallel_execute_with_tips(
|
||||
params.swqos_clients,
|
||||
params.payer,
|
||||
@@ -155,9 +155,9 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
return Err(anyhow!("RPC is not set"));
|
||||
}
|
||||
let rpc = params.rpc.as_ref().unwrap().clone();
|
||||
let mut timer = TradeTimer::new("构建卖出交易指令");
|
||||
let mut timer = TradeTimer::new("Building sell transaction instructions");
|
||||
|
||||
// 构建指令
|
||||
// Build instructions
|
||||
let instructions = self.instruction_builder.build_sell_instructions(¶ms).await?;
|
||||
let final_instructions = match middleware_manager.clone() {
|
||||
Some(middleware_manager) => middleware_manager
|
||||
@@ -168,9 +168,9 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
)?,
|
||||
None => instructions,
|
||||
};
|
||||
timer.stage("卖出交易指令");
|
||||
timer.stage("Sell transaction instructions");
|
||||
|
||||
// 构建交易
|
||||
// Build transaction
|
||||
let transaction = build_sell_transaction(
|
||||
params.payer.clone(),
|
||||
¶ms.priority_fee,
|
||||
@@ -182,9 +182,9 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
false,
|
||||
)
|
||||
.await?;
|
||||
timer.stage("卖出交易签名");
|
||||
timer.stage("Sell transaction signing");
|
||||
|
||||
// 发送交易
|
||||
// Send transaction
|
||||
if params.wait_transaction_confirmed {
|
||||
rpc.send_and_confirm_transaction(&transaction).await?;
|
||||
} else {
|
||||
@@ -200,9 +200,9 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
params: SellWithTipParams,
|
||||
middleware_manager: Option<Arc<MiddlewareManager>>,
|
||||
) -> Result<()> {
|
||||
let timer = TradeTimer::new("构建卖出交易指令");
|
||||
let timer = TradeTimer::new("Building sell transaction instructions");
|
||||
|
||||
// 转换为SellParams进行指令构建
|
||||
// Convert to SellParams for instruction building
|
||||
let sell_params = SellParams {
|
||||
rpc: params.rpc,
|
||||
payer: params.payer.clone(),
|
||||
@@ -216,7 +216,7 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
protocol_params: params.protocol_params.clone(),
|
||||
};
|
||||
|
||||
// 构建指令
|
||||
// Build instructions
|
||||
let instructions = self.instruction_builder.build_sell_instructions(&sell_params).await?;
|
||||
let final_instructions = match middleware_manager.clone() {
|
||||
Some(middleware_manager) => middleware_manager
|
||||
@@ -230,7 +230,7 @@ impl TradeExecutor for GenericTradeExecutor {
|
||||
|
||||
timer.finish();
|
||||
|
||||
// 并行执行交易
|
||||
// Execute transactions in parallel
|
||||
parallel_execute_with_tips(
|
||||
params.swqos_clients,
|
||||
params.payer,
|
||||
|
||||
Reference in New Issue
Block a user