sol_parser_sdk/core/
events.rs

1//! 所有具体的事件类型定义
2//!
3//! 基于您提供的回调事件列表,定义所有需要的具体事件类型
4
5// use prost_types::Timestamp;
6use serde::{Deserialize, Serialize};
7use solana_sdk::{pubkey::Pubkey, signature::Signature};
8
9/// 基础元数据 - 所有事件共享的字段
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct EventMetadata {
12    pub signature: Signature,
13    pub slot: u64,
14    pub tx_index: u64,  // 交易在slot中的索引,参考solana-streamer
15    pub block_time_us: i64,
16    pub grpc_recv_us: i64,
17}
18
19/// Block Meta Event
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct BlockMetaEvent {
22    pub metadata: EventMetadata,
23}
24
25/// Bonk Pool Create Event
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct BonkPoolCreateEvent {
28    pub metadata: EventMetadata,
29    pub base_mint_param: BaseMintParam,
30    pub pool_state: Pubkey,
31    pub creator: Pubkey,
32}
33
34#[derive(Debug, Clone, Serialize, Deserialize)]
35pub struct BaseMintParam {
36    pub symbol: String,
37    pub name: String,
38    pub uri: String,
39    pub decimals: u8,
40}
41
42/// Bonk Trade Event
43#[derive(Debug, Clone, Serialize, Deserialize)]
44pub struct BonkTradeEvent {
45    pub metadata: EventMetadata,
46    // === 事件核心字段 ===
47    pub pool_state: Pubkey,
48    pub user: Pubkey,
49    pub amount_in: u64,
50    pub amount_out: u64,
51    pub is_buy: bool,
52    pub trade_direction: TradeDirection,
53    pub exact_in: bool,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub enum TradeDirection {
58    Buy,
59    Sell,
60}
61
62/// Bonk Migrate AMM Event
63#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct BonkMigrateAmmEvent {
65    pub metadata: EventMetadata,
66    pub old_pool: Pubkey,
67    pub new_pool: Pubkey,
68    pub user: Pubkey,
69    pub liquidity_amount: u64,
70}
71
72/// PumpFun Trade Event - 基于官方IDL定义
73///
74/// 字段来源标记:
75/// - [EVENT]: 来自原始IDL事件定义,由程序日志直接解析获得
76/// - [INSTRUCTION]: 来自指令解析,用于补充事件缺失的上下文信息
77#[derive(Debug, Clone, Serialize, Deserialize)]
78pub struct PumpFunTradeEvent {
79    pub metadata: EventMetadata,
80
81    // === IDL TradeEvent 事件字段 ===
82    pub mint: Pubkey,
83    pub sol_amount: u64,
84    pub token_amount: u64,
85    pub is_buy: bool,
86    pub is_created_buy: bool,
87    pub user: Pubkey,
88    pub timestamp: i64,
89    pub virtual_sol_reserves: u64,
90    pub virtual_token_reserves: u64,
91    pub real_sol_reserves: u64,
92    pub real_token_reserves: u64,
93    pub fee_recipient: Pubkey,
94    pub fee_basis_points: u64,
95    pub fee: u64,
96    pub creator: Pubkey,
97    pub creator_fee_basis_points: u64,
98    pub creator_fee: u64,
99    pub track_volume: bool,
100    pub total_unclaimed_tokens: u64,
101    pub total_claimed_tokens: u64,
102    pub current_sol_volume: u64,
103    pub last_update_timestamp: i64,
104
105    // === 指令参数字段 (暂时注释,以后可能会用到,AI不要删除) ===
106    // pub amount: u64,                     // buy/sell.args.amount
107    // pub max_sol_cost: u64,               // buy.args.maxSolCost
108    // pub min_sol_output: u64,             // sell.args.minSolOutput
109
110    // === 指令账户字段 (暂时注释,以后可能会用到,AI不要删除) ===
111    // pub global: Pubkey,                  // 0: global
112    // pub bonding_curve: Pubkey,           // 3: bonding_curve
113    // pub associated_bonding_curve: Pubkey, // 4: associated_bonding_curve
114    // pub associated_user: Pubkey,         // 5: associated_user
115}
116
117/// PumpFun Complete Token Event
118#[derive(Debug, Clone, Serialize, Deserialize)]
119pub struct PumpFunCompleteTokenEvent {
120    pub metadata: EventMetadata,
121    pub user: Pubkey,
122    pub mint: Pubkey,
123    pub bonding_curve: Pubkey,
124    pub timestamp: i64,
125}
126
127/// PumpFun Migrate Event
128#[derive(Debug, Clone, Serialize, Deserialize)]
129pub struct PumpFunMigrateEvent {
130    pub metadata: EventMetadata,
131    pub user: Pubkey,
132    pub mint: Pubkey,
133    pub mint_amount: u64,
134    pub sol_amount: u64,
135    pub pool_migration_fee: u64,
136    pub bonding_curve: Pubkey,
137    pub timestamp: i64,
138    pub pool: Pubkey,
139    // === 额外账户信息(用于指令解析,暂时注释,以后可能会用到,AI不要删除) ===
140    // pub global: Pubkey,
141    // pub withdraw_authority: Pubkey,
142    // pub associated_bonding_curve: Pubkey,
143    // pub pump_amm: Pubkey,
144    // pub pool_authority: Pubkey,
145    // pub pool_authority_mint_account: Pubkey,
146    // pub pool_authority_wsol_account: Pubkey,
147    // pub amm_global_config: Pubkey,
148    // pub wsol_mint: Pubkey,
149    // pub lp_mint: Pubkey,
150    // pub user_pool_token_account: Pubkey,
151    // pub pool_base_token_account: Pubkey,
152    // pub pool_quote_token_account: Pubkey,
153}
154
155/// PumpFun Create Token Event - 基于IDL CreateEvent定义
156#[derive(Debug, Clone, Serialize, Deserialize)]
157pub struct PumpFunCreateTokenEvent {
158    pub metadata: EventMetadata,
159    // IDL CreateEvent 字段
160    pub name: String,
161    pub symbol: String,
162    pub uri: String,
163    pub mint: Pubkey,
164    pub bonding_curve: Pubkey,
165    pub user: Pubkey,
166    pub creator: Pubkey,
167    pub timestamp: i64,
168    pub virtual_token_reserves: u64,
169    pub virtual_sol_reserves: u64,
170    pub real_token_reserves: u64,
171    pub token_total_supply: u64,
172}
173
174/// PumpSwap Buy Event
175#[derive(Debug, Clone, Serialize, Deserialize)]
176pub struct PumpSwapBuyEvent {
177    pub metadata: EventMetadata,
178    pub pool_id: Pubkey,
179    pub user: Pubkey,
180    pub token_mint: Pubkey,
181    pub sol_amount: u64,
182    pub token_amount: u64,
183    pub price: u64,
184    pub slippage: u16,
185}
186
187/// PumpSwap Sell Event
188#[derive(Debug, Clone, Serialize, Deserialize)]
189pub struct PumpSwapSellEvent {
190    pub metadata: EventMetadata,
191    pub pool_id: Pubkey,
192    pub user: Pubkey,
193    pub token_mint: Pubkey,
194    pub token_amount: u64,
195    pub sol_amount: u64,
196    pub price: u64,
197    pub slippage: u16,
198}
199
200/// PumpSwap Create Pool Event
201#[derive(Debug, Clone, Serialize, Deserialize)]
202pub struct PumpSwapCreatePoolEvent {
203    pub metadata: EventMetadata,
204    pub pool_id: Pubkey,
205    pub creator: Pubkey,
206    pub token_mint: Pubkey,
207    pub initial_sol_amount: u64,
208    pub initial_token_amount: u64,
209    pub fee_rate: u16,
210}
211
212/// PumpSwap Pool Created Event - 指令解析版本
213#[derive(Debug, Clone, Serialize, Deserialize)]
214pub struct PumpSwapPoolCreated {
215    pub metadata: EventMetadata,
216    pub pool_account: Pubkey,
217    pub token_a_mint: Pubkey,
218    pub token_b_mint: Pubkey,
219    pub token_a_vault: Pubkey,
220    pub token_b_vault: Pubkey,
221    pub lp_mint: Pubkey,
222    pub creator: Pubkey,
223    pub authority: Pubkey,
224    pub initial_token_a_amount: u64,
225    pub initial_token_b_amount: u64,
226}
227
228/// PumpSwap Trade Event - 指令解析版本
229#[derive(Debug, Clone, Serialize, Deserialize)]
230pub struct PumpSwapTrade {
231    pub metadata: EventMetadata,
232    pub pool_account: Pubkey,
233    pub user: Pubkey,
234    pub user_token_in_account: Pubkey,
235    pub user_token_out_account: Pubkey,
236    pub pool_token_in_vault: Pubkey,
237    pub pool_token_out_vault: Pubkey,
238    pub token_in_mint: Pubkey,
239    pub token_out_mint: Pubkey,
240    pub amount_in: u64,
241    pub minimum_amount_out: u64,
242    pub is_token_a_to_b: bool,
243}
244
245/// PumpSwap Liquidity Added Event - 指令解析版本
246#[derive(Debug, Clone, Serialize, Deserialize)]
247pub struct PumpSwapLiquidityAdded {
248    pub metadata: EventMetadata,
249    pub pool_account: Pubkey,
250    pub user: Pubkey,
251    pub user_token_a_account: Pubkey,
252    pub user_token_b_account: Pubkey,
253    pub user_lp_token_account: Pubkey,
254    pub pool_token_a_vault: Pubkey,
255    pub pool_token_b_vault: Pubkey,
256    pub lp_mint: Pubkey,
257    pub token_a_mint: Pubkey,
258    pub token_b_mint: Pubkey,
259    pub max_token_a_amount: u64,
260    pub max_token_b_amount: u64,
261    pub min_lp_tokens: u64,
262}
263
264/// PumpSwap Liquidity Removed Event - 指令解析版本
265#[derive(Debug, Clone, Serialize, Deserialize)]
266pub struct PumpSwapLiquidityRemoved {
267    pub metadata: EventMetadata,
268    pub pool_account: Pubkey,
269    pub user: Pubkey,
270    pub user_token_a_account: Pubkey,
271    pub user_token_b_account: Pubkey,
272    pub user_lp_token_account: Pubkey,
273    pub pool_token_a_vault: Pubkey,
274    pub pool_token_b_vault: Pubkey,
275    pub lp_mint: Pubkey,
276    pub token_a_mint: Pubkey,
277    pub token_b_mint: Pubkey,
278    pub lp_tokens_to_burn: u64,
279    pub min_token_a_amount: u64,
280    pub min_token_b_amount: u64,
281}
282
283/// PumpSwap Pool Updated Event - 指令解析版本
284#[derive(Debug, Clone, Serialize, Deserialize)]
285pub struct PumpSwapPoolUpdated {
286    pub metadata: EventMetadata,
287    pub pool_account: Pubkey,
288    pub authority: Pubkey,
289    pub admin: Pubkey,
290    pub new_fee_rate: u64,
291}
292
293/// PumpSwap Fees Claimed Event - 指令解析版本
294#[derive(Debug, Clone, Serialize, Deserialize)]
295pub struct PumpSwapFeesClaimed {
296    pub metadata: EventMetadata,
297    pub pool_account: Pubkey,
298    pub authority: Pubkey,
299    pub admin: Pubkey,
300    pub admin_token_a_account: Pubkey,
301    pub admin_token_b_account: Pubkey,
302    pub pool_fee_vault: Pubkey,
303}
304
305/// PumpSwap Deposit Event
306#[derive(Debug, Clone, Serialize, Deserialize)]
307pub struct PumpSwapDepositEvent {
308    pub metadata: EventMetadata,
309    pub pool: Pubkey,
310    pub user: Pubkey,
311    pub amount: u64,
312}
313
314/// PumpSwap Withdraw Event
315#[derive(Debug, Clone, Serialize, Deserialize)]
316pub struct PumpSwapWithdrawEvent {
317    pub metadata: EventMetadata,
318    pub pool: Pubkey,
319    pub user: Pubkey,
320    pub amount: u64,
321}
322
323/// Raydium CPMM Swap Event (基于IDL SwapEvent + swapBaseInput指令定义)
324#[derive(Debug, Clone, Serialize, Deserialize)]
325pub struct RaydiumCpmmSwapEvent {
326    pub metadata: EventMetadata,
327
328    // === IDL SwapEvent 事件字段 ===
329    pub pool_id: Pubkey,
330    pub input_vault_before: u64,
331    pub output_vault_before: u64,
332    pub input_amount: u64,
333    pub output_amount: u64,
334    pub input_transfer_fee: u64,
335    pub output_transfer_fee: u64,
336    pub base_input: bool,
337
338    // === 指令参数字段 (暂时注释,以后可能会用到,AI不要删除) ===
339    // pub amount_in: u64,
340    // pub minimum_amount_out: u64,
341
342    // === 指令账户字段 (暂时注释,以后可能会用到,AI不要删除) ===
343    // pub payer: Pubkey,              // 0: payer
344    // pub authority: Pubkey,          // 1: authority
345    // pub amm_config: Pubkey,         // 2: ammConfig
346    // pub pool_state: Pubkey,         // 3: poolState
347    // pub input_token_account: Pubkey, // 4: inputTokenAccount
348    // pub output_token_account: Pubkey, // 5: outputTokenAccount
349    // pub input_vault: Pubkey,        // 6: inputVault
350    // pub output_vault: Pubkey,       // 7: outputVault
351    // pub input_token_mint: Pubkey,   // 10: inputTokenMint
352    // pub output_token_mint: Pubkey,  // 11: outputTokenMint
353}
354
355/// Raydium CPMM Deposit Event
356#[derive(Debug, Clone, Serialize, Deserialize)]
357pub struct RaydiumCpmmDepositEvent {
358    pub metadata: EventMetadata,
359    pub pool: Pubkey,
360    pub user: Pubkey,
361    pub lp_token_amount: u64,
362    pub token0_amount: u64,
363    pub token1_amount: u64,
364}
365
366/// Raydium CPMM Initialize Event
367#[derive(Debug, Clone, Serialize, Deserialize)]
368pub struct RaydiumCpmmInitializeEvent {
369    pub metadata: EventMetadata,
370    pub pool: Pubkey,
371    pub creator: Pubkey,
372    pub init_amount0: u64,
373    pub init_amount1: u64,
374}
375
376/// Raydium CPMM Withdraw Event
377#[derive(Debug, Clone, Serialize, Deserialize)]
378pub struct RaydiumCpmmWithdrawEvent {
379    pub metadata: EventMetadata,
380    pub pool: Pubkey,
381    pub user: Pubkey,
382    pub lp_token_amount: u64,
383    pub token0_amount: u64,
384    pub token1_amount: u64,
385}
386
387/// Raydium CLMM Swap Event (基于IDL SwapEvent + swap指令定义)
388#[derive(Debug, Clone, Serialize, Deserialize)]
389pub struct RaydiumClmmSwapEvent {
390    pub metadata: EventMetadata,
391
392    // === IDL SwapEvent 事件字段 ===
393    pub pool_state: Pubkey,
394    pub sender: Pubkey,
395    pub token_account_0: Pubkey,
396    pub token_account_1: Pubkey,
397    pub amount_0: u64,
398    pub transfer_fee_0: u64,
399    pub amount_1: u64,
400    pub transfer_fee_1: u64,
401    pub zero_for_one: bool,
402    pub sqrt_price_x64: u128,
403    pub liquidity: u128,
404    pub tick: i32,
405
406    // === 指令参数字段 (暂时注释,以后可能会用到,AI不要删除) ===
407    // pub amount: u64,
408    // pub other_amount_threshold: u64,
409    // pub sqrt_price_limit_x64: u128,
410    // pub is_base_input: bool,
411
412    // === 指令账户字段 (暂时注释,以后可能会用到,AI不要删除) ===
413    // TODO: 根据Raydium CLMM swap指令IDL添加账户字段
414}
415
416/// Raydium CLMM Close Position Event
417#[derive(Debug, Clone, Serialize, Deserialize)]
418pub struct RaydiumClmmClosePositionEvent {
419    pub metadata: EventMetadata,
420    pub pool: Pubkey,
421    pub user: Pubkey,
422    pub position_nft_mint: Pubkey,
423}
424
425/// Raydium CLMM Decrease Liquidity Event
426#[derive(Debug, Clone, Serialize, Deserialize)]
427pub struct RaydiumClmmDecreaseLiquidityEvent {
428    pub metadata: EventMetadata,
429    pub pool: Pubkey,
430    pub user: Pubkey,
431    pub liquidity: u128,
432    pub amount0_min: u64,
433    pub amount1_min: u64,
434}
435
436/// Raydium CLMM Collect Fee Event
437#[derive(Debug, Clone, Serialize, Deserialize)]
438pub struct RaydiumClmmCollectFeeEvent {
439    pub metadata: EventMetadata,
440    pub pool_state: Pubkey,
441    pub position_nft_mint: Pubkey,
442    pub amount_0: u64,
443    pub amount_1: u64,
444}
445
446/// Raydium CLMM Create Pool Event
447#[derive(Debug, Clone, Serialize, Deserialize)]
448pub struct RaydiumClmmCreatePoolEvent {
449    pub metadata: EventMetadata,
450    pub pool: Pubkey,
451    pub creator: Pubkey,
452    pub sqrt_price_x64: u128,
453    pub open_time: u64,
454}
455
456/// Raydium CLMM Increase Liquidity Event
457#[derive(Debug, Clone, Serialize, Deserialize)]
458pub struct RaydiumClmmIncreaseLiquidityEvent {
459    pub metadata: EventMetadata,
460    pub pool: Pubkey,
461    pub user: Pubkey,
462    pub liquidity: u128,
463    pub amount0_max: u64,
464    pub amount1_max: u64,
465}
466
467/// Raydium CLMM Open Position with Token Extension NFT Event
468#[derive(Debug, Clone, Serialize, Deserialize)]
469pub struct RaydiumClmmOpenPositionWithTokenExtNftEvent {
470    pub metadata: EventMetadata,
471    pub pool: Pubkey,
472    pub user: Pubkey,
473    pub position_nft_mint: Pubkey,
474    pub tick_lower_index: i32,
475    pub tick_upper_index: i32,
476    pub liquidity: u128,
477}
478
479/// Raydium CLMM Open Position Event
480#[derive(Debug, Clone, Serialize, Deserialize)]
481pub struct RaydiumClmmOpenPositionEvent {
482    pub metadata: EventMetadata,
483    pub pool: Pubkey,
484    pub user: Pubkey,
485    pub position_nft_mint: Pubkey,
486    pub tick_lower_index: i32,
487    pub tick_upper_index: i32,
488    pub liquidity: u128,
489}
490
491/// Raydium AMM V4 Deposit Event (简化版)
492#[derive(Debug, Clone, Serialize, Deserialize)]
493pub struct RaydiumAmmDepositEvent {
494    pub metadata: EventMetadata,
495    pub amm_id: Pubkey,
496    pub user: Pubkey,
497    pub max_coin_amount: u64,
498    pub max_pc_amount: u64,
499}
500
501/// Raydium AMM V4 Initialize Alt Event (简化版)
502#[derive(Debug, Clone, Serialize, Deserialize)]
503pub struct RaydiumAmmInitializeAltEvent {
504    pub metadata: EventMetadata,
505    pub amm_id: Pubkey,
506    pub creator: Pubkey,
507    pub nonce: u8,
508    pub open_time: u64,
509}
510
511/// Raydium AMM V4 Withdraw Event (简化版)
512#[derive(Debug, Clone, Serialize, Deserialize)]
513pub struct RaydiumAmmWithdrawEvent {
514    pub metadata: EventMetadata,
515    pub amm_id: Pubkey,
516    pub user: Pubkey,
517    pub pool_coin_amount: u64,
518}
519
520/// Raydium AMM V4 Withdraw PnL Event (简化版)
521#[derive(Debug, Clone, Serialize, Deserialize)]
522pub struct RaydiumAmmWithdrawPnlEvent {
523    pub metadata: EventMetadata,
524    pub amm_id: Pubkey,
525    pub user: Pubkey,
526}
527
528// ====================== Raydium AMM V4 Events ======================
529
530/// Raydium AMM V4 Swap Event
531#[derive(Debug, Clone, Serialize, Deserialize)]
532pub struct RaydiumAmmV4SwapEvent {
533    pub metadata: EventMetadata,
534    // base in
535    pub amount_in: u64,
536    pub minimum_amount_out: u64,
537    // base out
538    pub max_amount_in: u64,
539    pub amount_out: u64,
540
541    pub token_program: Pubkey,
542    pub amm: Pubkey,
543    pub amm_authority: Pubkey,
544    pub amm_open_orders: Pubkey,
545    pub amm_target_orders: Option<Pubkey>,
546    pub pool_coin_token_account: Pubkey,
547    pub pool_pc_token_account: Pubkey,
548    pub serum_program: Pubkey,
549    pub serum_market: Pubkey,
550    pub serum_bids: Pubkey,
551    pub serum_asks: Pubkey,
552    pub serum_event_queue: Pubkey,
553    pub serum_coin_vault_account: Pubkey,
554    pub serum_pc_vault_account: Pubkey,
555    pub serum_vault_signer: Pubkey,
556    pub user_source_token_account: Pubkey,
557    pub user_destination_token_account: Pubkey,
558    pub user_source_owner: Pubkey,
559}
560
561/// Raydium AMM V4 Deposit Event
562#[derive(Debug, Clone, Serialize, Deserialize)]
563pub struct RaydiumAmmV4DepositEvent {
564    pub metadata: EventMetadata,
565    pub max_coin_amount: u64,
566    pub max_pc_amount: u64,
567    pub base_side: u64,
568
569    pub token_program: Pubkey,
570    pub amm: Pubkey,
571    pub amm_authority: Pubkey,
572    pub amm_open_orders: Pubkey,
573    pub amm_target_orders: Pubkey,
574    pub lp_mint_address: Pubkey,
575    pub pool_coin_token_account: Pubkey,
576    pub pool_pc_token_account: Pubkey,
577    pub serum_market: Pubkey,
578    pub user_coin_token_account: Pubkey,
579    pub user_pc_token_account: Pubkey,
580    pub user_lp_token_account: Pubkey,
581    pub user_owner: Pubkey,
582    pub serum_event_queue: Pubkey,
583}
584
585/// Raydium AMM V4 Initialize2 Event
586#[derive(Debug, Clone, Serialize, Deserialize)]
587pub struct RaydiumAmmV4Initialize2Event {
588    pub metadata: EventMetadata,
589    pub nonce: u8,
590    pub open_time: u64,
591    pub init_pc_amount: u64,
592    pub init_coin_amount: u64,
593
594    pub token_program: Pubkey,
595    pub spl_associated_token_account: Pubkey,
596    pub system_program: Pubkey,
597    pub rent: Pubkey,
598    pub amm: Pubkey,
599    pub amm_authority: Pubkey,
600    pub amm_open_orders: Pubkey,
601    pub lp_mint: Pubkey,
602    pub coin_mint: Pubkey,
603    pub pc_mint: Pubkey,
604    pub pool_coin_token_account: Pubkey,
605    pub pool_pc_token_account: Pubkey,
606    pub pool_withdraw_queue: Pubkey,
607    pub amm_target_orders: Pubkey,
608    pub pool_temp_lp: Pubkey,
609    pub serum_program: Pubkey,
610    pub serum_market: Pubkey,
611    pub user_wallet: Pubkey,
612    pub user_token_coin: Pubkey,
613    pub user_token_pc: Pubkey,
614    pub user_lp_token_account: Pubkey,
615}
616
617/// Raydium AMM V4 Withdraw Event
618#[derive(Debug, Clone, Serialize, Deserialize)]
619pub struct RaydiumAmmV4WithdrawEvent {
620    pub metadata: EventMetadata,
621    pub amount: u64,
622
623    pub token_program: Pubkey,
624    pub amm: Pubkey,
625    pub amm_authority: Pubkey,
626    pub amm_open_orders: Pubkey,
627    pub amm_target_orders: Pubkey,
628    pub lp_mint_address: Pubkey,
629    pub pool_coin_token_account: Pubkey,
630    pub pool_pc_token_account: Pubkey,
631    pub pool_withdraw_queue: Pubkey,
632    pub pool_temp_lp_token_account: Pubkey,
633    pub serum_program: Pubkey,
634    pub serum_market: Pubkey,
635    pub serum_coin_vault_account: Pubkey,
636    pub serum_pc_vault_account: Pubkey,
637    pub serum_vault_signer: Pubkey,
638    pub user_lp_token_account: Pubkey,
639    pub user_coin_token_account: Pubkey,
640    pub user_pc_token_account: Pubkey,
641    pub user_owner: Pubkey,
642    pub serum_event_queue: Pubkey,
643    pub serum_bids: Pubkey,
644    pub serum_asks: Pubkey,
645}
646
647/// Raydium AMM V4 Withdraw PnL Event
648#[derive(Debug, Clone, Serialize, Deserialize)]
649pub struct RaydiumAmmV4WithdrawPnlEvent {
650    pub metadata: EventMetadata,
651
652    pub token_program: Pubkey,
653    pub amm: Pubkey,
654    pub amm_config: Pubkey,
655    pub amm_authority: Pubkey,
656    pub amm_open_orders: Pubkey,
657    pub pool_coin_token_account: Pubkey,
658    pub pool_pc_token_account: Pubkey,
659    pub coin_pnl_token_account: Pubkey,
660    pub pc_pnl_token_account: Pubkey,
661    pub pnl_owner: Pubkey,
662    pub amm_target_orders: Pubkey,
663    pub serum_program: Pubkey,
664    pub serum_market: Pubkey,
665    pub serum_event_queue: Pubkey,
666    pub serum_coin_vault_account: Pubkey,
667    pub serum_pc_vault_account: Pubkey,
668    pub serum_vault_signer: Pubkey,
669}
670
671// ====================== Account Events ======================
672
673/// Bonk Pool State Account Event
674#[derive(Debug, Clone, Serialize, Deserialize)]
675pub struct BonkPoolStateAccountEvent {
676    pub metadata: EventMetadata,
677    pub pubkey: Pubkey,
678    pub pool_state: BonkPoolState,
679}
680
681#[derive(Debug, Clone, Serialize, Deserialize)]
682pub struct BonkPoolState {
683    pub creator: Pubkey,
684    pub base_mint: Pubkey,
685    pub quote_mint: Pubkey,
686    pub virtual_base: u64,
687    pub virtual_quote: u64,
688    pub real_base: u64,
689    pub real_quote: u64,
690}
691
692/// Bonk Global Config Account Event
693#[derive(Debug, Clone, Serialize, Deserialize)]
694pub struct BonkGlobalConfigAccountEvent {
695    pub metadata: EventMetadata,
696    pub pubkey: Pubkey,
697    pub global_config: BonkGlobalConfig,
698}
699
700#[derive(Debug, Clone, Serialize, Deserialize)]
701pub struct BonkGlobalConfig {
702    pub protocol_fee_rate: u64,
703    pub trade_fee_rate: u64,
704    pub migration_fee_rate: u64,
705}
706
707/// Bonk Platform Config Account Event
708#[derive(Debug, Clone, Serialize, Deserialize)]
709pub struct BonkPlatformConfigAccountEvent {
710    pub metadata: EventMetadata,
711    pub pubkey: Pubkey,
712    pub platform_config: BonkPlatformConfig,
713}
714
715#[derive(Debug, Clone, Serialize, Deserialize)]
716pub struct BonkPlatformConfig {
717    pub fee_recipient: Pubkey,
718    pub fee_rate: u64,
719}
720
721/// PumpSwap Global Config Account Event
722#[derive(Debug, Clone, Serialize, Deserialize)]
723pub struct PumpSwapGlobalConfigAccountEvent {
724    pub metadata: EventMetadata,
725    pub pubkey: Pubkey,
726    pub global_config: PumpSwapGlobalConfig,
727}
728
729#[derive(Debug, Clone, Serialize, Deserialize)]
730pub struct PumpSwapGlobalConfig {
731    pub fee_recipient: Pubkey,
732    pub fee_rate: u64,
733}
734
735/// PumpSwap Pool Account Event
736#[derive(Debug, Clone, Serialize, Deserialize)]
737pub struct PumpSwapPoolAccountEvent {
738    pub metadata: EventMetadata,
739    pub pubkey: Pubkey,
740    pub pool: PumpSwapPool,
741}
742
743#[derive(Debug, Clone, Serialize, Deserialize)]
744pub struct PumpSwapPool {
745    pub base_mint: Pubkey,
746    pub quote_mint: Pubkey,
747    pub base_reserves: u64,
748    pub quote_reserves: u64,
749}
750
751/// PumpFun Bonding Curve Account Event
752#[derive(Debug, Clone, Serialize, Deserialize)]
753pub struct PumpFunBondingCurveAccountEvent {
754    pub metadata: EventMetadata,
755    pub pubkey: Pubkey,
756    pub bonding_curve: PumpFunBondingCurve,
757}
758
759#[derive(Debug, Clone, Serialize, Deserialize)]
760pub struct PumpFunBondingCurve {
761    pub virtual_token_reserves: u64,
762    pub virtual_sol_reserves: u64,
763    pub real_token_reserves: u64,
764    pub real_sol_reserves: u64,
765    pub token_total_supply: u64,
766    pub complete: bool,
767}
768
769/// PumpFun Global Account Event
770#[derive(Debug, Clone, Serialize, Deserialize)]
771pub struct PumpFunGlobalAccountEvent {
772    pub metadata: EventMetadata,
773    pub pubkey: Pubkey,
774    pub global: PumpFunGlobal,
775}
776
777#[derive(Debug, Clone, Serialize, Deserialize)]
778pub struct PumpFunGlobal {
779    pub discriminator: u64,
780    pub initialized: bool,
781    pub authority: Pubkey,
782    pub fee_recipient: Pubkey,
783    pub initial_virtual_token_reserves: u64,
784    pub initial_virtual_sol_reserves: u64,
785    pub initial_real_token_reserves: u64,
786    pub token_total_supply: u64,
787    pub fee_basis_points: u64,
788}
789
790/// Raydium AMM V4 Info Account Event
791#[derive(Debug, Clone, Serialize, Deserialize)]
792pub struct RaydiumAmmAmmInfoAccountEvent {
793    pub metadata: EventMetadata,
794    pub pubkey: Pubkey,
795    pub amm_info: RaydiumAmmInfo,
796}
797
798#[derive(Debug, Clone, Serialize, Deserialize)]
799pub struct RaydiumAmmInfo {
800    pub status: u64,
801    pub nonce: u64,
802    pub order_num: u64,
803    pub depth: u64,
804    pub coin_decimals: u64,
805    pub pc_decimals: u64,
806    pub state: u64,
807    pub reset_flag: u64,
808    pub min_size: u64,
809    pub vol_max_cut_ratio: u64,
810    pub amount_wave_ratio: u64,
811    pub coin_lot_size: u64,
812    pub pc_lot_size: u64,
813    pub min_price_multiplier: u64,
814    pub max_price_multiplier: u64,
815    pub sys_decimal_value: u64,
816}
817
818/// Raydium CLMM AMM Config Account Event
819#[derive(Debug, Clone, Serialize, Deserialize)]
820pub struct RaydiumClmmAmmConfigAccountEvent {
821    pub metadata: EventMetadata,
822    pub pubkey: Pubkey,
823    pub amm_config: RaydiumClmmAmmConfig,
824}
825
826#[derive(Debug, Clone, Serialize, Deserialize)]
827pub struct RaydiumClmmAmmConfig {
828    pub bump: u8,
829    pub index: u16,
830    pub owner: Pubkey,
831    pub protocol_fee_rate: u32,
832    pub trade_fee_rate: u32,
833    pub tick_spacing: u16,
834    pub fund_fee_rate: u32,
835    pub fund_owner: Pubkey,
836}
837
838/// Raydium CLMM Pool State Account Event
839#[derive(Debug, Clone, Serialize, Deserialize)]
840pub struct RaydiumClmmPoolStateAccountEvent {
841    pub metadata: EventMetadata,
842    pub pubkey: Pubkey,
843    pub pool_state: RaydiumClmmPoolState,
844}
845
846#[derive(Debug, Clone, Serialize, Deserialize)]
847pub struct RaydiumClmmPoolState {
848    pub bump: [u8; 1],
849    pub amm_config: Pubkey,
850    pub owner: Pubkey,
851    pub token_mint0: Pubkey,
852    pub token_mint1: Pubkey,
853    pub token_vault0: Pubkey,
854    pub token_vault1: Pubkey,
855    pub observation_key: Pubkey,
856    pub mint_decimals0: u8,
857    pub mint_decimals1: u8,
858    pub tick_spacing: u16,
859    pub liquidity: u128,
860    pub sqrt_price_x64: u128,
861    pub tick_current: i32,
862}
863
864/// Raydium CLMM Tick Array State Account Event
865#[derive(Debug, Clone, Serialize, Deserialize)]
866pub struct RaydiumClmmTickArrayStateAccountEvent {
867    pub metadata: EventMetadata,
868    pub pubkey: Pubkey,
869    pub tick_array_state: RaydiumClmmTickArrayState,
870}
871
872#[derive(Debug, Clone, Serialize, Deserialize)]
873pub struct RaydiumClmmTickArrayState {
874    pub discriminator: u64,
875    pub pool_id: Pubkey,
876    pub start_tick_index: i32,
877    pub ticks: Vec<Tick>,
878    pub initialized_tick_count: u8,
879}
880
881#[derive(Debug, Clone, Serialize, Deserialize)]
882pub struct Tick {
883    pub tick: i32,
884    pub liquidity_net: i128,
885    pub liquidity_gross: u128,
886    pub fee_growth_outside_0_x64: u128,
887    pub fee_growth_outside_1_x64: u128,
888    pub reward_growths_outside_x64: [u128; 3],
889}
890
891/// Raydium CPMM AMM Config Account Event
892#[derive(Debug, Clone, Serialize, Deserialize)]
893pub struct RaydiumCpmmAmmConfigAccountEvent {
894    pub metadata: EventMetadata,
895    pub pubkey: Pubkey,
896    pub amm_config: RaydiumCpmmAmmConfig,
897}
898
899#[derive(Debug, Clone, Serialize, Deserialize)]
900pub struct RaydiumCpmmAmmConfig {
901    pub bump: u8,
902    pub disable_create_pool: bool,
903    pub index: u16,
904    pub trade_fee_rate: u64,
905    pub protocol_fee_rate: u64,
906    pub fund_fee_rate: u64,
907    pub create_pool_fee: u64,
908    pub protocol_owner: Pubkey,
909    pub fund_owner: Pubkey,
910}
911
912/// Raydium CPMM Pool State Account Event
913#[derive(Debug, Clone, Serialize, Deserialize)]
914pub struct RaydiumCpmmPoolStateAccountEvent {
915    pub metadata: EventMetadata,
916    pub pubkey: Pubkey,
917    pub pool_state: RaydiumCpmmPoolState,
918}
919
920#[derive(Debug, Clone, Serialize, Deserialize)]
921pub struct RaydiumCpmmPoolState {
922    pub amm_config: Pubkey,
923    pub pool_creator: Pubkey,
924    pub token0_vault: Pubkey,
925    pub token1_vault: Pubkey,
926    pub lp_mint: Pubkey,
927    pub token0_mint: Pubkey,
928    pub token1_mint: Pubkey,
929    pub token0_program: Pubkey,
930    pub token1_program: Pubkey,
931    pub auth_bump: u8,
932    pub status: u8,
933    pub lp_mint_decimals: u8,
934    pub mint0_decimals: u8,
935    pub mint1_decimals: u8,
936    pub lp_supply: u64,
937    pub protocol_fees_token0: u64,
938    pub protocol_fees_token1: u64,
939    pub fund_fees_token0: u64,
940    pub fund_fees_token1: u64,
941    pub open_time: u64,
942}
943
944/// Token Account Event
945#[derive(Debug, Clone, Serialize, Deserialize)]
946pub struct TokenAccountEvent {
947    pub metadata: EventMetadata,
948    pub pubkey: Pubkey,
949    pub owner: Pubkey,
950    pub mint: Pubkey,
951    pub amount: u64,
952    pub delegate: Option<Pubkey>,
953    pub state: u8,
954    pub is_native: Option<u64>,
955    pub delegated_amount: u64,
956    pub close_authority: Option<Pubkey>,
957}
958
959/// Nonce Account Event
960#[derive(Debug, Clone, Serialize, Deserialize)]
961pub struct NonceAccountEvent {
962    pub metadata: EventMetadata,
963    pub pubkey: Pubkey,
964    pub authority: Pubkey,
965    pub nonce: String,
966    pub fee_calculator: FeeCalculator,
967}
968
969#[derive(Debug, Clone, Serialize, Deserialize)]
970pub struct FeeCalculator {
971    pub lamports_per_signature: u64,
972}
973
974/// Token Info Event
975#[derive(Debug, Clone, Serialize, Deserialize)]
976pub struct TokenInfoEvent {
977    pub metadata: EventMetadata,
978    pub mint: Pubkey,
979    pub name: String,
980    pub symbol: String,
981    pub decimals: u8,
982    pub supply: u64,
983}
984
985// ====================== Orca Whirlpool Events ======================
986
987/// Orca Whirlpool Swap Event (基于 TradedEvent,不是 SwapEvent)
988#[derive(Debug, Clone, Serialize, Deserialize)]
989pub struct OrcaWhirlpoolSwapEvent {
990    pub metadata: EventMetadata,
991
992    // === IDL TradedEvent 事件字段 ===
993    pub whirlpool: Pubkey,
994    pub a_to_b: bool,
995    pub pre_sqrt_price: u128,
996    pub post_sqrt_price: u128,
997    pub input_amount: u64,
998    pub output_amount: u64,
999    pub input_transfer_fee: u64,
1000    pub output_transfer_fee: u64,
1001    pub lp_fee: u64,
1002    pub protocol_fee: u64,
1003
1004    // === 指令参数字段 (暂时注释,以后可能会用到,AI不要删除) ===
1005    // pub amount: u64,
1006    // pub other_amount_threshold: u64,
1007    // pub sqrt_price_limit: u128,
1008    // pub amount_specified_is_input: bool,
1009
1010    // === 指令账户字段 (暂时注释,以后可能会用到,AI不要删除) ===
1011    // pub token_authority: Pubkey,    // 1: tokenAuthority
1012    // pub token_owner_account_a: Pubkey, // 3: tokenOwnerAccountA
1013    // pub token_vault_a: Pubkey,      // 4: tokenVaultA
1014    // pub token_owner_account_b: Pubkey, // 5: tokenOwnerAccountB
1015    // pub token_vault_b: Pubkey,      // 6: tokenVaultB
1016    // pub tick_array_0: Pubkey,       // 7: tickArray0
1017    // pub tick_array_1: Pubkey,       // 8: tickArray1
1018    // pub tick_array_2: Pubkey,       // 9: tickArray2
1019}
1020
1021/// Orca Whirlpool Liquidity Increased Event
1022#[derive(Debug, Clone, Serialize, Deserialize)]
1023pub struct OrcaWhirlpoolLiquidityIncreasedEvent {
1024    pub metadata: EventMetadata,
1025    pub whirlpool: Pubkey,
1026    pub position: Pubkey,
1027    pub tick_lower_index: i32,
1028    pub tick_upper_index: i32,
1029    pub liquidity: u128,
1030    pub token_a_amount: u64,
1031    pub token_b_amount: u64,
1032    pub token_a_transfer_fee: u64,
1033    pub token_b_transfer_fee: u64,
1034}
1035
1036/// Orca Whirlpool Liquidity Decreased Event
1037#[derive(Debug, Clone, Serialize, Deserialize)]
1038pub struct OrcaWhirlpoolLiquidityDecreasedEvent {
1039    pub metadata: EventMetadata,
1040    pub whirlpool: Pubkey,
1041    pub position: Pubkey,
1042    pub tick_lower_index: i32,
1043    pub tick_upper_index: i32,
1044    pub liquidity: u128,
1045    pub token_a_amount: u64,
1046    pub token_b_amount: u64,
1047    pub token_a_transfer_fee: u64,
1048    pub token_b_transfer_fee: u64,
1049}
1050
1051/// Orca Whirlpool Pool Initialized Event
1052#[derive(Debug, Clone, Serialize, Deserialize)]
1053pub struct OrcaWhirlpoolPoolInitializedEvent {
1054    pub metadata: EventMetadata,
1055    pub whirlpool: Pubkey,
1056    pub whirlpools_config: Pubkey,
1057    pub token_mint_a: Pubkey,
1058    pub token_mint_b: Pubkey,
1059    pub tick_spacing: u16,
1060    pub token_program_a: Pubkey,
1061    pub token_program_b: Pubkey,
1062    pub decimals_a: u8,
1063    pub decimals_b: u8,
1064    pub initial_sqrt_price: u128,
1065}
1066
1067// ====================== Meteora Pools Events ======================
1068
1069/// Meteora Pools Swap Event
1070#[derive(Debug, Clone, Serialize, Deserialize)]
1071pub struct MeteoraPoolsSwapEvent {
1072    pub metadata: EventMetadata,
1073    pub in_amount: u64,
1074    pub out_amount: u64,
1075    pub trade_fee: u64,
1076    pub admin_fee: u64,  // IDL字段名: adminFee
1077    pub host_fee: u64,
1078}
1079
1080/// Meteora Pools Add Liquidity Event
1081#[derive(Debug, Clone, Serialize, Deserialize)]
1082pub struct MeteoraPoolsAddLiquidityEvent {
1083    pub metadata: EventMetadata,
1084    pub lp_mint_amount: u64,
1085    pub token_a_amount: u64,
1086    pub token_b_amount: u64,
1087}
1088
1089/// Meteora Pools Remove Liquidity Event
1090#[derive(Debug, Clone, Serialize, Deserialize)]
1091pub struct MeteoraPoolsRemoveLiquidityEvent {
1092    pub metadata: EventMetadata,
1093    pub lp_unmint_amount: u64,
1094    pub token_a_out_amount: u64,
1095    pub token_b_out_amount: u64,
1096}
1097
1098/// Meteora Pools Bootstrap Liquidity Event
1099#[derive(Debug, Clone, Serialize, Deserialize)]
1100pub struct MeteoraPoolsBootstrapLiquidityEvent {
1101    pub metadata: EventMetadata,
1102    pub lp_mint_amount: u64,
1103    pub token_a_amount: u64,
1104    pub token_b_amount: u64,
1105    pub pool: Pubkey,
1106}
1107
1108/// Meteora Pools Pool Created Event
1109#[derive(Debug, Clone, Serialize, Deserialize)]
1110pub struct MeteoraPoolsPoolCreatedEvent {
1111    pub metadata: EventMetadata,
1112    pub lp_mint: Pubkey,
1113    pub token_a_mint: Pubkey,
1114    pub token_b_mint: Pubkey,
1115    pub pool_type: u8,
1116    pub pool: Pubkey,
1117}
1118
1119/// Meteora Pools Set Pool Fees Event
1120#[derive(Debug, Clone, Serialize, Deserialize)]
1121pub struct MeteoraPoolsSetPoolFeesEvent {
1122    pub metadata: EventMetadata,
1123    pub trade_fee_numerator: u64,
1124    pub trade_fee_denominator: u64,
1125    pub owner_trade_fee_numerator: u64,  // IDL字段名: ownerTradeFeeNumerator
1126    pub owner_trade_fee_denominator: u64,  // IDL字段名: ownerTradeFeeDenominator
1127    pub pool: Pubkey,
1128}
1129
1130// ====================== Meteora DAMM V2 Events ======================
1131
1132/// Meteora DAMM V2 Swap Event
1133#[derive(Debug, Clone, Serialize, Deserialize)]
1134pub struct MeteoraDammV2SwapEvent {
1135    pub metadata: EventMetadata,
1136    // === 事件核心字段 ===
1137    pub lb_pair: Pubkey,
1138    pub from: Pubkey,
1139    pub start_bin_id: i32,
1140    pub end_bin_id: i32,
1141    pub amount_in: u64,
1142    pub amount_out: u64,
1143    pub swap_for_y: bool,
1144    pub fee: u64,
1145    pub protocol_fee: u64,
1146    pub fee_bps: u128,
1147    pub host_fee: u64,
1148}
1149
1150/// Meteora DAMM V2 Add Liquidity Event
1151#[derive(Debug, Clone, Serialize, Deserialize)]
1152pub struct MeteoraDammV2AddLiquidityEvent {
1153    pub metadata: EventMetadata,
1154    pub lb_pair: Pubkey,
1155    pub from: Pubkey,
1156    pub position: Pubkey,
1157    pub amounts: [u64; 2],
1158    pub active_bin_id: i32,
1159}
1160
1161/// Meteora DAMM V2 Remove Liquidity Event
1162#[derive(Debug, Clone, Serialize, Deserialize)]
1163pub struct MeteoraDammV2RemoveLiquidityEvent {
1164    pub metadata: EventMetadata,
1165    pub lb_pair: Pubkey,
1166    pub from: Pubkey,
1167    pub position: Pubkey,
1168    pub amounts: [u64; 2],
1169    pub active_bin_id: i32,
1170}
1171
1172/// Meteora DAMM V2 Initialize Pool Event
1173#[derive(Debug, Clone, Serialize, Deserialize)]
1174pub struct MeteoraDammV2InitializePoolEvent {
1175    pub metadata: EventMetadata,
1176    pub lb_pair: Pubkey,
1177    pub bin_step: u16,
1178    pub token_x: Pubkey,
1179    pub token_y: Pubkey,
1180}
1181
1182/// Meteora DAMM V2 Create Position Event
1183#[derive(Debug, Clone, Serialize, Deserialize)]
1184pub struct MeteoraDammV2CreatePositionEvent {
1185    pub metadata: EventMetadata,
1186    pub lb_pair: Pubkey,
1187    pub position: Pubkey,
1188    pub owner: Pubkey,
1189}
1190
1191/// Meteora DAMM V2 Close Position Event
1192#[derive(Debug, Clone, Serialize, Deserialize)]
1193pub struct MeteoraDammV2ClosePositionEvent {
1194    pub metadata: EventMetadata,
1195    pub position: Pubkey,
1196    pub owner: Pubkey,
1197}
1198
1199/// Meteora DAMM V2 Claim Position Fee Event
1200#[derive(Debug, Clone, Serialize, Deserialize)]
1201pub struct MeteoraDammV2ClaimPositionFeeEvent {
1202    pub metadata: EventMetadata,
1203    pub lb_pair: Pubkey,
1204    pub position: Pubkey,
1205    pub owner: Pubkey,
1206    pub fee_x: u64,
1207    pub fee_y: u64,
1208}
1209
1210/// Meteora DAMM V2 Initialize Reward Event
1211#[derive(Debug, Clone, Serialize, Deserialize)]
1212pub struct MeteoraDammV2InitializeRewardEvent {
1213    pub metadata: EventMetadata,
1214    pub lb_pair: Pubkey,
1215    pub reward_mint: Pubkey,
1216    pub funder: Pubkey,
1217    pub reward_index: u64,
1218    pub reward_duration: u64,
1219}
1220
1221/// Meteora DAMM V2 Fund Reward Event
1222#[derive(Debug, Clone, Serialize, Deserialize)]
1223pub struct MeteoraDammV2FundRewardEvent {
1224    pub metadata: EventMetadata,
1225    pub lb_pair: Pubkey,
1226    pub funder: Pubkey,
1227    pub reward_index: u64,
1228    pub amount: u64,
1229}
1230
1231/// Meteora DAMM V2 Claim Reward Event
1232#[derive(Debug, Clone, Serialize, Deserialize)]
1233pub struct MeteoraDammV2ClaimRewardEvent {
1234    pub metadata: EventMetadata,
1235    pub lb_pair: Pubkey,
1236    pub position: Pubkey,
1237    pub owner: Pubkey,
1238    pub reward_index: u64,
1239    pub total_reward: u64,
1240}
1241
1242/// Meteora DLMM Swap Event
1243#[derive(Debug, Clone, Serialize, Deserialize)]
1244pub struct MeteoraDlmmSwapEvent {
1245    pub metadata: EventMetadata,
1246    pub pool: Pubkey,  // lbPair in IDL
1247    pub from: Pubkey,
1248    pub start_bin_id: i32,
1249    pub end_bin_id: i32,
1250    pub amount_in: u64,
1251    pub amount_out: u64,
1252    pub swap_for_y: bool,
1253    pub fee: u64,
1254    pub protocol_fee: u64,
1255    pub fee_bps: u128,  // IDL字段
1256    pub host_fee: u64,
1257}
1258
1259/// Meteora DLMM Add Liquidity Event
1260#[derive(Debug, Clone, Serialize, Deserialize)]
1261pub struct MeteoraDlmmAddLiquidityEvent {
1262    pub metadata: EventMetadata,
1263    pub pool: Pubkey,  // lbPair in IDL
1264    pub from: Pubkey,
1265    pub position: Pubkey,  // IDL字段
1266    pub amounts: [u64; 2],  // IDL定义为固定大小数组
1267    pub active_bin_id: i32,  // IDL字段 activeBinId
1268}
1269
1270/// Meteora DLMM Remove Liquidity Event
1271#[derive(Debug, Clone, Serialize, Deserialize)]
1272pub struct MeteoraDlmmRemoveLiquidityEvent {
1273    pub metadata: EventMetadata,
1274    pub pool: Pubkey,  // lbPair in IDL
1275    pub from: Pubkey,
1276    pub position: Pubkey,  // IDL字段
1277    pub amounts: [u64; 2],  // IDL定义为固定大小数组
1278    pub active_bin_id: i32,  // IDL字段 activeBinId
1279}
1280
1281/// Meteora DLMM Initialize Pool Event
1282#[derive(Debug, Clone, Serialize, Deserialize)]
1283pub struct MeteoraDlmmInitializePoolEvent {
1284    pub metadata: EventMetadata,
1285    pub pool: Pubkey,
1286    pub creator: Pubkey,
1287    pub active_bin_id: i32,
1288    pub bin_step: u16,
1289}
1290
1291/// Meteora DLMM Initialize Bin Array Event
1292#[derive(Debug, Clone, Serialize, Deserialize)]
1293pub struct MeteoraDlmmInitializeBinArrayEvent {
1294    pub metadata: EventMetadata,
1295    pub pool: Pubkey,
1296    pub bin_array: Pubkey,
1297    pub index: i64,
1298}
1299
1300/// Meteora DLMM Create Position Event
1301#[derive(Debug, Clone, Serialize, Deserialize)]
1302pub struct MeteoraDlmmCreatePositionEvent {
1303    pub metadata: EventMetadata,
1304    pub pool: Pubkey,
1305    pub position: Pubkey,
1306    pub owner: Pubkey,
1307    pub lower_bin_id: i32,
1308    pub width: u32,
1309}
1310
1311/// Meteora DLMM Close Position Event
1312#[derive(Debug, Clone, Serialize, Deserialize)]
1313pub struct MeteoraDlmmClosePositionEvent {
1314    pub metadata: EventMetadata,
1315    pub pool: Pubkey,
1316    pub position: Pubkey,
1317    pub owner: Pubkey,
1318}
1319
1320/// Meteora DLMM Claim Fee Event
1321#[derive(Debug, Clone, Serialize, Deserialize)]
1322pub struct MeteoraDlmmClaimFeeEvent {
1323    pub metadata: EventMetadata,
1324    pub pool: Pubkey,
1325    pub position: Pubkey,
1326    pub owner: Pubkey,
1327    pub fee_x: u64,
1328    pub fee_y: u64,
1329}
1330
1331// ====================== 统一的 DEX 事件枚举 ======================
1332
1333/// 统一的 DEX 事件枚举 - 参考 sol-dex-shreds 的做法
1334#[derive(Debug, Clone, Serialize, Deserialize)]
1335pub enum DexEvent {
1336    // PumpFun 事件
1337    PumpFunCreate(PumpFunCreateTokenEvent),
1338    PumpFunTrade(PumpFunTradeEvent),
1339    PumpFunComplete(PumpFunCompleteTokenEvent),
1340    PumpFunMigrate(PumpFunMigrateEvent),
1341
1342    // Bonk 事件
1343    BonkTrade(BonkTradeEvent),
1344    BonkPoolCreate(BonkPoolCreateEvent),
1345    BonkMigrateAmm(BonkMigrateAmmEvent),
1346
1347    // PumpSwap 事件
1348    PumpSwapBuy(PumpSwapBuyEvent),
1349    PumpSwapSell(PumpSwapSellEvent),
1350    PumpSwapCreatePool(PumpSwapCreatePoolEvent),
1351    PumpSwapPoolCreated(PumpSwapPoolCreated),
1352    PumpSwapTrade(PumpSwapTrade),
1353    PumpSwapLiquidityAdded(PumpSwapLiquidityAdded),
1354    PumpSwapLiquidityRemoved(PumpSwapLiquidityRemoved),
1355    PumpSwapPoolUpdated(PumpSwapPoolUpdated),
1356    PumpSwapFeesClaimed(PumpSwapFeesClaimed),
1357
1358    // Raydium CLMM 事件
1359    RaydiumClmmSwap(RaydiumClmmSwapEvent),
1360    RaydiumClmmCreatePool(RaydiumClmmCreatePoolEvent),
1361    RaydiumClmmOpenPosition(RaydiumClmmOpenPositionEvent),
1362    RaydiumClmmOpenPositionWithTokenExtNft(RaydiumClmmOpenPositionWithTokenExtNftEvent),
1363    RaydiumClmmClosePosition(RaydiumClmmClosePositionEvent),
1364    RaydiumClmmIncreaseLiquidity(RaydiumClmmIncreaseLiquidityEvent),
1365    RaydiumClmmDecreaseLiquidity(RaydiumClmmDecreaseLiquidityEvent),
1366    RaydiumClmmCollectFee(RaydiumClmmCollectFeeEvent),
1367
1368    // Raydium CPMM 事件
1369    RaydiumCpmmSwap(RaydiumCpmmSwapEvent),
1370    RaydiumCpmmDeposit(RaydiumCpmmDepositEvent),
1371    RaydiumCpmmWithdraw(RaydiumCpmmWithdrawEvent),
1372    RaydiumCpmmInitialize(RaydiumCpmmInitializeEvent),
1373
1374    // Raydium AMM V4 事件
1375    RaydiumAmmV4Swap(RaydiumAmmV4SwapEvent),
1376    RaydiumAmmV4Deposit(RaydiumAmmV4DepositEvent),
1377    RaydiumAmmV4Initialize2(RaydiumAmmV4Initialize2Event),
1378    RaydiumAmmV4Withdraw(RaydiumAmmV4WithdrawEvent),
1379    RaydiumAmmV4WithdrawPnl(RaydiumAmmV4WithdrawPnlEvent),
1380
1381    // Orca Whirlpool 事件
1382    OrcaWhirlpoolSwap(OrcaWhirlpoolSwapEvent),
1383    OrcaWhirlpoolLiquidityIncreased(OrcaWhirlpoolLiquidityIncreasedEvent),
1384    OrcaWhirlpoolLiquidityDecreased(OrcaWhirlpoolLiquidityDecreasedEvent),
1385    OrcaWhirlpoolPoolInitialized(OrcaWhirlpoolPoolInitializedEvent),
1386
1387    // Meteora Pools 事件
1388    MeteoraPoolsSwap(MeteoraPoolsSwapEvent),
1389    MeteoraPoolsAddLiquidity(MeteoraPoolsAddLiquidityEvent),
1390    MeteoraPoolsRemoveLiquidity(MeteoraPoolsRemoveLiquidityEvent),
1391    MeteoraPoolsBootstrapLiquidity(MeteoraPoolsBootstrapLiquidityEvent),
1392    MeteoraPoolsPoolCreated(MeteoraPoolsPoolCreatedEvent),
1393    MeteoraPoolsSetPoolFees(MeteoraPoolsSetPoolFeesEvent),
1394
1395    // Meteora DAMM V2 事件
1396    MeteoraDammV2Swap(MeteoraDammV2SwapEvent),
1397    MeteoraDammV2AddLiquidity(MeteoraDammV2AddLiquidityEvent),
1398    MeteoraDammV2RemoveLiquidity(MeteoraDammV2RemoveLiquidityEvent),
1399    MeteoraDammV2InitializePool(MeteoraDammV2InitializePoolEvent),
1400    MeteoraDammV2CreatePosition(MeteoraDammV2CreatePositionEvent),
1401    MeteoraDammV2ClosePosition(MeteoraDammV2ClosePositionEvent),
1402    MeteoraDammV2ClaimPositionFee(MeteoraDammV2ClaimPositionFeeEvent),
1403    MeteoraDammV2InitializeReward(MeteoraDammV2InitializeRewardEvent),
1404    MeteoraDammV2FundReward(MeteoraDammV2FundRewardEvent),
1405    MeteoraDammV2ClaimReward(MeteoraDammV2ClaimRewardEvent),
1406
1407    // Meteora DLMM 事件
1408    MeteoraDlmmSwap(MeteoraDlmmSwapEvent),
1409    MeteoraDlmmAddLiquidity(MeteoraDlmmAddLiquidityEvent),
1410    MeteoraDlmmRemoveLiquidity(MeteoraDlmmRemoveLiquidityEvent),
1411    MeteoraDlmmInitializePool(MeteoraDlmmInitializePoolEvent),
1412    MeteoraDlmmInitializeBinArray(MeteoraDlmmInitializeBinArrayEvent),
1413    MeteoraDlmmCreatePosition(MeteoraDlmmCreatePositionEvent),
1414    MeteoraDlmmClosePosition(MeteoraDlmmClosePositionEvent),
1415    MeteoraDlmmClaimFee(MeteoraDlmmClaimFeeEvent),
1416
1417    // 账户事件
1418    TokenAccount(TokenAccountEvent),
1419    NonceAccount(NonceAccountEvent),
1420
1421    // 区块元数据事件
1422    BlockMeta(BlockMetaEvent),
1423
1424    // Token 信息事件
1425    TokenInfo(TokenInfoEvent),
1426
1427    // 错误事件
1428    Error(String),
1429}