Merge commit '7024e100b9a427adf4f0e70ac91d8e90927d7538'
This commit is contained in:
-16
@@ -201,8 +201,6 @@ impl PumpFun {
|
|||||||
&self,
|
&self,
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
creator: Pubkey,
|
creator: Pubkey,
|
||||||
dev_buy_token: u64,
|
|
||||||
dev_sol_cost: u64,
|
|
||||||
buy_sol_cost: u64,
|
buy_sol_cost: u64,
|
||||||
slippage_basis_points: Option<u64>,
|
slippage_basis_points: Option<u64>,
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
@@ -212,8 +210,6 @@ impl PumpFun {
|
|||||||
self.payer.clone(),
|
self.payer.clone(),
|
||||||
mint,
|
mint,
|
||||||
creator,
|
creator,
|
||||||
dev_buy_token,
|
|
||||||
dev_sol_cost,
|
|
||||||
buy_sol_cost,
|
buy_sol_cost,
|
||||||
slippage_basis_points,
|
slippage_basis_points,
|
||||||
self.priority_fee.clone(),
|
self.priority_fee.clone(),
|
||||||
@@ -228,8 +224,6 @@ impl PumpFun {
|
|||||||
&self,
|
&self,
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
creator: Pubkey,
|
creator: Pubkey,
|
||||||
dev_buy_token: u64,
|
|
||||||
dev_sol_cost: u64,
|
|
||||||
buy_sol_cost: u64,
|
buy_sol_cost: u64,
|
||||||
slippage_basis_points: Option<u64>,
|
slippage_basis_points: Option<u64>,
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
@@ -242,8 +236,6 @@ impl PumpFun {
|
|||||||
self.payer.clone(),
|
self.payer.clone(),
|
||||||
mint,
|
mint,
|
||||||
creator,
|
creator,
|
||||||
dev_buy_token,
|
|
||||||
dev_sol_cost,
|
|
||||||
buy_sol_cost,
|
buy_sol_cost,
|
||||||
slippage_basis_points,
|
slippage_basis_points,
|
||||||
self.priority_fee.clone(),
|
self.priority_fee.clone(),
|
||||||
@@ -279,8 +271,6 @@ impl PumpFun {
|
|||||||
&self,
|
&self,
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
creator: Pubkey,
|
creator: Pubkey,
|
||||||
dev_buy_token: u64,
|
|
||||||
dev_sol_cost: u64,
|
|
||||||
buy_sol_cost: u64,
|
buy_sol_cost: u64,
|
||||||
slippage_basis_points: Option<u64>,
|
slippage_basis_points: Option<u64>,
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
@@ -290,8 +280,6 @@ impl PumpFun {
|
|||||||
self.payer.clone(),
|
self.payer.clone(),
|
||||||
mint,
|
mint,
|
||||||
creator,
|
creator,
|
||||||
dev_buy_token,
|
|
||||||
dev_sol_cost,
|
|
||||||
buy_sol_cost,
|
buy_sol_cost,
|
||||||
slippage_basis_points,
|
slippage_basis_points,
|
||||||
self.priority_fee.clone(),
|
self.priority_fee.clone(),
|
||||||
@@ -306,8 +294,6 @@ impl PumpFun {
|
|||||||
&self,
|
&self,
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
creator: Pubkey,
|
creator: Pubkey,
|
||||||
dev_buy_token: u64,
|
|
||||||
dev_sol_cost: u64,
|
|
||||||
buy_sol_cost: u64,
|
buy_sol_cost: u64,
|
||||||
slippage_basis_points: Option<u64>,
|
slippage_basis_points: Option<u64>,
|
||||||
recent_blockhash: Hash,
|
recent_blockhash: Hash,
|
||||||
@@ -326,8 +312,6 @@ impl PumpFun {
|
|||||||
self.payer.clone(),
|
self.payer.clone(),
|
||||||
mint,
|
mint,
|
||||||
creator,
|
creator,
|
||||||
dev_buy_token,
|
|
||||||
dev_sol_cost,
|
|
||||||
buy_sol_cost,
|
buy_sol_cost,
|
||||||
slippage_basis_points,
|
slippage_basis_points,
|
||||||
priority_fee.clone(),
|
priority_fee.clone(),
|
||||||
|
|||||||
@@ -281,8 +281,6 @@ async fn test_sell() -> AnyResult<()> {
|
|||||||
};
|
};
|
||||||
let pumpfun_client = PumpFun::new(Arc::new(payer), &cluster).await;
|
let pumpfun_client = PumpFun::new(Arc::new(payer), &cluster).await;
|
||||||
let creator = Pubkey::from_str("43tFsRkZyhE1JXGivxWthApHPqWCnDqs7E1ZNdy7gkNz")?;
|
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 buy_sol_cost = 500_000; // 0.0005 SOL
|
||||||
let slippage_basis_points = Some(100);
|
let slippage_basis_points = Some(100);
|
||||||
let rpc = RpcClient::new(cluster.rpc_url);
|
let rpc = RpcClient::new(cluster.rpc_url);
|
||||||
@@ -294,8 +292,6 @@ async fn test_sell() -> AnyResult<()> {
|
|||||||
.copy_buy(
|
.copy_buy(
|
||||||
mint_pubkey,
|
mint_pubkey,
|
||||||
creator,
|
creator,
|
||||||
dev_buy_token,
|
|
||||||
dev_sol_cost,
|
|
||||||
buy_sol_cost,
|
buy_sol_cost,
|
||||||
slippage_basis_points,
|
slippage_basis_points,
|
||||||
recent_blockhash,
|
recent_blockhash,
|
||||||
|
|||||||
+4
-12
@@ -1,12 +1,12 @@
|
|||||||
use solana_hash::Hash;
|
use crate::accounts::BondingCurveAccount;
|
||||||
use solana_sdk::{pubkey::Pubkey, signature::Keypair};
|
|
||||||
use std::sync::Arc;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{PriorityFee, SolanaRpcClient},
|
common::{PriorityFee, SolanaRpcClient},
|
||||||
swqos::FeeClient,
|
swqos::FeeClient,
|
||||||
trading::{core::params::PumpFunParams, factory::Protocol, BuyParams, TradeFactory},
|
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;
|
const MAX_LOADED_ACCOUNTS_DATA_SIZE_LIMIT: u32 = 250000;
|
||||||
|
|
||||||
pub async fn buy(
|
pub async fn buy(
|
||||||
@@ -14,8 +14,6 @@ pub async fn buy(
|
|||||||
payer: Arc<Keypair>,
|
payer: Arc<Keypair>,
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
creator: Pubkey,
|
creator: Pubkey,
|
||||||
dev_buy_token: u64,
|
|
||||||
dev_sol_cost: u64,
|
|
||||||
buy_sol_cost: u64,
|
buy_sol_cost: u64,
|
||||||
slippage_basis_points: Option<u64>,
|
slippage_basis_points: Option<u64>,
|
||||||
priority_fee: PriorityFee,
|
priority_fee: PriorityFee,
|
||||||
@@ -28,8 +26,6 @@ pub async fn buy(
|
|||||||
let executor = TradeFactory::create_executor(Protocol::PumpFun);
|
let executor = TradeFactory::create_executor(Protocol::PumpFun);
|
||||||
// 创建协议特定参数
|
// 创建协议特定参数
|
||||||
let protocol_params = Box::new(PumpFunParams {
|
let protocol_params = Box::new(PumpFunParams {
|
||||||
dev_buy_token: dev_buy_token,
|
|
||||||
dev_sol_cost: dev_sol_cost,
|
|
||||||
trade_type: trade_type,
|
trade_type: trade_type,
|
||||||
bonding_curve: bonding_curve,
|
bonding_curve: bonding_curve,
|
||||||
});
|
});
|
||||||
@@ -57,8 +53,6 @@ pub async fn buy_with_tip(
|
|||||||
payer: Arc<Keypair>,
|
payer: Arc<Keypair>,
|
||||||
mint: Pubkey,
|
mint: Pubkey,
|
||||||
creator: Pubkey,
|
creator: Pubkey,
|
||||||
dev_buy_token: u64,
|
|
||||||
dev_sol_cost: u64,
|
|
||||||
buy_sol_cost: u64,
|
buy_sol_cost: u64,
|
||||||
slippage_basis_points: Option<u64>,
|
slippage_basis_points: Option<u64>,
|
||||||
priority_fee: PriorityFee,
|
priority_fee: PriorityFee,
|
||||||
@@ -71,8 +65,6 @@ pub async fn buy_with_tip(
|
|||||||
let executor = TradeFactory::create_executor(Protocol::PumpFun);
|
let executor = TradeFactory::create_executor(Protocol::PumpFun);
|
||||||
// 创建协议特定参数
|
// 创建协议特定参数
|
||||||
let protocol_params = Box::new(PumpFunParams {
|
let protocol_params = Box::new(PumpFunParams {
|
||||||
dev_buy_token: dev_buy_token,
|
|
||||||
dev_sol_cost: dev_sol_cost,
|
|
||||||
trade_type: trade_type,
|
trade_type: trade_type,
|
||||||
bonding_curve: bonding_curve,
|
bonding_curve: bonding_curve,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -244,22 +244,6 @@ pub async fn get_bonding_curve_account_v2(
|
|||||||
Ok((Arc::new(bonding_curve), bonding_curve_pda))
|
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]
|
#[inline]
|
||||||
pub fn get_buy_token_amount(
|
pub fn get_buy_token_amount(
|
||||||
bonding_curve_account: &BondingCurveAccount,
|
bonding_curve_account: &BondingCurveAccount,
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ pub struct SellWithTipParams {
|
|||||||
/// PumpFun协议特定参数
|
/// PumpFun协议特定参数
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct PumpFunParams {
|
pub struct PumpFunParams {
|
||||||
pub dev_buy_token: u64,
|
|
||||||
pub dev_sol_cost: u64,
|
|
||||||
pub trade_type: String,
|
pub trade_type: String,
|
||||||
pub bonding_curve: Option<Arc<BondingCurveAccount>>,
|
pub bonding_curve: Option<Arc<BondingCurveAccount>>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,17 +41,10 @@ impl InstructionBuilder for PumpFunInstructionBuilder {
|
|||||||
return Err(anyhow!("Amount cannot be zero"));
|
return Err(anyhow!("Amount cannot be zero"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取或初始化bonding curve账户
|
let bonding_curve = if protocol_params.bonding_curve.is_some() {
|
||||||
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 {
|
|
||||||
protocol_params.bonding_curve.clone().unwrap()
|
protocol_params.bonding_curve.clone().unwrap()
|
||||||
|
} else {
|
||||||
|
return Err(anyhow!("Bonding curve not found"));
|
||||||
};
|
};
|
||||||
|
|
||||||
let max_sol_cost = calculate_with_slippage_buy(
|
let max_sol_cost = calculate_with_slippage_buy(
|
||||||
|
|||||||
Reference in New Issue
Block a user