refactor: Refactor SDK core architecture and trading parameter system
- Refactor SolanaTrade main class structure with improved modular design - Refactor trading parameter system: BuyParams/SellParams -> InternalBuyParams/InternalSellParams - Remove deprecated PriorityFee and related utility functions - Add SwqosSettings to replace legacy SwqosConfig - Add comprehensive technical documentation: • Address Lookup Table usage guide (EN/CN) • Nonce Cache mechanism documentation (EN/CN) • Trading Parameters documentation (EN/CN) - Refactor all example code to adapt to new API interfaces - Optimize public API design and code comments - Clean up redundant utility functions and type definitions Impact: 43 files changed, 2013 insertions(+), 1735 deletions(-)
This commit is contained in:
@@ -9,6 +9,7 @@ pub mod node1;
|
||||
pub mod flashblock;
|
||||
pub mod blockrazor;
|
||||
pub mod astralane;
|
||||
pub mod settings;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -107,14 +108,23 @@ pub enum SwqosRegion {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum SwqosConfig {
|
||||
Default(String),
|
||||
/// Jito(uuid, region, custom_url)
|
||||
Jito(String, SwqosRegion, Option<String>),
|
||||
/// NextBlock(api_token, region, custom_url)
|
||||
NextBlock(String, SwqosRegion, Option<String>),
|
||||
/// Bloxroute(api_token, region, custom_url)
|
||||
Bloxroute(String, SwqosRegion, Option<String>),
|
||||
/// Temporal(api_token, region, custom_url)
|
||||
Temporal(String, SwqosRegion, Option<String>),
|
||||
/// ZeroSlot(api_token, region, custom_url)
|
||||
ZeroSlot(String, SwqosRegion, Option<String>),
|
||||
/// Node1(api_token, region, custom_url)
|
||||
Node1(String, SwqosRegion, Option<String>),
|
||||
/// FlashBlock(api_token, region, custom_url)
|
||||
FlashBlock(String, SwqosRegion, Option<String>),
|
||||
/// BlockRazor(api_token, region, custom_url)
|
||||
BlockRazor(String, SwqosRegion, Option<String>),
|
||||
/// Astralane(api_token, region, custom_url)
|
||||
Astralane(String, SwqosRegion, Option<String>),
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
use crate::swqos::{SwqosClient, SwqosConfig};
|
||||
use solana_sdk::commitment_config::CommitmentConfig;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct SwqosSettings {
|
||||
pub swqos_config: SwqosConfig,
|
||||
pub swqos_client: Option<Arc<SwqosClient>>,
|
||||
pub unit_limit: u32,
|
||||
pub unit_price: u64,
|
||||
pub buy_tip_fee: f64,
|
||||
pub sell_tip_fee: f64,
|
||||
}
|
||||
|
||||
impl SwqosSettings {
|
||||
/// Create a new SwqosSettings
|
||||
/// swqos_config: SwqosConfig,
|
||||
/// unit_limit: u32,
|
||||
/// unit_price: u64,
|
||||
/// buy_tip_fee: f64,
|
||||
/// sell_tip_fee: f64,
|
||||
pub fn new(
|
||||
swqos_config: SwqosConfig,
|
||||
unit_limit: u32,
|
||||
unit_price: u64,
|
||||
buy_tip_fee: f64,
|
||||
sell_tip_fee: f64,
|
||||
) -> Self {
|
||||
Self { swqos_config, swqos_client: None, unit_limit, unit_price, buy_tip_fee, sell_tip_fee }
|
||||
}
|
||||
|
||||
pub fn setup_swqos_client(&mut self, rpc_url: String, commitment: CommitmentConfig) {
|
||||
let swqos_client =
|
||||
SwqosConfig::get_swqos_client(rpc_url, commitment, self.swqos_config.clone());
|
||||
self.swqos_client = Some(swqos_client);
|
||||
}
|
||||
|
||||
pub fn clone(&self) -> Self {
|
||||
Self {
|
||||
swqos_config: self.swqos_config.clone(),
|
||||
swqos_client: self.swqos_client.clone(),
|
||||
unit_limit: self.unit_limit,
|
||||
unit_price: self.unit_price,
|
||||
buy_tip_fee: self.buy_tip_fee,
|
||||
sell_tip_fee: self.sell_tip_fee,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user