diff --git a/examples/pumpswap_trading/src/main.rs b/examples/pumpswap_trading/src/main.rs
index 77938a4..2602fc5 100644
--- a/examples/pumpswap_trading/src/main.rs
+++ b/examples/pumpswap_trading/src/main.rs
@@ -21,7 +21,7 @@ use sol_trade_sdk::{
SolanaTrade,
};
use sol_trade_sdk::{
- constants::pumpswap::accounts,
+ instruction::utils::pumpswap::accounts,
solana_streamer_sdk::streaming::event_parser::{
common::filter::EventTypeFilter, protocols::pumpswap::PumpSwapBuyEvent,
},
diff --git a/examples/raydium_amm_v4_trading/src/main.rs b/examples/raydium_amm_v4_trading/src/main.rs
index 0bd1c54..687e97b 100644
--- a/examples/raydium_amm_v4_trading/src/main.rs
+++ b/examples/raydium_amm_v4_trading/src/main.rs
@@ -3,7 +3,7 @@ use std::sync::{
Arc,
};
-use sol_trade_sdk::{constants::raydium_amm_v4::accounts, solana_streamer_sdk::{match_event, streaming::event_parser::protocols::raydium_amm_v4::RaydiumAmmV4SwapEvent}, trading::common::get_multi_token_balances};
+use sol_trade_sdk::{instruction::utils::raydium_amm_v4::{accounts, fetch_amm_info}, solana_streamer_sdk::{match_event, streaming::event_parser::protocols::raydium_amm_v4::RaydiumAmmV4SwapEvent}, trading::common::get_multi_token_balances};
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::filter::EventTypeFilter;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::common::EventType;
use sol_trade_sdk::solana_streamer_sdk::streaming::event_parser::protocols::raydium_amm_v4::parser::RAYDIUM_AMM_V4_PROGRAM_ID;
@@ -131,9 +131,7 @@ async fn raydium_amm_v4_copy_trade_with_grpc(trade_info: RaydiumAmmV4SwapEvent)
let slippage_basis_points = Some(100);
let recent_blockhash = client.rpc.get_latest_blockhash().await?;
- let amm_info =
- sol_trade_sdk::trading::raydium_amm_v4::common::fetch_amm_info(&client.rpc, trade_info.amm)
- .await?;
+ let amm_info = fetch_amm_info(&client.rpc, trade_info.amm).await?;
let (coin_reserve, pc_reserve) =
get_multi_token_balances(&client.rpc, &amm_info.token_coin, &amm_info.token_pc).await?;
let mint_pubkey = if amm_info.pc_mint == accounts::WSOL_TOKEN_ACCOUNT {
diff --git a/examples/raydium_cpmm_trading/src/main.rs b/examples/raydium_cpmm_trading/src/main.rs
index a7d4738..e81f10b 100644
--- a/examples/raydium_cpmm_trading/src/main.rs
+++ b/examples/raydium_cpmm_trading/src/main.rs
@@ -17,7 +17,7 @@ use sol_trade_sdk::{
SolanaTrade,
};
use sol_trade_sdk::{
- constants::raydium_cpmm::accounts,
+ instruction::utils::raydium_cpmm::accounts,
solana_streamer_sdk::streaming::event_parser::protocols::raydium_cpmm::parser::RAYDIUM_CPMM_PROGRAM_ID,
};
use sol_trade_sdk::{
diff --git a/src/common/bonding_curve.rs b/src/common/bonding_curve.rs
index dbba619..b3a7b01 100755
--- a/src/common/bonding_curve.rs
+++ b/src/common/bonding_curve.rs
@@ -25,10 +25,14 @@
//! - `get_final_market_cap_sol`: Calculates the final market cap in SOL after all tokens are sold
//! - `get_buy_out_price`: Calculates the price to buy out all remaining tokens
-use serde::{Serialize, Deserialize};
+use serde::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
-use crate::{constants::pumpfun::global_constants::{INITIAL_REAL_TOKEN_RESERVES, INITIAL_VIRTUAL_SOL_RESERVES, INITIAL_VIRTUAL_TOKEN_RESERVES, TOKEN_TOTAL_SUPPLY}, trading::pumpfun::common::{get_bonding_curve_pda, get_creator_vault_pda}};
+use crate::instruction::utils::pumpfun::global_constants::{
+ INITIAL_REAL_TOKEN_RESERVES, INITIAL_VIRTUAL_SOL_RESERVES, INITIAL_VIRTUAL_TOKEN_RESERVES,
+ TOKEN_TOTAL_SUPPLY,
+};
+use crate::instruction::utils::pumpfun::{get_bonding_curve_pda, get_creator_vault_pda};
use crate::solana_streamer_sdk::streaming::event_parser::protocols::pumpfun::PumpFunTradeEvent;
/// Represents the global configuration account for token pricing and fees
@@ -55,7 +59,12 @@ pub struct BondingCurveAccount {
}
impl BondingCurveAccount {
- pub fn from_dev_trade(mint: &Pubkey, dev_token_amount: u64, dev_sol_amount: u64, creator: Pubkey) -> Self {
+ pub fn from_dev_trade(
+ mint: &Pubkey,
+ dev_token_amount: u64,
+ dev_sol_amount: u64,
+ creator: Pubkey,
+ ) -> Self {
Self {
discriminator: 0,
account: get_bonding_curve_pda(mint).unwrap(),
@@ -118,11 +127,7 @@ impl BondingCurveAccount {
// Convert back to u64 and return the minimum of calculated tokens and real reserves
let s_u64 = s as u64;
- Ok(if s_u64 < self.real_token_reserves {
- s_u64
- } else {
- self.real_token_reserves
- })
+ Ok(if s_u64 < self.real_token_reserves { s_u64 } else { self.real_token_reserves })
}
/// Calculates the amount of SOL received for selling tokens
diff --git a/src/common/global.rs b/src/common/global.rs
index 3a5c414..ea37fb9 100755
--- a/src/common/global.rs
+++ b/src/common/global.rs
@@ -23,10 +23,16 @@
//! - `creator_fee`: Fee for creators
//! - `fee_recipients`: Array of fee recipient accounts
+use serde::{Deserialize, Serialize};
use solana_sdk::pubkey::Pubkey;
-use serde::{Serialize, Deserialize};
-use crate::constants::pumpfun::global_constants::*;
+use crate::instruction::utils::pumpfun::global_constants::{
+ AUTHORITY, CREATOR_FEE, ENABLE_MIGRATE, FEE_BASIS_POINTS, FEE_RECIPIENT, GLOBAL_ACCOUNT,
+ INITIAL_REAL_TOKEN_RESERVES, INITIAL_VIRTUAL_SOL_RESERVES, INITIAL_VIRTUAL_TOKEN_RESERVES,
+ POOL_MIGRATION_FEE, PUMPFUN_AMM_FEE_1, PUMPFUN_AMM_FEE_2, PUMPFUN_AMM_FEE_3, PUMPFUN_AMM_FEE_4,
+ PUMPFUN_AMM_FEE_5, PUMPFUN_AMM_FEE_6, PUMPFUN_AMM_FEE_7, TOKEN_TOTAL_SUPPLY,
+ WITHDRAW_AUTHORITY,
+};
/// Represents the global configuration account for token pricing and fees
#[derive(Debug, Clone, Serialize, Deserialize)]
diff --git a/src/constants/bonk.rs b/src/constants/bonk.rs
deleted file mode 100755
index 87470c0..0000000
--- a/src/constants/bonk.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-//! Constants used by the crate.
-//!
-//! This module contains various constants used throughout the crate, including:
-//!
-//! - Seeds for deriving Program Derived Addresses (PDAs)
-//! - Program account addresses and public keys
-//!
-//! The constants are organized into submodules for better organization:
-//!
-//! - `seeds`: Contains seed values used for PDA derivation
-//! - `accounts`: Contains important program account addresses
-
-/// Constants used as seeds for deriving PDAs (Program Derived Addresses)
-pub mod seeds {
- pub const POOL_SEED: &[u8] = b"pool";
- pub const POOL_VAULT_SEED: &[u8] = b"pool_vault";
-}
-
-/// Constants related to program accounts and authorities
-pub mod accounts {
- use solana_sdk::{pubkey, pubkey::Pubkey};
-
- pub const AUTHORITY: Pubkey = pubkey!("WLHv2UAZm6z4KyaaELi5pjdbJh6RESMva1Rnn8pJVVh");
- pub const GLOBAL_CONFIG: Pubkey = pubkey!("6s1xP3hpbAfFoNtUNF8mfHsjr2Bd97JxFJRWLbL6aHuX");
- pub const TOKEN_PROGRAM: Pubkey = spl_token::ID;
- pub const EVENT_AUTHORITY: Pubkey = pubkey!("2DPAtwB8L12vrMRExbLuyGnC7n2J5LNoZQSejeQGpwkr");
- pub const WSOL_TOKEN_ACCOUNT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
- pub const BONK: Pubkey = pubkey!("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj");
- pub const SYSTEM_PROGRAM: Pubkey = solana_sdk::system_program::ID;
-
- pub const PLATFORM_FEE_RATE: u128 = 100; // 1%
- pub const PROTOCOL_FEE_RATE: u128 = 25; // 0.25%
- pub const SHARE_FEE_RATE: u128 = 0; // 0%
-}
-
-pub const BUY_EXECT_IN_DISCRIMINATOR: [u8; 8] = [250, 234, 13, 123, 213, 156, 19, 236];
-pub const SELL_EXECT_IN_DISCRIMINATOR: [u8; 8] = [149, 39, 222, 155, 211, 124, 152, 26];
diff --git a/src/constants/mod.rs b/src/constants/mod.rs
index 472b7bb..37a7081 100755
--- a/src/constants/mod.rs
+++ b/src/constants/mod.rs
@@ -1,17 +1,4 @@
-pub mod bonk;
-pub mod pumpfun;
-pub mod pumpswap;
+pub mod decimals;
pub mod swqos;
pub mod trade;
-pub mod raydium_cpmm;
-pub mod raydium_amm_v4;
-pub mod decimals;
-
-pub mod trade_platform {
- pub const PUMPFUN: &'static str = "pumpfun";
- pub const PUMPFUN_SWAP: &'static str = "pumpswap";
- pub const BONK: &'static str = "bonk";
- pub const RAYDIUM_CPMM: &'static str = "raydium_cpmm";
- pub const RAYDIUM_CLMM: &'static str = "raydium_clmm";
- pub const RAYDIUM_AMM_V4: &'static str = "raydium_amm_v4";
-}
+pub mod trade_platform;
diff --git a/src/constants/pumpfun.rs b/src/constants/pumpfun.rs
deleted file mode 100755
index 057ae9c..0000000
--- a/src/constants/pumpfun.rs
+++ /dev/null
@@ -1,121 +0,0 @@
-//! Constants used by the crate.
-//!
-//! This module contains various constants used throughout the crate, including:
-//!
-//! - Seeds for deriving Program Derived Addresses (PDAs)
-//! - Program account addresses and public keys
-//!
-//! The constants are organized into submodules for better organization:
-//!
-//! - `seeds`: Contains seed values used for PDA derivation
-//! - `accounts`: Contains important program account addresses
-
-/// Constants used as seeds for deriving PDAs (Program Derived Addresses)
-pub mod seeds {
- /// Seed for the global state PDA
- pub const GLOBAL_SEED: &[u8] = b"global";
-
- /// Seed for the mint authority PDA
- pub const MINT_AUTHORITY_SEED: &[u8] = b"mint-authority";
-
- /// Seed for bonding curve PDAs
- pub const BONDING_CURVE_SEED: &[u8] = b"bonding-curve";
-
- /// Seed for creator vault PDAs
- pub const CREATOR_VAULT_SEED: &[u8] = b"creator-vault";
-
- /// 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 const FEE_CONFIG_SEED: &[u8] = b"fee_config";
-}
-
-pub mod global_constants {
- use solana_sdk::{pubkey, pubkey::Pubkey};
-
- pub const INITIAL_VIRTUAL_TOKEN_RESERVES: u64 = 1_073_000_000_000_000;
-
- pub const INITIAL_VIRTUAL_SOL_RESERVES: u64 = 30_000_000_000;
-
- pub const INITIAL_REAL_TOKEN_RESERVES: u64 = 793_100_000_000_000;
-
- pub const TOKEN_TOTAL_SUPPLY: u64 = 1_000_000_000_000_000;
-
- pub const FEE_BASIS_POINTS: u64 = 95;
-
- pub const ENABLE_MIGRATE: bool = false;
-
- pub const POOL_MIGRATION_FEE: u64 = 15_000_001;
-
- pub const CREATOR_FEE: u64 = 5;
-
- pub const SCALE: u64 = 1_000_000; // 10^6 for token decimals
-
- pub const LAMPORTS_PER_SOL: u64 = 1_000_000_000; // 10^9 for solana lamports
-
- pub const COMPLETION_LAMPORTS: u64 = 85 * LAMPORTS_PER_SOL; // ~ 85 SOL
-
- /// Public key for the fee recipient
- pub const FEE_RECIPIENT: Pubkey = pubkey!("62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV");
-
- /// Public key for the global PDA
- pub const GLOBAL_ACCOUNT: Pubkey = pubkey!("4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf");
-
- /// Public key for the authority
- pub const AUTHORITY: Pubkey = pubkey!("FFWtrEQ4B4PKQoVuHYzZq8FabGkVatYzDpEVHsK5rrhF");
-
- /// Public key for the withdraw authority
- pub const WITHDRAW_AUTHORITY: Pubkey = pubkey!("39azUYFWPz3VHgKCf3VChUwbpURdCHRxjWVowf5jUJjg");
-
- pub const PUMPFUN_AMM_FEE_1: Pubkey = pubkey!("7VtfL8fvgNfhz17qKRMjzQEXgbdpnHHHQRh54R9jP2RJ"); // Pump.fun AMM: Protocol Fee 1
- pub const PUMPFUN_AMM_FEE_2: Pubkey = pubkey!("7hTckgnGnLQR6sdH7YkqFTAA7VwTfYFaZ6EhEsU3saCX"); // Pump.fun AMM: Protocol Fee 2
- pub const PUMPFUN_AMM_FEE_3: Pubkey = pubkey!("9rPYyANsfQZw3DnDmKE3YCQF5E8oD89UXoHn9JFEhJUz"); // Pump.fun AMM: Protocol Fee 3
- pub const PUMPFUN_AMM_FEE_4: Pubkey = pubkey!("AVmoTthdrX6tKt4nDjco2D775W2YK3sDhxPcMmzUAmTY"); // Pump.fun AMM: Protocol Fee 4
- pub const PUMPFUN_AMM_FEE_5: Pubkey = pubkey!("CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM"); // Pump.fun AMM: Protocol Fee 5
- pub const PUMPFUN_AMM_FEE_6: Pubkey = pubkey!("FWsW1xNtWscwNmKv6wVsU1iTzRN6wmmk3MjxRP5tT7hz"); // Pump.fun AMM: Protocol Fee 6
- pub const PUMPFUN_AMM_FEE_7: Pubkey = pubkey!("G5UZAVbAf46s7cKWoyKu8kYTip9DGTpbLZ2qa9Aq69dP");
- // Pump.fun AMM: Protocol Fee 7
-}
-
-/// Constants related to program accounts and authorities
-pub mod accounts {
- use solana_sdk::{pubkey, pubkey::Pubkey};
-
- /// Public key for the Pump.fun program
- pub const PUMPFUN: Pubkey = pubkey!("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");
-
- /// Public key for the MPL Token Metadata program
- pub const MPL_TOKEN_METADATA: Pubkey = pubkey!("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
-
- /// Authority for program events
- pub const EVENT_AUTHORITY: Pubkey = pubkey!("Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1");
-
- /// System Program ID
- pub const SYSTEM_PROGRAM: Pubkey = pubkey!("11111111111111111111111111111111");
-
- /// Token Program ID
- pub const TOKEN_PROGRAM: Pubkey = spl_token::ID;
-
- /// Associated Token Program ID
- pub const ASSOCIATED_TOKEN_PROGRAM: Pubkey =
- pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
-
- /// Rent Sysvar ID
- pub const RENT: Pubkey = pubkey!("SysvarRent111111111111111111111111111111111");
-
- pub const AMM_PROGRAM: Pubkey = pubkey!("675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8");
-
- pub const FEE_PROGRAM: Pubkey = pubkey!("pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ");
-}
-
-pub struct Symbol;
-
-impl Symbol {
- pub const SOLANA: &'static str = "solana";
-}
diff --git a/src/constants/pumpswap.rs b/src/constants/pumpswap.rs
deleted file mode 100755
index 6c4c385..0000000
--- a/src/constants/pumpswap.rs
+++ /dev/null
@@ -1,74 +0,0 @@
-//! Constants used by the crate.
-//!
-//! This module contains various constants used throughout the crate, including:
-//!
-//! - Seeds for deriving Program Derived Addresses (PDAs)
-//! - Program account addresses and public keys
-//!
-//! The constants are organized into submodules for better organization:
-//!
-//! - `seeds`: Contains seed values used for PDA derivation
-//! - `accounts`: Contains important program account addresses
-
-/// Constants used as seeds for deriving PDAs (Program Derived Addresses)
-pub mod seeds {
- /// Seed for the global state PDA
- pub const GLOBAL_SEED: &[u8] = b"global";
-
- /// Seed for the mint authority PDA
- pub const MINT_AUTHORITY_SEED: &[u8] = b"mint-authority";
-
- /// Seed for bonding curve PDAs
- pub const BONDING_CURVE_SEED: &[u8] = b"bonding-curve";
-
- /// Seed for metadata PDAs
- pub const METADATA_SEED: &[u8] = b"metadata";
-
- 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
-pub mod accounts {
- use solana_sdk::{pubkey, pubkey::Pubkey};
-
- /// Public key for the fee recipient
- pub const FEE_RECIPIENT: Pubkey = pubkey!("62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV");
-
- /// Public key for the global PDA
- pub const GLOBAL_ACCOUNT: Pubkey = pubkey!("ADyA8hdefvWN2dbGGWFotbzWxrAvLW83WG6QCVXvJKqw");
-
- /// Authority for program events
- pub const EVENT_AUTHORITY: Pubkey = pubkey!("GS4CU59F31iL7aR2Q8zVS8DRrcRnXX1yjQ66TqNVQnaR");
-
- pub const WSOL_TOKEN_ACCOUNT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
-
- /// System Program ID
- pub const SYSTEM_PROGRAM: Pubkey = pubkey!("11111111111111111111111111111111");
-
- /// Token Program ID
- pub const TOKEN_PROGRAM: Pubkey = spl_token::ID;
-
- /// Associated Token Program ID
- pub const ASSOCIATED_TOKEN_PROGRAM: Pubkey =
- pubkey!("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL");
-
- // PumpSwap 协议费用接收者
- pub const PROTOCOL_FEE_RECIPIENT: Pubkey =
- pubkey!("62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV");
-
- /// Rent Sysvar ID
- pub const RENT: Pubkey = pubkey!("SysvarRent111111111111111111111111111111111");
-
- pub const AMM_PROGRAM: Pubkey = pubkey!("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA");
-
- 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];
-pub const SELL_DISCRIMINATOR: [u8; 8] = [51, 230, 133, 164, 1, 127, 131, 173];
diff --git a/src/constants/raydium_cpmm.rs b/src/constants/raydium_cpmm.rs
deleted file mode 100755
index c66c959..0000000
--- a/src/constants/raydium_cpmm.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-//! Constants used by the crate.
-//!
-//! This module contains various constants used throughout the crate, including:
-//!
-//! - Seeds for deriving Program Derived Addresses (PDAs)
-//! - Program account addresses and public keys
-//!
-//! The constants are organized into submodules for better organization:
-//!
-//! - `seeds`: Contains seed values used for PDA derivation
-//! - `accounts`: Contains important program account addresses
-
-/// Constants used as seeds for deriving PDAs (Program Derived Addresses)
-pub mod seeds {
- pub const POOL_SEED: &[u8] = b"pool";
- pub const POOL_VAULT_SEED: &[u8] = b"pool_vault";
- pub const OBSERVATION_STATE_SEED: &[u8] = b"observation";
-}
-
-/// Constants related to program accounts and authorities
-pub mod accounts {
- use solana_sdk::{pubkey, pubkey::Pubkey};
- pub const AUTHORITY: Pubkey = pubkey!("GpMZbSM2GgvTKHJirzeGfMFoaZ8UR2X7F4v8vHTvxFbL");
- pub const AMM_CONFIG: Pubkey = pubkey!("D4FPEruKEHrG5TenZ2mpDGEfu1iUvTiqBxvpU8HLBvC2");
- pub const TOKEN_PROGRAM: Pubkey = spl_token::ID;
- pub const WSOL_TOKEN_ACCOUNT: Pubkey = pubkey!("So11111111111111111111111111111111111111112");
- pub const RAYDIUM_CPMM: Pubkey = pubkey!("CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C");
-
- pub const FEE_RATE_DENOMINATOR_VALUE: u128 = 1_000_000;
- pub const TRADE_FEE_RATE: u64 = 2500;
- pub const CREATOR_FEE_RATE: u64 = 0;
- pub const PROTOCOL_FEE_RATE: u64 = 120000;
- pub const FUND_FEE_RATE: u64 = 40000;
-}
-
-pub const SWAP_BASE_IN_DISCRIMINATOR: &[u8] = &[143, 190, 90, 218, 196, 30, 51, 222];
-pub const SWAP_BASE_OUT_DISCRIMINATOR: &[u8] = &[55, 217, 98, 86, 163, 74, 180, 173];
diff --git a/src/constants/trade.rs b/src/constants/trade.rs
index 043ba09..4a96442 100644
--- a/src/constants/trade.rs
+++ b/src/constants/trade.rs
@@ -6,4 +6,4 @@ pub mod trade {
pub const DEFAULT_SELL_TIP_FEE: f64 = 0.0001;
pub const DEFAULT_RPC_UNIT_LIMIT: u32 = 78000;
pub const DEFAULT_RPC_UNIT_PRICE: u64 = 500000;
-}
+}
\ No newline at end of file
diff --git a/src/constants/trade_platform.rs b/src/constants/trade_platform.rs
new file mode 100644
index 0000000..642aeae
--- /dev/null
+++ b/src/constants/trade_platform.rs
@@ -0,0 +1,8 @@
+pub mod trade_platform {
+ pub const PUMPFUN: &'static str = "pumpfun";
+ pub const PUMPFUN_SWAP: &'static str = "pumpswap";
+ pub const BONK: &'static str = "bonk";
+ pub const RAYDIUM_CPMM: &'static str = "raydium_cpmm";
+ pub const RAYDIUM_CLMM: &'static str = "raydium_clmm";
+ pub const RAYDIUM_AMM_V4: &'static str = "raydium_amm_v4";
+}
diff --git a/src/instruction/bonk.rs b/src/instruction/bonk.rs
index aeaaa85..39d3efc 100755
--- a/src/instruction/bonk.rs
+++ b/src/instruction/bonk.rs
@@ -5,12 +5,12 @@ use spl_associated_token_account::instruction::create_associated_token_account_i
use spl_token::instruction::close_account;
use crate::{
- constants::{
- bonk::{accounts, BUY_EXECT_IN_DISCRIMINATOR, SELL_EXECT_IN_DISCRIMINATOR},
- trade::trade::DEFAULT_SLIPPAGE,
+ constants::trade::trade::DEFAULT_SLIPPAGE,
+ instruction::utils::bonk::{
+ accounts, get_pool_pda, get_vault_pda, BUY_EXECT_IN_DISCRIMINATOR,
+ SELL_EXECT_IN_DISCRIMINATOR,
},
trading::{
- bonk::common::{get_pool_pda, get_vault_pda},
common::utils::get_token_balance,
core::{
params::{BonkParams, BuyParams, SellParams},
diff --git a/src/instruction/mod.rs b/src/instruction/mod.rs
index 81bdcc0..3f94772 100755
--- a/src/instruction/mod.rs
+++ b/src/instruction/mod.rs
@@ -2,4 +2,5 @@ pub mod pumpfun;
pub mod pumpswap;
pub mod bonk;
pub mod raydium_cpmm;
-pub mod raydium_amm_v4;
\ No newline at end of file
+pub mod raydium_amm_v4;
+pub mod utils;
\ No newline at end of file
diff --git a/src/instruction/pumpfun.rs b/src/instruction/pumpfun.rs
index 0f6b23d..1893749 100755
--- a/src/instruction/pumpfun.rs
+++ b/src/instruction/pumpfun.rs
@@ -6,9 +6,10 @@ use spl_associated_token_account::{
use spl_token::instruction::close_account;
use crate::{
- constants,
- trading::pumpfun::common::{
- get_bonding_curve_pda, get_fee_config_pda, get_global_volume_accumulator_pda, get_user_volume_accumulator_pda
+ instruction::utils::pumpfun::{
+ accounts, get_bonding_curve_pda, get_creator_vault_pda, get_fee_config_pda,
+ get_global_volume_accumulator_pda, get_user_volume_accumulator_pda,
+ global_constants::{self, FEE_RECIPIENT},
},
utils::calc::{
common::{calculate_with_slippage_buy, calculate_with_slippage_sell},
@@ -19,13 +20,11 @@ use crate::{
use solana_sdk::{instruction::AccountMeta, pubkey::Pubkey, signature::Keypair, signer::Signer};
use crate::{
- constants::pumpfun::global_constants::FEE_RECIPIENT,
constants::trade::trade::DEFAULT_SLIPPAGE,
trading::core::{
params::{BuyParams, PumpFunParams, SellParams},
traits::InstructionBuilder,
},
- trading::pumpfun::common::get_creator_vault_pda,
};
/// Instruction builder for PumpFun protocol
@@ -58,9 +57,9 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
Pubkey::default()
} else {
// Fast check against cached default creator vault
- static DEFAULT_CREATOR_VAULT: std::sync::LazyLock