refactor: Update GasFeeStrategy to instance-based API and update docs

This commit is contained in:
ysq
2025-10-07 23:12:37 +08:00
parent e13c891cc9
commit 85154f6c01
28 changed files with 269 additions and 120 deletions
+12 -10
View File
@@ -8,21 +8,23 @@ async fn main() {
println!("🚀 Gas Fee Strategy Demo");
println!("========================");
let gas_fee_strategy = GasFeeStrategy::new();
// Set global strategy
println!("1. Set global strategy");
GasFeeStrategy::set_global_fee_strategy(150000, 500000, 0.001, 0.001);
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Print all strategies
println!("\n2. Print all strategies");
GasFeeStrategy::print_all_strategies();
gas_fee_strategy.print_all_strategies();
// Clear all strategies
println!("\n3. Clear all strategies");
GasFeeStrategy::clear();
gas_fee_strategy.clear();
// Add normal fee strategy for SwqosType::Default
println!("\n4. Add normal fee strategy for SwqosType::Default");
GasFeeStrategy::set_normal_fee_strategy(
gas_fee_strategy.set_normal_fee_strategy(
SwqosType::Default,
150000, // cu_limit
500000, // cu_price
@@ -32,7 +34,7 @@ async fn main() {
// Add high-low fee strategy for SwqosType::Jito on Buy
println!("\n5. Add high-low fee strategy for SwqosType::Jito on Buy");
GasFeeStrategy::set_high_low_fee_strategy(
gas_fee_strategy.set_high_low_fee_strategy(
SwqosType::Jito,
TradeType::Buy,
150000, // cu_limit
@@ -44,11 +46,11 @@ async fn main() {
// Print all strategies
println!("\n6. Print all current strategies");
GasFeeStrategy::print_all_strategies();
gas_fee_strategy.print_all_strategies();
// Add normal fee strategy for SwqosType::Jito on Buy (will override previous high-low strategy)
println!("\n7. Add normal fee strategy for SwqosType::Jito (will override previous high-low strategy)");
GasFeeStrategy::set_normal_fee_strategy(
gas_fee_strategy.set_normal_fee_strategy(
SwqosType::Jito,
150000, // cu_limit
500000, // cu_price
@@ -58,15 +60,15 @@ async fn main() {
// Print all strategies
println!("\n8. Print all current strategies");
GasFeeStrategy::print_all_strategies();
gas_fee_strategy.print_all_strategies();
// Remove strategy for SwqosType::Jito on Buy
println!("\n9. Remove strategy for SwqosType::Jito on Buy");
GasFeeStrategy::del_all(SwqosType::Jito, TradeType::Buy);
gas_fee_strategy.del_all(SwqosType::Jito, TradeType::Buy);
// Print all strategies
println!("\n10. Print all current strategies");
GasFeeStrategy::print_all_strategies();
gas_fee_strategy.print_all_strategies();
println!("\n✅ Gas Fee Strategy Demo completed!");
}