mirror of
https://github.com/0xfnzero/solana-streamer.git
synced 2026-08-23 05:48:05 +00:00
feat: bridge streamer to sol-parser-sdk
This commit is contained in:
@@ -93,7 +93,8 @@ pub fn pump_swap_buy_event_log_decode(data: &[u8]) -> Option<PumpSwapBuyEvent> {
|
||||
let user_base_token_account = Pubkey::new_from_array(data.get(176..208)?.try_into().ok()?);
|
||||
let user_quote_token_account = Pubkey::new_from_array(data.get(208..240)?.try_into().ok()?);
|
||||
let protocol_fee_recipient = Pubkey::new_from_array(data.get(240..272)?.try_into().ok()?);
|
||||
let protocol_fee_recipient_token_account = Pubkey::new_from_array(data.get(272..304)?.try_into().ok()?);
|
||||
let protocol_fee_recipient_token_account =
|
||||
Pubkey::new_from_array(data.get(272..304)?.try_into().ok()?);
|
||||
let coin_creator = Pubkey::new_from_array(data.get(304..336)?.try_into().ok()?);
|
||||
let coin_creator_fee_basis_points = read_u64_le(data, 336)?;
|
||||
let coin_creator_fee = read_u64_le(data, 344)?;
|
||||
@@ -243,11 +244,13 @@ pub fn pump_swap_sell_event_log_decode(data: &[u8]) -> Option<PumpSwapSellEvent>
|
||||
let user_base_token_account = Pubkey::new_from_array(data.get(176..208)?.try_into().ok()?);
|
||||
let user_quote_token_account = Pubkey::new_from_array(data.get(208..240)?.try_into().ok()?);
|
||||
let protocol_fee_recipient = Pubkey::new_from_array(data.get(240..272)?.try_into().ok()?);
|
||||
let protocol_fee_recipient_token_account = Pubkey::new_from_array(data.get(272..304)?.try_into().ok()?);
|
||||
let protocol_fee_recipient_token_account =
|
||||
Pubkey::new_from_array(data.get(272..304)?.try_into().ok()?);
|
||||
let coin_creator = Pubkey::new_from_array(data.get(304..336)?.try_into().ok()?);
|
||||
let coin_creator_fee_basis_points = read_u64_le(data, 336)?;
|
||||
let coin_creator_fee = read_u64_le(data, 344)?;
|
||||
let (cashback_fee_basis_points, cashback) = if data.len() >= PUMP_SWAP_SELL_EVENT_WITH_CASHBACK {
|
||||
let (cashback_fee_basis_points, cashback) = if data.len() >= PUMP_SWAP_SELL_EVENT_WITH_CASHBACK
|
||||
{
|
||||
(read_u64_le(data, 352)?, read_u64_le(data, 360)?)
|
||||
} else {
|
||||
(0, 0)
|
||||
|
||||
@@ -25,11 +25,11 @@ pub fn parse_pumpswap_instruction_data(
|
||||
) -> Option<DexEvent> {
|
||||
match discriminator {
|
||||
discriminators::BUY_IX => parse_buy_instruction(data, accounts, metadata),
|
||||
discriminators::BUY_EXACT_QUOTE_IN_IX => parse_buy_exact_quote_in_instruction(data, accounts, metadata),
|
||||
discriminators::SELL_IX => parse_sell_instruction(data, accounts, metadata),
|
||||
discriminators::CREATE_POOL_IX => {
|
||||
parse_create_pool_instruction(data, accounts, metadata)
|
||||
discriminators::BUY_EXACT_QUOTE_IN_IX => {
|
||||
parse_buy_exact_quote_in_instruction(data, accounts, metadata)
|
||||
}
|
||||
discriminators::SELL_IX => parse_sell_instruction(data, accounts, metadata),
|
||||
discriminators::CREATE_POOL_IX => parse_create_pool_instruction(data, accounts, metadata),
|
||||
discriminators::DEPOSIT_IX => parse_deposit_instruction(data, accounts, metadata),
|
||||
discriminators::WITHDRAW_IX => parse_withdraw_instruction(data, accounts, metadata),
|
||||
_ => None,
|
||||
@@ -47,16 +47,13 @@ pub fn parse_pumpswap_inner_instruction_data(
|
||||
match discriminator {
|
||||
discriminators::BUY_EVENT => parse_buy_inner_instruction(data, metadata),
|
||||
discriminators::SELL_EVENT => parse_sell_inner_instruction(data, metadata),
|
||||
discriminators::CREATE_POOL_EVENT => {
|
||||
parse_create_pool_inner_instruction(data, metadata)
|
||||
}
|
||||
discriminators::CREATE_POOL_EVENT => parse_create_pool_inner_instruction(data, metadata),
|
||||
discriminators::DEPOSIT_EVENT => parse_deposit_inner_instruction(data, metadata),
|
||||
discriminators::WITHDRAW_EVENT => parse_withdraw_inner_instruction(data, metadata),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 解析 PumpSwap 账户数据
|
||||
///
|
||||
/// 根据判别器路由到具体的账户解析函数
|
||||
@@ -67,10 +64,14 @@ pub fn parse_pumpswap_account_data(
|
||||
) -> Option<crate::streaming::event_parser::DexEvent> {
|
||||
match discriminator {
|
||||
discriminators::GLOBAL_CONFIG_ACCOUNT => {
|
||||
crate::streaming::event_parser::protocols::pumpswap::types::global_config_parser(account, metadata)
|
||||
crate::streaming::event_parser::protocols::pumpswap::types::global_config_parser(
|
||||
account, metadata,
|
||||
)
|
||||
}
|
||||
discriminators::POOL_ACCOUNT => {
|
||||
crate::streaming::event_parser::protocols::pumpswap::types::pool_parser(account, metadata)
|
||||
crate::streaming::event_parser::protocols::pumpswap::types::pool_parser(
|
||||
account, metadata,
|
||||
)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
@@ -97,10 +98,7 @@ fn parse_sell_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<
|
||||
}
|
||||
|
||||
/// 解析创建池子日志事件
|
||||
fn parse_create_pool_inner_instruction(
|
||||
data: &[u8],
|
||||
metadata: EventMetadata,
|
||||
) -> Option<DexEvent> {
|
||||
fn parse_create_pool_inner_instruction(data: &[u8], metadata: EventMetadata) -> Option<DexEvent> {
|
||||
// Note: event_type will be set by instruction parser
|
||||
if let Some(event) = pump_swap_create_pool_event_log_decode(data) {
|
||||
Some(DexEvent::PumpSwapCreatePoolEvent(PumpSwapCreatePoolEvent { metadata, ..event }))
|
||||
|
||||
Reference in New Issue
Block a user