feat(pumpswap): enhance PumpSwap trading functionality and logs parsing system

- Expand buy/sell trading logic with optimized execution flow
- Improve logs data structures and parser performance
- Enhance common utilities and pool management features
- Refactor main program architecture for better maintainability
- Update library export interfaces with improved API design
This commit is contained in:
sgxiang
2025-06-12 00:00:30 +08:00
parent 6f819be4e0
commit 165335af11
8 changed files with 828 additions and 235 deletions
+26
View File
@@ -48,6 +48,19 @@ pub struct BuyEvent {
pub coin_creator_fee: u64,
#[borsh(skip)]
pub signature: String,
#[borsh(skip)]
pub base_mint: Pubkey,
#[borsh(skip)]
pub quote_mint: Pubkey,
#[borsh(skip)]
pub pool_base_token_account: Pubkey,
#[borsh(skip)]
pub pool_quote_token_account: Pubkey,
#[borsh(skip)]
pub coin_creator_vault_ata: Pubkey,
#[borsh(skip)]
pub coin_creator_vault_authority: Pubkey,
}
/// 卖出事件
@@ -80,6 +93,19 @@ pub struct SellEvent {
pub coin_creator_fee: u64,
#[borsh(skip)]
pub signature: String,
#[borsh(skip)]
pub base_mint: Pubkey,
#[borsh(skip)]
pub quote_mint: Pubkey,
#[borsh(skip)]
pub pool_base_token_account: Pubkey,
#[borsh(skip)]
pub pool_quote_token_account: Pubkey,
#[borsh(skip)]
pub coin_creator_vault_ata: Pubkey,
#[borsh(skip)]
pub coin_creator_vault_authority: Pubkey,
}
/// 创建池子事件
+15 -1
View File
@@ -113,7 +113,7 @@ pub fn parse_pumpswap_instruction(instruction: &CompiledInstruction, _accounts:
}
let base_amount_out = u64::from_le_bytes(data[0..8].try_into().ok()?);
let max_quote_amount_in = u64::from_le_bytes(data[8..16].try_into().ok()?);
Some(PumpSwapInstruction::Buy(BuyEvent {
base_amount_out,
max_quote_amount_in,
@@ -124,6 +124,13 @@ pub fn parse_pumpswap_instruction(instruction: &CompiledInstruction, _accounts:
protocol_fee_recipient: accounts[9],
protocol_fee_recipient_token_account: accounts[10],
timestamp: current_timestamp(),
base_mint: accounts[3],
quote_mint: accounts[4],
pool_base_token_account: accounts[7],
pool_quote_token_account: accounts[8],
coin_creator_vault_ata: if accounts.len() > 17 { accounts[17] } else { Pubkey::default() },
coin_creator_vault_authority: if accounts.len() > 18 { accounts[18] } else { Pubkey::default() },
..Default::default()
}))
},
@@ -148,6 +155,13 @@ pub fn parse_pumpswap_instruction(instruction: &CompiledInstruction, _accounts:
protocol_fee_recipient: accounts[9],
protocol_fee_recipient_token_account: accounts[10],
timestamp: current_timestamp(),
base_mint: accounts[3],
quote_mint: accounts[4],
pool_base_token_account: accounts[7],
pool_quote_token_account: accounts[8],
coin_creator_vault_ata: if accounts.len() > 17 { accounts[17] } else { Pubkey::default() },
coin_creator_vault_authority: if accounts.len() > 18 { accounts[18] } else { Pubkey::default() },
..Default::default()
}))
},