diff --git a/Cargo.toml b/Cargo.toml index 2a66a17..1773f18 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sol-trade-sdk" -version = "0.2.9" +version = "0.2.10" edition = "2021" authors = ["William ", "sgxiang ", "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" diff --git a/README.md b/README.md index 791362a..359e007 100755 --- a/README.md +++ b/README.md @@ -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 diff --git a/README_CN.md b/README_CN.md index 80e0164..4c4f3ce 100755 --- a/README_CN.md +++ b/README_CN.md @@ -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" ``` ## 使用示例 diff --git a/src/constants/pumpfun.rs b/src/constants/pumpfun.rs index 0434671..bb21d66 100755 --- a/src/constants/pumpfun.rs +++ b/src/constants/pumpfun.rs @@ -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 { diff --git a/src/instruction/pumpfun.rs b/src/instruction/pumpfun.rs index 6a19e00..8a08fce 100755 --- a/src/instruction/pumpfun.rs +++ b/src/instruction/pumpfun.rs @@ -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), ], ) } diff --git a/src/trading/pumpfun/common.rs b/src/trading/pumpfun/common.rs index 0425826..4870cdc 100755 --- a/src/trading/pumpfun/common.rs +++ b/src/trading/pumpfun/common.rs @@ -62,6 +62,22 @@ pub fn get_creator_vault_pda(creator: &Pubkey) -> Option { pda.map(|pubkey| pubkey.0) } +#[inline] +pub fn get_user_volume_accumulator_pda(user: &Pubkey) -> Option { + 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 { + 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(