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:
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sol-trade-sdk"
|
name = "sol-trade-sdk"
|
||||||
version = "0.2.9"
|
version = "0.2.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
authors = ["William <byteblock6@gmail.com>", "sgxiang <sgxiang@gmail.com>", "wei <1415121722@qq.com>"]
|
||||||
repository = "https://github.com/0xfnzero/sol-trade-sdk"
|
repository = "https://github.com/0xfnzero/sol-trade-sdk"
|
||||||
@@ -13,7 +13,7 @@ readme = "README.md"
|
|||||||
crate-type = ["cdylib", "rlib"]
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
solana-streamer-sdk = "0.1.7"
|
solana-streamer-sdk = "0.1.8"
|
||||||
solana-sdk = "2.1.16"
|
solana-sdk = "2.1.16"
|
||||||
solana-client = "2.1.16"
|
solana-client = "2.1.16"
|
||||||
solana-program = "2.1.16"
|
solana-program = "2.1.16"
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ Add the dependency to your `Cargo.toml`:
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.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
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
sol-trade-sdk = "0.2.9"
|
sol-trade-sdk = "0.2.10"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
|
|||||||
+2
-2
@@ -31,14 +31,14 @@ git clone https://github.com/0xfnzero/sol-trade-sdk
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.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
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
sol-trade-sdk = "0.2.9"
|
sol-trade-sdk = "0.2.10"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 使用示例
|
## 使用示例
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ pub mod seeds {
|
|||||||
|
|
||||||
/// Seed for metadata PDAs
|
/// Seed for metadata PDAs
|
||||||
pub const METADATA_SEED: &[u8] = b"metadata";
|
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 {
|
pub mod global_constants {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use spl_token::instruction::close_account;
|
|||||||
use crate::{
|
use crate::{
|
||||||
constants,
|
constants,
|
||||||
trading::pumpfun::common::{
|
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(*creator_vault_pda, false),
|
||||||
AccountMeta::new_readonly(constants::pumpfun::accounts::EVENT_AUTHORITY, false),
|
AccountMeta::new_readonly(constants::pumpfun::accounts::EVENT_AUTHORITY, false),
|
||||||
AccountMeta::new_readonly(constants::pumpfun::accounts::PUMPFUN, 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),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,22 @@ pub fn get_creator_vault_pda(creator: &Pubkey) -> Option<Pubkey> {
|
|||||||
pda.map(|pubkey| pubkey.0)
|
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]
|
#[inline]
|
||||||
pub fn get_metadata_pda(mint: &Pubkey) -> Pubkey {
|
pub fn get_metadata_pda(mint: &Pubkey) -> Pubkey {
|
||||||
Pubkey::find_program_address(
|
Pubkey::find_program_address(
|
||||||
|
|||||||
Reference in New Issue
Block a user