Merge branch 'main' into feat/support-usdc-quote

# Conflicts:
#	examples/pumpswap_trading/src/main.rs
#	examples/raydium_cpmm_trading/src/main.rs
#	src/trading/core/executor.rs
This commit is contained in:
tommggo
2025-10-12 15:39:43 +08:00
73 changed files with 7589 additions and 768 deletions
+9 -20
View File
@@ -1,6 +1,5 @@
use sol_trade_sdk::common::address_lookup_cache::AddressLookupTableCache;
use sol_trade_sdk::common::SolanaRpcClient;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::common::address_lookup::fetch_address_lookup_table_account;
use sol_trade_sdk::common::{gas_fee_strategy, GasFeeStrategy, TradeConfig};
use sol_trade_sdk::{
common::AnyResult,
swqos::SwqosConfig,
@@ -97,18 +96,6 @@ fn create_event_callback() -> impl Fn(Box<dyn UnifiedEvent>) {
}
}
/// Setup lookup table cache
async fn setup_lookup_table_cache(
client: Arc<SolanaRpcClient>,
lookup_table_address: Pubkey,
) -> AnyResult<()> {
AddressLookupTableCache::get_instance()
.set_address_lookup_table(client, &lookup_table_address)
.await
.map_err(|e| anyhow::anyhow!("Failed to set address lookup table: {}", e))?;
Ok(())
}
/// Create SolanaTrade client
/// Initializes a new SolanaTrade client with configuration
async fn create_solana_trade_client() -> AnyResult<SolanaTrade> {
@@ -119,8 +106,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)
}
@@ -136,8 +121,11 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let lookup_table_key = Pubkey::from_str("use_your_lookup_table_key_here").unwrap();
// Setup lookup table cache
setup_lookup_table_cache(client.rpc.clone(), lookup_table_key).await?;
let address_lookup_table_account =
fetch_address_lookup_table_account(&client.rpc, &lookup_table_key).await.ok();
let gas_fee_strategy = GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from PumpFun...");
@@ -161,7 +149,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
trade_info.real_sol_reserves,
None,
)),
lookup_table_key: Some(lookup_table_key), // you still need to update the AddressLookupTableCache
address_lookup_table_account: address_lookup_table_account,
wait_transaction_confirmed: true,
create_input_token_ata: false,
close_input_token_ata: false,
@@ -169,6 +157,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.buy(buy_params).await?;
+8 -5
View File
@@ -3,7 +3,7 @@ use std::sync::{
Arc,
};
use sol_trade_sdk::common::spl_associated_token_account::get_associated_token_address;
use sol_trade_sdk::common::{spl_associated_token_account::get_associated_token_address, GasFeeStrategy};
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::{
common::AnyResult,
@@ -110,8 +110,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)
}
@@ -126,6 +124,9 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()>
let slippage_basis_points = Some(100);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from Bonk...");
let input_token_type =
@@ -156,7 +157,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()>
trade_info.creator_associated_account,
trade_info.global_config,
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: false,
@@ -164,6 +165,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()>
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -199,7 +201,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()>
trade_info.creator_associated_account,
trade_info.global_config,
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
open_seed_optimize: false,
with_tip: false,
@@ -207,6 +209,7 @@ async fn bonk_copy_trade_with_grpc(trade_info: BonkTradeEvent) -> AnyResult<()>
create_output_token_ata: false,
close_output_token_ata: false,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
+7 -4
View File
@@ -80,8 +80,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)
}
@@ -96,6 +94,9 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult<
let slippage_basis_points = Some(300);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let token_type = if trade_info.quote_token_mint == sol_trade_sdk::constants::USD1_TOKEN_ACCOUNT
{
sol_trade_sdk::TradeTokenType::USD1
@@ -126,7 +127,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult<
trade_info.creator_associated_account,
trade_info.global_config,
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: true,
@@ -134,6 +135,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult<
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -162,7 +164,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult<
trade_info.creator_associated_account,
trade_info.global_config,
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: true,
@@ -170,6 +172,7 @@ async fn bonk_sniper_trade_with_shreds(trade_info: BonkTradeEvent) -> AnyResult<
with_tip: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
+50 -12
View File
@@ -614,6 +614,9 @@ async fn handle_buy_pumpfun(
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap();
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 = TradeBuyParams {
dex_type: DexType::PumpFun,
input_token_type: TradeTokenType::SOL,
@@ -622,7 +625,7 @@ async fn handle_buy_pumpfun(
slippage_basis_points: slippage,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: false,
close_input_token_ata: false,
@@ -630,6 +633,7 @@ async fn handle_buy_pumpfun(
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.buy(buy_params).await {
Ok((_, signature)) => {
@@ -664,6 +668,9 @@ async fn handle_buy_pumpswap(
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap();
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 = TradeBuyParams {
dex_type: DexType::PumpSwap,
input_token_type: TradeTokenType::WSOL,
@@ -672,7 +679,7 @@ async fn handle_buy_pumpswap(
slippage_basis_points: slippage,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: false,
@@ -680,6 +687,7 @@ async fn handle_buy_pumpswap(
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.buy(buy_params).await {
Ok((_, signature)) => {
@@ -713,6 +721,9 @@ async fn handle_buy_bonk(
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap();
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 = TradeBuyParams {
dex_type: DexType::Bonk,
input_token_type: TradeTokenType::WSOL,
@@ -721,7 +732,7 @@ async fn handle_buy_bonk(
slippage_basis_points: slippage,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: false,
@@ -729,6 +740,7 @@ async fn handle_buy_bonk(
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.buy(buy_params).await {
Ok((_, signature)) => {
@@ -766,6 +778,9 @@ async fn handle_buy_raydium_v4(
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap();
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 = TradeBuyParams {
dex_type: DexType::RaydiumAmmV4,
input_token_type: TradeTokenType::WSOL,
@@ -774,7 +789,7 @@ async fn handle_buy_raydium_v4(
slippage_basis_points: slippage,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: false,
@@ -782,6 +797,7 @@ async fn handle_buy_raydium_v4(
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.buy(buy_params).await {
Ok((_, signature)) => {
@@ -819,6 +835,9 @@ async fn handle_buy_raydium_cpmm(
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap();
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 = TradeBuyParams {
dex_type: DexType::RaydiumCpmm,
input_token_type: TradeTokenType::WSOL,
@@ -827,7 +846,7 @@ async fn handle_buy_raydium_cpmm(
slippage_basis_points: slippage,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: false,
@@ -835,6 +854,7 @@ async fn handle_buy_raydium_cpmm(
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.buy(buy_params).await {
Ok((_, signature)) => {
@@ -982,6 +1002,9 @@ async fn handle_sell_pumpfun(
let param = PumpFunParams::from_mint_by_rpc(&client.rpc, &mint_pubkey).await?;
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let sell_params = TradeSellParams {
dex_type: DexType::PumpFun,
output_token_type: TradeTokenType::SOL,
@@ -991,13 +1014,14 @@ async fn handle_sell_pumpfun(
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: false,
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.sell(sell_params).await {
@@ -1035,6 +1059,9 @@ async fn handle_sell_pumpswap(
let param = PumpSwapParams::from_mint_by_rpc(&client.rpc, &mint_pubkey).await?;
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let sell_params = TradeSellParams {
dex_type: DexType::PumpSwap,
output_token_type: TradeTokenType::WSOL,
@@ -1044,13 +1071,14 @@ async fn handle_sell_pumpswap(
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: false,
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.sell(sell_params).await {
Ok((_, signature)) => {
@@ -1087,6 +1115,9 @@ async fn handle_sell_bonk(
let param = BonkParams::from_mint_by_rpc(&client.rpc, &mint_pubkey, false).await?;
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let sell_params = TradeSellParams {
dex_type: DexType::Bonk,
output_token_type: TradeTokenType::WSOL,
@@ -1096,13 +1127,14 @@ async fn handle_sell_bonk(
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: false,
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.sell(sell_params).await {
Ok((_, signature)) => {
@@ -1142,6 +1174,9 @@ async fn handle_sell_raydium_v4(
let param = RaydiumAmmV4Params::from_amm_address_by_rpc(&client.rpc, amm_pubkey).await?;
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let sell_params = TradeSellParams {
dex_type: DexType::RaydiumAmmV4,
output_token_type: TradeTokenType::WSOL,
@@ -1151,13 +1186,14 @@ async fn handle_sell_raydium_v4(
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: false,
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.sell(sell_params).await {
Ok((_, signature)) => {
@@ -1197,6 +1233,9 @@ async fn handle_sell_raydium_cpmm(
let param = RaydiumCpmmParams::from_pool_address_by_rpc(&client.rpc, &pool_pubkey).await?;
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let sell_params = TradeSellParams {
dex_type: DexType::RaydiumCpmm,
output_token_type: TradeTokenType::WSOL,
@@ -1206,13 +1245,14 @@ async fn handle_sell_raydium_cpmm(
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(param),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: false,
open_seed_optimize: use_seed,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
match client.sell(sell_params).await {
Ok((_, signature)) => {
@@ -1325,8 +1365,6 @@ async fn initialize_real_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(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)
}
+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!");
}
@@ -22,6 +22,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pool = Pubkey::from_str("7dVri3qjYD3uobSZL3Zth8vSCgU6r6R2nvFsh7uVfDte").unwrap();
let mint_pubkey = Pubkey::from_str("PRVT6TB7uss3FrUd2D9xs2zqDBsa3GbMJMwCQsgmeta").unwrap();
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from Metaora Damm V2...");
let input_token_amount = 100_000;
@@ -35,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
extension_params: Box::new(
MeteoraDammV2Params::from_pool_address_by_rpc(&client.rpc, &pool).await?,
),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: false, //if input token is SOL/WSOL,set to true,if input token is USDC,set to false.
close_input_token_ata: false, //if input token is SOL/WSOL,set to true,if input token is USDC,set to false.
@@ -43,6 +46,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: Some(1),
gas_fee_strategy: gas_fee_strategy.clone()
};
client.buy(buy_params).await?;
@@ -67,13 +71,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
extension_params: Box::new(
MeteoraDammV2Params::from_pool_address_by_rpc(&client.rpc, &pool).await?,
),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: false, //if output token is SOL/WSOL,set to true,if output token is USDC,set to false.
close_output_token_ata: false, //if output token is SOL/WSOL,set to true,if output token is USDC,set to false.
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: Some(1),
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
@@ -91,8 +96,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)
}
+5 -3
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,
@@ -92,7 +93,7 @@ async fn test_middleware() -> AnyResult<()> {
extension_params: Box::new(
PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool_address).await?,
),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: true,
@@ -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");
+16 -14
View File
@@ -1,10 +1,12 @@
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
use std::{
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
};
use sol_trade_sdk::common::nonce_cache::NonceCache;
use sol_trade_sdk::common::TradeConfig;
use sol_trade_sdk::common::{nonce_cache::fetch_nonce_info, TradeConfig};
use sol_trade_sdk::TradeTokenType;
use sol_trade_sdk::{
common::AnyResult,
@@ -13,7 +15,7 @@ use sol_trade_sdk::{
SolanaTrade,
};
use solana_commitment_config::CommitmentConfig;
use solana_sdk::signature::Keypair;
use solana_sdk::{pubkey::Pubkey, signature::Keypair};
use solana_streamer_sdk::match_event;
use solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use solana_streamer_sdk::streaming::event_parser::common::EventType;
@@ -104,8 +106,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)
}
@@ -121,10 +121,11 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
// Setup nonce cache
let nonce_account_str = "use_your_nonce_account_here";
NonceCache::get_instance().init(Some(nonce_account_str.to_string()));
NonceCache::get_instance().fetch_nonce_info_use_rpc(&client.rpc).await?;
let durable_nonce = NonceCache::get_durable_nonce_info();
let nonce_account_str = Pubkey::from_str("use_your_nonce_account_here")?;
let durable_nonce = fetch_nonce_info(&client.rpc, nonce_account_str).await;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from PumpFun...");
@@ -148,14 +149,15 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
trade_info.real_sol_reserves,
None,
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: false,
close_input_token_ata: false,
create_mint_ata: true,
open_seed_optimize: false,
durable_nonce: Some(durable_nonce),
durable_nonce: durable_nonce,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.buy(buy_params).await?;
+7 -4
View File
@@ -106,8 +106,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)
}
@@ -122,6 +120,9 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
let slippage_basis_points = Some(100);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from PumpFun...");
let buy_sol_amount = 100_000;
@@ -144,7 +145,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
trade_info.real_sol_reserves,
None,
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: false,
close_input_token_ata: false,
@@ -152,6 +153,7 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -186,13 +188,14 @@ async fn pumpfun_copy_trade_with_grpc(trade_info: PumpFunTradeEvent) -> AnyResul
trade_info.real_sol_reserves,
Some(true),
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: false,
close_output_token_ata: false,
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
+7 -4
View File
@@ -74,8 +74,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)
}
@@ -90,6 +88,9 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR
let slippage_basis_points = Some(300);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from PumpFun...");
let buy_sol_amount = 100_000;
@@ -110,7 +111,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR
trade_info.creator_vault,
None,
)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: true,
@@ -118,6 +119,7 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -141,13 +143,14 @@ async fn pumpfun_sniper_trade_with_shreds(trade_info: PumpFunTradeEvent) -> AnyR
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(PumpFunParams::immediate_sell(trade_info.creator_vault, true)),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: true,
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
+7 -4
View File
@@ -22,6 +22,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pool = Pubkey::from_str("539m4mVWt6iduB6W8rDGPMarzNCMesuqY5eUTiiYHAgR").unwrap();
let mint_pubkey = Pubkey::from_str("pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn").unwrap();
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from PumpSwap...");
let buy_sol_amount = 100_000;
@@ -35,7 +38,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
extension_params: Box::new(
PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?,
),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: true,
@@ -43,6 +46,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -66,13 +70,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
extension_params: Box::new(
PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?,
),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: true,
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
@@ -90,8 +95,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)
}
+7 -4
View File
@@ -131,8 +131,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)
}
@@ -192,6 +190,9 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) -
let slippage_basis_points = Some(500);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
let is_sol = params.base_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT
|| params.quote_mint == sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT;
@@ -206,7 +207,7 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) -
slippage_basis_points: slippage_basis_points,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(params.clone()),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: is_sol,
close_input_token_ata: is_sol,
@@ -214,6 +215,7 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) -
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -239,13 +241,14 @@ async fn pumpswap_trade_with_grpc(mint_pubkey: Pubkey, params: PumpSwapParams) -
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(params.clone()),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: is_sol,
close_output_token_ata: is_sol,
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
+8 -4
View File
@@ -107,8 +107,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)
}
@@ -140,6 +138,10 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent)
coin_reserve,
pc_reserve,
);
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from Raydium_amm_v4...");
let input_token_amount = 100_000;
@@ -153,7 +155,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent)
slippage_basis_points: slippage_basis_points,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(params),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: is_wsol,
close_input_token_ata: is_wsol,
@@ -161,6 +163,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent)
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -185,13 +188,14 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent)
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(params),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: is_wsol,
close_output_token_ata: is_wsol,
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
+7 -4
View File
@@ -109,8 +109,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)
}
@@ -131,6 +129,9 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) ->
let slippage_basis_points = Some(100);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
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 =
RaydiumCpmmParams::from_pool_address_by_rpc(&client.rpc, &trade_info.pool_state).await?;
@@ -148,7 +149,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) ->
slippage_basis_points: slippage_basis_points,
recent_blockhash: Some(recent_blockhash),
extension_params: Box::new(buy_params),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: is_wsol,
close_input_token_ata: is_wsol,
@@ -156,6 +157,7 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) ->
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -182,13 +184,14 @@ async fn raydium_cpmm_copy_trade_with_grpc(trade_info: RaydiumCpmmSwapEvent) ->
recent_blockhash: Some(recent_blockhash),
with_tip: false,
extension_params: Box::new(sell_params),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: is_wsol,
close_output_token_ata: is_wsol,
open_seed_optimize: false,
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
+7 -4
View File
@@ -21,6 +21,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let pool = Pubkey::from_str("9qKxzRejsV6Bp2zkefXWCbGvg61c3hHei7ShXJ4FythA").unwrap();
let mint_pubkey = Pubkey::from_str("2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv").unwrap();
let gas_fee_strategy = sol_trade_sdk::common::GasFeeStrategy::new();
gas_fee_strategy.set_global_fee_strategy(150000, 500000, 0.001, 0.001);
// Buy tokens
println!("Buying tokens from PumpSwap...");
let buy_sol_amount = 100_000;
@@ -34,7 +37,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
extension_params: Box::new(
PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?,
),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_input_token_ata: true,
close_input_token_ata: true,
@@ -42,6 +45,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
open_seed_optimize: true, // ❗️❗️❗️❗️ open seed optimize
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy.clone(),
};
client.buy(buy_params).await?;
@@ -73,13 +77,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
extension_params: Box::new(
PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool).await?,
),
lookup_table_key: None,
address_lookup_table_account: None,
wait_transaction_confirmed: true,
create_output_token_ata: true,
close_output_token_ata: true,
open_seed_optimize: true, // ❗️❗️❗️❗️ open seed optimize
durable_nonce: None,
fixed_output_token_amount: None,
gas_fee_strategy: gas_fee_strategy,
};
client.sell(sell_params).await?;
@@ -97,8 +102,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)
}
-2
View File
@@ -36,8 +36,6 @@ async fn create_solana_trade_client() -> AnyResult<SolanaTrade> {
];
let trade_config = TradeConfig::new(rpc_url, swqos_configs, commitment);
let solana_trade_client = 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 created successfully!");
Ok(solana_trade_client)
}
-2
View File
@@ -59,8 +59,6 @@ async fn create_solana_trade_client() -> Result<SolanaTrade, Box<dyn std::error:
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)
}