feat: upgrade to v0.5.3

This commit is contained in:
ysq
2025-08-31 22:54:08 +08:00
parent 9438172029
commit 865ad8148e
6 changed files with 25 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "sol-trade-sdk"
version = "0.5.2"
version = "0.5.3"
edition = "2021"
authors = [
"William <byteblock6@gmail.com>",
+2 -2
View File
@@ -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.5.2" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.5.3" }
```
### Use crates.io
```toml
# Add to your Cargo.toml
sol-trade-sdk = "0.5.2"
sol-trade-sdk = "0.5.3"
```
## Usage Examples
+2 -2
View File
@@ -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.5.2" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.5.3" }
```
### 使用 crates.io
```toml
# 添加到您的 Cargo.toml
sol-trade-sdk = "0.5.2"
sol-trade-sdk = "0.5.3"
```
## 使用示例
+4
View File
@@ -32,6 +32,8 @@ pub mod seeds {
/// Seed for global volume accumulator PDAs
pub const GLOBAL_VOLUME_ACCUMULATOR_SEED: &[u8] = b"global_volume_accumulator";
pub const FEE_CONFIG_SEED: &[u8] = b"fee_config";
}
pub mod global_constants {
@@ -108,6 +110,8 @@ pub mod accounts {
pub const RENT: Pubkey = pubkey!("SysvarRent111111111111111111111111111111111");
pub const AMM_PROGRAM: Pubkey = pubkey!("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8");
pub const FEE_PROGRAM: Pubkey = pubkey!("pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ");
}
pub struct Symbol;
+5 -3
View File
@@ -8,7 +8,7 @@ use spl_token::instruction::close_account;
use crate::{
constants,
trading::pumpfun::common::{
get_bonding_curve_pda, get_global_volume_accumulator_pda, get_user_volume_accumulator_pda,
get_bonding_curve_pda, get_fee_config_pda, get_global_volume_accumulator_pda, get_user_volume_accumulator_pda
},
utils::calc::{
common::{calculate_with_slippage_buy, calculate_with_slippage_sell},
@@ -209,6 +209,8 @@ pub fn buy(
AccountMeta::new_readonly(constants::pumpfun::accounts::PUMPFUN, false),
AccountMeta::new(get_global_volume_accumulator_pda().unwrap(), false),
AccountMeta::new(get_user_volume_accumulator_pda(&payer.pubkey()).unwrap(), false),
AccountMeta::new_readonly(get_fee_config_pda().unwrap(), false),
AccountMeta::new_readonly(constants::pumpfun::accounts::FEE_PROGRAM, false),
],
)
}
@@ -237,8 +239,8 @@ pub fn sell(
AccountMeta::new_readonly(constants::pumpfun::accounts::TOKEN_PROGRAM, false),
AccountMeta::new_readonly(constants::pumpfun::accounts::EVENT_AUTHORITY, false),
AccountMeta::new_readonly(constants::pumpfun::accounts::PUMPFUN, false),
AccountMeta::new(get_global_volume_accumulator_pda().unwrap(), false),
AccountMeta::new(get_user_volume_accumulator_pda(&payer.pubkey()).unwrap(), false),
AccountMeta::new_readonly(get_fee_config_pda().unwrap(), false),
AccountMeta::new_readonly(constants::pumpfun::accounts::FEE_PROGRAM, false),
],
)
}
+11
View File
@@ -73,6 +73,17 @@ pub fn get_global_volume_accumulator_pda() -> Option<Pubkey> {
pda.map(|pubkey| pubkey.0)
}
#[inline]
pub fn get_fee_config_pda() -> Option<Pubkey> {
let seeds: &[&[u8]; 2] = &[
constants::pumpfun::seeds::FEE_CONFIG_SEED,
constants::pumpfun::accounts::PUMPFUN.as_ref(),
];
let program_id: &Pubkey = &constants::pumpfun::accounts::FEE_PROGRAM;
let pda: Option<(Pubkey, u8)> = Pubkey::try_find_program_address(seeds, program_id);
pda.map(|pubkey| pubkey.0)
}
#[inline]
pub fn get_metadata_pda(mint: &Pubkey) -> Pubkey {
Pubkey::find_program_address(