feat(pumpswap): Add fee configuration support v0.5.6

This commit is contained in:
ysq
2025-09-03 21:06:14 +08:00
parent db3b50fc28
commit 02af3e98e2
6 changed files with 30 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "sol-trade-sdk"
version = "0.5.5"
version = "0.5.6"
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.5" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.5.6" }
```
### Use crates.io
```toml
# Add to your Cargo.toml
sol-trade-sdk = "0.5.5"
sol-trade-sdk = "0.5.6"
```
## 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.5" }
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.5.6" }
```
### 使用 crates.io
```toml
# 添加到您的 Cargo.toml
sol-trade-sdk = "0.5.5"
sol-trade-sdk = "0.5.6"
```
## 使用示例
+3 -1
View File
@@ -26,6 +26,7 @@ pub mod seeds {
pub const USER_VOLUME_ACCUMULATOR_SEED: &[u8] = b"user_volume_accumulator";
pub const GLOBAL_VOLUME_ACCUMULATOR_SEED: &[u8] = b"global_volume_accumulator";
pub const FEE_CONFIG_SEED: &[u8] = b"fee_config";
}
/// Constants related to program accounts and authorities
@@ -65,7 +66,8 @@ pub mod accounts {
pub const LP_FEE_BASIS_POINTS: u64 = 20;
pub const PROTOCOL_FEE_BASIS_POINTS: u64 = 5;
pub const COIN_CREATOR_FEE_BASIS_POINTS: u64 = 5;
pub const FEE_PROGRAM: Pubkey = pubkey!("pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ");
}
pub const BUY_DISCRIMINATOR: [u8; 8] = [102, 6, 61, 18, 1, 218, 235, 234];
+10 -1
View File
@@ -16,7 +16,7 @@ use crate::{
},
pumpswap::common::{
coin_creator_vault_ata, coin_creator_vault_authority, fee_recipient_ata,
get_global_volume_accumulator_pda, get_user_volume_accumulator_pda,
get_fee_config_pda, get_global_volume_accumulator_pda, get_user_volume_accumulator_pda,
},
},
utils::calc::pumpswap::{buy_quote_input_internal, sell_base_input_internal},
@@ -272,6 +272,10 @@ impl PumpSwapInstructionBuilder {
false,
));
}
accounts
.push(solana_sdk::instruction::AccountMeta::new(get_fee_config_pda().unwrap(), false));
accounts
.push(solana_sdk::instruction::AccountMeta::new_readonly(accounts::FEE_PROGRAM, false));
// Create instruction data
let mut data = vec![];
@@ -461,6 +465,11 @@ impl PumpSwapInstructionBuilder {
));
}
accounts
.push(solana_sdk::instruction::AccountMeta::new(get_fee_config_pda().unwrap(), false));
accounts
.push(solana_sdk::instruction::AccountMeta::new_readonly(accounts::FEE_PROGRAM, false));
// Create instruction data
let mut data = vec![];
if quote_mint_is_wsol {
+12 -1
View File
@@ -1,5 +1,5 @@
use crate::common::SolanaRpcClient;
use crate::constants::pumpswap::accounts;
use crate::{common::SolanaRpcClient, constants};
use anyhow::anyhow;
use solana_account_decoder::UiAccountEncoding;
use solana_sdk::pubkey::Pubkey;
@@ -164,3 +164,14 @@ pub async fn get_token_balances(
Ok((base_amount, quote_amount))
}
#[inline]
pub fn get_fee_config_pda() -> Option<Pubkey> {
let seeds: &[&[u8]; 2] = &[
constants::pumpswap::seeds::FEE_CONFIG_SEED,
constants::pumpswap::accounts::AMM_PROGRAM.as_ref(),
];
let program_id: &Pubkey = &constants::pumpswap::accounts::FEE_PROGRAM;
let pda: Option<(Pubkey, u8)> = Pubkey::try_find_program_address(seeds, program_id);
pda.map(|pubkey| pubkey.0)
}