feat(pumpswap): Add fee configuration support v0.5.6
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "sol-trade-sdk"
|
name = "sol-trade-sdk"
|
||||||
version = "0.5.5"
|
version = "0.5.6"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = [
|
authors = [
|
||||||
"William <byteblock6@gmail.com>",
|
"William <byteblock6@gmail.com>",
|
||||||
|
|||||||
@@ -33,14 +33,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.5.5" }
|
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.5.6" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use crates.io
|
### Use crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# Add to your Cargo.toml
|
# Add to your Cargo.toml
|
||||||
sol-trade-sdk = "0.5.5"
|
sol-trade-sdk = "0.5.6"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
|
|||||||
+2
-2
@@ -33,14 +33,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.5.5" }
|
sol-trade-sdk = { path = "./sol-trade-sdk", version = "0.5.6" }
|
||||||
```
|
```
|
||||||
|
|
||||||
### 使用 crates.io
|
### 使用 crates.io
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
# 添加到您的 Cargo.toml
|
# 添加到您的 Cargo.toml
|
||||||
sol-trade-sdk = "0.5.5"
|
sol-trade-sdk = "0.5.6"
|
||||||
```
|
```
|
||||||
|
|
||||||
## 使用示例
|
## 使用示例
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ pub mod seeds {
|
|||||||
|
|
||||||
pub const USER_VOLUME_ACCUMULATOR_SEED: &[u8] = b"user_volume_accumulator";
|
pub const USER_VOLUME_ACCUMULATOR_SEED: &[u8] = b"user_volume_accumulator";
|
||||||
pub const GLOBAL_VOLUME_ACCUMULATOR_SEED: &[u8] = b"global_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
|
/// Constants related to program accounts and authorities
|
||||||
@@ -66,6 +67,7 @@ pub mod accounts {
|
|||||||
pub const PROTOCOL_FEE_BASIS_POINTS: u64 = 5;
|
pub const PROTOCOL_FEE_BASIS_POINTS: u64 = 5;
|
||||||
pub const COIN_CREATOR_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];
|
pub const BUY_DISCRIMINATOR: [u8; 8] = [102, 6, 61, 18, 1, 218, 235, 234];
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::{
|
|||||||
},
|
},
|
||||||
pumpswap::common::{
|
pumpswap::common::{
|
||||||
coin_creator_vault_ata, coin_creator_vault_authority, fee_recipient_ata,
|
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},
|
utils::calc::pumpswap::{buy_quote_input_internal, sell_base_input_internal},
|
||||||
@@ -272,6 +272,10 @@ impl PumpSwapInstructionBuilder {
|
|||||||
false,
|
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
|
// Create instruction data
|
||||||
let mut data = vec![];
|
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
|
// Create instruction data
|
||||||
let mut data = vec![];
|
let mut data = vec![];
|
||||||
if quote_mint_is_wsol {
|
if quote_mint_is_wsol {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::common::SolanaRpcClient;
|
|
||||||
use crate::constants::pumpswap::accounts;
|
use crate::constants::pumpswap::accounts;
|
||||||
|
use crate::{common::SolanaRpcClient, constants};
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use solana_account_decoder::UiAccountEncoding;
|
use solana_account_decoder::UiAccountEncoding;
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
@@ -164,3 +164,14 @@ pub async fn get_token_balances(
|
|||||||
|
|
||||||
Ok((base_amount, quote_amount))
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user