refactor: unify trading parameters and add USD1 token pool support

- Merge BuyParams and SellParams into unified SwapParams structure
- Add USD1 token pool support with related constants and configurations
- Refactor trade executor by combining buy_with_tip and sell_with_tip into swap method
- Update all protocol instruction builders to support new parameter structure
- Standardize ATA creation/closing parameter naming conventions
- Update example code to use new API interfaces
- Optimize trading logic with automatic direction detection based on input token type
This commit is contained in:
ysq
2025-09-22 00:05:20 +08:00
parent f8891f3147
commit 4780e71c11
16 changed files with 274 additions and 235 deletions
+2 -2
View File
@@ -694,7 +694,7 @@ async fn handle_buy_bonk(
println!(" Slippage: {}%", slippage.unwrap());
}
let mint_pubkey = Pubkey::from_str(mint)?;
let param = BonkParams::from_mint_by_rpc(&client.rpc, &mint_pubkey).await?;
let param = BonkParams::from_mint_by_rpc(&client.rpc, &mint_pubkey, false).await?;
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let sol_lamports = sol_str_to_lamports(sol_amount.to_string().as_str()).unwrap();
@@ -1059,7 +1059,7 @@ async fn handle_sell_bonk(
}
let client = initialize_real_client().await?;
let mint_pubkey = Pubkey::from_str(mint)?;
let param = BonkParams::from_mint_by_rpc(&client.rpc, &mint_pubkey).await?;
let param = BonkParams::from_mint_by_rpc(&client.rpc, &mint_pubkey, false).await?;
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
let sell_params = TradeSellParams {