feat: v0.5.5 - enhanced priority fee system and dependency updates
- Update solana-streamer-sdk to 0.4.1 - Refactor priority fee API (custom_buy_tip_fee → custom_priority_fee) - Simplify documentation and clean up examples BREAKING CHANGE: priority fee parameter type changed
This commit is contained in:
+11
-33
@@ -132,7 +132,7 @@ impl SolanaTrade {
|
||||
/// * `sol_amount` - Amount of SOL to spend on the purchase (in lamports)
|
||||
/// * `slippage_basis_points` - Optional slippage tolerance in basis points (e.g., 100 = 1%)
|
||||
/// * `recent_blockhash` - Recent blockhash for transaction validity
|
||||
/// * `custom_buy_tip_fee` - Optional custom tip fee for priority processing (in SOL)
|
||||
/// * `custom_priority_fee` - Optional custom priority fee for priority processing
|
||||
/// * `extension_params` - Optional protocol-specific parameters (uses defaults if None)
|
||||
/// * `lookup_table_key` - Optional address lookup table key for transaction optimization
|
||||
/// * `wait_transaction_confirmed` - Whether to wait for the transaction to be confirmed
|
||||
@@ -155,11 +155,10 @@ impl SolanaTrade {
|
||||
sol_amount: u64,
|
||||
slippage_basis_points: Option<u64>,
|
||||
recent_blockhash: Hash,
|
||||
custom_buy_tip_fee: Option<f64>,
|
||||
custom_priority_fee: Option<PriorityFee>,
|
||||
extension_params: Box<dyn ProtocolParams>,
|
||||
lookup_table_key: Option<Pubkey>,
|
||||
wait_transaction_confirmed: bool,
|
||||
priority_fee: Option<PriorityFee>,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let executor = TradeFactory::create_executor(dex_type.clone());
|
||||
let protocol_params = extension_params;
|
||||
@@ -179,8 +178,8 @@ impl SolanaTrade {
|
||||
wait_transaction_confirmed: wait_transaction_confirmed,
|
||||
protocol_params: protocol_params.clone(),
|
||||
};
|
||||
if priority_fee.is_some() {
|
||||
let mut custom_priority_fee = priority_fee.unwrap();
|
||||
if custom_priority_fee.is_some() {
|
||||
let mut custom_priority_fee = custom_priority_fee.unwrap();
|
||||
// Fill the array, only fill the missing elements
|
||||
if custom_priority_fee.buy_tip_fees.len() < self.swqos_clients.len() {
|
||||
let mut buy_tip_fees = custom_priority_fee.buy_tip_fees.clone();
|
||||
@@ -196,15 +195,6 @@ impl SolanaTrade {
|
||||
}
|
||||
buy_params.priority_fee = custom_priority_fee;
|
||||
}
|
||||
if custom_buy_tip_fee.is_some() {
|
||||
buy_params.priority_fee.buy_tip_fee = custom_buy_tip_fee.unwrap();
|
||||
buy_params.priority_fee.buy_tip_fees = buy_params
|
||||
.priority_fee
|
||||
.buy_tip_fees
|
||||
.iter()
|
||||
.map(|_| custom_buy_tip_fee.unwrap())
|
||||
.collect();
|
||||
}
|
||||
let buy_with_tip_params = buy_params.clone().with_tip(self.swqos_clients.clone());
|
||||
|
||||
// Validate protocol params
|
||||
@@ -238,7 +228,7 @@ impl SolanaTrade {
|
||||
/// * `token_amount` - Amount of tokens to sell (in smallest token units)
|
||||
/// * `slippage_basis_points` - Optional slippage tolerance in basis points (e.g., 100 = 1%)
|
||||
/// * `recent_blockhash` - Recent blockhash for transaction validity
|
||||
/// * `custom_buy_tip_fee` - Optional custom tip fee for priority processing (in SOL)
|
||||
/// * `custom_priority_fee` - Optional custom priority fee for priority processing
|
||||
/// * `with_tip` - Optional boolean to indicate if the transaction should be sent with tip
|
||||
/// * `extension_params` - Optional protocol-specific parameters (uses defaults if None)
|
||||
/// * `lookup_table_key` - Optional address lookup table key for transaction optimization
|
||||
@@ -263,12 +253,11 @@ impl SolanaTrade {
|
||||
token_amount: u64,
|
||||
slippage_basis_points: Option<u64>,
|
||||
recent_blockhash: Hash,
|
||||
custom_buy_tip_fee: Option<f64>,
|
||||
custom_priority_fee: Option<PriorityFee>,
|
||||
with_tip: bool,
|
||||
extension_params: Box<dyn ProtocolParams>,
|
||||
lookup_table_key: Option<Pubkey>,
|
||||
wait_transaction_confirmed: bool,
|
||||
priority_fee: Option<PriorityFee>,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let executor = TradeFactory::create_executor(dex_type.clone());
|
||||
let protocol_params = extension_params;
|
||||
@@ -287,8 +276,8 @@ impl SolanaTrade {
|
||||
wait_transaction_confirmed: wait_transaction_confirmed,
|
||||
protocol_params: protocol_params.clone(),
|
||||
};
|
||||
if priority_fee.is_some() {
|
||||
let mut custom_priority_fee = priority_fee.unwrap();
|
||||
if custom_priority_fee.is_some() {
|
||||
let mut custom_priority_fee = custom_priority_fee.unwrap();
|
||||
// Fill the array, only fill the missing elements
|
||||
if custom_priority_fee.buy_tip_fees.len() < self.swqos_clients.len() {
|
||||
let mut buy_tip_fees = custom_priority_fee.buy_tip_fees.clone();
|
||||
@@ -304,15 +293,6 @@ impl SolanaTrade {
|
||||
}
|
||||
sell_params.priority_fee = custom_priority_fee;
|
||||
}
|
||||
if custom_buy_tip_fee.is_some() {
|
||||
sell_params.priority_fee.buy_tip_fee = custom_buy_tip_fee.unwrap();
|
||||
sell_params.priority_fee.buy_tip_fees = sell_params
|
||||
.priority_fee
|
||||
.buy_tip_fees
|
||||
.iter()
|
||||
.map(|_| custom_buy_tip_fee.unwrap())
|
||||
.collect();
|
||||
}
|
||||
let sell_with_tip_params = sell_params.clone().with_tip(self.swqos_clients.clone());
|
||||
|
||||
// Validate protocol params
|
||||
@@ -355,7 +335,7 @@ impl SolanaTrade {
|
||||
/// * `percent` - Percentage of tokens to sell (1-100, where 100 = 100%)
|
||||
/// * `slippage_basis_points` - Optional slippage tolerance in basis points (e.g., 100 = 1%)
|
||||
/// * `recent_blockhash` - Recent blockhash for transaction validity
|
||||
/// * `custom_buy_tip_fee` - Optional custom tip fee for priority processing (in SOL)
|
||||
/// * `custom_priority_fee` - Optional custom priority fee for priority processing
|
||||
/// * `with_tip` - Whether to use tip for priority processing
|
||||
/// * `extension_params` - Optional protocol-specific parameters (uses defaults if None)
|
||||
/// * `lookup_table_key` - Optional lookup table key for address lookup optimization
|
||||
@@ -382,12 +362,11 @@ impl SolanaTrade {
|
||||
percent: u64,
|
||||
slippage_basis_points: Option<u64>,
|
||||
recent_blockhash: Hash,
|
||||
custom_buy_tip_fee: Option<f64>,
|
||||
custom_priority_fee: Option<PriorityFee>,
|
||||
with_tip: bool,
|
||||
extension_params: Box<dyn ProtocolParams>,
|
||||
lookup_table_key: Option<Pubkey>,
|
||||
wait_transaction_confirmed: bool,
|
||||
priority_fee: Option<PriorityFee>,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
if percent == 0 || percent > 100 {
|
||||
return Err(anyhow::anyhow!("Percentage must be between 1 and 100"));
|
||||
@@ -399,12 +378,11 @@ impl SolanaTrade {
|
||||
amount,
|
||||
slippage_basis_points,
|
||||
recent_blockhash,
|
||||
custom_buy_tip_fee,
|
||||
custom_priority_fee,
|
||||
with_tip,
|
||||
extension_params,
|
||||
lookup_table_key,
|
||||
wait_transaction_confirmed,
|
||||
priority_fee,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user