diff --git a/src/lib.rs b/src/lib.rs index 1dcb849..7cbc197 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -201,8 +201,6 @@ impl PumpFun { &self, mint: Pubkey, creator: Pubkey, - dev_buy_token: u64, - dev_sol_cost: u64, buy_sol_cost: u64, slippage_basis_points: Option, recent_blockhash: Hash, @@ -212,8 +210,6 @@ impl PumpFun { self.payer.clone(), mint, creator, - dev_buy_token, - dev_sol_cost, buy_sol_cost, slippage_basis_points, self.priority_fee.clone(), @@ -228,8 +224,6 @@ impl PumpFun { &self, mint: Pubkey, creator: Pubkey, - dev_buy_token: u64, - dev_sol_cost: u64, buy_sol_cost: u64, slippage_basis_points: Option, recent_blockhash: Hash, @@ -242,8 +236,6 @@ impl PumpFun { self.payer.clone(), mint, creator, - dev_buy_token, - dev_sol_cost, buy_sol_cost, slippage_basis_points, self.priority_fee.clone(), @@ -279,8 +271,6 @@ impl PumpFun { &self, mint: Pubkey, creator: Pubkey, - dev_buy_token: u64, - dev_sol_cost: u64, buy_sol_cost: u64, slippage_basis_points: Option, recent_blockhash: Hash, @@ -290,8 +280,6 @@ impl PumpFun { self.payer.clone(), mint, creator, - dev_buy_token, - dev_sol_cost, buy_sol_cost, slippage_basis_points, self.priority_fee.clone(), @@ -306,8 +294,6 @@ impl PumpFun { &self, mint: Pubkey, creator: Pubkey, - dev_buy_token: u64, - dev_sol_cost: u64, buy_sol_cost: u64, slippage_basis_points: Option, recent_blockhash: Hash, @@ -326,8 +312,6 @@ impl PumpFun { self.payer.clone(), mint, creator, - dev_buy_token, - dev_sol_cost, buy_sol_cost, slippage_basis_points, priority_fee.clone(), diff --git a/src/main.rs b/src/main.rs index 76db952..9c183ab 100755 --- a/src/main.rs +++ b/src/main.rs @@ -281,8 +281,6 @@ async fn test_sell() -> AnyResult<()> { }; let pumpfun_client = PumpFun::new(Arc::new(payer), &cluster).await; let creator = Pubkey::from_str("43tFsRkZyhE1JXGivxWthApHPqWCnDqs7E1ZNdy7gkNz")?; - let dev_buy_token = 0; - let dev_sol_cost = 0; let buy_sol_cost = 500_000; // 0.0005 SOL let slippage_basis_points = Some(100); let rpc = RpcClient::new(cluster.rpc_url); @@ -294,8 +292,6 @@ async fn test_sell() -> AnyResult<()> { .copy_buy( mint_pubkey, creator, - dev_buy_token, - dev_sol_cost, buy_sol_cost, slippage_basis_points, recent_blockhash, diff --git a/src/pumpfun/buy.rs b/src/pumpfun/buy.rs index e854877..3790a01 100755 --- a/src/pumpfun/buy.rs +++ b/src/pumpfun/buy.rs @@ -1,12 +1,12 @@ -use solana_hash::Hash; -use solana_sdk::{pubkey::Pubkey, signature::Keypair}; -use std::sync::Arc; +use crate::accounts::BondingCurveAccount; use crate::{ common::{PriorityFee, SolanaRpcClient}, swqos::FeeClient, trading::{core::params::PumpFunParams, factory::Protocol, BuyParams, TradeFactory}, }; -use crate::accounts::BondingCurveAccount; +use solana_hash::Hash; +use solana_sdk::{pubkey::Pubkey, signature::Keypair}; +use std::sync::Arc; const MAX_LOADED_ACCOUNTS_DATA_SIZE_LIMIT: u32 = 250000; pub async fn buy( @@ -14,8 +14,6 @@ pub async fn buy( payer: Arc, mint: Pubkey, creator: Pubkey, - dev_buy_token: u64, - dev_sol_cost: u64, buy_sol_cost: u64, slippage_basis_points: Option, priority_fee: PriorityFee, @@ -28,8 +26,6 @@ pub async fn buy( let executor = TradeFactory::create_executor(Protocol::PumpFun); // 创建协议特定参数 let protocol_params = Box::new(PumpFunParams { - dev_buy_token: dev_buy_token, - dev_sol_cost: dev_sol_cost, trade_type: trade_type, bonding_curve: bonding_curve, }); @@ -57,8 +53,6 @@ pub async fn buy_with_tip( payer: Arc, mint: Pubkey, creator: Pubkey, - dev_buy_token: u64, - dev_sol_cost: u64, buy_sol_cost: u64, slippage_basis_points: Option, priority_fee: PriorityFee, @@ -71,8 +65,6 @@ pub async fn buy_with_tip( let executor = TradeFactory::create_executor(Protocol::PumpFun); // 创建协议特定参数 let protocol_params = Box::new(PumpFunParams { - dev_buy_token: dev_buy_token, - dev_sol_cost: dev_sol_cost, trade_type: trade_type, bonding_curve: bonding_curve, }); diff --git a/src/pumpfun/common.rs b/src/pumpfun/common.rs index 3da8b4e..01c2631 100755 --- a/src/pumpfun/common.rs +++ b/src/pumpfun/common.rs @@ -244,22 +244,6 @@ pub async fn get_bonding_curve_account_v2( Ok((Arc::new(bonding_curve), bonding_curve_pda)) } -// #[inline] -// pub fn get_buy_token_amount( -// mint: &Pubkey, -// dev_buy_token: u64, -// dev_cost_sol: u64, -// bot_cost_sol: u64, -// slippage_basis_points: Option, -// ) -> anyhow::Result<(u64, u64)> { -// let bonding_curve_account = BondingCurveAccount::new(mint, dev_buy_token, dev_cost_sol); -// let buy_token = bonding_curve_account.get_buy_price(bot_cost_sol).map_err(|e| anyhow!(e))?; - -// let max_sol_cost = calculate_with_slippage_buy(bot_cost_sol, slippage_basis_points.unwrap_or(DEFAULT_SLIPPAGE)); - -// Ok((buy_token, max_sol_cost)) -// } - #[inline] pub fn get_buy_token_amount( bonding_curve_account: &BondingCurveAccount, diff --git a/src/trading/core/params.rs b/src/trading/core/params.rs index f742c89..7cf51bc 100755 --- a/src/trading/core/params.rs +++ b/src/trading/core/params.rs @@ -74,8 +74,6 @@ pub struct SellWithTipParams { /// PumpFun协议特定参数 #[derive(Clone)] pub struct PumpFunParams { - pub dev_buy_token: u64, - pub dev_sol_cost: u64, pub trade_type: String, pub bonding_curve: Option>, } diff --git a/src/trading/protocols/pumpfun.rs b/src/trading/protocols/pumpfun.rs index 7ae899b..4941547 100755 --- a/src/trading/protocols/pumpfun.rs +++ b/src/trading/protocols/pumpfun.rs @@ -41,17 +41,10 @@ impl InstructionBuilder for PumpFunInstructionBuilder { return Err(anyhow!("Amount cannot be zero")); } - // 获取或初始化bonding curve账户 - let bonding_curve = if protocol_params.trade_type == SNIPER_BUY { - init_bonding_curve_account( - ¶ms.mint, - protocol_params.dev_buy_token, - protocol_params.dev_sol_cost, - params.creator, - ) - .await? - } else { + let bonding_curve = if protocol_params.bonding_curve.is_some() { protocol_params.bonding_curve.clone().unwrap() + } else { + return Err(anyhow!("Bonding curve not found")); }; let max_sol_cost = calculate_with_slippage_buy(