Files
sol-trade-sdk/src/swqos/mod.rs
T

57 lines
1.4 KiB
Rust
Raw Normal View History

2025-04-02 13:39:59 +08:00
pub mod common;
2025-07-06 22:06:44 +08:00
pub mod solana_rpc;
pub mod jito;
pub mod nextblock;
pub mod zeroslot;
pub mod nozomi;
pub mod types;
use solana_sdk::signature::Signature;
use solana_sdk::transaction::VersionedTransaction;
use tokio::sync::RwLock;
use anyhow::Result;
2025-02-13 20:44:20 +08:00
2025-04-02 13:39:59 +08:00
lazy_static::lazy_static! {
static ref TIP_ACCOUNT_CACHE: RwLock<Vec<String>> = RwLock::new(Vec::new());
2025-01-14 19:18:48 +08:00
}
2025-04-02 13:39:59 +08:00
#[derive(Debug, Clone, Copy)]
pub enum TradeType {
Create,
CreateAndBuy,
Buy,
Sell,
}
impl std::fmt::Display for TradeType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
TradeType::Create => "创建",
TradeType::CreateAndBuy => "创建并买入",
TradeType::Buy => "买入",
TradeType::Sell => "卖出",
};
write!(f, "{}", s)
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
2025-04-02 13:39:59 +08:00
pub enum ClientType {
Jito,
NextBlock,
ZeroSlot,
Nozomi,
Rpc,
2025-04-02 13:39:59 +08:00
}
2025-07-06 22:06:44 +08:00
pub type SwqosClient = dyn SwqosClientTrait + Send + Sync + 'static;
2025-04-02 13:39:59 +08:00
#[async_trait::async_trait]
2025-07-06 22:06:44 +08:00
pub trait SwqosClientTrait {
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<Signature>;
async fn send_transactions(&self, trade_type: TradeType, transactions: &Vec<VersionedTransaction>) -> Result<Vec<Signature>>;
fn get_tip_account(&self) -> Result<String>;
fn get_client_type(&self) -> ClientType;
2025-04-02 13:39:59 +08:00
}