refactor(gas-fee): Refactor Gas Fee Strategy API

- Rename add_* methods to set_* for clarity
- Simplify normal strategy API (remove TradeType param)
- Expose set/del methods for flexible strategy management
- Update docs and examples to match new API

BREAKING CHANGE: Method names changed for Gas Fee Strategy
This commit is contained in:
ysq
2025-09-21 21:34:19 +08:00
parent 0ac710ce75
commit 9ba8e3b3e7
4 changed files with 122 additions and 39 deletions
+5 -5
View File
@@ -30,12 +30,12 @@ GasFeeStrategy::set_global_fee_strategy(
```rust
// Configure normal strategy for SwqosType::Jito during Buy
GasFeeStrategy::add_normal_fee_strategy(
GasFeeStrategy::set_normal_fee_strategy(
SwqosType::Jito,
TradeType::Buy,
xxxxx, // cu_limit
xxxx, // cu_price
xxxxx // tip
xxxxx, // buy_tip
xxxxx, // sell_tip
);
```
@@ -43,7 +43,7 @@ GasFeeStrategy::add_normal_fee_strategy(
```rust
// Configure high-low fee strategy for SwqosType::Jito during Buy
GasFeeStrategy::add_high_low_fee_strategy(
GasFeeStrategy::set_high_low_fee_strategy(
SwqosType::Jito,
TradeType::Buy,
xxxxx, // cu_limit
@@ -58,7 +58,7 @@ GasFeeStrategy::add_high_low_fee_strategy(
```rust
// Remove a specific strategy
GasFeeStrategy::remove_strategy(SwqosType::Jito, TradeType::Buy);
GasFeeStrategy::del(SwqosType::Jito, TradeType::Buy);
// View all strategies
GasFeeStrategy::print_all_strategies();
// Clear all strategies
+5 -5
View File
@@ -30,12 +30,12 @@ GasFeeStrategy::set_global_fee_strategy(
```rust
// 为 SwqosType::Jito 在 Buy 时配置 normal 策略
GasFeeStrategy::add_normal_fee_strategy(
GasFeeStrategy::set_normal_fee_strategy(
SwqosType::Jito,
TradeType::Buy,
xxxxx, // cu_limit
xxxx, // cu_price
xxxxx // tip
xxxxx, // buy_tip
xxxxx // sell_tip
);
```
@@ -43,7 +43,7 @@ GasFeeStrategy::add_normal_fee_strategy(
```rust
// 为 SwqosType::Jito 在 Buy 时配置高低费率策略
GasFeeStrategy::add_high_low_fee_strategy(
GasFeeStrategy::set_high_low_fee_strategy(
SwqosType::Jito,
TradeType::Buy,
xxxxx, // cu_limit
@@ -58,7 +58,7 @@ GasFeeStrategy::add_high_low_fee_strategy(
```rust
// 移除某个策略
GasFeeStrategy::remove_strategy(SwqosType::Jito, TradeType::Buy);
GasFeeStrategy::del(SwqosType::Jito, TradeType::Buy);
// 查看所有策略
GasFeeStrategy::print_all_strategies();
// 清空所有策略