feat: v0.2.10 - add PumpFun volume accumulator support

- Bump version to 0.2.10
- Upgrade solana-streamer-sdk to 0.1.8
- Add volume accumulator PDAs and functions
This commit is contained in:
ysq
2025-08-01 22:59:39 +08:00
parent e09d42531d
commit 07a42641de
6 changed files with 31 additions and 7 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
[package]
name = "sol-trade-sdk"
version = "0.2.9"
version = "0.2.10"
edition = "2021"
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
repository = "https://github.com/0xfnzero/sol-trade-sdk"
@@ -13,7 +13,7 @@ readme = "README.md"
crate-type = ["cdylib", "rlib"]
[dependencies]
solana-streamer-sdk = "0.1.7"
solana-streamer-sdk = "0.1.8"
solana-sdk = "2.1.16"
solana-client = "2.1.16"
solana-program = "2.1.16"
+2 -2
View File
@@ -31,14 +31,14 @@ Add the dependency to your `Cargo.toml`:
```toml
# Add to your Cargo.toml
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.9" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.10" }
```
### Use crates.io
```toml
# Add to your Cargo.toml
sol-trade-sdk = "0.2.9"
sol-trade-sdk = "0.2.10"
```
## Usage Examples
+2 -2
View File
@@ -31,14 +31,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk
```toml
# 添加到您的 Cargo.toml
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.9" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.2.10" }
```
### 使用 crates.io
```toml
# 添加到您的 Cargo.toml
sol-trade-sdk = "0.2.9"
sol-trade-sdk = "0.2.10"
```
## 使用示例
+6
View File
@@ -26,6 +26,12 @@ pub mod seeds {
/// Seed for metadata PDAs
pub const METADATA_SEED: &[u8] = b"metadata";
/// Seed for user volume accumulator PDAs
pub const USER_VOLUME_ACCUMULATOR_SEED: &[u8] = b"user_volume_accumulator";
/// Seed for global volume accumulator PDAs
pub const GLOBAL_VOLUME_ACCUMULATOR_SEED: &[u8] = b"global_volume_accumulator";
}
pub mod global_constants {
+3 -1
View File
@@ -8,7 +8,7 @@ use spl_token::instruction::close_account;
use crate::{
constants,
trading::pumpfun::common::{
get_bonding_curve_pda, get_global_pda, get_metadata_pda, get_mint_authority_pda,
get_bonding_curve_pda, get_global_pda, get_global_volume_accumulator_pda, get_metadata_pda, get_mint_authority_pda, get_user_volume_accumulator_pda
},
};
@@ -198,6 +198,8 @@ pub fn buy(
AccountMeta::new(*creator_vault_pda, 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),
],
)
}
+16
View File
@@ -62,6 +62,22 @@ pub fn get_creator_vault_pda(creator: &Pubkey) -> Option<Pubkey> {
pda.map(|pubkey| pubkey.0)
}
#[inline]
pub fn get_user_volume_accumulator_pda(user: &Pubkey) -> Option<Pubkey> {
let seeds: &[&[u8]; 2] = &[constants::pumpfun::seeds::USER_VOLUME_ACCUMULATOR_SEED, user.as_ref()];
let program_id: &Pubkey = &constants::pumpfun::accounts::PUMPFUN;
let pda: Option<(Pubkey, u8)> = Pubkey::try_find_program_address(seeds, program_id);
pda.map(|pubkey| pubkey.0)
}
#[inline]
pub fn get_global_volume_accumulator_pda() -> Option<Pubkey> {
let seeds: &[&[u8]; 1] = &[constants::pumpfun::seeds::GLOBAL_VOLUME_ACCUMULATOR_SEED];
let program_id: &Pubkey = &constants::pumpfun::accounts::PUMPFUN;
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(