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
+4 -2
View File
@@ -64,8 +64,6 @@ async fn create_solana_trade_client() -> AnyResult<SolanaTrade> {
let swqos_configs: Vec<SwqosConfig> = vec![SwqosConfig::Default(rpc_url.clone())];
let trade_config = TradeConfig::new(rpc_url, swqos_configs, commitment);
let solana_trade = SolanaTrade::new(Arc::new(payer), trade_config).await;
// set global strategy
sol_trade_sdk::common::GasFeeStrategy::set_global_fee_strategy(150000, 500000, 0.001, 0.001);
println!("✅ SolanaTrade client initialized successfully!");
Ok(solana_trade)
}
@@ -82,6 +80,9 @@ async fn test_middleware() -> AnyResult<()> {
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let pool_address = Pubkey::from_str("539m4mVWt6iduB6W8rDGPMarzNCMesuqY5eUTiiYHAgR")?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let buy_params = sol_trade_sdk::TradeBuyParams {
dex_type: DexType::PumpSwap,
input_token_type: TradeTokenType::WSOL,
@@ -100,6 +101,7 @@ async fn test_middleware() -> AnyResult<()> {
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.buy(buy_params).await?;
println!("tip: This transaction will not succeed because we're using a test account. You can modify the code to initialize the payer with your own private key");