feat(swqos): add minimum tip constants and conditional transaction building
- Define minimum tip constants for each SWQOS provider (JITO, NextBlock, Node1, etc.) - Add dynamic filtering in execute_parallel to skip transaction building when tip is below provider's minimum - Add missing SWQOS_ENDPOINTS_ASTRALANE constant - Ensure SWQOS clients are always initialized but transactions are conditionally built based on current tip amount
This commit is contained in:
@@ -217,3 +217,13 @@ pub const SWQOS_ENDPOINTS_ASTRALANE: [&str; 8] = [
|
|||||||
"http://lim.gateway.astralane.io/iris",
|
"http://lim.gateway.astralane.io/iris",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
pub const SWQOS_MIN_TIP_DEFAULT: f64 = 0.00001; // 其它SWQOS默认最低小费
|
||||||
|
pub const SWQOS_MIN_TIP_JITO: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
pub const SWQOS_MIN_TIP_NEXTBLOCK: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
pub const SWQOS_MIN_TIP_ZERO_SLOT: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
pub const SWQOS_MIN_TIP_TEMPORAL: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
pub const SWQOS_MIN_TIP_BLOXROUTE: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
pub const SWQOS_MIN_TIP_NODE1: f64 = 0.002; // 如需更高阈值可调整
|
||||||
|
pub const SWQOS_MIN_TIP_FLASHBLOCK: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
pub const SWQOS_MIN_TIP_BLOCKRAZOR: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
pub const SWQOS_MIN_TIP_ASTRALANE: f64 = SWQOS_MIN_TIP_DEFAULT;
|
||||||
|
|||||||
@@ -46,24 +46,10 @@ pub async fn build_transaction(
|
|||||||
|
|
||||||
// Add tip transfer instruction
|
// Add tip transfer instruction
|
||||||
if with_tip && tip_amount > 0.0 {
|
if with_tip && tip_amount > 0.0 {
|
||||||
// 🔧 Node1 最小小费金额限制:0.002 SOL(仅限 Node1)
|
|
||||||
const MIN_TIP_AMOUNT: f64 = 0.002;
|
|
||||||
|
|
||||||
// 检查是否是 Node1 的 tip_account
|
|
||||||
let is_node1 = NODE1_TIP_ACCOUNTS.iter().any(|&account| account == *tip_account);
|
|
||||||
|
|
||||||
let actual_tip_amount = if is_node1 && tip_amount < MIN_TIP_AMOUNT {
|
|
||||||
// Node1 要求最小 0.002 SOL
|
|
||||||
MIN_TIP_AMOUNT
|
|
||||||
} else {
|
|
||||||
// 其他 swqos 使用原始金额
|
|
||||||
tip_amount
|
|
||||||
};
|
|
||||||
|
|
||||||
instructions.push(transfer(
|
instructions.push(transfer(
|
||||||
&payer.pubkey(),
|
&payer.pubkey(),
|
||||||
tip_account,
|
tip_account,
|
||||||
sol_str_to_lamports(actual_tip_amount.to_string().as_str()).unwrap_or(0),
|
sol_str_to_lamports(tip_amount.to_string().as_str()).unwrap_or(0),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,18 @@ use crate::{
|
|||||||
common::{GasFeeStrategy, SolanaRpcClient},
|
common::{GasFeeStrategy, SolanaRpcClient},
|
||||||
swqos::{SwqosClient, SwqosType, TradeType},
|
swqos::{SwqosClient, SwqosType, TradeType},
|
||||||
trading::{common::build_transaction, MiddlewareManager},
|
trading::{common::build_transaction, MiddlewareManager},
|
||||||
|
constants::swqos::{
|
||||||
|
SWQOS_MIN_TIP_DEFAULT,
|
||||||
|
SWQOS_MIN_TIP_JITO,
|
||||||
|
SWQOS_MIN_TIP_NEXTBLOCK,
|
||||||
|
SWQOS_MIN_TIP_ZERO_SLOT,
|
||||||
|
SWQOS_MIN_TIP_TEMPORAL,
|
||||||
|
SWQOS_MIN_TIP_BLOXROUTE,
|
||||||
|
SWQOS_MIN_TIP_NODE1,
|
||||||
|
SWQOS_MIN_TIP_FLASHBLOCK,
|
||||||
|
SWQOS_MIN_TIP_BLOCKRAZOR,
|
||||||
|
SWQOS_MIN_TIP_ASTRALANE,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[repr(align(64))]
|
#[repr(align(64))]
|
||||||
@@ -142,6 +154,26 @@ pub async fn execute_parallel(
|
|||||||
gas_fee_strategy_configs
|
gas_fee_strategy_configs
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|config| config.0.eq(&swqos_client.get_swqos_type()))
|
.filter(|config| config.0.eq(&swqos_client.get_swqos_type()))
|
||||||
|
.filter(|config| {
|
||||||
|
// 当需要 tip 且不是 Default 时,按 provider 最低小费进行筛选
|
||||||
|
if with_tip && !matches!(config.0, SwqosType::Default) {
|
||||||
|
let min_tip = match config.0 {
|
||||||
|
SwqosType::Jito => SWQOS_MIN_TIP_JITO,
|
||||||
|
SwqosType::NextBlock => SWQOS_MIN_TIP_NEXTBLOCK,
|
||||||
|
SwqosType::ZeroSlot => SWQOS_MIN_TIP_ZERO_SLOT,
|
||||||
|
SwqosType::Temporal => SWQOS_MIN_TIP_TEMPORAL,
|
||||||
|
SwqosType::Bloxroute => SWQOS_MIN_TIP_BLOXROUTE,
|
||||||
|
SwqosType::Node1 => SWQOS_MIN_TIP_NODE1,
|
||||||
|
SwqosType::FlashBlock => SWQOS_MIN_TIP_FLASHBLOCK,
|
||||||
|
SwqosType::BlockRazor => SWQOS_MIN_TIP_BLOCKRAZOR,
|
||||||
|
SwqosType::Astralane => SWQOS_MIN_TIP_ASTRALANE,
|
||||||
|
SwqosType::Default => SWQOS_MIN_TIP_DEFAULT,
|
||||||
|
};
|
||||||
|
config.2.tip >= min_tip
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
})
|
||||||
.map(move |config| (i, swqos_client.clone(), config))
|
.map(move |config| (i, swqos_client.clone(), config))
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|||||||
Reference in New Issue
Block a user