refactor: improve trading params API and fix bonk calculation bug

- Bump version to 0.4.0 with breaking API changes
- Standardize dex params to Box<T> instead of Option<Box<T>>
- Add convenient factory methods for all trading params
- Fix critical bug in bonk sell calculation (virtual_base logic)
- Update documentation and examples with new API usage
- Improve ergonomics by removing manual params construction
This commit is contained in:
ysq
2025-08-18 20:41:01 +08:00
parent 57474bfa6e
commit d02d734026
5 changed files with 96 additions and 123 deletions
+6 -6
View File
@@ -219,7 +219,7 @@ async fn test_pumpswap() -> AnyResult<()> {
slippage_basis_points,
recent_blockhash,
None,
// 经过 rpc,增加耗时,可以通过from_buy_trade或者自行初始化PumpSwapParams参数来优化耗时
// Through RPC call, adds latency. Can optimize by using from_buy_trade or manually initializing PumpSwapParams
Box::new(PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool_address).await?),
None,
)
@@ -238,7 +238,7 @@ async fn test_pumpswap() -> AnyResult<()> {
recent_blockhash,
None,
false,
// 经过 rpc,增加耗时,可以通过from_sell_trade或者自行初始化PumpSwapParams参数来优化耗时
// Through RPC call, adds latency. Can optimize by using from_sell_trade or manually initializing PumpSwapParams
Box::new(PumpSwapParams::from_pool_address_by_rpc(&client.rpc, &pool_address).await?),
None,
)
@@ -363,7 +363,7 @@ async fn test_bonk() -> Result<(), Box<dyn std::error::Error>> {
slippage_basis_points,
recent_blockhash,
None,
// 经过 rpc,增加耗时,可以通过from_trade或者自行初始化BonkParams参数来优化耗时
// Through RPC call, adds latency. Can optimize by using from_trade or manually initializing BonkParams
Box::new(BonkParams::from_mint_by_rpc(&client.rpc, &mint_pubkey).await?),
None,
)
@@ -382,7 +382,7 @@ async fn test_bonk() -> Result<(), Box<dyn std::error::Error>> {
recent_blockhash,
None,
false,
// 经过 rpc,增加耗时,可以通过from_trade或者自行初始化BonkParams参数来优化耗时
// Through RPC call, adds latency. Can optimize by using from_trade or manually initializing BonkParams
Box::new(BonkParams::from_mint_by_rpc(&client.rpc, &mint_pubkey).await?),
None,
)
@@ -411,7 +411,7 @@ async fn test_raydium_cpmm() -> Result<(), Box<dyn std::error::Error>> {
slippage_basis_points,
recent_blockhash,
None,
// 经过 rpc,增加耗时,或者自行初始化RaydiumCpmmParams参数
// Through RPC call, adds latency, or manually initialize RaydiumCpmmParams
Box::new(
RaydiumCpmmParams::from_pool_address_by_rpc(&client.rpc, &pool_address).await?,
),
@@ -432,7 +432,7 @@ async fn test_raydium_cpmm() -> Result<(), Box<dyn std::error::Error>> {
recent_blockhash,
None,
false,
// 经过 rpc,增加耗时,或者自行初始化RaydiumCpmmParams参数
// Through RPC call, adds latency, or manually initialize RaydiumCpmmParams
Box::new(
RaydiumCpmmParams::from_pool_address_by_rpc(&client.rpc, &pool_address).await?,
),