feat: Add account event parser and protocol type definitions

- Add account event parser (account_event_parser.rs) for account-level event handling
- Introduce type definitions for pumpfun, pumpswap, raydium_amm_v4, raydium_clmm, raydium_cpmm protocols
- Enhance event processor to support account event processing alongside transactions
- Improve subscription system with separate transaction and account filters
- Optimize parser configuration using Option types for cleaner code structure
- Update examples and documentation to reflect new capabilities

Changes include:
- 6 new types.rs files for protocol-specific data structures
- Updated event processor for account, transaction, and block meta events
- Refactored subscription manager with account filtering support
- Enhanced metrics and batch processing logic
This commit is contained in:
ysq
2025-08-13 23:30:59 +08:00
parent c753c8418d
commit aee8921ad5
40 changed files with 1845 additions and 349 deletions
@@ -38,8 +38,8 @@ impl RaydiumCpmmEventParser {
inner_instruction_discriminator: "",
instruction_discriminator: discriminators::SWAP_BASE_IN,
event_type: EventType::RaydiumCpmmSwapBaseInput,
inner_instruction_parser: Self::empty_parse,
instruction_parser: Self::parse_swap_base_input_instruction,
inner_instruction_parser: None,
instruction_parser: Some(Self::parse_swap_base_input_instruction),
},
GenericEventParseConfig {
program_id: RAYDIUM_CPMM_PROGRAM_ID,
@@ -47,8 +47,8 @@ impl RaydiumCpmmEventParser {
inner_instruction_discriminator: "",
instruction_discriminator: discriminators::SWAP_BASE_OUT,
event_type: EventType::RaydiumCpmmSwapBaseOutput,
inner_instruction_parser: Self::empty_parse,
instruction_parser: Self::parse_swap_base_output_instruction,
inner_instruction_parser: None,
instruction_parser: Some(Self::parse_swap_base_output_instruction),
},
GenericEventParseConfig {
program_id: RAYDIUM_CPMM_PROGRAM_ID,
@@ -56,8 +56,8 @@ impl RaydiumCpmmEventParser {
inner_instruction_discriminator: "",
instruction_discriminator: discriminators::DEPOSIT,
event_type: EventType::RaydiumCpmmDeposit,
inner_instruction_parser: Self::empty_parse,
instruction_parser: Self::parse_deposit_instruction,
inner_instruction_parser: None,
instruction_parser: Some(Self::parse_deposit_instruction),
},
GenericEventParseConfig {
program_id: RAYDIUM_CPMM_PROGRAM_ID,
@@ -65,8 +65,8 @@ impl RaydiumCpmmEventParser {
inner_instruction_discriminator: "",
instruction_discriminator: discriminators::INITIALIZE,
event_type: EventType::RaydiumCpmmInitialize,
inner_instruction_parser: Self::empty_parse,
instruction_parser: Self::parse_initialize_instruction,
inner_instruction_parser: None,
instruction_parser: Some(Self::parse_initialize_instruction),
},
GenericEventParseConfig {
program_id: RAYDIUM_CPMM_PROGRAM_ID,
@@ -74,8 +74,8 @@ impl RaydiumCpmmEventParser {
inner_instruction_discriminator: "",
instruction_discriminator: discriminators::WITHDRAW,
event_type: EventType::RaydiumCpmmWithdraw,
inner_instruction_parser: Self::empty_parse,
instruction_parser: Self::parse_withdraw_instruction,
inner_instruction_parser: None,
instruction_parser: Some(Self::parse_withdraw_instruction),
},
];
@@ -84,10 +84,6 @@ impl RaydiumCpmmEventParser {
Self { inner }
}
fn empty_parse(_data: &[u8], _metadata: EventMetadata) -> Option<Box<dyn UnifiedEvent>> {
None
}
/// 解析提款指令事件
fn parse_withdraw_instruction(
data: &[u8],