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
+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(