change project name
This commit is contained in:
+1
-1
@@ -87,4 +87,4 @@ tokio-tungstenite = { version = "0.26.1", features = ["native-tls"] }
|
||||
indicatif = "0.17.11"
|
||||
toml = "0.8.20"
|
||||
|
||||
pumpfun_program = { version = "4.2.0", package = "pumpfun" }
|
||||
pumpfun_program = { version = "4.3.0", package = "pumpfun" }
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use solana_client::rpc_client::RpcClient;
|
||||
use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey, signature::Keypair};
|
||||
use serde::Deserialize;
|
||||
use crate::{constants::pumpfun::trade::{DEFAULT_BUY_TIP_FEE, DEFAULT_COMPUTE_UNIT_LIMIT, DEFAULT_COMPUTE_UNIT_PRICE, DEFAULT_SELL_TIP_FEE}, swqos::FeeClient};
|
||||
use crate::{constants::pumpfun::trade::{DEFAULT_BUY_TIP_FEE, DEFAULT_COMPUTE_UNIT_LIMIT, DEFAULT_COMPUTE_UNIT_PRICE, DEFAULT_RPC_UNIT_LIMIT, DEFAULT_RPC_UNIT_PRICE, DEFAULT_SELL_TIP_FEE}, swqos::FeeClient};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum FeeType {
|
||||
@@ -87,8 +87,8 @@ impl Default for PriorityFee {
|
||||
Self {
|
||||
unit_limit: DEFAULT_COMPUTE_UNIT_LIMIT,
|
||||
unit_price: DEFAULT_COMPUTE_UNIT_PRICE,
|
||||
rpc_unit_limit: 0,
|
||||
rpc_unit_price: 0,
|
||||
rpc_unit_limit: DEFAULT_RPC_UNIT_LIMIT,
|
||||
rpc_unit_price: DEFAULT_RPC_UNIT_PRICE,
|
||||
buy_tip_fee: DEFAULT_BUY_TIP_FEE,
|
||||
buy_tip_fees: vec![],
|
||||
sell_tip_fee: DEFAULT_SELL_TIP_FEE
|
||||
|
||||
@@ -165,6 +165,8 @@ pub mod trade {
|
||||
pub const DEFAULT_COMPUTE_UNIT_PRICE: u64 = 500000;
|
||||
pub const DEFAULT_BUY_TIP_FEE: f64 = 0.0006;
|
||||
pub const DEFAULT_SELL_TIP_FEE: f64 = 0.0001;
|
||||
pub const DEFAULT_RPC_UNIT_LIMIT: u32 = 1000000;
|
||||
pub const DEFAULT_RPC_UNIT_PRICE: u64 = 500000;
|
||||
}
|
||||
|
||||
pub struct Symbol;
|
||||
|
||||
+18
@@ -640,6 +640,15 @@ impl PumpFun {
|
||||
Ok(actual_sol_reserves)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub async fn get_creator(&self, mint: &Pubkey) -> Result<Pubkey, anyhow::Error> {
|
||||
let (bonding_curve, _) = pumpfun::common::get_bonding_curve_account_v2(&self.rpc, mint).await?;
|
||||
|
||||
let creator = bonding_curve.creator;
|
||||
|
||||
Ok(creator)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub async fn get_current_price_with_pumpswap(&self, pool_address: &Pubkey) -> Result<f64, anyhow::Error> {
|
||||
let pool = pumpswap::pool::Pool::fetch(&self.rpc, pool_address).await?;
|
||||
@@ -665,4 +674,13 @@ impl PumpFun {
|
||||
|
||||
Ok(quote_amount)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub async fn get_payer_token_balance_with_pumpswap(&self, pool_address: &Pubkey) -> Result<u64, anyhow::Error> {
|
||||
let pool = pumpswap::pool::Pool::fetch(&self.rpc, pool_address).await?;
|
||||
|
||||
let (base_amount, _) = pool.get_token_balances(&self.rpc).await?;
|
||||
|
||||
Ok(base_amount)
|
||||
}
|
||||
}
|
||||
|
||||
+26
-10
@@ -7,7 +7,7 @@ use spl_associated_token_account::get_associated_token_address;
|
||||
use spl_token::instruction::close_account;
|
||||
use tokio::task::JoinHandle;
|
||||
use std::{str::FromStr, sync::Arc, time::Instant};
|
||||
|
||||
use crate::PumpFun;
|
||||
use crate::{common::{address_lookup_cache::get_address_lookup_table_account, PriorityFee, SolanaRpcClient}, constants::pumpfun::{global_constants::FEE_RECIPIENT}, instruction, swqos::{FeeClient, TradeType, ClientType}};
|
||||
|
||||
use super::common::get_creator_vault_pda;
|
||||
@@ -270,7 +270,18 @@ pub async fn build_sell_instructions(
|
||||
let creator_vault_pda = get_creator_vault_pda(&creator).unwrap();
|
||||
let ata = get_associated_token_address(&payer.pubkey(), &mint);
|
||||
|
||||
let instructions = vec![
|
||||
// Get token balance
|
||||
let rpc = PumpFun::get_instance().get_rpc().clone();
|
||||
let balance = rpc.get_token_account_balance(&ata).await?;
|
||||
let balance_u64 = balance.amount.parse::<u64>()
|
||||
.map_err(|_| anyhow!("Failed to parse token balance"))?;
|
||||
|
||||
let mut amount_token = amount_token;
|
||||
if amount_token > balance_u64 {
|
||||
amount_token = balance_u64;
|
||||
}
|
||||
|
||||
let mut instructions = vec![
|
||||
instruction::sell(
|
||||
payer.as_ref(),
|
||||
&mint,
|
||||
@@ -281,15 +292,20 @@ pub async fn build_sell_instructions(
|
||||
_min_sol_output: 1,
|
||||
},
|
||||
),
|
||||
|
||||
close_account(
|
||||
&spl_token::ID,
|
||||
&ata,
|
||||
&payer.pubkey(),
|
||||
&payer.pubkey(),
|
||||
&[&payer.pubkey()],
|
||||
)?
|
||||
];
|
||||
|
||||
// Only add close account instruction if amount is less than balance
|
||||
if amount_token >= balance_u64 {
|
||||
instructions.push(
|
||||
close_account(
|
||||
&spl_token::ID,
|
||||
&ata,
|
||||
&payer.pubkey(),
|
||||
&payer.pubkey(),
|
||||
&[&payer.pubkey()],
|
||||
)?
|
||||
);
|
||||
}
|
||||
|
||||
Ok(instructions)
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ impl FeeClientTrait for SolRpcClient {
|
||||
Ok(_) => (),
|
||||
Err(_) => (),
|
||||
}
|
||||
println!(" signature: {:?}", signature);
|
||||
println!(" rpc{}确认: {:?}", trade_type, start_time.elapsed());
|
||||
|
||||
Ok(signature)
|
||||
|
||||
Reference in New Issue
Block a user