Merge commit '7024e100b9a427adf4f0e70ac91d8e90927d7538'
This commit is contained in:
-16
@@ -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<u64>,
|
||||
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<u64>,
|
||||
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<u64>,
|
||||
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<u64>,
|
||||
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(),
|
||||
|
||||
@@ -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,
|
||||
|
||||
+4
-12
@@ -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<Keypair>,
|
||||
mint: Pubkey,
|
||||
creator: Pubkey,
|
||||
dev_buy_token: u64,
|
||||
dev_sol_cost: u64,
|
||||
buy_sol_cost: u64,
|
||||
slippage_basis_points: Option<u64>,
|
||||
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<Keypair>,
|
||||
mint: Pubkey,
|
||||
creator: Pubkey,
|
||||
dev_buy_token: u64,
|
||||
dev_sol_cost: u64,
|
||||
buy_sol_cost: u64,
|
||||
slippage_basis_points: Option<u64>,
|
||||
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,
|
||||
});
|
||||
|
||||
@@ -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<u64>,
|
||||
// ) -> 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,
|
||||
|
||||
@@ -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<Arc<BondingCurveAccount>>,
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user