add nextblock, 0slot support

This commit is contained in:
William
2025-04-02 13:39:59 +08:00
parent 2dc15b9020
commit ec03ed8edc
59 changed files with 5315 additions and 1855 deletions
+2
View File
@@ -13,6 +13,7 @@ pub enum DexInstruction {
#[derive(Clone, Debug, Default, PartialEq, BorshDeserialize, BorshSerialize)]
pub struct CreateTokenInfo {
pub slot: u64,
pub name: String,
pub symbol: String,
pub uri: String,
@@ -23,6 +24,7 @@ pub struct CreateTokenInfo {
#[derive(Clone, Debug, Default, PartialEq, BorshDeserialize, BorshSerialize)]
pub struct TradeInfo {
pub slot: u64,
pub mint: Pubkey,
pub sol_amount: u64,
pub token_amount: u64,
+1
View File
@@ -8,6 +8,7 @@ pub const PROGRAM_DATA: &str = "Program data: ";
#[derive(Debug)]
pub enum PumpfunEvent {
NewToken(CreateTokenInfo),
NewDevTrade(TradeInfo),
NewUserTrade(TradeInfo),
NewBotTrade(TradeInfo),
Error(String),
+2
View File
@@ -94,6 +94,7 @@ pub fn parse_create_token_data(data: &str) -> ClientResult<CreateTokenInfo> {
let user = bs58::encode(&decoded[cursor..cursor+32]).into_string();
Ok(CreateTokenInfo {
slot: 0,
name,
symbol,
uri,
@@ -158,6 +159,7 @@ pub fn parse_trade_data(data: &str) -> ClientResult<TradeInfo> {
let real_token_reserves = u64::from_le_bytes(decoded[cursor..cursor + 8].try_into().unwrap());
Ok(TradeInfo {
slot: 0,
mint: Pubkey::from_str(&mint).unwrap(),
sol_amount,
token_amount,
+3
View File
@@ -3,3 +3,6 @@ pub mod logs_parser;
pub mod logs_filters;
pub mod logs_subscribe;
pub mod logs_events;
pub mod types;
pub use types::*;
+93
View File
@@ -0,0 +1,93 @@
use std::sync::Arc;
use solana_client::rpc_client::RpcClient;
use solana_sdk::{commitment_config::CommitmentConfig, signature::Keypair};
use serde::Deserialize;
use crate::{constants::trade::{DEFAULT_BUY_TIP_FEE, DEFAULT_COMPUTE_UNIT_LIMIT, DEFAULT_COMPUTE_UNIT_PRICE, DEFAULT_SELL_TIP_FEE}, jito::FeeClient};
#[derive(Debug, Clone, PartialEq)]
pub enum FeeType {
Jito,
NextBlock,
}
#[derive(Debug, Clone)]
pub struct Cluster {
pub rpc_url: String,
pub block_engine_url: String,
pub nextblock_url: String,
pub nextblock_auth_token: String,
pub zeroslot_url: String,
pub zeroslot_auth_token: String,
pub use_jito: bool,
pub use_nextblock: bool,
pub use_zeroslot: bool,
pub priority_fee: PriorityFee,
pub commitment: CommitmentConfig,
}
impl Cluster {
pub fn new(
rpc_url: String,
block_engine_url:
String, nextblock_url:
String, nextblock_auth_token:
String, zeroslot_url: String,
zeroslot_auth_token: String,
priority_fee: PriorityFee,
commitment: CommitmentConfig,
use_jito: bool,
use_nextblock: bool,
use_zeroslot: bool
) -> Self {
Self {
rpc_url,
block_engine_url,
nextblock_url,
nextblock_auth_token,
zeroslot_url,
zeroslot_auth_token,
priority_fee,
commitment,
use_jito,
use_nextblock,
use_zeroslot
}
}
}
#[derive(Debug, Deserialize, Clone, Copy, PartialEq)]
pub struct PriorityFee {
pub unit_limit: u32,
pub unit_price: u64,
pub buy_tip_fee: f64,
pub sell_tip_fee: f64,
}
impl Default for PriorityFee {
fn default() -> Self {
Self {
unit_limit: DEFAULT_COMPUTE_UNIT_LIMIT,
unit_price: DEFAULT_COMPUTE_UNIT_PRICE,
buy_tip_fee: DEFAULT_BUY_TIP_FEE,
sell_tip_fee: DEFAULT_SELL_TIP_FEE
}
}
}
pub type SolanaRpcClient = solana_client::nonblocking::rpc_client::RpcClient;
pub struct MethodArgs {
pub payer: Arc<Keypair>,
pub rpc: Arc<RpcClient>,
pub nonblocking_rpc: Arc<SolanaRpcClient>,
pub jito_client: Arc<FeeClient>,
}
impl MethodArgs {
pub fn new(payer: Arc<Keypair>, rpc: Arc<RpcClient>, nonblocking_rpc: Arc<SolanaRpcClient>, jito_client: Arc<FeeClient>) -> Self {
Self { payer, rpc, nonblocking_rpc, jito_client }
}
}