feat: refactor seed optimization to global configuration in v3.2.0

- Remove open_seed_optimize parameter from TradeBuyParams and TradeSellParams structs
- Add global use_seed_optimize configuration in TradeConfig with default value true
- Add create_wsol_ata_on_startup configuration in TradeConfig with default value true
- Implement automatic WSOL ATA creation and verification on SDK initialization
- Add with_wsol_ata_config() builder method to TradeConfig for custom WSOL settings
- Update all examples to remove open_seed_optimize parameter usage
- Update documentation (README, TRADING_PARAMETERS) to reflect new configuration approach
- Upgrade package version from 3.1.7 to 3.2.0

Breaking Changes:
- open_seed_optimize parameter removed from trade parameters (now global setting)
- Seed optimization is now enabled by default for all operations
This commit is contained in:
ysq
2025-11-07 16:57:28 +08:00
parent 9824576164
commit c5a55b1c14
23 changed files with 173 additions and 74 deletions
+24
View File
@@ -68,3 +68,27 @@ pub fn create_wsol_ata(payer: &Pubkey) -> Vec<Instruction> {
&crate::constants::TOKEN_PROGRAM,
)
}
/// 只充值SOL到已存在的WSOL ATA(不创建账户)- 标准方式
#[inline]
pub fn wrap_sol_only(payer: &Pubkey, amount_in: u64) -> SmallVec<[Instruction; 2]> {
let wsol_token_account =
crate::common::fast_fn::get_associated_token_address_with_program_id_fast(
&payer,
&crate::constants::WSOL_TOKEN_ACCOUNT,
&crate::constants::TOKEN_PROGRAM,
);
let mut insts = SmallVec::<[Instruction; 2]>::new();
insts.extend([
transfer(&payer, &wsol_token_account, amount_in),
// sync_native
Instruction {
program_id: crate::constants::TOKEN_PROGRAM,
accounts: vec![AccountMeta::new(wsol_token_account, false)],
data: vec![17],
},
]);
insts
}
-18
View File
@@ -74,24 +74,6 @@ impl PreallocatedTxBuilder {
// ✅ 如果有查找表,使用 V0 消息
if let Some(address_lookup_table_account) = address_lookup_table_account {
// self.lookup_tables.push(v0::MessageAddressTableLookup {
// account_key: table_key,
// writable_indexes: vec![],
// readonly_indexes: vec![],
// });
// // 使用 Message::new 创建 legacy 消息,然后提取编译后的指令
// let legacy_msg = Message::new(&self.instructions, Some(payer));
// // 构建 V0 消息
// let message = v0::Message {
// header: legacy_msg.header,
// account_keys: legacy_msg.account_keys,
// recent_blockhash,
// instructions: legacy_msg.instructions,
// address_table_lookups: self.lookup_tables.clone(),
// };
let message = v0::Message::try_compile(
payer,
&self.instructions,