From c9b5c98a367f15f3db949edc17e9545e350bad81 Mon Sep 17 00:00:00 2001 From: ysq Date: Thu, 21 Aug 2025 23:54:26 +0800 Subject: [PATCH] feat: v0.4.5 - add immediate sell functionality and default implementations - Bump version to 0.4.5 - Add Default traits for BondingCurveAccount and BonkParams - Add immediate_sell methods for PumpFun and Bonk params - Update README version references --- Cargo.toml | 2 +- README.md | 4 ++-- README_CN.md | 4 ++-- src/common/bonding_curve.rs | 2 +- src/trading/core/params.rs | 12 +++++++++++- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 48dbc4b..1edbe4a 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sol-trade-sdk" -version = "0.4.4" +version = "0.4.5" edition = "2021" authors = ["William ", "sgxiang ", "wei <1415121722@qq.com>"] repository = "https://github.com/0xfnzero/sol-trade-sdk" diff --git a/README.md b/README.md index 5982669..cc6d278 100755 --- a/README.md +++ b/README.md @@ -33,14 +33,14 @@ Add the dependency to your `Cargo.toml`: ```toml # Add to your Cargo.toml -sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.4.4" } +sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.4.5" } ``` ### Use crates.io ```toml # Add to your Cargo.toml -sol-trade-sdk = "0.4.4" +sol-trade-sdk = "0.4.5" ``` ## Usage Examples diff --git a/README_CN.md b/README_CN.md index 0574014..839e22e 100755 --- a/README_CN.md +++ b/README_CN.md @@ -33,14 +33,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk ```toml # 添加到您的 Cargo.toml -sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.4.4" } +sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.4.5" } ``` ### 使用 crates.io ```toml # 添加到您的 Cargo.toml -sol-trade-sdk = "0.4.4" +sol-trade-sdk = "0.4.5" ``` ## 使用示例 diff --git a/src/common/bonding_curve.rs b/src/common/bonding_curve.rs index b2fa95c..dbba619 100755 --- a/src/common/bonding_curve.rs +++ b/src/common/bonding_curve.rs @@ -32,7 +32,7 @@ use crate::{constants::pumpfun::global_constants::{INITIAL_REAL_TOKEN_RESERVES, use crate::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent; /// Represents the global configuration account for token pricing and fees -#[derive(Debug, Clone, Serialize, Deserialize)] +#[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct BondingCurveAccount { /// Unique identifier for the bonding curve pub discriminator: u64, diff --git a/src/trading/core/params.rs b/src/trading/core/params.rs index ac21e63..af48b71 100755 --- a/src/trading/core/params.rs +++ b/src/trading/core/params.rs @@ -104,6 +104,13 @@ pub struct PumpFunParams { } impl PumpFunParams { + pub fn immediate_sell(close_token_account_when_sell: bool) -> Self { + Self { + bonding_curve: Arc::new(BondingCurveAccount { ..Default::default() }), + close_token_account_when_sell: Some(close_token_account_when_sell), + } + } + pub fn from_dev_trade( mint: &Pubkey, dev_token_amount: u64, @@ -221,7 +228,7 @@ impl ProtocolParams for PumpSwapParams { /// Bonk protocol specific parameters /// Configuration parameters specific to Bonk trading protocol -#[derive(Clone)] +#[derive(Clone, Default)] pub struct BonkParams { pub virtual_base: u128, pub virtual_quote: u128, @@ -234,6 +241,9 @@ pub struct BonkParams { } impl BonkParams { + pub fn immediate_sell() -> Self { + Self { auto_handle_wsol: true, ..Default::default() } + } pub fn from_trade(trade_info: BonkTradeEvent) -> Self { Self { virtual_base: trade_info.virtual_base as u128,