refactor: optimize trading execution architecture and add wSOL management

- Simplify TradeExecutor interface by integrating middleware and swqos clients into params
- Refactor parallel execution module with dedicated buy/sell execute functions
- Add SOL wrapping/unwrapping functionality for wSOL management
- Remove redundant parameter passing in sell operations
- Delete example main.rs file
- Optimize transaction building with integrated parameter structures

BREAKING CHANGE: TradeExecutor interface simplified, middleware and swqos_clients now passed through params
This commit is contained in:
ysq
2025-09-09 17:02:24 +08:00
parent b9fa2f2f0f
commit 48a6c6283a
34 changed files with 586 additions and 853 deletions
+3 -17
View File
@@ -1,28 +1,14 @@
use std::sync::Arc;
use crate::{swqos::SwqosClient, trading::MiddlewareManager};
use super::params::{BuyParams, SellParams};
use anyhow::Result;
use solana_sdk::instruction::Instruction;
use super::params::{BuyParams, SellParams};
/// 交易执行器trait - 定义了所有交易协议都需要实现的核心方法
#[async_trait::async_trait]
pub trait TradeExecutor: Send + Sync {
/// 使用MEV服务执行买入交易
async fn buy_with_tip(
&self,
params: BuyParams,
swqos_clients: Vec<Arc<SwqosClient>>,
middleware_manager: Option<Arc<MiddlewareManager>>,
) -> Result<()>;
async fn buy_with_tip(&self, params: BuyParams) -> Result<()>;
/// 使用MEV服务执行卖出交易
async fn sell_with_tip(
&self,
params: SellParams,
swqos_clients: Vec<Arc<SwqosClient>>,
middleware_manager: Option<Arc<MiddlewareManager>>,
) -> Result<()>;
async fn sell_with_tip(&self, params: SellParams) -> Result<()>;
/// 获取协议名称
fn protocol_name(&self) -> &'static str;
}