update swqos config
This commit is contained in:
@@ -90,13 +90,15 @@ let priority_fee = PriorityFee {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Configure multiple swqos in single region, can send transactions concurrently
|
// Configure multiple swqos in single region, can send transactions concurrently
|
||||||
let swqos_configs = vec![
|
|
||||||
SwqosConfig::new(None, None, SwqosType::Jito, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::ZeroSlot, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::Temporal, SwqosRegion::Frankfurt),
|
|
||||||
];
|
|
||||||
|
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
|
let swqos_configs = vec![
|
||||||
|
SwqosConfig::Jito(SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
|
];
|
||||||
|
|
||||||
// Define sdk configuration
|
// Define sdk configuration
|
||||||
let trade_config = TradeConfig {
|
let trade_config = TradeConfig {
|
||||||
@@ -302,13 +304,15 @@ use solana_client::rpc_client::RpcClient;
|
|||||||
use sol_trade_sdk::{common::{Cluster, PriorityFee}, SolanaTrade};
|
use sol_trade_sdk::{common::{Cluster, PriorityFee}, SolanaTrade};
|
||||||
|
|
||||||
// Configure multiple swqos in single region, can send transactions concurrently
|
// Configure multiple swqos in single region, can send transactions concurrently
|
||||||
let swqos_configs = vec![
|
|
||||||
SwqosConfig::new(None, None, SwqosType::Jito, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::ZeroSlot, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::Temporal, SwqosRegion::Frankfurt),
|
|
||||||
];
|
|
||||||
|
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
|
let swqos_configs = vec![
|
||||||
|
SwqosConfig::Jito(SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
|
];
|
||||||
|
|
||||||
// Define sdk configuration
|
// Define sdk configuration
|
||||||
let trade_config = TradeConfig {
|
let trade_config = TradeConfig {
|
||||||
|
|||||||
+16
-12
@@ -90,13 +90,15 @@ let priority_fee = PriorityFee {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 单区域配置多个swqos,可同时发送交易
|
// 单区域配置多个swqos,可同时发送交易
|
||||||
let swqos_configs = vec![
|
|
||||||
SwqosConfig::new(None, None, SwqosType::Jito, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::ZeroSlot, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::Temporal, SwqosRegion::Frankfurt),
|
|
||||||
];
|
|
||||||
|
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
|
let swqos_configs = vec![
|
||||||
|
SwqosConfig::Jito(SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
|
];
|
||||||
|
|
||||||
// 定义sdk配置参数
|
// 定义sdk配置参数
|
||||||
let trade_config = TradeConfig {
|
let trade_config = TradeConfig {
|
||||||
@@ -302,13 +304,15 @@ use solana_client::rpc_client::RpcClient;
|
|||||||
use sol_trade_sdk::{common::{Cluster, PriorityFee}, SolanaTrade};
|
use sol_trade_sdk::{common::{Cluster, PriorityFee}, SolanaTrade};
|
||||||
|
|
||||||
// 单区域配置多个swqos,可同时发送交易
|
// 单区域配置多个swqos,可同时发送交易
|
||||||
let swqos_configs = vec![
|
|
||||||
SwqosConfig::new(None, None, SwqosType::Jito, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::ZeroSlot, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token".to_string()), SwqosType::Temporal, SwqosRegion::Frankfurt),
|
|
||||||
];
|
|
||||||
|
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
|
let swqos_configs = vec![
|
||||||
|
SwqosConfig::Jito(SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
|
];
|
||||||
|
|
||||||
// 定义sdk配置参数
|
// 定义sdk配置参数
|
||||||
let trade_config = TradeConfig {
|
let trade_config = TradeConfig {
|
||||||
|
|||||||
+9
-47
@@ -29,6 +29,8 @@ use constants::trade_type::{COPY_BUY, SNIPER_BUY};
|
|||||||
use constants::trade_platform::{PUMPFUN, PUMPFUN_SWAP};
|
use constants::trade_platform::{PUMPFUN, PUMPFUN_SWAP};
|
||||||
use accounts::BondingCurveAccount;
|
use accounts::BondingCurveAccount;
|
||||||
|
|
||||||
|
use crate::swqos::bloxroute::BloxrouteClient;
|
||||||
|
use crate::swqos::SwqosConfig;
|
||||||
use crate::swqos::SwqosType;
|
use crate::swqos::SwqosType;
|
||||||
use crate::swqos::jito::JitoClient;
|
use crate::swqos::jito::JitoClient;
|
||||||
use crate::swqos::nextblock::NextBlockClient;
|
use crate::swqos::nextblock::NextBlockClient;
|
||||||
@@ -81,58 +83,18 @@ impl SolanaTrade {
|
|||||||
let priority_fee = trade_config.priority_fee.clone();
|
let priority_fee = trade_config.priority_fee.clone();
|
||||||
let commitment = trade_config.commitment.clone();
|
let commitment = trade_config.commitment.clone();
|
||||||
|
|
||||||
let rpc = SolanaRpcClient::new_with_commitment(
|
|
||||||
rpc_url.clone(),
|
|
||||||
commitment
|
|
||||||
);
|
|
||||||
let rpc = Arc::new(rpc);
|
|
||||||
|
|
||||||
let mut swqos_clients: Vec<Arc<SwqosClient>> = vec![];
|
let mut swqos_clients: Vec<Arc<SwqosClient>> = vec![];
|
||||||
|
|
||||||
for swqos in swqos_configs {
|
for swqos in swqos_configs {
|
||||||
match swqos.swqos_type {
|
let swqos_client = SwqosConfig::get_swqos_client(rpc_url.clone(), commitment.clone(), swqos.clone());
|
||||||
SwqosType::Jito => {
|
swqos_clients.push(swqos_client);
|
||||||
let jito_client = JitoClient::new(
|
|
||||||
rpc_url.clone(),
|
|
||||||
swqos.endpoint,
|
|
||||||
swqos.auth_token
|
|
||||||
);
|
|
||||||
swqos_clients.push(Arc::new(jito_client));
|
|
||||||
}
|
|
||||||
SwqosType::NextBlock => {
|
|
||||||
let nextblock_client = NextBlockClient::new(
|
|
||||||
rpc_url.clone(),
|
|
||||||
swqos.endpoint,
|
|
||||||
swqos.auth_token
|
|
||||||
);
|
|
||||||
swqos_clients.push(Arc::new(nextblock_client));
|
|
||||||
}
|
|
||||||
SwqosType::ZeroSlot => {
|
|
||||||
let zeroslot_client = ZeroSlotClient::new(
|
|
||||||
rpc_url.clone(),
|
|
||||||
swqos.endpoint,
|
|
||||||
swqos.auth_token
|
|
||||||
);
|
|
||||||
swqos_clients.push(Arc::new(zeroslot_client));
|
|
||||||
}
|
|
||||||
SwqosType::Temporal => {
|
|
||||||
let temporal_client = TemporalClient::new(
|
|
||||||
rpc_url.clone(),
|
|
||||||
swqos.endpoint,
|
|
||||||
swqos.auth_token
|
|
||||||
);
|
|
||||||
swqos_clients.push(Arc::new(temporal_client));
|
|
||||||
}
|
|
||||||
SwqosType::Rpc => {
|
|
||||||
let rpc_client = SolRpcClient::new(rpc.clone());
|
|
||||||
swqos_clients.push(Arc::new(rpc_client));
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
println!("Unsupported swqos type: {:?}", swqos.swqos_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let rpc = Arc::new(SolanaRpcClient::new_with_commitment(
|
||||||
|
rpc_url.clone(),
|
||||||
|
commitment
|
||||||
|
));
|
||||||
|
|
||||||
let instance = Self {
|
let instance = Self {
|
||||||
payer,
|
payer,
|
||||||
rpc,
|
rpc,
|
||||||
|
|||||||
+25
-18
@@ -245,13 +245,16 @@ async fn test_raydium_with_grpc() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
async fn test_pumpfun_sniper() -> AnyResult<()> {
|
async fn test_pumpfun_sniper() -> AnyResult<()> {
|
||||||
// 创建一个随机账户作为交易者
|
// 创建一个随机账户作为交易者
|
||||||
let payer = Keypair::new();
|
let payer = Keypair::new();
|
||||||
let swqos_configs = vec![
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for jito".to_string()), SwqosType::Jito, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for zeroslot".to_string()), SwqosType::ZeroSlot, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for temporal".to_string()), SwqosType::Temporal, SwqosRegion::Frankfurt),
|
|
||||||
];
|
|
||||||
|
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
|
let swqos_configs = vec![
|
||||||
|
SwqosConfig::Jito(SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
|
];
|
||||||
|
|
||||||
// Define cluster configuration
|
// Define cluster configuration
|
||||||
let trade_config = TradeConfig {
|
let trade_config = TradeConfig {
|
||||||
@@ -291,13 +294,15 @@ async fn test_pumpfun_sniper() -> AnyResult<()> {
|
|||||||
async fn test_pumpfun() -> AnyResult<()> {
|
async fn test_pumpfun() -> AnyResult<()> {
|
||||||
let payer = Keypair::new();
|
let payer = Keypair::new();
|
||||||
|
|
||||||
let swqos_configs = vec![
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for jito".to_string()), SwqosType::Jito, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for zeroslot".to_string()), SwqosType::ZeroSlot, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for temporal".to_string()), SwqosType::Temporal, SwqosRegion::Frankfurt),
|
|
||||||
];
|
|
||||||
|
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
|
let swqos_configs = vec![
|
||||||
|
SwqosConfig::Jito(SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
|
];
|
||||||
|
|
||||||
// Define cluster configuration
|
// Define cluster configuration
|
||||||
let trade_config = TradeConfig {
|
let trade_config = TradeConfig {
|
||||||
@@ -362,13 +367,15 @@ async fn test_pumpfun() -> AnyResult<()> {
|
|||||||
async fn test_pumpswap() -> AnyResult<()> {
|
async fn test_pumpswap() -> AnyResult<()> {
|
||||||
let payer = Keypair::new();
|
let payer = Keypair::new();
|
||||||
|
|
||||||
let swqos_configs = vec![
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for jito".to_string()), SwqosType::Jito, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for zeroslot".to_string()), SwqosType::ZeroSlot, SwqosRegion::Frankfurt),
|
|
||||||
SwqosConfig::new(None, Some("your auth_token for temporal".to_string()), SwqosType::Temporal, SwqosRegion::Frankfurt),
|
|
||||||
];
|
|
||||||
|
|
||||||
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
let rpc_url = "https://mainnet.helius-rpc.com/?api-key=xxxxxx".to_string();
|
||||||
|
let swqos_configs = vec![
|
||||||
|
SwqosConfig::Jito(SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::NextBlock("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Bloxroute("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::ZeroSlot("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Temporal("your api_token".to_string(), SwqosRegion::Frankfurt),
|
||||||
|
SwqosConfig::Default(rpc_url.clone()),
|
||||||
|
];
|
||||||
|
|
||||||
// Define cluster configuration
|
// Define cluster configuration
|
||||||
let trade_config = TradeConfig {
|
let trade_config = TradeConfig {
|
||||||
|
|||||||
+74
-14
@@ -6,12 +6,14 @@ pub mod zeroslot;
|
|||||||
pub mod temporal;
|
pub mod temporal;
|
||||||
pub mod bloxroute;
|
pub mod bloxroute;
|
||||||
|
|
||||||
use solana_sdk::transaction::VersionedTransaction;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use solana_sdk::{commitment_config::CommitmentConfig, transaction::VersionedTransaction};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::constants::swqos::{SWQOS_ENDPOINTS_BLOX, SWQOS_ENDPOINTS_JITO, SWQOS_ENDPOINTS_NEXTBLOCK, SWQOS_ENDPOINTS_TEMPORAL, SWQOS_ENDPOINTS_ZERO_SLOT};
|
use crate::{common::SolanaRpcClient, constants::swqos::{SWQOS_ENDPOINTS_BLOX, SWQOS_ENDPOINTS_JITO, SWQOS_ENDPOINTS_NEXTBLOCK, SWQOS_ENDPOINTS_TEMPORAL, SWQOS_ENDPOINTS_ZERO_SLOT}, swqos::{bloxroute::BloxrouteClient, jito::JitoClient, nextblock::NextBlockClient, solana_rpc::SolRpcClient, temporal::TemporalClient, zeroslot::ZeroSlotClient}};
|
||||||
|
|
||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
static ref TIP_ACCOUNT_CACHE: RwLock<Vec<String>> = RwLock::new(Vec::new());
|
static ref TIP_ACCOUNT_CACHE: RwLock<Vec<String>> = RwLock::new(Vec::new());
|
||||||
@@ -44,7 +46,7 @@ pub enum SwqosType {
|
|||||||
ZeroSlot,
|
ZeroSlot,
|
||||||
Temporal,
|
Temporal,
|
||||||
Bloxroute,
|
Bloxroute,
|
||||||
Rpc,
|
Default,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type SwqosClient = dyn SwqosClientTrait + Send + Sync + 'static;
|
pub type SwqosClient = dyn SwqosClientTrait + Send + Sync + 'static;
|
||||||
@@ -69,25 +71,83 @@ pub enum SwqosRegion {
|
|||||||
Default,
|
Default,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct SwqosConfig {
|
pub enum SwqosConfig {
|
||||||
pub endpoint: String,
|
Default(String),
|
||||||
pub auth_token: String,
|
Jito(SwqosRegion),
|
||||||
pub swqos_type: SwqosType,
|
NextBlock(String, SwqosRegion),
|
||||||
|
Bloxroute(String, SwqosRegion),
|
||||||
|
Temporal(String, SwqosRegion),
|
||||||
|
ZeroSlot(String, SwqosRegion),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SwqosConfig {
|
impl SwqosConfig {
|
||||||
pub fn new(endpoint: Option<String>, auth_token: Option<String>, swqos_type: SwqosType, region: SwqosRegion) -> Self {
|
pub fn get_endpoint(swqos_type: SwqosType, region: SwqosRegion) -> String {
|
||||||
let auth_token = auth_token.unwrap_or_else(|| "".to_string());
|
match swqos_type {
|
||||||
let endpoint = endpoint.unwrap_or_else(|| match swqos_type {
|
|
||||||
SwqosType::Jito => SWQOS_ENDPOINTS_JITO[region as usize].to_string(),
|
SwqosType::Jito => SWQOS_ENDPOINTS_JITO[region as usize].to_string(),
|
||||||
SwqosType::NextBlock => SWQOS_ENDPOINTS_NEXTBLOCK[region as usize].to_string(),
|
SwqosType::NextBlock => SWQOS_ENDPOINTS_NEXTBLOCK[region as usize].to_string(),
|
||||||
SwqosType::ZeroSlot => SWQOS_ENDPOINTS_ZERO_SLOT[region as usize].to_string(),
|
SwqosType::ZeroSlot => SWQOS_ENDPOINTS_ZERO_SLOT[region as usize].to_string(),
|
||||||
SwqosType::Temporal => SWQOS_ENDPOINTS_TEMPORAL[region as usize].to_string(),
|
SwqosType::Temporal => SWQOS_ENDPOINTS_TEMPORAL[region as usize].to_string(),
|
||||||
SwqosType::Bloxroute => SWQOS_ENDPOINTS_BLOX[region as usize].to_string(),
|
SwqosType::Bloxroute => SWQOS_ENDPOINTS_BLOX[region as usize].to_string(),
|
||||||
SwqosType::Rpc => "".to_string(),
|
SwqosType::Default => "".to_string(),
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Self { endpoint, auth_token, swqos_type }
|
pub fn get_swqos_client(rpc_url: String, commitment: CommitmentConfig, swqos_config: SwqosConfig) -> Arc<SwqosClient> {
|
||||||
|
match swqos_config {
|
||||||
|
SwqosConfig::Jito(region) => {
|
||||||
|
let endpoint = SwqosConfig::get_endpoint(SwqosType::Jito, region);
|
||||||
|
let jito_client = JitoClient::new(
|
||||||
|
rpc_url.clone(),
|
||||||
|
endpoint,
|
||||||
|
"".to_string()
|
||||||
|
);
|
||||||
|
Arc::new(jito_client)
|
||||||
|
}
|
||||||
|
SwqosConfig::NextBlock(auth_token, region) => {
|
||||||
|
let endpoint = SwqosConfig::get_endpoint(SwqosType::NextBlock, region);
|
||||||
|
let nextblock_client = NextBlockClient::new(
|
||||||
|
rpc_url.clone(),
|
||||||
|
endpoint.to_string(),
|
||||||
|
auth_token
|
||||||
|
);
|
||||||
|
Arc::new(nextblock_client)
|
||||||
|
},
|
||||||
|
SwqosConfig::ZeroSlot(auth_token, region) => {
|
||||||
|
let endpoint = SwqosConfig::get_endpoint(SwqosType::ZeroSlot, region);
|
||||||
|
let zeroslot_client = ZeroSlotClient::new(
|
||||||
|
rpc_url.clone(),
|
||||||
|
endpoint.to_string(),
|
||||||
|
auth_token
|
||||||
|
);
|
||||||
|
Arc::new(zeroslot_client)
|
||||||
|
},
|
||||||
|
SwqosConfig::Temporal(auth_token, region) => {
|
||||||
|
let endpoint = SwqosConfig::get_endpoint(SwqosType::Temporal, region);
|
||||||
|
let temporal_client = TemporalClient::new(
|
||||||
|
rpc_url.clone(),
|
||||||
|
endpoint.to_string(),
|
||||||
|
auth_token
|
||||||
|
);
|
||||||
|
Arc::new(temporal_client)
|
||||||
|
},
|
||||||
|
SwqosConfig::Bloxroute(auth_token, region) => {
|
||||||
|
let endpoint = SwqosConfig::get_endpoint(SwqosType::Bloxroute, region);
|
||||||
|
let bloxroute_client = BloxrouteClient::new(
|
||||||
|
rpc_url.clone(),
|
||||||
|
endpoint.to_string(),
|
||||||
|
auth_token
|
||||||
|
);
|
||||||
|
Arc::new(bloxroute_client)
|
||||||
|
},
|
||||||
|
SwqosConfig::Default(endpoint) => {
|
||||||
|
let rpc = SolanaRpcClient::new_with_commitment(
|
||||||
|
endpoint,
|
||||||
|
commitment
|
||||||
|
);
|
||||||
|
let rpc_client = SolRpcClient::new(Arc::new(rpc));
|
||||||
|
Arc::new(rpc_client)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ impl SwqosClientTrait for SolRpcClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_swqos_type(&self) -> SwqosType {
|
fn get_swqos_type(&self) -> SwqosType {
|
||||||
SwqosType::Rpc
|
SwqosType::Default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ pub async fn parallel_execute_with_tips(
|
|||||||
let handle = tokio::spawn(async move {
|
let handle = tokio::spawn(async move {
|
||||||
core_affinity::set_for_current(core_id);
|
core_affinity::set_for_current(core_id);
|
||||||
let transaction = if matches!(trade_type, TradeType::Sell)
|
let transaction = if matches!(trade_type, TradeType::Sell)
|
||||||
&& swqos_client.get_swqos_type() == SwqosType::Rpc
|
&& swqos_client.get_swqos_type() == SwqosType::Default
|
||||||
{
|
{
|
||||||
build_sell_transaction(
|
build_sell_transaction(
|
||||||
payer,
|
payer,
|
||||||
@@ -48,7 +48,7 @@ pub async fn parallel_execute_with_tips(
|
|||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else if matches!(trade_type, TradeType::Sell)
|
} else if matches!(trade_type, TradeType::Sell)
|
||||||
&& swqos_client.get_swqos_type() != SwqosType::Rpc
|
&& swqos_client.get_swqos_type() != SwqosType::Default
|
||||||
{
|
{
|
||||||
let tip_account = swqos_client.get_tip_account()?;
|
let tip_account = swqos_client.get_tip_account()?;
|
||||||
let tip_account = Arc::new(Pubkey::from_str(&tip_account).map_err(|e| anyhow!(e))?);
|
let tip_account = Arc::new(Pubkey::from_str(&tip_account).map_err(|e| anyhow!(e))?);
|
||||||
@@ -61,7 +61,7 @@ pub async fn parallel_execute_with_tips(
|
|||||||
recent_blockhash,
|
recent_blockhash,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
} else if swqos_client.get_swqos_type() == SwqosType::Rpc {
|
} else if swqos_client.get_swqos_type() == SwqosType::Default {
|
||||||
build_rpc_transaction(
|
build_rpc_transaction(
|
||||||
payer,
|
payer,
|
||||||
&priority_fee,
|
&priority_fee,
|
||||||
|
|||||||
Reference in New Issue
Block a user