update trade config and swqos
This commit is contained in:
Executable
+23
@@ -0,0 +1,23 @@
|
||||
pub const SWQOS_ENDPOINTS_JITO: [&str; 3] = [
|
||||
"https://ny.mainnet.block-engine.jito.wtf/api/v1/bundles",
|
||||
"https://ams.block-engine.jito.wtf/api/v1/bundles",
|
||||
"https://frankfurt.mainnet.block-engine.jito.wtf/api/v1/bundles",
|
||||
];
|
||||
|
||||
pub const SWQOS_ENDPOINTS_NEXTBLOCK: [&str; 3] = [
|
||||
"https://fra.nextblock.io",
|
||||
"https://ams.nextblock.io",
|
||||
"https://ny.nextblock.io",
|
||||
];
|
||||
|
||||
pub const SWQOS_ENDPOINTS_ZERO_SLOT: [&str; 3] = [
|
||||
"http://de1.0slot.trade",
|
||||
"http://ams.0slot.trade",
|
||||
"http://ny.0slot.trade",
|
||||
];
|
||||
|
||||
pub const SWQOS_ENDPOINTS_TEMPORAL: [&str; 3] = [
|
||||
"http://fra2.nozomi.temporal.xyz",
|
||||
"http://ams2.nozomi.temporal.xyz",
|
||||
"http://ny2.nozomi.temporal.xyz",
|
||||
];
|
||||
+3
-3
@@ -8,7 +8,7 @@ use std::sync::Arc;
|
||||
use solana_sdk::{transaction::VersionedTransaction, signature::Signature};
|
||||
use crate::protos::searcher::searcher_service_client::SearcherServiceClient;
|
||||
use crate::protos::searcher_client::{self, get_searcher_client_no_auth, send_bundle_with_confirmation};
|
||||
use crate::swqos::{ClientType, TradeType};
|
||||
use crate::swqos::{SwqosType, TradeType};
|
||||
use crate::swqos::SwqosClientTrait;
|
||||
|
||||
use crate::{common::SolanaRpcClient, constants::pumpfun::accounts::JITO_TIP_ACCOUNTS};
|
||||
@@ -37,8 +37,8 @@ impl SwqosClientTrait for JitoClient {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_client_type(&self) -> ClientType {
|
||||
ClientType::Jito
|
||||
fn get_swqos_type(&self) -> SwqosType {
|
||||
SwqosType::Jito
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+38
-6
@@ -4,8 +4,8 @@ pub mod solana_rpc;
|
||||
pub mod jito;
|
||||
pub mod nextblock;
|
||||
pub mod zeroslot;
|
||||
pub mod nozomi;
|
||||
pub mod types;
|
||||
pub mod temporal;
|
||||
pub mod define;
|
||||
|
||||
use solana_sdk::signature::Signature;
|
||||
use solana_sdk::transaction::VersionedTransaction;
|
||||
@@ -13,6 +13,8 @@ use tokio::sync::RwLock;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::swqos::define::{SWQOS_ENDPOINTS_JITO, SWQOS_ENDPOINTS_NEXTBLOCK, SWQOS_ENDPOINTS_TEMPORAL, SWQOS_ENDPOINTS_ZERO_SLOT};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref TIP_ACCOUNT_CACHE: RwLock<Vec<String>> = RwLock::new(Vec::new());
|
||||
}
|
||||
@@ -37,12 +39,12 @@ impl std::fmt::Display for TradeType {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum ClientType {
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum SwqosType {
|
||||
Jito,
|
||||
NextBlock,
|
||||
ZeroSlot,
|
||||
Nozomi,
|
||||
Temporal,
|
||||
Rpc,
|
||||
}
|
||||
|
||||
@@ -53,5 +55,35 @@ 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;
|
||||
fn get_swqos_type(&self) -> SwqosType;
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum SwqosRegion {
|
||||
NewYork,
|
||||
Amsterdam,
|
||||
Frankfurt,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct SwqosConfig {
|
||||
pub endpoint: String,
|
||||
pub auth_token: String,
|
||||
pub swqos_type: SwqosType,
|
||||
}
|
||||
|
||||
impl SwqosConfig {
|
||||
pub fn new(endpoint: Option<String>, auth_token: Option<String>, swqos_type: SwqosType, region: SwqosRegion) -> Self {
|
||||
let endpoint = endpoint.unwrap_or_else(|| match swqos_type {
|
||||
SwqosType::Jito => SWQOS_ENDPOINTS_JITO[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::Temporal => SWQOS_ENDPOINTS_TEMPORAL[region as usize].to_string(),
|
||||
SwqosType::Rpc => "".to_string(),
|
||||
});
|
||||
|
||||
let auth_token = auth_token.unwrap();
|
||||
|
||||
Self { endpoint, auth_token, swqos_type }
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ use tonic::transport::ClientTlsConfig;
|
||||
|
||||
use anyhow::Result;
|
||||
use solana_sdk::transaction::VersionedTransaction;
|
||||
use crate::swqos::{ClientType, TradeType};
|
||||
use crate::swqos::{SwqosType, TradeType};
|
||||
use crate::swqos::SwqosClientTrait;
|
||||
|
||||
use crate::{common::SolanaRpcClient, constants::pumpfun::accounts::NEXTBLOCK_TIP_ACCOUNTS};
|
||||
@@ -67,8 +67,8 @@ impl SwqosClientTrait for NextBlockClient {
|
||||
Ok(tip_account.to_string())
|
||||
}
|
||||
|
||||
fn get_client_type(&self) -> ClientType {
|
||||
ClientType::NextBlock
|
||||
fn get_swqos_type(&self) -> SwqosType {
|
||||
SwqosType::NextBlock
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use solana_sdk::{
|
||||
};
|
||||
use solana_transaction_status::UiTransactionEncoding;
|
||||
|
||||
use crate::{common::SolanaRpcClient, swqos::{common::poll_transaction_confirmation, ClientType, TradeType}};
|
||||
use crate::{common::SolanaRpcClient, swqos::{common::poll_transaction_confirmation, SwqosType, TradeType}};
|
||||
use crate::swqos::SwqosClientTrait;
|
||||
use anyhow::Result;
|
||||
|
||||
@@ -52,8 +52,8 @@ impl SwqosClientTrait for SolRpcClient {
|
||||
Ok("".to_string())
|
||||
}
|
||||
|
||||
fn get_client_type(&self) -> ClientType {
|
||||
ClientType::Rpc
|
||||
fn get_swqos_type(&self) -> SwqosType {
|
||||
SwqosType::Rpc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,14 @@ use solana_transaction_status::UiTransactionEncoding;
|
||||
|
||||
use anyhow::Result;
|
||||
use solana_sdk::transaction::VersionedTransaction;
|
||||
use crate::swqos::{ClientType, TradeType};
|
||||
use crate::swqos::{SwqosType, TradeType};
|
||||
use crate::swqos::SwqosClientTrait;
|
||||
|
||||
use crate::{common::SolanaRpcClient, constants::pumpfun::accounts::NOZOMI_TIP_ACCOUNTS};
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct NozomiClient {
|
||||
pub struct TemporalClient {
|
||||
pub rpc_client: Arc<SolanaRpcClient>,
|
||||
pub endpoint: String,
|
||||
pub auth_token: String,
|
||||
@@ -27,7 +27,7 @@ pub struct NozomiClient {
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl SwqosClientTrait for NozomiClient {
|
||||
impl SwqosClientTrait for TemporalClient {
|
||||
async fn send_transaction(&self, trade_type: TradeType, transaction: &VersionedTransaction) -> Result<Signature> {
|
||||
self.send_transaction(trade_type, transaction).await
|
||||
}
|
||||
@@ -41,12 +41,12 @@ impl SwqosClientTrait for NozomiClient {
|
||||
Ok(tip_account.to_string())
|
||||
}
|
||||
|
||||
fn get_client_type(&self) -> ClientType {
|
||||
ClientType::Nozomi
|
||||
fn get_swqos_type(&self) -> SwqosType {
|
||||
SwqosType::Temporal
|
||||
}
|
||||
}
|
||||
|
||||
impl NozomiClient {
|
||||
impl TemporalClient {
|
||||
pub fn new(rpc_url: String, endpoint: String, auth_token: String) -> Self {
|
||||
let rpc_client = SolanaRpcClient::new(rpc_url);
|
||||
let http_client = Client::builder()
|
||||
@@ -10,7 +10,7 @@ use solana_transaction_status::UiTransactionEncoding;
|
||||
use anyhow::Result;
|
||||
use solana_sdk::signature::Signature;
|
||||
use solana_sdk::transaction::VersionedTransaction;
|
||||
use crate::swqos::{ClientType, TradeType};
|
||||
use crate::swqos::{SwqosType, TradeType};
|
||||
use crate::swqos::SwqosClientTrait;
|
||||
|
||||
use crate::{common::SolanaRpcClient, constants::pumpfun::accounts::ZEROSLOT_TIP_ACCOUNTS};
|
||||
@@ -39,8 +39,8 @@ impl SwqosClientTrait for ZeroSlotClient {
|
||||
Ok(tip_account.to_string())
|
||||
}
|
||||
|
||||
fn get_client_type(&self) -> ClientType {
|
||||
ClientType::ZeroSlot
|
||||
fn get_swqos_type(&self) -> SwqosType {
|
||||
SwqosType::ZeroSlot
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user