2025-10-10 18:19:44 +08:00
|
|
|
use crate::streaming::event_parser::common::EventMetadata;
|
|
|
|
|
use crate::streaming::event_parser::core::account_event_parser::{
|
|
|
|
|
NonceAccountEvent, TokenAccountEvent, TokenInfoEvent,
|
|
|
|
|
};
|
2025-11-16 22:49:37 +08:00
|
|
|
use crate::streaming::event_parser::core::common_event_parser::{
|
|
|
|
|
SetComputeUnitLimitEvent, SetComputeUnitPriceEvent,
|
|
|
|
|
};
|
2025-10-10 18:19:44 +08:00
|
|
|
use crate::streaming::event_parser::protocols::block::block_meta_event::BlockMetaEvent;
|
|
|
|
|
use crate::streaming::event_parser::protocols::bonk::events::*;
|
2025-11-10 00:38:23 +08:00
|
|
|
use crate::streaming::event_parser::protocols::meteora_damm_v2::events::*;
|
2025-10-10 18:19:44 +08:00
|
|
|
use crate::streaming::event_parser::protocols::pumpfun::events::*;
|
|
|
|
|
use crate::streaming::event_parser::protocols::pumpswap::events::*;
|
|
|
|
|
use crate::streaming::event_parser::protocols::raydium_amm_v4::events::*;
|
|
|
|
|
use crate::streaming::event_parser::protocols::raydium_clmm::events::*;
|
|
|
|
|
use crate::streaming::event_parser::protocols::raydium_cpmm::events::*;
|
2026-05-15 05:09:29 +08:00
|
|
|
use crate::streaming::event_parser::protocols::sol_parser_forward::events::{
|
|
|
|
|
MeteoraDlmmAddLiquidityEvent, MeteoraDlmmClaimFeeEvent, MeteoraDlmmClosePositionEvent,
|
|
|
|
|
MeteoraDlmmCreatePositionEvent, MeteoraDlmmInitializeBinArrayEvent,
|
|
|
|
|
MeteoraDlmmInitializePoolEvent, MeteoraDlmmRemoveLiquidityEvent, MeteoraDlmmSwapEvent,
|
|
|
|
|
MeteoraPoolsAddLiquidityEvent, MeteoraPoolsBootstrapLiquidityEvent,
|
|
|
|
|
MeteoraPoolsPoolCreatedEvent, MeteoraPoolsRemoveLiquidityEvent, MeteoraPoolsSetPoolFeesEvent,
|
|
|
|
|
MeteoraPoolsSwapEvent, OrcaWhirlpoolLiquidityDecreasedEvent,
|
|
|
|
|
OrcaWhirlpoolLiquidityIncreasedEvent, OrcaWhirlpoolPoolInitializedEvent,
|
|
|
|
|
OrcaWhirlpoolSwapEvent, ParserSdkErrorEvent,
|
|
|
|
|
};
|
2025-10-10 18:19:44 +08:00
|
|
|
use serde::{Deserialize, Serialize};
|
2025-07-19 23:46:42 +08:00
|
|
|
use std::fmt::Debug;
|
2025-08-31 22:18:18 +08:00
|
|
|
|
2025-10-10 18:19:44 +08:00
|
|
|
/// Unified Event Enum - Replaces the trait-based approach with a type-safe enum
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
2025-10-12 22:00:15 +08:00
|
|
|
pub enum DexEvent {
|
2025-10-10 18:19:44 +08:00
|
|
|
// Bonk events
|
|
|
|
|
BonkTradeEvent(BonkTradeEvent),
|
|
|
|
|
BonkPoolCreateEvent(BonkPoolCreateEvent),
|
|
|
|
|
BonkMigrateToAmmEvent(BonkMigrateToAmmEvent),
|
|
|
|
|
BonkMigrateToCpswapEvent(BonkMigrateToCpswapEvent),
|
|
|
|
|
BonkPoolStateAccountEvent(BonkPoolStateAccountEvent),
|
|
|
|
|
BonkGlobalConfigAccountEvent(BonkGlobalConfigAccountEvent),
|
|
|
|
|
BonkPlatformConfigAccountEvent(BonkPlatformConfigAccountEvent),
|
2025-07-19 23:46:42 +08:00
|
|
|
|
2025-10-10 18:19:44 +08:00
|
|
|
// PumpFun events
|
|
|
|
|
PumpFunCreateTokenEvent(PumpFunCreateTokenEvent),
|
2025-11-09 23:30:48 +08:00
|
|
|
PumpFunCreateV2TokenEvent(PumpFunCreateV2TokenEvent),
|
2025-10-10 18:19:44 +08:00
|
|
|
PumpFunTradeEvent(PumpFunTradeEvent),
|
|
|
|
|
PumpFunMigrateEvent(PumpFunMigrateEvent),
|
2026-05-15 05:09:29 +08:00
|
|
|
PumpFeesCreateFeeSharingConfigEvent(PumpFeesCreateFeeSharingConfigEvent),
|
|
|
|
|
PumpFeesInitializeFeeConfigEvent(PumpFeesInitializeFeeConfigEvent),
|
|
|
|
|
PumpFeesResetFeeSharingConfigEvent(PumpFeesResetFeeSharingConfigEvent),
|
|
|
|
|
PumpFeesRevokeFeeSharingAuthorityEvent(PumpFeesRevokeFeeSharingAuthorityEvent),
|
|
|
|
|
PumpFeesTransferFeeSharingAuthorityEvent(PumpFeesTransferFeeSharingAuthorityEvent),
|
|
|
|
|
PumpFeesUpdateAdminEvent(PumpFeesUpdateAdminEvent),
|
|
|
|
|
PumpFeesUpdateFeeConfigEvent(PumpFeesUpdateFeeConfigEvent),
|
|
|
|
|
PumpFeesUpdateFeeSharesEvent(PumpFeesUpdateFeeSharesEvent),
|
|
|
|
|
PumpFeesUpsertFeeTiersEvent(PumpFeesUpsertFeeTiersEvent),
|
|
|
|
|
PumpFunMigrateBondingCurveCreatorEvent(PumpFunMigrateBondingCurveCreatorEvent),
|
2025-10-10 18:19:44 +08:00
|
|
|
PumpFunBondingCurveAccountEvent(PumpFunBondingCurveAccountEvent),
|
|
|
|
|
PumpFunGlobalAccountEvent(PumpFunGlobalAccountEvent),
|
2025-07-19 23:46:42 +08:00
|
|
|
|
2025-10-10 18:19:44 +08:00
|
|
|
// PumpSwap events
|
|
|
|
|
PumpSwapBuyEvent(PumpSwapBuyEvent),
|
|
|
|
|
PumpSwapSellEvent(PumpSwapSellEvent),
|
|
|
|
|
PumpSwapCreatePoolEvent(PumpSwapCreatePoolEvent),
|
|
|
|
|
PumpSwapDepositEvent(PumpSwapDepositEvent),
|
|
|
|
|
PumpSwapWithdrawEvent(PumpSwapWithdrawEvent),
|
|
|
|
|
PumpSwapGlobalConfigAccountEvent(PumpSwapGlobalConfigAccountEvent),
|
|
|
|
|
PumpSwapPoolAccountEvent(PumpSwapPoolAccountEvent),
|
2025-07-19 23:46:42 +08:00
|
|
|
|
2025-10-10 18:19:44 +08:00
|
|
|
// Raydium AMM V4 events
|
|
|
|
|
RaydiumAmmV4SwapEvent(RaydiumAmmV4SwapEvent),
|
|
|
|
|
RaydiumAmmV4DepositEvent(RaydiumAmmV4DepositEvent),
|
|
|
|
|
RaydiumAmmV4WithdrawEvent(RaydiumAmmV4WithdrawEvent),
|
|
|
|
|
RaydiumAmmV4WithdrawPnlEvent(RaydiumAmmV4WithdrawPnlEvent),
|
|
|
|
|
RaydiumAmmV4Initialize2Event(RaydiumAmmV4Initialize2Event),
|
|
|
|
|
RaydiumAmmV4AmmInfoAccountEvent(RaydiumAmmV4AmmInfoAccountEvent),
|
2025-07-19 23:46:42 +08:00
|
|
|
|
2025-10-10 18:19:44 +08:00
|
|
|
// Raydium CLMM events
|
|
|
|
|
RaydiumClmmSwapEvent(RaydiumClmmSwapEvent),
|
|
|
|
|
RaydiumClmmSwapV2Event(RaydiumClmmSwapV2Event),
|
|
|
|
|
RaydiumClmmClosePositionEvent(RaydiumClmmClosePositionEvent),
|
|
|
|
|
RaydiumClmmIncreaseLiquidityV2Event(RaydiumClmmIncreaseLiquidityV2Event),
|
|
|
|
|
RaydiumClmmDecreaseLiquidityV2Event(RaydiumClmmDecreaseLiquidityV2Event),
|
2026-05-15 05:09:29 +08:00
|
|
|
RaydiumClmmCollectFeeEvent(RaydiumClmmCollectFeeEvent),
|
2025-10-10 18:19:44 +08:00
|
|
|
RaydiumClmmCreatePoolEvent(RaydiumClmmCreatePoolEvent),
|
|
|
|
|
RaydiumClmmOpenPositionWithToken22NftEvent(RaydiumClmmOpenPositionWithToken22NftEvent),
|
|
|
|
|
RaydiumClmmOpenPositionV2Event(RaydiumClmmOpenPositionV2Event),
|
|
|
|
|
RaydiumClmmAmmConfigAccountEvent(RaydiumClmmAmmConfigAccountEvent),
|
|
|
|
|
RaydiumClmmPoolStateAccountEvent(RaydiumClmmPoolStateAccountEvent),
|
|
|
|
|
RaydiumClmmTickArrayStateAccountEvent(RaydiumClmmTickArrayStateAccountEvent),
|
2025-07-29 14:48:43 +08:00
|
|
|
|
2025-10-10 18:19:44 +08:00
|
|
|
// Raydium CPMM events
|
|
|
|
|
RaydiumCpmmSwapEvent(RaydiumCpmmSwapEvent),
|
|
|
|
|
RaydiumCpmmDepositEvent(RaydiumCpmmDepositEvent),
|
|
|
|
|
RaydiumCpmmWithdrawEvent(RaydiumCpmmWithdrawEvent),
|
|
|
|
|
RaydiumCpmmInitializeEvent(RaydiumCpmmInitializeEvent),
|
|
|
|
|
RaydiumCpmmAmmConfigAccountEvent(RaydiumCpmmAmmConfigAccountEvent),
|
|
|
|
|
RaydiumCpmmPoolStateAccountEvent(RaydiumCpmmPoolStateAccountEvent),
|
2025-07-29 14:48:43 +08:00
|
|
|
|
2025-11-10 00:38:23 +08:00
|
|
|
// Meteora DAMM v2 events
|
|
|
|
|
MeteoraDammV2SwapEvent(MeteoraDammV2SwapEvent),
|
|
|
|
|
MeteoraDammV2Swap2Event(MeteoraDammV2Swap2Event),
|
|
|
|
|
MeteoraDammV2InitializePoolEvent(MeteoraDammV2InitializePoolEvent),
|
|
|
|
|
MeteoraDammV2InitializeCustomizablePoolEvent(MeteoraDammV2InitializeCustomizablePoolEvent),
|
2026-05-15 05:09:29 +08:00
|
|
|
MeteoraDammV2InitializePoolWithDynamicConfigEvent(
|
|
|
|
|
MeteoraDammV2InitializePoolWithDynamicConfigEvent,
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
MeteoraDammV2AddLiquidityEvent(MeteoraDammV2AddLiquidityEvent),
|
|
|
|
|
MeteoraDammV2RemoveLiquidityEvent(MeteoraDammV2RemoveLiquidityEvent),
|
|
|
|
|
MeteoraDammV2CreatePositionEvent(MeteoraDammV2CreatePositionEvent),
|
|
|
|
|
MeteoraDammV2ClosePositionEvent(MeteoraDammV2ClosePositionEvent),
|
|
|
|
|
|
|
|
|
|
OrcaWhirlpoolSwapEvent(OrcaWhirlpoolSwapEvent),
|
|
|
|
|
OrcaWhirlpoolLiquidityIncreasedEvent(OrcaWhirlpoolLiquidityIncreasedEvent),
|
|
|
|
|
OrcaWhirlpoolLiquidityDecreasedEvent(OrcaWhirlpoolLiquidityDecreasedEvent),
|
|
|
|
|
OrcaWhirlpoolPoolInitializedEvent(OrcaWhirlpoolPoolInitializedEvent),
|
|
|
|
|
|
|
|
|
|
MeteoraPoolsSwapEvent(MeteoraPoolsSwapEvent),
|
|
|
|
|
MeteoraPoolsAddLiquidityEvent(MeteoraPoolsAddLiquidityEvent),
|
|
|
|
|
MeteoraPoolsRemoveLiquidityEvent(MeteoraPoolsRemoveLiquidityEvent),
|
|
|
|
|
MeteoraPoolsBootstrapLiquidityEvent(MeteoraPoolsBootstrapLiquidityEvent),
|
|
|
|
|
MeteoraPoolsPoolCreatedEvent(MeteoraPoolsPoolCreatedEvent),
|
|
|
|
|
MeteoraPoolsSetPoolFeesEvent(MeteoraPoolsSetPoolFeesEvent),
|
|
|
|
|
|
|
|
|
|
MeteoraDlmmSwapEvent(MeteoraDlmmSwapEvent),
|
|
|
|
|
MeteoraDlmmAddLiquidityEvent(MeteoraDlmmAddLiquidityEvent),
|
|
|
|
|
MeteoraDlmmRemoveLiquidityEvent(MeteoraDlmmRemoveLiquidityEvent),
|
|
|
|
|
MeteoraDlmmInitializePoolEvent(MeteoraDlmmInitializePoolEvent),
|
|
|
|
|
MeteoraDlmmInitializeBinArrayEvent(MeteoraDlmmInitializeBinArrayEvent),
|
|
|
|
|
MeteoraDlmmCreatePositionEvent(MeteoraDlmmCreatePositionEvent),
|
|
|
|
|
MeteoraDlmmClosePositionEvent(MeteoraDlmmClosePositionEvent),
|
|
|
|
|
MeteoraDlmmClaimFeeEvent(MeteoraDlmmClaimFeeEvent),
|
2025-11-10 00:38:23 +08:00
|
|
|
|
2025-10-10 18:19:44 +08:00
|
|
|
// Common events
|
|
|
|
|
TokenAccountEvent(TokenAccountEvent),
|
|
|
|
|
NonceAccountEvent(NonceAccountEvent),
|
|
|
|
|
TokenInfoEvent(TokenInfoEvent),
|
|
|
|
|
BlockMetaEvent(BlockMetaEvent),
|
2025-11-16 22:49:37 +08:00
|
|
|
SetComputeUnitLimitEvent(SetComputeUnitLimitEvent),
|
|
|
|
|
SetComputeUnitPriceEvent(SetComputeUnitPriceEvent),
|
2026-05-15 05:09:29 +08:00
|
|
|
ParserSdkErrorEvent(ParserSdkErrorEvent),
|
2025-07-19 23:46:42 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-07 07:10:34 +00:00
|
|
|
/// Macro to generate metadata accessors for all DexEvent variants
|
|
|
|
|
macro_rules! impl_dex_event_metadata {
|
|
|
|
|
($($variant:ident),* $(,)?) => {
|
|
|
|
|
impl DexEvent {
|
|
|
|
|
pub fn metadata(&self) -> &EventMetadata {
|
|
|
|
|
match self {
|
|
|
|
|
$(DexEvent::$variant(e) => &e.metadata,)*
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-10 18:19:44 +08:00
|
|
|
|
2026-03-07 07:10:34 +00:00
|
|
|
pub fn metadata_mut(&mut self) -> &mut EventMetadata {
|
|
|
|
|
match self {
|
|
|
|
|
$(DexEvent::$variant(e) => &mut e.metadata,)*
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-10 18:19:44 +08:00
|
|
|
}
|
2026-03-07 07:10:34 +00:00
|
|
|
};
|
2025-07-19 23:46:42 +08:00
|
|
|
}
|
2026-03-07 07:10:34 +00:00
|
|
|
|
|
|
|
|
impl_dex_event_metadata!(
|
|
|
|
|
// Bonk events
|
|
|
|
|
BonkTradeEvent,
|
|
|
|
|
BonkPoolCreateEvent,
|
|
|
|
|
BonkMigrateToAmmEvent,
|
|
|
|
|
BonkMigrateToCpswapEvent,
|
|
|
|
|
BonkPoolStateAccountEvent,
|
|
|
|
|
BonkGlobalConfigAccountEvent,
|
|
|
|
|
BonkPlatformConfigAccountEvent,
|
|
|
|
|
// PumpFun events
|
|
|
|
|
PumpFunCreateTokenEvent,
|
|
|
|
|
PumpFunCreateV2TokenEvent,
|
|
|
|
|
PumpFunTradeEvent,
|
|
|
|
|
PumpFunMigrateEvent,
|
2026-05-15 05:09:29 +08:00
|
|
|
PumpFeesCreateFeeSharingConfigEvent,
|
|
|
|
|
PumpFeesInitializeFeeConfigEvent,
|
|
|
|
|
PumpFeesResetFeeSharingConfigEvent,
|
|
|
|
|
PumpFeesRevokeFeeSharingAuthorityEvent,
|
|
|
|
|
PumpFeesTransferFeeSharingAuthorityEvent,
|
|
|
|
|
PumpFeesUpdateAdminEvent,
|
|
|
|
|
PumpFeesUpdateFeeConfigEvent,
|
|
|
|
|
PumpFeesUpdateFeeSharesEvent,
|
|
|
|
|
PumpFeesUpsertFeeTiersEvent,
|
|
|
|
|
PumpFunMigrateBondingCurveCreatorEvent,
|
2026-03-07 07:10:34 +00:00
|
|
|
PumpFunBondingCurveAccountEvent,
|
|
|
|
|
PumpFunGlobalAccountEvent,
|
|
|
|
|
// PumpSwap events
|
|
|
|
|
PumpSwapBuyEvent,
|
|
|
|
|
PumpSwapSellEvent,
|
|
|
|
|
PumpSwapCreatePoolEvent,
|
|
|
|
|
PumpSwapDepositEvent,
|
|
|
|
|
PumpSwapWithdrawEvent,
|
|
|
|
|
PumpSwapGlobalConfigAccountEvent,
|
|
|
|
|
PumpSwapPoolAccountEvent,
|
|
|
|
|
// Raydium AMM V4 events
|
|
|
|
|
RaydiumAmmV4SwapEvent,
|
|
|
|
|
RaydiumAmmV4DepositEvent,
|
|
|
|
|
RaydiumAmmV4WithdrawEvent,
|
|
|
|
|
RaydiumAmmV4WithdrawPnlEvent,
|
|
|
|
|
RaydiumAmmV4Initialize2Event,
|
|
|
|
|
RaydiumAmmV4AmmInfoAccountEvent,
|
|
|
|
|
// Raydium CLMM events
|
|
|
|
|
RaydiumClmmSwapEvent,
|
|
|
|
|
RaydiumClmmSwapV2Event,
|
|
|
|
|
RaydiumClmmClosePositionEvent,
|
|
|
|
|
RaydiumClmmIncreaseLiquidityV2Event,
|
|
|
|
|
RaydiumClmmDecreaseLiquidityV2Event,
|
2026-05-15 05:09:29 +08:00
|
|
|
RaydiumClmmCollectFeeEvent,
|
2026-03-07 07:10:34 +00:00
|
|
|
RaydiumClmmCreatePoolEvent,
|
|
|
|
|
RaydiumClmmOpenPositionWithToken22NftEvent,
|
|
|
|
|
RaydiumClmmOpenPositionV2Event,
|
|
|
|
|
RaydiumClmmAmmConfigAccountEvent,
|
|
|
|
|
RaydiumClmmPoolStateAccountEvent,
|
|
|
|
|
RaydiumClmmTickArrayStateAccountEvent,
|
|
|
|
|
// Raydium CPMM events
|
|
|
|
|
RaydiumCpmmSwapEvent,
|
|
|
|
|
RaydiumCpmmDepositEvent,
|
|
|
|
|
RaydiumCpmmWithdrawEvent,
|
|
|
|
|
RaydiumCpmmInitializeEvent,
|
|
|
|
|
RaydiumCpmmAmmConfigAccountEvent,
|
|
|
|
|
RaydiumCpmmPoolStateAccountEvent,
|
|
|
|
|
// Meteora DAMM v2 events
|
|
|
|
|
MeteoraDammV2SwapEvent,
|
|
|
|
|
MeteoraDammV2Swap2Event,
|
|
|
|
|
MeteoraDammV2InitializePoolEvent,
|
|
|
|
|
MeteoraDammV2InitializeCustomizablePoolEvent,
|
|
|
|
|
MeteoraDammV2InitializePoolWithDynamicConfigEvent,
|
2026-05-15 05:09:29 +08:00
|
|
|
MeteoraDammV2AddLiquidityEvent,
|
|
|
|
|
MeteoraDammV2RemoveLiquidityEvent,
|
|
|
|
|
MeteoraDammV2CreatePositionEvent,
|
|
|
|
|
MeteoraDammV2ClosePositionEvent,
|
|
|
|
|
OrcaWhirlpoolSwapEvent,
|
|
|
|
|
OrcaWhirlpoolLiquidityIncreasedEvent,
|
|
|
|
|
OrcaWhirlpoolLiquidityDecreasedEvent,
|
|
|
|
|
OrcaWhirlpoolPoolInitializedEvent,
|
|
|
|
|
MeteoraPoolsSwapEvent,
|
|
|
|
|
MeteoraPoolsAddLiquidityEvent,
|
|
|
|
|
MeteoraPoolsRemoveLiquidityEvent,
|
|
|
|
|
MeteoraPoolsBootstrapLiquidityEvent,
|
|
|
|
|
MeteoraPoolsPoolCreatedEvent,
|
|
|
|
|
MeteoraPoolsSetPoolFeesEvent,
|
|
|
|
|
MeteoraDlmmSwapEvent,
|
|
|
|
|
MeteoraDlmmAddLiquidityEvent,
|
|
|
|
|
MeteoraDlmmRemoveLiquidityEvent,
|
|
|
|
|
MeteoraDlmmInitializePoolEvent,
|
|
|
|
|
MeteoraDlmmInitializeBinArrayEvent,
|
|
|
|
|
MeteoraDlmmCreatePositionEvent,
|
|
|
|
|
MeteoraDlmmClosePositionEvent,
|
|
|
|
|
MeteoraDlmmClaimFeeEvent,
|
2026-03-07 07:10:34 +00:00
|
|
|
// Common events
|
|
|
|
|
TokenAccountEvent,
|
|
|
|
|
NonceAccountEvent,
|
|
|
|
|
TokenInfoEvent,
|
|
|
|
|
BlockMetaEvent,
|
|
|
|
|
SetComputeUnitLimitEvent,
|
|
|
|
|
SetComputeUnitPriceEvent,
|
2026-05-15 05:09:29 +08:00
|
|
|
ParserSdkErrorEvent,
|
2026-03-07 07:10:34 +00:00
|
|
|
);
|