Skip to main content

sol_parser_sdk/core/
events.rs

1//! 所有具体的事件类型定义
2//!
3//! 基于您提供的回调事件列表,定义所有需要的具体事件类型
4
5// use prost_types::Timestamp;
6use borsh::BorshDeserialize;
7use serde::{Deserialize, Serialize};
8use solana_sdk::{pubkey::Pubkey, signature::Signature};
9
10/// 基础元数据 - 所有事件共享的字段
11#[derive(Debug, Clone, Serialize, Deserialize, Default)]
12pub struct EventMetadata {
13    pub signature: Signature,
14    pub slot: u64,
15    pub tx_index: u64, // 交易在slot中的索引,参考solana-streamer
16    pub block_time_us: i64,
17    pub grpc_recv_us: i64,
18    /// Transaction's recent blockhash as base58 string, when available.
19    #[serde(default)]
20    pub recent_blockhash: Option<String>,
21}
22
23/// Block Meta Event
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct BlockMetaEvent {
26    pub metadata: EventMetadata,
27}
28
29/// Bonk Pool Create Event
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct BonkPoolCreateEvent {
32    pub metadata: EventMetadata,
33    pub base_mint_param: BaseMintParam,
34    pub pool_state: Pubkey,
35    pub creator: Pubkey,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct BaseMintParam {
40    pub symbol: String,
41    pub name: String,
42    pub uri: String,
43    pub decimals: u8,
44}
45
46/// Bonk Trade Event
47#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct BonkTradeEvent {
50    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
51    pub metadata: EventMetadata,
52
53    // === Borsh 序列化字段(从 inner instruction data 读取)===
54    pub pool_state: Pubkey,      // 32 bytes
55    pub user: Pubkey,             // 32 bytes
56    pub amount_in: u64,           // 8 bytes
57    pub amount_out: u64,          // 8 bytes
58    pub is_buy: bool,             // 1 byte
59
60    // === 非 Borsh 字段(派生字段)===
61    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
62    pub trade_direction: TradeDirection,
63    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
64    pub exact_in: bool,
65}
66
67#[derive(Debug, Clone, Serialize, Deserialize, Default)]
68pub enum TradeDirection {
69    #[default]
70    Buy,
71    Sell,
72}
73
74/// Bonk Migrate AMM Event
75#[derive(Debug, Clone, Serialize, Deserialize)]
76pub struct BonkMigrateAmmEvent {
77    pub metadata: EventMetadata,
78    pub old_pool: Pubkey,
79    pub new_pool: Pubkey,
80    pub user: Pubkey,
81    pub liquidity_amount: u64,
82}
83
84/// PumpFun Trade Event - 基于官方IDL定义
85///
86/// 字段来源标记:
87/// - [EVENT]: 来自原始IDL事件定义,由程序日志直接解析获得
88/// - [INSTRUCTION]: 来自指令解析,用于补充事件缺失的上下文信息
89#[derive(Debug, Clone, Serialize, Deserialize, Default, BorshDeserialize)]
90pub struct PumpFunTradeEvent {
91    #[borsh(skip)]
92    pub metadata: EventMetadata,
93
94    // === IDL TradeEvent 事件字段(Borsh 序列化字段,按顺序)===
95    pub mint: Pubkey,
96    pub sol_amount: u64,
97    pub token_amount: u64,
98    pub is_buy: bool,
99    #[borsh(skip)]
100    pub is_created_buy: bool,  // 由外层逻辑设置,不在 Borsh 数据中
101    pub user: Pubkey,
102    pub timestamp: i64,
103    pub virtual_sol_reserves: u64,
104    pub virtual_token_reserves: u64,
105    pub real_sol_reserves: u64,
106    pub real_token_reserves: u64,
107    pub fee_recipient: Pubkey,
108    pub fee_basis_points: u64,
109    pub fee: u64,
110    pub creator: Pubkey,
111    pub creator_fee_basis_points: u64,
112    pub creator_fee: u64,
113    pub track_volume: bool,
114    pub total_unclaimed_tokens: u64,
115    pub total_claimed_tokens: u64,
116    pub current_sol_volume: u64,
117    pub last_update_timestamp: i64,
118    /// Instruction name: "buy" | "sell" | "buy_exact_sol_in"
119    pub ix_name: String,
120    /// Mayhem mode flag (new field from IDL update)
121    pub mayhem_mode: bool,
122    /// Cashback fee basis points (PUMP_CASHBACK_README)
123    pub cashback_fee_basis_points: u64,
124    /// Cashback amount (PUMP_CASHBACK_README)
125    pub cashback: u64,
126    /// 是否返现代币(由 cashback_fee_basis_points > 0 推导,供 sol-trade-sdk 等构造 sell 指令用)
127    #[borsh(skip)]
128    pub is_cashback_coin: bool,
129
130    // === Instruction parameter fields (reserved for future use, DO NOT delete) ===
131    // pub amount: u64,                     // buy/sell.args.amount
132    // pub max_sol_cost: u64,               // buy.args.maxSolCost
133    // pub min_sol_output: u64,             // sell.args.minSolOutput
134
135    // === 指令账户字段 (从指令账户填充,不在 Borsh 数据中) ===
136    // pub global: Pubkey,                  // 0
137    #[borsh(skip)]
138    pub bonding_curve: Pubkey,            // 3
139    #[borsh(skip)]
140    pub associated_bonding_curve: Pubkey, // 4
141    // pub associated_user: Pubkey,         // 5
142    #[borsh(skip)]
143    pub token_program: Pubkey, // sell - 9 / buy - 8
144    #[borsh(skip)]
145    pub creator_vault: Pubkey, // sell - 8 / buy - 9
146    /// 第 17 个指令账户 (index 16),区块浏览器显示为 "Account",部分 buy/sell 会传入
147    #[borsh(skip)]
148    pub account: Option<Pubkey>,
149}
150
151/// PumpFun Migrate Event
152#[derive(Debug, Clone, Serialize, Deserialize, Default, BorshDeserialize)]
153pub struct PumpFunMigrateEvent {
154    #[borsh(skip)]
155    pub metadata: EventMetadata,
156    // Borsh 序列化字段(按顺序)
157    pub user: Pubkey,
158    pub mint: Pubkey,
159    pub mint_amount: u64,
160    pub sol_amount: u64,
161    pub pool_migration_fee: u64,
162    pub bonding_curve: Pubkey,
163    pub timestamp: i64,
164    pub pool: Pubkey,
165    // === 额外账户信息(用于指令解析,暂时注释,以后可能会用到,AI不要删除) ===
166    // pub global: Pubkey,
167    // pub withdraw_authority: Pubkey,
168    // pub associated_bonding_curve: Pubkey,
169    // pub pump_amm: Pubkey,
170    // pub pool_authority: Pubkey,
171    // pub pool_authority_mint_account: Pubkey,
172    // pub pool_authority_wsol_account: Pubkey,
173    // pub amm_global_config: Pubkey,
174    // pub wsol_mint: Pubkey,
175    // pub lp_mint: Pubkey,
176    // pub user_pool_token_account: Pubkey,
177    // pub pool_base_token_account: Pubkey,
178    // pub pool_quote_token_account: Pubkey,
179}
180
181/// PumpFun Create Token Event - Based on IDL CreateEvent definition
182#[derive(Debug, Clone, Serialize, Deserialize, Default, BorshDeserialize)]
183pub struct PumpFunCreateTokenEvent {
184    #[borsh(skip)]
185    pub metadata: EventMetadata,
186    // IDL CreateEvent 字段(Borsh 序列化字段,按顺序)
187    pub name: String,
188    pub symbol: String,
189    pub uri: String,
190    pub mint: Pubkey,
191    pub bonding_curve: Pubkey,
192    pub user: Pubkey,
193    pub creator: Pubkey,
194    pub timestamp: i64,
195    pub virtual_token_reserves: u64,
196    pub virtual_sol_reserves: u64,
197    pub real_token_reserves: u64,
198    pub token_total_supply: u64,
199
200    pub token_program: Pubkey,
201    pub is_mayhem_mode: bool,
202    /// Cashback 是否开启 (IDL CreateEvent.is_cashback_enabled)
203    pub is_cashback_enabled: bool,
204}
205
206/// PumpFun Create V2 Token Event (SPL-22 / Mayhem Mode)
207/// 与 solana-streamer 对齐;指令解析时从 accounts 0..15 填充。
208#[derive(Debug, Clone, Serialize, Deserialize, Default, BorshDeserialize)]
209pub struct PumpFunCreateV2TokenEvent {
210    #[borsh(skip)]
211    pub metadata: EventMetadata,
212    pub name: String,
213    pub symbol: String,
214    pub uri: String,
215    pub mint: Pubkey,
216    pub bonding_curve: Pubkey,
217    pub user: Pubkey,
218    pub creator: Pubkey,
219    pub timestamp: i64,
220    pub virtual_token_reserves: u64,
221    pub virtual_sol_reserves: u64,
222    pub real_token_reserves: u64,
223    pub token_total_supply: u64,
224    pub token_program: Pubkey,
225    pub is_mayhem_mode: bool,
226    pub is_cashback_enabled: bool,
227    #[borsh(skip)]
228    pub mint_authority: Pubkey,
229    #[borsh(skip)]
230    pub associated_bonding_curve: Pubkey,
231    #[borsh(skip)]
232    pub global: Pubkey,
233    #[borsh(skip)]
234    pub system_program: Pubkey,
235    #[borsh(skip)]
236    pub associated_token_program: Pubkey,
237    #[borsh(skip)]
238    pub mayhem_program_id: Pubkey,
239    #[borsh(skip)]
240    pub global_params: Pubkey,
241    #[borsh(skip)]
242    pub sol_vault: Pubkey,
243    #[borsh(skip)]
244    pub mayhem_state: Pubkey,
245    #[borsh(skip)]
246    pub mayhem_token_vault: Pubkey,
247    #[borsh(skip)]
248    pub event_authority: Pubkey,
249    #[borsh(skip)]
250    pub program: Pubkey,
251}
252
253/// PumpSwap Trade Event - Unified trade event from IDL TradeEvent
254/// Produced by: buy, sell, buy_exact_sol_in instructions
255#[derive(Debug, Clone, Serialize, Deserialize, Default)]
256pub struct PumpSwapTradeEvent {
257    pub metadata: EventMetadata,
258    // === IDL TradeEvent fields ===
259    pub mint: Pubkey,
260    pub sol_amount: u64,
261    pub token_amount: u64,
262    pub is_buy: bool,
263    pub user: Pubkey,
264    pub timestamp: i64,
265    pub virtual_sol_reserves: u64,
266    pub virtual_token_reserves: u64,
267    pub real_sol_reserves: u64,
268    pub real_token_reserves: u64,
269    pub fee_recipient: Pubkey,
270    pub fee_basis_points: u64,
271    pub fee: u64,
272    pub creator: Pubkey,
273    pub creator_fee_basis_points: u64,
274    pub creator_fee: u64,
275    pub track_volume: bool,
276    pub total_unclaimed_tokens: u64,
277    pub total_claimed_tokens: u64,
278    pub current_sol_volume: u64,
279    pub last_update_timestamp: i64,
280    pub ix_name: String, // "buy" | "sell" | "buy_exact_sol_in"
281}
282
283/// PumpSwap Buy Event
284#[derive(Debug, Clone, Serialize, Deserialize, Default, BorshDeserialize)]
285pub struct PumpSwapBuyEvent {
286    #[borsh(skip)]
287    pub metadata: EventMetadata,
288    pub timestamp: i64,
289    pub base_amount_out: u64,
290    pub max_quote_amount_in: u64,
291    pub user_base_token_reserves: u64,
292    pub user_quote_token_reserves: u64,
293    pub pool_base_token_reserves: u64,
294    pub pool_quote_token_reserves: u64,
295    pub quote_amount_in: u64,
296    pub lp_fee_basis_points: u64,
297    pub lp_fee: u64,
298    pub protocol_fee_basis_points: u64,
299    pub protocol_fee: u64,
300    pub quote_amount_in_with_lp_fee: u64,
301    pub user_quote_amount_in: u64,
302    pub pool: Pubkey,
303    pub user: Pubkey,
304    pub user_base_token_account: Pubkey,
305    pub user_quote_token_account: Pubkey,
306    pub protocol_fee_recipient: Pubkey,
307    pub protocol_fee_recipient_token_account: Pubkey,
308    pub coin_creator: Pubkey,
309    pub coin_creator_fee_basis_points: u64,
310    pub coin_creator_fee: u64,
311    pub track_volume: bool,
312    pub total_unclaimed_tokens: u64,
313    pub total_claimed_tokens: u64,
314    pub current_sol_volume: u64,
315    pub last_update_timestamp: i64,
316    /// Minimum base token amount expected (new field from IDL update)
317    pub min_base_amount_out: u64,
318    /// Instruction name (new field from IDL update)
319    pub ix_name: String,
320    /// Cashback fee basis points (PUMP_CASHBACK_README)
321    pub cashback_fee_basis_points: u64,
322    /// Cashback amount (PUMP_CASHBACK_README)
323    pub cashback: u64,
324
325    // === 额外的信息 ===
326    #[borsh(skip)]
327    pub is_pump_pool: bool,
328
329    // === 额外账户信息 (from instruction accounts, not event data) ===
330    #[borsh(skip)]
331    pub base_mint: Pubkey,
332    #[borsh(skip)]
333    pub quote_mint: Pubkey,
334    #[borsh(skip)]
335    pub pool_base_token_account: Pubkey,
336    #[borsh(skip)]
337    pub pool_quote_token_account: Pubkey,
338    #[borsh(skip)]
339    pub coin_creator_vault_ata: Pubkey,
340    #[borsh(skip)]
341    pub coin_creator_vault_authority: Pubkey,
342    #[borsh(skip)]
343    pub base_token_program: Pubkey,
344    #[borsh(skip)]
345    pub quote_token_program: Pubkey,
346}
347
348/// PumpSwap Sell Event
349#[derive(Debug, Clone, Serialize, Deserialize, Default, BorshDeserialize)]
350pub struct PumpSwapSellEvent {
351    #[borsh(skip)]
352    pub metadata: EventMetadata,
353    pub timestamp: i64,
354    pub base_amount_in: u64,
355    pub min_quote_amount_out: u64,
356    pub user_base_token_reserves: u64,
357    pub user_quote_token_reserves: u64,
358    pub pool_base_token_reserves: u64,
359    pub pool_quote_token_reserves: u64,
360    pub quote_amount_out: u64,
361    pub lp_fee_basis_points: u64,
362    pub lp_fee: u64,
363    pub protocol_fee_basis_points: u64,
364    pub protocol_fee: u64,
365    pub quote_amount_out_without_lp_fee: u64,
366    pub user_quote_amount_out: u64,
367    pub pool: Pubkey,
368    pub user: Pubkey,
369    pub user_base_token_account: Pubkey,
370    pub user_quote_token_account: Pubkey,
371    pub protocol_fee_recipient: Pubkey,
372    pub protocol_fee_recipient_token_account: Pubkey,
373    pub coin_creator: Pubkey,
374    pub coin_creator_fee_basis_points: u64,
375    pub coin_creator_fee: u64,
376    /// Cashback fee basis points (PUMP_CASHBACK_README)
377    pub cashback_fee_basis_points: u64,
378    /// Cashback amount (PUMP_CASHBACK_README)
379    pub cashback: u64,
380
381    // === 额外的信息 ===
382    #[borsh(skip)]
383    pub is_pump_pool: bool,
384
385    // === 额外账户信息 (from instruction accounts, not event data) ===
386    #[borsh(skip)]
387    pub base_mint: Pubkey,
388    #[borsh(skip)]
389    pub quote_mint: Pubkey,
390    #[borsh(skip)]
391    pub pool_base_token_account: Pubkey,
392    #[borsh(skip)]
393    pub pool_quote_token_account: Pubkey,
394    #[borsh(skip)]
395    pub coin_creator_vault_ata: Pubkey,
396    #[borsh(skip)]
397    pub coin_creator_vault_authority: Pubkey,
398    #[borsh(skip)]
399    pub base_token_program: Pubkey,
400    #[borsh(skip)]
401    pub quote_token_program: Pubkey,
402}
403
404/// PumpSwap Create Pool Event
405#[derive(Debug, Clone, Serialize, Deserialize, Default)]
406pub struct PumpSwapCreatePoolEvent {
407    pub metadata: EventMetadata,
408    pub timestamp: i64,
409    pub index: u16,
410    pub creator: Pubkey,
411    pub base_mint: Pubkey,
412    pub quote_mint: Pubkey,
413    pub base_mint_decimals: u8,
414    pub quote_mint_decimals: u8,
415    pub base_amount_in: u64,
416    pub quote_amount_in: u64,
417    pub pool_base_amount: u64,
418    pub pool_quote_amount: u64,
419    pub minimum_liquidity: u64,
420    pub initial_liquidity: u64,
421    pub lp_token_amount_out: u64,
422    pub pool_bump: u8,
423    pub pool: Pubkey,
424    pub lp_mint: Pubkey,
425    pub user_base_token_account: Pubkey,
426    pub user_quote_token_account: Pubkey,
427    pub coin_creator: Pubkey,
428    /// IDL CreatePoolEvent 最后一列
429    pub is_mayhem_mode: bool,
430}
431
432/// PumpSwap Pool Created Event - 指令解析版本
433#[derive(Debug, Clone, Serialize, Deserialize)]
434pub struct PumpSwapPoolCreated {
435    pub metadata: EventMetadata,
436    pub pool_account: Pubkey,
437    pub token_a_mint: Pubkey,
438    pub token_b_mint: Pubkey,
439    pub token_a_vault: Pubkey,
440    pub token_b_vault: Pubkey,
441    pub lp_mint: Pubkey,
442    pub creator: Pubkey,
443    pub authority: Pubkey,
444    pub initial_token_a_amount: u64,
445    pub initial_token_b_amount: u64,
446}
447
448/// PumpSwap Trade Event - 指令解析版本
449// #[derive(Debug, Clone, Serialize, Deserialize)]
450// pub struct PumpSwapTrade {
451//     pub metadata: EventMetadata,
452//     pub pool_account: Pubkey,
453//     pub user: Pubkey,
454//     pub user_token_in_account: Pubkey,
455//     pub user_token_out_account: Pubkey,
456//     pub pool_token_in_vault: Pubkey,
457//     pub pool_token_out_vault: Pubkey,
458//     pub token_in_mint: Pubkey,
459//     pub token_out_mint: Pubkey,
460//     pub amount_in: u64,
461//     pub minimum_amount_out: u64,
462//     pub is_token_a_to_b: bool,
463// }
464
465/// PumpSwap Liquidity Added Event - Instruction parsing version
466#[derive(Debug, Clone, Serialize, Deserialize, Default)]
467pub struct PumpSwapLiquidityAdded {
468    pub metadata: EventMetadata,
469    pub timestamp: i64,
470    pub lp_token_amount_out: u64,
471    pub max_base_amount_in: u64,
472    pub max_quote_amount_in: u64,
473    pub user_base_token_reserves: u64,
474    pub user_quote_token_reserves: u64,
475    pub pool_base_token_reserves: u64,
476    pub pool_quote_token_reserves: u64,
477    pub base_amount_in: u64,
478    pub quote_amount_in: u64,
479    pub lp_mint_supply: u64,
480    pub pool: Pubkey,
481    pub user: Pubkey,
482    pub user_base_token_account: Pubkey,
483    pub user_quote_token_account: Pubkey,
484    pub user_pool_token_account: Pubkey,
485}
486
487/// PumpSwap Liquidity Removed Event - Instruction parsing version
488#[derive(Debug, Clone, Serialize, Deserialize, Default)]
489pub struct PumpSwapLiquidityRemoved {
490    pub metadata: EventMetadata,
491    pub timestamp: i64,
492    pub lp_token_amount_in: u64,
493    pub min_base_amount_out: u64,
494    pub min_quote_amount_out: u64,
495    pub user_base_token_reserves: u64,
496    pub user_quote_token_reserves: u64,
497    pub pool_base_token_reserves: u64,
498    pub pool_quote_token_reserves: u64,
499    pub base_amount_out: u64,
500    pub quote_amount_out: u64,
501    pub lp_mint_supply: u64,
502    pub pool: Pubkey,
503    pub user: Pubkey,
504    pub user_base_token_account: Pubkey,
505    pub user_quote_token_account: Pubkey,
506    pub user_pool_token_account: Pubkey,
507}
508
509/// PumpSwap Pool Updated Event - 指令解析版本
510#[derive(Debug, Clone, Serialize, Deserialize)]
511pub struct PumpSwapPoolUpdated {
512    pub metadata: EventMetadata,
513    pub pool_account: Pubkey,
514    pub authority: Pubkey,
515    pub admin: Pubkey,
516    pub new_fee_rate: u64,
517}
518
519/// PumpSwap Fees Claimed Event - 指令解析版本
520#[derive(Debug, Clone, Serialize, Deserialize)]
521pub struct PumpSwapFeesClaimed {
522    pub metadata: EventMetadata,
523    pub pool_account: Pubkey,
524    pub authority: Pubkey,
525    pub admin: Pubkey,
526    pub admin_token_a_account: Pubkey,
527    pub admin_token_b_account: Pubkey,
528    pub pool_fee_vault: Pubkey,
529}
530
531/// PumpSwap Deposit Event
532#[derive(Debug, Clone, Serialize, Deserialize)]
533pub struct PumpSwapDepositEvent {
534    pub metadata: EventMetadata,
535    pub pool: Pubkey,
536    pub user: Pubkey,
537    pub amount: u64,
538}
539
540/// PumpSwap Withdraw Event
541#[derive(Debug, Clone, Serialize, Deserialize)]
542pub struct PumpSwapWithdrawEvent {
543    pub metadata: EventMetadata,
544    pub pool: Pubkey,
545    pub user: Pubkey,
546    pub amount: u64,
547}
548
549/// Raydium CPMM Swap Event (基于IDL SwapEvent + swapBaseInput指令定义)
550#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
551#[derive(Debug, Clone, Serialize, Deserialize)]
552pub struct RaydiumCpmmSwapEvent {
553    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
554    pub metadata: EventMetadata,
555
556    // === Borsh 序列化字段(从 inner instruction 事件)===
557    pub pool_id: Pubkey,
558    pub input_amount: u64,
559    pub output_amount: u64,
560
561    // === 非 Borsh 字段 ===
562    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
563    pub input_vault_before: u64,
564    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
565    pub output_vault_before: u64,
566    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
567    pub input_transfer_fee: u64,
568    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
569    pub output_transfer_fee: u64,
570    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
571    pub base_input: bool,
572    // === 指令参数字段 (暂时注释,以后可能会用到,AI不要删除) ===
573    // pub amount_in: u64,
574    // pub minimum_amount_out: u64,
575
576    // === 指令账户字段 (暂时注释,以后可能会用到,AI不要删除) ===
577    // pub payer: Pubkey,              // 0: payer
578    // pub authority: Pubkey,          // 1: authority
579    // pub amm_config: Pubkey,         // 2: ammConfig
580    // pub pool_state: Pubkey,         // 3: poolState
581    // pub input_token_account: Pubkey, // 4: inputTokenAccount
582    // pub output_token_account: Pubkey, // 5: outputTokenAccount
583    // pub input_vault: Pubkey,        // 6: inputVault
584    // pub output_vault: Pubkey,       // 7: outputVault
585    // pub input_token_mint: Pubkey,   // 10: inputTokenMint
586    // pub output_token_mint: Pubkey,  // 11: outputTokenMint
587}
588
589/// Raydium CPMM Deposit Event
590#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
591#[derive(Debug, Clone, Serialize, Deserialize)]
592pub struct RaydiumCpmmDepositEvent {
593    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
594    pub metadata: EventMetadata,
595
596    // === Borsh 序列化字段(从 inner instruction 事件)===
597    pub pool: Pubkey,
598    pub token0_amount: u64,
599    pub token1_amount: u64,
600    pub lp_token_amount: u64,
601
602    // === 非 Borsh 字段 ===
603    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
604    pub user: Pubkey,
605}
606
607/// Raydium CPMM Initialize Event
608#[derive(Debug, Clone, Serialize, Deserialize)]
609pub struct RaydiumCpmmInitializeEvent {
610    pub metadata: EventMetadata,
611    pub pool: Pubkey,
612    pub creator: Pubkey,
613    pub init_amount0: u64,
614    pub init_amount1: u64,
615}
616
617/// Raydium CPMM Withdraw Event
618#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
619#[derive(Debug, Clone, Serialize, Deserialize)]
620pub struct RaydiumCpmmWithdrawEvent {
621    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
622    pub metadata: EventMetadata,
623
624    // === Borsh 序列化字段(从 inner instruction 事件)===
625    pub pool: Pubkey,
626    pub lp_token_amount: u64,
627    pub token0_amount: u64,
628    pub token1_amount: u64,
629
630    // === 非 Borsh 字段 ===
631    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
632    pub user: Pubkey,
633}
634
635/// Raydium CLMM Swap Event (基于IDL SwapEvent + swap指令定义)
636#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
637#[derive(Debug, Clone, Serialize, Deserialize)]
638pub struct RaydiumClmmSwapEvent {
639    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
640    pub metadata: EventMetadata,
641
642    // === IDL SwapEvent 事件字段 (Borsh 序列化字段) ===
643    pub pool_state: Pubkey,
644    pub token_account_0: Pubkey,
645    pub token_account_1: Pubkey,
646    pub amount_0: u64,
647    pub amount_1: u64,
648    pub zero_for_one: bool,
649    pub sqrt_price_x64: u128,
650    pub liquidity: u128,
651
652    // === 非 Borsh 字段 ===
653    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
654    pub sender: Pubkey,
655    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
656    pub transfer_fee_0: u64,
657    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
658    pub transfer_fee_1: u64,
659    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
660    pub tick: i32,
661    // === 指令参数字段 (暂时注释,以后可能会用到,AI不要删除) ===
662    // pub amount: u64,
663    // pub other_amount_threshold: u64,
664    // pub sqrt_price_limit_x64: u128,
665    // pub is_base_input: bool,
666
667    // === 指令账户字段 (暂时注释,以后可能会用到,AI不要删除) ===
668    // TODO: 根据Raydium CLMM swap指令IDL添加账户字段
669}
670
671/// Raydium CLMM Close Position Event
672#[derive(Debug, Clone, Serialize, Deserialize)]
673pub struct RaydiumClmmClosePositionEvent {
674    pub metadata: EventMetadata,
675    pub pool: Pubkey,
676    pub user: Pubkey,
677    pub position_nft_mint: Pubkey,
678}
679
680/// Raydium CLMM Decrease Liquidity Event
681#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
682#[derive(Debug, Clone, Serialize, Deserialize)]
683pub struct RaydiumClmmDecreaseLiquidityEvent {
684    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
685    pub metadata: EventMetadata,
686
687    // === Borsh 序列化字段 ===
688    pub pool: Pubkey,
689    pub position_nft_mint: Pubkey,
690    pub amount0_min: u64,
691    pub amount1_min: u64,
692    pub liquidity: u128,
693
694    // === 非 Borsh 字段 ===
695    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
696    pub user: Pubkey,
697}
698
699/// Raydium CLMM Collect Fee Event
700#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
701#[derive(Debug, Clone, Serialize, Deserialize)]
702pub struct RaydiumClmmCollectFeeEvent {
703    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
704    pub metadata: EventMetadata,
705
706    // === Borsh 序列化字段 ===
707    pub pool_state: Pubkey,
708    pub position_nft_mint: Pubkey,
709    pub amount_0: u64,
710    pub amount_1: u64,
711}
712
713/// Raydium CLMM Create Pool Event
714#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
715#[derive(Debug, Clone, Serialize, Deserialize)]
716pub struct RaydiumClmmCreatePoolEvent {
717    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
718    pub metadata: EventMetadata,
719
720    // === Borsh 序列化字段(从 inner instruction 事件)===
721    pub pool: Pubkey,
722    pub token_0_mint: Pubkey,
723    pub token_1_mint: Pubkey,
724    pub tick_spacing: u16,
725    pub fee_rate: u32,
726    pub sqrt_price_x64: u128,
727
728    // === 非 Borsh 字段(从指令或账户) ===
729    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
730    pub creator: Pubkey,
731    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
732    pub open_time: u64,
733}
734
735/// Raydium CLMM Increase Liquidity Event
736#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
737#[derive(Debug, Clone, Serialize, Deserialize)]
738pub struct RaydiumClmmIncreaseLiquidityEvent {
739    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
740    pub metadata: EventMetadata,
741
742    // === Borsh 序列化字段 ===
743    pub pool: Pubkey,
744    pub position_nft_mint: Pubkey,
745    pub amount0_max: u64,
746    pub amount1_max: u64,
747    pub liquidity: u128,
748
749    // === 非 Borsh 字段 ===
750    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
751    pub user: Pubkey,
752}
753
754/// Raydium CLMM Open Position with Token Extension NFT Event
755#[derive(Debug, Clone, Serialize, Deserialize)]
756pub struct RaydiumClmmOpenPositionWithTokenExtNftEvent {
757    pub metadata: EventMetadata,
758    pub pool: Pubkey,
759    pub user: Pubkey,
760    pub position_nft_mint: Pubkey,
761    pub tick_lower_index: i32,
762    pub tick_upper_index: i32,
763    pub liquidity: u128,
764}
765
766/// Raydium CLMM Open Position Event
767#[derive(Debug, Clone, Serialize, Deserialize)]
768pub struct RaydiumClmmOpenPositionEvent {
769    pub metadata: EventMetadata,
770    pub pool: Pubkey,
771    pub user: Pubkey,
772    pub position_nft_mint: Pubkey,
773    pub tick_lower_index: i32,
774    pub tick_upper_index: i32,
775    pub liquidity: u128,
776}
777
778/// Raydium AMM V4 Deposit Event (简化版)
779#[derive(Debug, Clone, Serialize, Deserialize)]
780pub struct RaydiumAmmDepositEvent {
781    pub metadata: EventMetadata,
782    pub amm_id: Pubkey,
783    pub user: Pubkey,
784    pub max_coin_amount: u64,
785    pub max_pc_amount: u64,
786}
787
788/// Raydium AMM V4 Initialize Alt Event (简化版)
789#[derive(Debug, Clone, Serialize, Deserialize)]
790pub struct RaydiumAmmInitializeAltEvent {
791    pub metadata: EventMetadata,
792    pub amm_id: Pubkey,
793    pub creator: Pubkey,
794    pub nonce: u8,
795    pub open_time: u64,
796}
797
798/// Raydium AMM V4 Withdraw Event (简化版)
799#[derive(Debug, Clone, Serialize, Deserialize)]
800pub struct RaydiumAmmWithdrawEvent {
801    pub metadata: EventMetadata,
802    pub amm_id: Pubkey,
803    pub user: Pubkey,
804    pub pool_coin_amount: u64,
805}
806
807/// Raydium AMM V4 Withdraw PnL Event (简化版)
808#[derive(Debug, Clone, Serialize, Deserialize)]
809pub struct RaydiumAmmWithdrawPnlEvent {
810    pub metadata: EventMetadata,
811    pub amm_id: Pubkey,
812    pub user: Pubkey,
813}
814
815// ====================== Raydium AMM V4 Events ======================
816
817/// Raydium AMM V4 Swap Event
818#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
819#[derive(Debug, Clone, Serialize, Deserialize)]
820pub struct RaydiumAmmV4SwapEvent {
821    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
822    pub metadata: EventMetadata,
823
824    // === Borsh 序列化字段(从 inner instruction 事件)===
825    pub amm: Pubkey,
826    pub amount_in: u64,
827    pub amount_out: u64,
828
829    // === 非 Borsh 字段 ===
830    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
831    pub minimum_amount_out: u64,
832    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
833    pub max_amount_in: u64,
834    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
835    pub token_program: Pubkey,
836    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
837    pub amm_authority: Pubkey,
838    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
839    pub amm_open_orders: Pubkey,
840    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
841    pub amm_target_orders: Option<Pubkey>,
842    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
843    pub pool_coin_token_account: Pubkey,
844    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
845    pub pool_pc_token_account: Pubkey,
846    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
847    pub serum_program: Pubkey,
848    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
849    pub serum_market: Pubkey,
850    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
851    pub serum_bids: Pubkey,
852    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
853    pub serum_asks: Pubkey,
854    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
855    pub serum_event_queue: Pubkey,
856    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
857    pub serum_coin_vault_account: Pubkey,
858    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
859    pub serum_pc_vault_account: Pubkey,
860    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
861    pub serum_vault_signer: Pubkey,
862    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
863    pub user_source_token_account: Pubkey,
864    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
865    pub user_destination_token_account: Pubkey,
866    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
867    pub user_source_owner: Pubkey,
868}
869
870/// Raydium AMM V4 Deposit Event
871#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
872#[derive(Debug, Clone, Serialize, Deserialize)]
873pub struct RaydiumAmmV4DepositEvent {
874    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
875    pub metadata: EventMetadata,
876
877    // === Borsh 序列化字段(从 inner instruction 事件)===
878    pub amm: Pubkey,
879    pub max_coin_amount: u64,
880    pub max_pc_amount: u64,
881
882    // === 非 Borsh 字段 ===
883    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
884    pub base_side: u64,
885    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
886    pub token_program: Pubkey,
887    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
888    pub amm_authority: Pubkey,
889    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
890    pub amm_open_orders: Pubkey,
891    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
892    pub amm_target_orders: Pubkey,
893    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
894    pub lp_mint_address: Pubkey,
895    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
896    pub pool_coin_token_account: Pubkey,
897    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
898    pub pool_pc_token_account: Pubkey,
899    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
900    pub serum_market: Pubkey,
901    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
902    pub user_coin_token_account: Pubkey,
903    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
904    pub user_pc_token_account: Pubkey,
905    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
906    pub user_lp_token_account: Pubkey,
907    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
908    pub user_owner: Pubkey,
909    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
910    pub serum_event_queue: Pubkey,
911}
912
913/// Raydium AMM V4 Initialize2 Event
914#[derive(Debug, Clone, Serialize, Deserialize)]
915pub struct RaydiumAmmV4Initialize2Event {
916    pub metadata: EventMetadata,
917    pub nonce: u8,
918    pub open_time: u64,
919    pub init_pc_amount: u64,
920    pub init_coin_amount: u64,
921
922    pub token_program: Pubkey,
923    pub spl_associated_token_account: Pubkey,
924    pub system_program: Pubkey,
925    pub rent: Pubkey,
926    pub amm: Pubkey,
927    pub amm_authority: Pubkey,
928    pub amm_open_orders: Pubkey,
929    pub lp_mint: Pubkey,
930    pub coin_mint: Pubkey,
931    pub pc_mint: Pubkey,
932    pub pool_coin_token_account: Pubkey,
933    pub pool_pc_token_account: Pubkey,
934    pub pool_withdraw_queue: Pubkey,
935    pub amm_target_orders: Pubkey,
936    pub pool_temp_lp: Pubkey,
937    pub serum_program: Pubkey,
938    pub serum_market: Pubkey,
939    pub user_wallet: Pubkey,
940    pub user_token_coin: Pubkey,
941    pub user_token_pc: Pubkey,
942    pub user_lp_token_account: Pubkey,
943}
944
945/// Raydium AMM V4 Withdraw Event
946#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
947#[derive(Debug, Clone, Serialize, Deserialize)]
948pub struct RaydiumAmmV4WithdrawEvent {
949    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
950    pub metadata: EventMetadata,
951
952    // === Borsh 序列化字段(从 inner instruction 事件)===
953    pub amm: Pubkey,
954    pub amount: u64,
955
956    // === 非 Borsh 字段 ===
957    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
958    pub token_program: Pubkey,
959    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
960    pub amm_authority: Pubkey,
961    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
962    pub amm_open_orders: Pubkey,
963    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
964    pub amm_target_orders: Pubkey,
965    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
966    pub lp_mint_address: Pubkey,
967    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
968    pub pool_coin_token_account: Pubkey,
969    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
970    pub pool_pc_token_account: Pubkey,
971    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
972    pub pool_withdraw_queue: Pubkey,
973    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
974    pub pool_temp_lp_token_account: Pubkey,
975    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
976    pub serum_program: Pubkey,
977    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
978    pub serum_market: Pubkey,
979    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
980    pub serum_coin_vault_account: Pubkey,
981    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
982    pub serum_pc_vault_account: Pubkey,
983    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
984    pub serum_vault_signer: Pubkey,
985    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
986    pub user_lp_token_account: Pubkey,
987    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
988    pub user_coin_token_account: Pubkey,
989    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
990    pub user_pc_token_account: Pubkey,
991    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
992    pub user_owner: Pubkey,
993    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
994    pub serum_event_queue: Pubkey,
995    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
996    pub serum_bids: Pubkey,
997    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
998    pub serum_asks: Pubkey,
999}
1000
1001/// Raydium AMM V4 Withdraw PnL Event
1002#[derive(Debug, Clone, Serialize, Deserialize)]
1003pub struct RaydiumAmmV4WithdrawPnlEvent {
1004    pub metadata: EventMetadata,
1005
1006    pub token_program: Pubkey,
1007    pub amm: Pubkey,
1008    pub amm_config: Pubkey,
1009    pub amm_authority: Pubkey,
1010    pub amm_open_orders: Pubkey,
1011    pub pool_coin_token_account: Pubkey,
1012    pub pool_pc_token_account: Pubkey,
1013    pub coin_pnl_token_account: Pubkey,
1014    pub pc_pnl_token_account: Pubkey,
1015    pub pnl_owner: Pubkey,
1016    pub amm_target_orders: Pubkey,
1017    pub serum_program: Pubkey,
1018    pub serum_market: Pubkey,
1019    pub serum_event_queue: Pubkey,
1020    pub serum_coin_vault_account: Pubkey,
1021    pub serum_pc_vault_account: Pubkey,
1022    pub serum_vault_signer: Pubkey,
1023}
1024
1025// ====================== Account Events ======================
1026
1027/// Bonk (Raydium Launchpad) AmmCreatorFeeOn enum
1028#[derive(Debug, Clone, Serialize, Deserialize)]
1029pub enum AmmCreatorFeeOn {
1030    QuoteToken = 0,
1031    BothToken = 1,
1032}
1033
1034/// Bonk (Raydium Launchpad) VestingSchedule
1035#[derive(Debug, Clone, Serialize, Deserialize)]
1036pub struct VestingSchedule {
1037    pub total_locked_amount: u64,
1038    pub cliff_period: u64,
1039    pub unlock_period: u64,
1040}
1041
1042/// Bonk Pool State Account Event
1043#[derive(Debug, Clone, Serialize, Deserialize)]
1044pub struct BonkPoolStateAccountEvent {
1045    pub metadata: EventMetadata,
1046    pub pubkey: Pubkey,
1047    pub pool_state: BonkPoolState,
1048}
1049
1050#[derive(Debug, Clone, Serialize, Deserialize)]
1051pub struct BonkPoolState {
1052    pub epoch: u64,
1053    pub auth_bump: u8,
1054    pub status: u8,
1055    pub base_decimals: u8,
1056    pub quote_decimals: u8,
1057    pub migrate_type: u8,
1058    pub supply: u64,
1059    pub total_base_sell: u64,
1060    pub virtual_base: u64,
1061    pub virtual_quote: u64,
1062    pub real_base: u64,
1063    pub real_quote: u64,
1064    pub total_quote_fund_raising: u64,
1065    pub quote_protocol_fee: u64,
1066    pub platform_fee: u64,
1067    pub migrate_fee: u64,
1068    pub vesting_schedule: VestingSchedule,
1069    pub global_config: Pubkey,
1070    pub platform_config: Pubkey,
1071    pub base_mint: Pubkey,
1072    pub quote_mint: Pubkey,
1073    pub base_vault: Pubkey,
1074    pub quote_vault: Pubkey,
1075    pub creator: Pubkey,
1076    pub token_program_flag: u8,
1077    pub amm_creator_fee_on: AmmCreatorFeeOn,
1078    pub platform_vesting_share: u64,
1079    #[serde(with = "serde_big_array::BigArray")]
1080    pub padding: [u8; 54],
1081}
1082
1083/// Bonk Global Config Account Event
1084#[derive(Debug, Clone, Serialize, Deserialize)]
1085pub struct BonkGlobalConfigAccountEvent {
1086    pub metadata: EventMetadata,
1087    pub pubkey: Pubkey,
1088    pub global_config: BonkGlobalConfig,
1089}
1090
1091#[derive(Debug, Clone, Serialize, Deserialize)]
1092pub struct BonkGlobalConfig {
1093    pub protocol_fee_rate: u64,
1094    pub trade_fee_rate: u64,
1095    pub migration_fee_rate: u64,
1096}
1097
1098/// Bonk Platform Config Account Event
1099#[derive(Debug, Clone, Serialize, Deserialize)]
1100pub struct BonkPlatformConfigAccountEvent {
1101    pub metadata: EventMetadata,
1102    pub pubkey: Pubkey,
1103    pub platform_config: BonkPlatformConfig,
1104}
1105
1106/// Bonk (Raydium Launchpad) BondingCurveParam
1107#[derive(Debug, Clone, Serialize, Deserialize)]
1108pub struct BondingCurveParam {
1109    pub migrate_type: u8,
1110    pub migrate_cpmm_fee_on: u8,
1111    pub supply: u64,
1112    pub total_base_sell: u64,
1113    pub total_quote_fund_raising: u64,
1114    pub total_locked_amount: u64,
1115    pub cliff_period: u64,
1116    pub unlock_period: u64,
1117}
1118
1119/// Bonk (Raydium Launchpad) PlatformCurveParam
1120#[derive(Debug, Clone, Serialize, Deserialize)]
1121pub struct PlatformCurveParam {
1122    pub epoch: u64,
1123    pub index: u8,
1124    pub global_config: Pubkey,
1125    pub bonding_curve_param: BondingCurveParam,
1126    #[serde(with = "serde_big_array::BigArray")]
1127    pub padding: [u64; 50],
1128}
1129
1130#[derive(Debug, Clone, Serialize, Deserialize)]
1131pub struct BonkPlatformConfig {
1132    pub epoch: u64,
1133    pub platform_fee_wallet: Pubkey,
1134    pub platform_nft_wallet: Pubkey,
1135    pub platform_scale: u64,
1136    pub creator_scale: u64,
1137    pub burn_scale: u64,
1138    pub fee_rate: u64,
1139    #[serde(with = "serde_big_array::BigArray")]
1140    pub name: [u8; 64],
1141    #[serde(with = "serde_big_array::BigArray")]
1142    pub web: [u8; 256],
1143    #[serde(with = "serde_big_array::BigArray")]
1144    pub img: [u8; 256],
1145    pub cpswap_config: Pubkey,
1146    pub creator_fee_rate: u64,
1147    pub transfer_fee_extension_auth: Pubkey,
1148    pub platform_vesting_wallet: Pubkey,
1149    pub platform_vesting_scale: u64,
1150    pub platform_cp_creator: Pubkey,
1151    #[serde(with = "serde_big_array::BigArray")]
1152    pub padding: [u8; 108],
1153    pub curve_params: Vec<PlatformCurveParam>,
1154}
1155
1156/// PumpSwap Global Config Account Event
1157#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1158pub struct PumpSwapGlobalConfigAccountEvent {
1159    pub metadata: EventMetadata,
1160    pub pubkey: Pubkey,
1161    pub executable: bool,
1162    pub lamports: u64,
1163    pub owner: Pubkey,
1164    pub rent_epoch: u64,
1165    pub global_config: PumpSwapGlobalConfig,
1166}
1167
1168#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1169pub struct PumpSwapGlobalConfig {
1170    pub admin: Pubkey,
1171    pub lp_fee_basis_points: u64,
1172    pub protocol_fee_basis_points: u64,
1173    pub disable_flags: u8,
1174    pub protocol_fee_recipients: [Pubkey; 8],
1175    pub coin_creator_fee_basis_points: u64,
1176    pub admin_set_coin_creator_authority: Pubkey,
1177    pub whitelist_pda: Pubkey,
1178    pub reserved_fee_recipient: Pubkey,
1179    pub mayhem_mode_enabled: bool,
1180    pub reserved_fee_recipients: [Pubkey; 7],
1181}
1182
1183/// PumpSwap Pool Account Event
1184#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1185pub struct PumpSwapPoolAccountEvent {
1186    pub metadata: EventMetadata,
1187    pub pubkey: Pubkey,
1188    pub executable: bool,
1189    pub lamports: u64,
1190    pub owner: Pubkey,
1191    pub rent_epoch: u64,
1192    pub pool: PumpSwapPool,
1193}
1194
1195#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1196pub struct PumpSwapPool {
1197    pub pool_bump: u8,
1198    pub index: u16,
1199    pub creator: Pubkey,
1200    pub base_mint: Pubkey,
1201    pub quote_mint: Pubkey,
1202    pub lp_mint: Pubkey,
1203    pub pool_base_token_account: Pubkey,
1204    pub pool_quote_token_account: Pubkey,
1205    pub lp_supply: u64,
1206    pub coin_creator: Pubkey,
1207}
1208
1209/// PumpFun Bonding Curve Account Event
1210#[derive(Debug, Clone, Serialize, Deserialize)]
1211pub struct PumpFunBondingCurveAccountEvent {
1212    pub metadata: EventMetadata,
1213    pub pubkey: Pubkey,
1214    pub bonding_curve: PumpFunBondingCurve,
1215}
1216
1217#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1218pub struct PumpFunBondingCurve {
1219    pub virtual_token_reserves: u64,
1220    pub virtual_sol_reserves: u64,
1221    pub real_token_reserves: u64,
1222    pub real_sol_reserves: u64,
1223    pub token_total_supply: u64,
1224    pub complete: bool,
1225    /// Cashback 币种标记 (PUMP_CASHBACK_README)
1226    #[serde(default)]
1227    pub is_cashback_coin: bool,
1228}
1229
1230/// PumpFun Global Account Event
1231#[derive(Debug, Clone, Serialize, Deserialize)]
1232pub struct PumpFunGlobalAccountEvent {
1233    pub metadata: EventMetadata,
1234    pub pubkey: Pubkey,
1235    pub global: PumpFunGlobal,
1236}
1237
1238#[derive(Debug, Clone, Serialize, Deserialize)]
1239pub struct PumpFunGlobal {
1240    pub initialized: bool,
1241    pub authority: Pubkey,
1242    pub fee_recipient: Pubkey,
1243    pub initial_virtual_token_reserves: u64,
1244    pub initial_virtual_sol_reserves: u64,
1245    pub initial_real_token_reserves: u64,
1246    pub token_total_supply: u64,
1247    pub fee_basis_points: u64,
1248    pub withdraw_authority: Pubkey,
1249    pub enable_migrate: bool,
1250    pub pool_migration_fee: u64,
1251    pub creator_fee_basis_points: u64,
1252    pub fee_recipients: [Pubkey; 8],
1253    pub set_creator_authority: Pubkey,
1254    pub admin_set_creator_authority: Pubkey,
1255    pub create_v2_enabled: bool,
1256    pub whitelist_pda: Pubkey,
1257    pub reserved_fee_recipient: Pubkey,
1258    pub mayhem_mode_enabled: bool,
1259    pub reserved_fee_recipients: [Pubkey; 7],
1260}
1261
1262/// Raydium AMM V4 Info Account Event
1263#[derive(Debug, Clone, Serialize, Deserialize)]
1264pub struct RaydiumAmmAmmInfoAccountEvent {
1265    pub metadata: EventMetadata,
1266    pub pubkey: Pubkey,
1267    pub amm_info: RaydiumAmmInfo,
1268}
1269
1270#[derive(Debug, Clone, Serialize, Deserialize)]
1271pub struct RaydiumAmmInfo {
1272    pub status: u64,
1273    pub nonce: u64,
1274    pub order_num: u64,
1275    pub depth: u64,
1276    pub coin_decimals: u64,
1277    pub pc_decimals: u64,
1278    pub state: u64,
1279    pub reset_flag: u64,
1280    pub min_size: u64,
1281    pub vol_max_cut_ratio: u64,
1282    pub amount_wave_ratio: u64,
1283    pub coin_lot_size: u64,
1284    pub pc_lot_size: u64,
1285    pub min_price_multiplier: u64,
1286    pub max_price_multiplier: u64,
1287    pub sys_decimal_value: u64,
1288}
1289
1290/// Raydium CLMM AMM Config Account Event
1291#[derive(Debug, Clone, Serialize, Deserialize)]
1292pub struct RaydiumClmmAmmConfigAccountEvent {
1293    pub metadata: EventMetadata,
1294    pub pubkey: Pubkey,
1295    pub amm_config: RaydiumClmmAmmConfig,
1296}
1297
1298#[derive(Debug, Clone, Serialize, Deserialize)]
1299pub struct RaydiumClmmAmmConfig {
1300    pub bump: u8,
1301    pub index: u16,
1302    pub owner: Pubkey,
1303    pub protocol_fee_rate: u32,
1304    pub trade_fee_rate: u32,
1305    pub tick_spacing: u16,
1306    pub fund_fee_rate: u32,
1307    pub fund_owner: Pubkey,
1308}
1309
1310/// Raydium CLMM Pool State Account Event
1311#[derive(Debug, Clone, Serialize, Deserialize)]
1312pub struct RaydiumClmmPoolStateAccountEvent {
1313    pub metadata: EventMetadata,
1314    pub pubkey: Pubkey,
1315    pub pool_state: RaydiumClmmPoolState,
1316}
1317
1318#[derive(Debug, Clone, Serialize, Deserialize)]
1319pub struct RaydiumClmmPoolState {
1320    pub bump: [u8; 1],
1321    pub amm_config: Pubkey,
1322    pub owner: Pubkey,
1323    pub token_mint0: Pubkey,
1324    pub token_mint1: Pubkey,
1325    pub token_vault0: Pubkey,
1326    pub token_vault1: Pubkey,
1327    pub observation_key: Pubkey,
1328    pub mint_decimals0: u8,
1329    pub mint_decimals1: u8,
1330    pub tick_spacing: u16,
1331    pub liquidity: u128,
1332    pub sqrt_price_x64: u128,
1333    pub tick_current: i32,
1334}
1335
1336/// Raydium CLMM Tick Array State Account Event
1337#[derive(Debug, Clone, Serialize, Deserialize)]
1338pub struct RaydiumClmmTickArrayStateAccountEvent {
1339    pub metadata: EventMetadata,
1340    pub pubkey: Pubkey,
1341    pub tick_array_state: RaydiumClmmTickArrayState,
1342}
1343
1344#[derive(Debug, Clone, Serialize, Deserialize)]
1345pub struct RaydiumClmmTickArrayState {
1346    pub discriminator: u64,
1347    pub pool_id: Pubkey,
1348    pub start_tick_index: i32,
1349    pub ticks: Vec<Tick>,
1350    pub initialized_tick_count: u8,
1351}
1352
1353#[derive(Debug, Clone, Serialize, Deserialize)]
1354pub struct Tick {
1355    pub tick: i32,
1356    pub liquidity_net: i128,
1357    pub liquidity_gross: u128,
1358    pub fee_growth_outside_0_x64: u128,
1359    pub fee_growth_outside_1_x64: u128,
1360    pub reward_growths_outside_x64: [u128; 3],
1361}
1362
1363/// Raydium CPMM AMM Config Account Event
1364#[derive(Debug, Clone, Serialize, Deserialize)]
1365pub struct RaydiumCpmmAmmConfigAccountEvent {
1366    pub metadata: EventMetadata,
1367    pub pubkey: Pubkey,
1368    pub amm_config: RaydiumCpmmAmmConfig,
1369}
1370
1371#[derive(Debug, Clone, Serialize, Deserialize)]
1372pub struct RaydiumCpmmAmmConfig {
1373    pub bump: u8,
1374    pub disable_create_pool: bool,
1375    pub index: u16,
1376    pub trade_fee_rate: u64,
1377    pub protocol_fee_rate: u64,
1378    pub fund_fee_rate: u64,
1379    pub create_pool_fee: u64,
1380    pub protocol_owner: Pubkey,
1381    pub fund_owner: Pubkey,
1382    pub creator_fee_rate: u64,
1383    pub padding: [u64; 15],
1384}
1385
1386/// Raydium CPMM Pool State Account Event
1387#[derive(Debug, Clone, Serialize, Deserialize)]
1388pub struct RaydiumCpmmPoolStateAccountEvent {
1389    pub metadata: EventMetadata,
1390    pub pubkey: Pubkey,
1391    pub pool_state: RaydiumCpmmPoolState,
1392}
1393
1394#[derive(Debug, Clone, Serialize, Deserialize)]
1395pub struct RaydiumCpmmPoolState {
1396    pub amm_config: Pubkey,
1397    pub pool_creator: Pubkey,
1398    pub token_0_vault: Pubkey,
1399    pub token_1_vault: Pubkey,
1400    pub lp_mint: Pubkey,
1401    pub token_0_mint: Pubkey,
1402    pub token_1_mint: Pubkey,
1403    pub token_0_program: Pubkey,
1404    pub token_1_program: Pubkey,
1405    pub observation_key: Pubkey,
1406    pub auth_bump: u8,
1407    pub status: u8,
1408    pub lp_mint_decimals: u8,
1409    pub mint_0_decimals: u8,
1410    pub mint_1_decimals: u8,
1411    pub lp_supply: u64,
1412    pub protocol_fees_token_0: u64,
1413    pub protocol_fees_token_1: u64,
1414    pub fund_fees_token_0: u64,
1415    pub fund_fees_token_1: u64,
1416    pub open_time: u64,
1417    pub recent_epoch: u64,
1418    pub creator_fee_on: u8,
1419    pub enable_creator_fee: bool,
1420    pub padding1: [u8; 6],
1421    pub creator_fees_token_0: u64,
1422    pub creator_fees_token_1: u64,
1423    pub padding: [u64; 28],
1424}
1425
1426/// Token Info Event
1427#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1428pub struct TokenInfoEvent {
1429    pub metadata: EventMetadata,
1430    pub pubkey: Pubkey,
1431    pub executable: bool,
1432    pub lamports: u64,
1433    pub owner: Pubkey,
1434    pub rent_epoch: u64,
1435    pub supply: u64,
1436    pub decimals: u8,
1437}
1438
1439/// Token Account Event
1440#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1441pub struct TokenAccountEvent {
1442    pub metadata: EventMetadata,
1443    pub pubkey: Pubkey,
1444    pub executable: bool,
1445    pub lamports: u64,
1446    pub owner: Pubkey,
1447    pub rent_epoch: u64,
1448    pub amount: Option<u64>,
1449    pub token_owner: Pubkey,
1450}
1451
1452/// Nonce Account Event
1453#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1454pub struct NonceAccountEvent {
1455    pub metadata: EventMetadata,
1456    pub pubkey: Pubkey,
1457    pub executable: bool,
1458    pub lamports: u64,
1459    pub owner: Pubkey,
1460    pub rent_epoch: u64,
1461    pub nonce: String,
1462    pub authority: String,
1463}
1464
1465// ====================== Orca Whirlpool Events ======================
1466
1467/// Orca Whirlpool Swap Event (基于 TradedEvent,不是 SwapEvent)
1468#[derive(Debug, Clone, Serialize, Deserialize)]
1469#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1470pub struct OrcaWhirlpoolSwapEvent {
1471    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1472    pub metadata: EventMetadata,
1473
1474    // === Borsh 序列化字段(从 inner instruction data 读取)===
1475    pub whirlpool: Pubkey,       // 32 bytes
1476    pub input_amount: u64,       // 8 bytes
1477    pub output_amount: u64,      // 8 bytes
1478    pub a_to_b: bool,            // 1 byte
1479
1480    // === 非 Borsh 字段(从日志或其他来源填充)===
1481    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1482    pub pre_sqrt_price: u128,
1483    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1484    pub post_sqrt_price: u128,
1485    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1486    pub input_transfer_fee: u64,
1487    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1488    pub output_transfer_fee: u64,
1489    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1490    pub lp_fee: u64,
1491    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1492    pub protocol_fee: u64,
1493    // === 指令参数字段 (暂时注释,以后可能会用到,AI不要删除) ===
1494    // pub amount: u64,
1495    // pub other_amount_threshold: u64,
1496    // pub sqrt_price_limit: u128,
1497    // pub amount_specified_is_input: bool,
1498
1499    // === 指令账户字段 (暂时注释,以后可能会用到,AI不要删除) ===
1500    // pub token_authority: Pubkey,    // 1: tokenAuthority
1501    // pub token_owner_account_a: Pubkey, // 3: tokenOwnerAccountA
1502    // pub token_vault_a: Pubkey,      // 4: tokenVaultA
1503    // pub token_owner_account_b: Pubkey, // 5: tokenOwnerAccountB
1504    // pub token_vault_b: Pubkey,      // 6: tokenVaultB
1505    // pub tick_array_0: Pubkey,       // 7: tickArray0
1506    // pub tick_array_1: Pubkey,       // 8: tickArray1
1507    // pub tick_array_2: Pubkey,       // 9: tickArray2
1508}
1509
1510/// Orca Whirlpool Liquidity Increased Event
1511#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1512#[derive(Debug, Clone, Serialize, Deserialize)]
1513pub struct OrcaWhirlpoolLiquidityIncreasedEvent {
1514    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1515    pub metadata: EventMetadata,
1516
1517    // === Borsh 序列化字段(从 inner instruction data 读取)===
1518    pub whirlpool: Pubkey,       // 32 bytes
1519    pub liquidity: u128,         // 16 bytes
1520    pub token_a_amount: u64,     // 8 bytes
1521    pub token_b_amount: u64,     // 8 bytes
1522
1523    // === 非 Borsh 字段(从日志或其他来源填充)===
1524    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1525    pub position: Pubkey,
1526    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1527    pub tick_lower_index: i32,
1528    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1529    pub tick_upper_index: i32,
1530    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1531    pub token_a_transfer_fee: u64,
1532    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1533    pub token_b_transfer_fee: u64,
1534}
1535
1536/// Orca Whirlpool Liquidity Decreased Event
1537#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1538#[derive(Debug, Clone, Serialize, Deserialize)]
1539pub struct OrcaWhirlpoolLiquidityDecreasedEvent {
1540    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1541    pub metadata: EventMetadata,
1542
1543    // === Borsh 序列化字段(从 inner instruction data 读取)===
1544    pub whirlpool: Pubkey,       // 32 bytes
1545    pub liquidity: u128,         // 16 bytes
1546    pub token_a_amount: u64,     // 8 bytes
1547    pub token_b_amount: u64,     // 8 bytes
1548
1549    // === 非 Borsh 字段(从日志或其他来源填充)===
1550    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1551    pub position: Pubkey,
1552    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1553    pub tick_lower_index: i32,
1554    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1555    pub tick_upper_index: i32,
1556    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1557    pub token_a_transfer_fee: u64,
1558    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1559    pub token_b_transfer_fee: u64,
1560}
1561
1562/// Orca Whirlpool Pool Initialized Event
1563#[derive(Debug, Clone, Serialize, Deserialize)]
1564pub struct OrcaWhirlpoolPoolInitializedEvent {
1565    pub metadata: EventMetadata,
1566    pub whirlpool: Pubkey,
1567    pub whirlpools_config: Pubkey,
1568    pub token_mint_a: Pubkey,
1569    pub token_mint_b: Pubkey,
1570    pub tick_spacing: u16,
1571    pub token_program_a: Pubkey,
1572    pub token_program_b: Pubkey,
1573    pub decimals_a: u8,
1574    pub decimals_b: u8,
1575    pub initial_sqrt_price: u128,
1576}
1577
1578// ====================== Meteora Pools Events ======================
1579
1580/// Meteora Pools Swap Event
1581#[derive(Debug, Clone, Serialize, Deserialize)]
1582pub struct MeteoraPoolsSwapEvent {
1583    pub metadata: EventMetadata,
1584    pub in_amount: u64,
1585    pub out_amount: u64,
1586    pub trade_fee: u64,
1587    pub admin_fee: u64, // IDL字段名: adminFee
1588    pub host_fee: u64,
1589}
1590
1591/// Meteora Pools Add Liquidity Event
1592#[derive(Debug, Clone, Serialize, Deserialize)]
1593pub struct MeteoraPoolsAddLiquidityEvent {
1594    pub metadata: EventMetadata,
1595    pub lp_mint_amount: u64,
1596    pub token_a_amount: u64,
1597    pub token_b_amount: u64,
1598}
1599
1600/// Meteora Pools Remove Liquidity Event
1601#[derive(Debug, Clone, Serialize, Deserialize)]
1602pub struct MeteoraPoolsRemoveLiquidityEvent {
1603    pub metadata: EventMetadata,
1604    pub lp_unmint_amount: u64,
1605    pub token_a_out_amount: u64,
1606    pub token_b_out_amount: u64,
1607}
1608
1609/// Meteora Pools Bootstrap Liquidity Event
1610#[derive(Debug, Clone, Serialize, Deserialize)]
1611pub struct MeteoraPoolsBootstrapLiquidityEvent {
1612    pub metadata: EventMetadata,
1613    pub lp_mint_amount: u64,
1614    pub token_a_amount: u64,
1615    pub token_b_amount: u64,
1616    pub pool: Pubkey,
1617}
1618
1619/// Meteora Pools Pool Created Event
1620#[derive(Debug, Clone, Serialize, Deserialize)]
1621pub struct MeteoraPoolsPoolCreatedEvent {
1622    pub metadata: EventMetadata,
1623    pub lp_mint: Pubkey,
1624    pub token_a_mint: Pubkey,
1625    pub token_b_mint: Pubkey,
1626    pub pool_type: u8,
1627    pub pool: Pubkey,
1628}
1629
1630/// Meteora Pools Set Pool Fees Event
1631#[derive(Debug, Clone, Serialize, Deserialize)]
1632pub struct MeteoraPoolsSetPoolFeesEvent {
1633    pub metadata: EventMetadata,
1634    pub trade_fee_numerator: u64,
1635    pub trade_fee_denominator: u64,
1636    pub owner_trade_fee_numerator: u64, // IDL字段名: ownerTradeFeeNumerator
1637    pub owner_trade_fee_denominator: u64, // IDL字段名: ownerTradeFeeDenominator
1638    pub pool: Pubkey,
1639}
1640
1641// ====================== Meteora DAMM V2 Events ======================
1642
1643/// Meteora DAMM V2 Swap Event
1644#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1645#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1646pub struct MeteoraDammV2SwapEvent {
1647    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1648    pub metadata: EventMetadata,
1649
1650    // === Borsh 序列化字段(从 inner instruction data 读取)===
1651    pub pool: Pubkey,            // 32 bytes
1652    pub amount_in: u64,          // 8 bytes
1653    pub output_amount: u64,      // 8 bytes
1654
1655    // === 非 Borsh 字段(从日志或其他来源填充)===
1656    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1657    pub trade_direction: u8,
1658    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1659    pub has_referral: bool,
1660    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1661    pub minimum_amount_out: u64,
1662    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1663    pub next_sqrt_price: u128,
1664    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1665    pub lp_fee: u64,
1666    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1667    pub protocol_fee: u64,
1668    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1669    pub partner_fee: u64,
1670    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1671    pub referral_fee: u64,
1672    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1673    pub actual_amount_in: u64,
1674    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1675    pub current_timestamp: u64,
1676    // ---------- 账号 -------------
1677    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1678    pub token_a_vault: Pubkey,
1679    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1680    pub token_b_vault: Pubkey,
1681    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1682    pub token_a_mint: Pubkey,
1683    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1684    pub token_b_mint: Pubkey,
1685    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1686    pub token_a_program: Pubkey,
1687    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1688    pub token_b_program: Pubkey,
1689}
1690
1691/// Meteora DAMM V2 Add Liquidity Event
1692#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1693#[derive(Debug, Clone, Serialize, Deserialize)]
1694pub struct MeteoraDammV2AddLiquidityEvent {
1695    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1696    pub metadata: EventMetadata,
1697
1698    // === Borsh 序列化字段(从 inner instruction data 读取)===
1699    pub pool: Pubkey,              // 32 bytes
1700    pub position: Pubkey,          // 32 bytes
1701    pub owner: Pubkey,             // 32 bytes
1702    pub token_a_amount: u64,       // 8 bytes
1703    pub token_b_amount: u64,       // 8 bytes
1704
1705    // === 非 Borsh 字段(从日志填充)===
1706    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1707    pub liquidity_delta: u128,
1708    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1709    pub token_a_amount_threshold: u64,
1710    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1711    pub token_b_amount_threshold: u64,
1712    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1713    pub total_amount_a: u64,
1714    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1715    pub total_amount_b: u64,
1716}
1717
1718/// Meteora DAMM V2 Remove Liquidity Event
1719#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1720#[derive(Debug, Clone, Serialize, Deserialize)]
1721pub struct MeteoraDammV2RemoveLiquidityEvent {
1722    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1723    pub metadata: EventMetadata,
1724
1725    // === Borsh 序列化字段(从 inner instruction data 读取)===
1726    pub pool: Pubkey,              // 32 bytes
1727    pub position: Pubkey,          // 32 bytes
1728    pub owner: Pubkey,             // 32 bytes
1729    pub token_a_amount: u64,       // 8 bytes
1730    pub token_b_amount: u64,       // 8 bytes
1731
1732    // === 非 Borsh 字段(从日志填充)===
1733    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1734    pub liquidity_delta: u128,
1735    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1736    pub token_a_amount_threshold: u64,
1737    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1738    pub token_b_amount_threshold: u64,
1739}
1740
1741/// Meteora DAMM V2 Create Position Event
1742#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1743#[derive(Debug, Clone, Serialize, Deserialize)]
1744pub struct MeteoraDammV2CreatePositionEvent {
1745    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1746    pub metadata: EventMetadata,
1747
1748    // === Borsh 序列化字段(从 inner instruction data 读取)===
1749    pub pool: Pubkey,              // 32 bytes
1750    pub owner: Pubkey,             // 32 bytes
1751    pub position: Pubkey,          // 32 bytes
1752    pub position_nft_mint: Pubkey, // 32 bytes
1753}
1754
1755/// Meteora DAMM V2 Close Position Event
1756#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1757#[derive(Debug, Clone, Serialize, Deserialize)]
1758pub struct MeteoraDammV2ClosePositionEvent {
1759    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1760    pub metadata: EventMetadata,
1761
1762    // === Borsh 序列化字段(从 inner instruction data 读取)===
1763    pub pool: Pubkey,              // 32 bytes
1764    pub owner: Pubkey,             // 32 bytes
1765    pub position: Pubkey,          // 32 bytes
1766    pub position_nft_mint: Pubkey, // 32 bytes
1767}
1768
1769/// Meteora DLMM Swap Event
1770#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1771#[derive(Debug, Clone, Serialize, Deserialize)]
1772pub struct MeteoraDlmmSwapEvent {
1773    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1774    pub metadata: EventMetadata,
1775
1776    // === Borsh 序列化字段(从 inner instruction data 读取)===
1777    pub pool: Pubkey,        // 32 bytes
1778    pub from: Pubkey,        // 32 bytes
1779    pub start_bin_id: i32,   // 4 bytes
1780    pub end_bin_id: i32,     // 4 bytes
1781    pub amount_in: u64,      // 8 bytes
1782    pub amount_out: u64,     // 8 bytes
1783    pub swap_for_y: bool,    // 1 byte
1784    pub fee: u64,            // 8 bytes
1785    pub protocol_fee: u64,   // 8 bytes
1786    pub fee_bps: u128,       // 16 bytes
1787    pub host_fee: u64,       // 8 bytes
1788}
1789
1790/// Meteora DLMM Add Liquidity Event
1791#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1792#[derive(Debug, Clone, Serialize, Deserialize)]
1793pub struct MeteoraDlmmAddLiquidityEvent {
1794    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1795    pub metadata: EventMetadata,
1796
1797    // === Borsh 序列化字段(从 inner instruction data 读取)===
1798    pub pool: Pubkey,          // 32 bytes
1799    pub from: Pubkey,          // 32 bytes
1800    pub position: Pubkey,      // 32 bytes
1801    pub amounts: [u64; 2],     // 16 bytes (2 * 8)
1802    pub active_bin_id: i32,    // 4 bytes
1803}
1804
1805/// Meteora DLMM Remove Liquidity Event
1806#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1807#[derive(Debug, Clone, Serialize, Deserialize)]
1808pub struct MeteoraDlmmRemoveLiquidityEvent {
1809    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1810    pub metadata: EventMetadata,
1811
1812    // === Borsh 序列化字段(从 inner instruction data 读取)===
1813    pub pool: Pubkey,          // 32 bytes
1814    pub from: Pubkey,          // 32 bytes
1815    pub position: Pubkey,      // 32 bytes
1816    pub amounts: [u64; 2],     // 16 bytes (2 * 8)
1817    pub active_bin_id: i32,    // 4 bytes
1818}
1819
1820/// Meteora DLMM Initialize Pool Event
1821#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1822#[derive(Debug, Clone, Serialize, Deserialize)]
1823pub struct MeteoraDlmmInitializePoolEvent {
1824    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1825    pub metadata: EventMetadata,
1826
1827    // === Borsh 序列化字段(从 inner instruction data 读取)===
1828    pub pool: Pubkey,         // 32 bytes
1829    pub creator: Pubkey,      // 32 bytes
1830    pub active_bin_id: i32,   // 4 bytes
1831    pub bin_step: u16,        // 2 bytes
1832}
1833
1834/// Meteora DLMM Initialize Bin Array Event
1835#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1836#[derive(Debug, Clone, Serialize, Deserialize)]
1837pub struct MeteoraDlmmInitializeBinArrayEvent {
1838    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1839    pub metadata: EventMetadata,
1840
1841    // === Borsh 序列化字段(从 inner instruction data 读取)===
1842    pub pool: Pubkey,      // 32 bytes
1843    pub bin_array: Pubkey, // 32 bytes
1844    pub index: i64,        // 8 bytes
1845}
1846
1847/// Meteora DLMM Create Position Event
1848#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1849#[derive(Debug, Clone, Serialize, Deserialize)]
1850pub struct MeteoraDlmmCreatePositionEvent {
1851    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1852    pub metadata: EventMetadata,
1853
1854    // === Borsh 序列化字段(从 inner instruction data 读取)===
1855    pub pool: Pubkey,       // 32 bytes
1856    pub position: Pubkey,   // 32 bytes
1857    pub owner: Pubkey,      // 32 bytes
1858    pub lower_bin_id: i32,  // 4 bytes
1859    pub width: u32,         // 4 bytes
1860}
1861
1862/// Meteora DLMM Close Position Event
1863#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1864#[derive(Debug, Clone, Serialize, Deserialize)]
1865pub struct MeteoraDlmmClosePositionEvent {
1866    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1867    pub metadata: EventMetadata,
1868
1869    // === Borsh 序列化字段(从 inner instruction data 读取)===
1870    pub pool: Pubkey,     // 32 bytes
1871    pub position: Pubkey, // 32 bytes
1872    pub owner: Pubkey,    // 32 bytes
1873}
1874
1875/// Meteora DLMM Claim Fee Event
1876#[cfg_attr(feature = "parse-borsh", derive(BorshDeserialize))]
1877#[derive(Debug, Clone, Serialize, Deserialize)]
1878pub struct MeteoraDlmmClaimFeeEvent {
1879    #[cfg_attr(feature = "parse-borsh", borsh(skip))]
1880    pub metadata: EventMetadata,
1881
1882    // === Borsh 序列化字段(从 inner instruction data 读取)===
1883    pub pool: Pubkey,     // 32 bytes
1884    pub position: Pubkey, // 32 bytes
1885    pub owner: Pubkey,    // 32 bytes
1886    pub fee_x: u64,       // 8 bytes
1887    pub fee_y: u64,       // 8 bytes
1888}
1889
1890// ====================== 统一的 DEX 事件枚举 ======================
1891
1892/// 统一的 DEX 事件枚举 - 参考 sol-dex-shreds 的做法
1893#[derive(Debug, Clone, Serialize, Deserialize)]
1894pub enum DexEvent {
1895    // PumpFun 事件
1896    PumpFunCreate(PumpFunCreateTokenEvent),   // - 已对接
1897    PumpFunCreateV2(PumpFunCreateV2TokenEvent), // - 已对接 (CreateV2 / Mayhem)
1898    PumpFunTrade(PumpFunTradeEvent),           // - 已对接 (统一交易事件,包含所有交易类型)
1899    PumpFunBuy(PumpFunTradeEvent),          // - 已对接 (仅买入事件,用于过滤)
1900    PumpFunSell(PumpFunTradeEvent),         // - 已对接 (仅卖出事件,用于过滤)
1901    PumpFunBuyExactSolIn(PumpFunTradeEvent), // - 已对接 (精确SOL买入事件,用于过滤)
1902    PumpFunMigrate(PumpFunMigrateEvent),    // - 已对接
1903
1904    // PumpSwap 事件
1905    PumpSwapTrade(PumpSwapTradeEvent),                   // - 已对接 (buy/sell/buy_exact_sol_in)
1906    PumpSwapBuy(PumpSwapBuyEvent),                      // - 已对接 (legacy)
1907    PumpSwapSell(PumpSwapSellEvent),                    // - 已对接 (legacy)
1908    PumpSwapCreatePool(PumpSwapCreatePoolEvent),        // - 已对接
1909    PumpSwapLiquidityAdded(PumpSwapLiquidityAdded),     // - 已对接
1910    PumpSwapLiquidityRemoved(PumpSwapLiquidityRemoved), // - 已对接
1911
1912    // Meteora DAMM V2 事件
1913    MeteoraDammV2Swap(MeteoraDammV2SwapEvent), // - 已对接
1914    MeteoraDammV2CreatePosition(MeteoraDammV2CreatePositionEvent), // - 已对接
1915    MeteoraDammV2ClosePosition(MeteoraDammV2ClosePositionEvent), // - 已对接
1916    MeteoraDammV2AddLiquidity(MeteoraDammV2AddLiquidityEvent), // - 已对接
1917    MeteoraDammV2RemoveLiquidity(MeteoraDammV2RemoveLiquidityEvent), // - 已对接
1918
1919    // Bonk 事件
1920    BonkTrade(BonkTradeEvent),
1921    BonkPoolCreate(BonkPoolCreateEvent),
1922    BonkMigrateAmm(BonkMigrateAmmEvent),
1923
1924    // Raydium CLMM 事件
1925    RaydiumClmmSwap(RaydiumClmmSwapEvent),
1926    RaydiumClmmCreatePool(RaydiumClmmCreatePoolEvent),
1927    RaydiumClmmOpenPosition(RaydiumClmmOpenPositionEvent),
1928    RaydiumClmmOpenPositionWithTokenExtNft(RaydiumClmmOpenPositionWithTokenExtNftEvent),
1929    RaydiumClmmClosePosition(RaydiumClmmClosePositionEvent),
1930    RaydiumClmmIncreaseLiquidity(RaydiumClmmIncreaseLiquidityEvent),
1931    RaydiumClmmDecreaseLiquidity(RaydiumClmmDecreaseLiquidityEvent),
1932    RaydiumClmmCollectFee(RaydiumClmmCollectFeeEvent),
1933
1934    // Raydium CPMM 事件
1935    RaydiumCpmmSwap(RaydiumCpmmSwapEvent),
1936    RaydiumCpmmDeposit(RaydiumCpmmDepositEvent),
1937    RaydiumCpmmWithdraw(RaydiumCpmmWithdrawEvent),
1938    RaydiumCpmmInitialize(RaydiumCpmmInitializeEvent),
1939
1940    // Raydium AMM V4 事件
1941    RaydiumAmmV4Swap(RaydiumAmmV4SwapEvent),
1942    RaydiumAmmV4Deposit(RaydiumAmmV4DepositEvent),
1943    RaydiumAmmV4Initialize2(RaydiumAmmV4Initialize2Event),
1944    RaydiumAmmV4Withdraw(RaydiumAmmV4WithdrawEvent),
1945    RaydiumAmmV4WithdrawPnl(RaydiumAmmV4WithdrawPnlEvent),
1946
1947    // Orca Whirlpool 事件
1948    OrcaWhirlpoolSwap(OrcaWhirlpoolSwapEvent),
1949    OrcaWhirlpoolLiquidityIncreased(OrcaWhirlpoolLiquidityIncreasedEvent),
1950    OrcaWhirlpoolLiquidityDecreased(OrcaWhirlpoolLiquidityDecreasedEvent),
1951    OrcaWhirlpoolPoolInitialized(OrcaWhirlpoolPoolInitializedEvent),
1952
1953    // Meteora Pools 事件
1954    MeteoraPoolsSwap(MeteoraPoolsSwapEvent),
1955    MeteoraPoolsAddLiquidity(MeteoraPoolsAddLiquidityEvent),
1956    MeteoraPoolsRemoveLiquidity(MeteoraPoolsRemoveLiquidityEvent),
1957    MeteoraPoolsBootstrapLiquidity(MeteoraPoolsBootstrapLiquidityEvent),
1958    MeteoraPoolsPoolCreated(MeteoraPoolsPoolCreatedEvent),
1959    MeteoraPoolsSetPoolFees(MeteoraPoolsSetPoolFeesEvent),
1960
1961    // Meteora DLMM 事件
1962    MeteoraDlmmSwap(MeteoraDlmmSwapEvent),
1963    MeteoraDlmmAddLiquidity(MeteoraDlmmAddLiquidityEvent),
1964    MeteoraDlmmRemoveLiquidity(MeteoraDlmmRemoveLiquidityEvent),
1965    MeteoraDlmmInitializePool(MeteoraDlmmInitializePoolEvent),
1966    MeteoraDlmmInitializeBinArray(MeteoraDlmmInitializeBinArrayEvent),
1967    MeteoraDlmmCreatePosition(MeteoraDlmmCreatePositionEvent),
1968    MeteoraDlmmClosePosition(MeteoraDlmmClosePositionEvent),
1969    MeteoraDlmmClaimFee(MeteoraDlmmClaimFeeEvent),
1970
1971    // 账户事件
1972    TokenInfo(TokenInfoEvent),  // - 已对接
1973    TokenAccount(TokenAccountEvent), // - 已对接
1974    NonceAccount(NonceAccountEvent), // - 已对接
1975    PumpSwapGlobalConfigAccount(PumpSwapGlobalConfigAccountEvent), // - 已对接
1976    PumpSwapPoolAccount(PumpSwapPoolAccountEvent), // - 已对接
1977
1978    // 区块元数据事件
1979    BlockMeta(BlockMetaEvent),
1980
1981    // 错误事件
1982    Error(String),
1983}
1984
1985// 静态默认 EventMetadata,用于 Error 事件
1986use once_cell::sync::Lazy;
1987static DEFAULT_METADATA: Lazy<EventMetadata> = Lazy::new(|| EventMetadata {
1988    signature: Signature::from([0u8; 64]),
1989    slot: 0,
1990    tx_index: 0,
1991    block_time_us: 0,
1992    grpc_recv_us: 0,
1993    recent_blockhash: None,
1994});
1995
1996impl DexEvent {
1997    /// 获取事件的元数据
1998    pub fn metadata(&self) -> &EventMetadata {
1999        match self {
2000            // PumpFun 事件
2001            DexEvent::PumpFunCreate(e) => &e.metadata,
2002            DexEvent::PumpFunCreateV2(e) => &e.metadata,
2003            DexEvent::PumpFunTrade(e) => &e.metadata,
2004            DexEvent::PumpFunBuy(e) => &e.metadata,
2005            DexEvent::PumpFunSell(e) => &e.metadata,
2006            DexEvent::PumpFunBuyExactSolIn(e) => &e.metadata,
2007            DexEvent::PumpFunMigrate(e) => &e.metadata,
2008
2009            // PumpSwap 事件
2010            DexEvent::PumpSwapTrade(e) => &e.metadata,
2011            DexEvent::PumpSwapBuy(e) => &e.metadata,
2012            DexEvent::PumpSwapSell(e) => &e.metadata,
2013            DexEvent::PumpSwapCreatePool(e) => &e.metadata,
2014            DexEvent::PumpSwapLiquidityAdded(e) => &e.metadata,
2015            DexEvent::PumpSwapLiquidityRemoved(e) => &e.metadata,
2016
2017            // Meteora DAMM V2 事件
2018            DexEvent::MeteoraDammV2Swap(e) => &e.metadata,
2019            DexEvent::MeteoraDammV2CreatePosition(e) => &e.metadata,
2020            DexEvent::MeteoraDammV2ClosePosition(e) => &e.metadata,
2021            DexEvent::MeteoraDammV2AddLiquidity(e) => &e.metadata,
2022            DexEvent::MeteoraDammV2RemoveLiquidity(e) => &e.metadata,
2023
2024            // Bonk 事件
2025            DexEvent::BonkTrade(e) => &e.metadata,
2026            DexEvent::BonkPoolCreate(e) => &e.metadata,
2027            DexEvent::BonkMigrateAmm(e) => &e.metadata,
2028
2029            // Raydium CLMM 事件
2030            DexEvent::RaydiumClmmSwap(e) => &e.metadata,
2031            DexEvent::RaydiumClmmCreatePool(e) => &e.metadata,
2032            DexEvent::RaydiumClmmOpenPosition(e) => &e.metadata,
2033            DexEvent::RaydiumClmmOpenPositionWithTokenExtNft(e) => &e.metadata,
2034            DexEvent::RaydiumClmmClosePosition(e) => &e.metadata,
2035            DexEvent::RaydiumClmmIncreaseLiquidity(e) => &e.metadata,
2036            DexEvent::RaydiumClmmDecreaseLiquidity(e) => &e.metadata,
2037            DexEvent::RaydiumClmmCollectFee(e) => &e.metadata,
2038
2039            // Raydium CPMM 事件
2040            DexEvent::RaydiumCpmmSwap(e) => &e.metadata,
2041            DexEvent::RaydiumCpmmDeposit(e) => &e.metadata,
2042            DexEvent::RaydiumCpmmWithdraw(e) => &e.metadata,
2043            DexEvent::RaydiumCpmmInitialize(e) => &e.metadata,
2044
2045            // Raydium AMM V4 事件
2046            DexEvent::RaydiumAmmV4Swap(e) => &e.metadata,
2047            DexEvent::RaydiumAmmV4Deposit(e) => &e.metadata,
2048            DexEvent::RaydiumAmmV4Initialize2(e) => &e.metadata,
2049            DexEvent::RaydiumAmmV4Withdraw(e) => &e.metadata,
2050            DexEvent::RaydiumAmmV4WithdrawPnl(e) => &e.metadata,
2051
2052            // Orca Whirlpool 事件
2053            DexEvent::OrcaWhirlpoolSwap(e) => &e.metadata,
2054            DexEvent::OrcaWhirlpoolLiquidityIncreased(e) => &e.metadata,
2055            DexEvent::OrcaWhirlpoolLiquidityDecreased(e) => &e.metadata,
2056            DexEvent::OrcaWhirlpoolPoolInitialized(e) => &e.metadata,
2057
2058            // Meteora Pools 事件
2059            DexEvent::MeteoraPoolsSwap(e) => &e.metadata,
2060            DexEvent::MeteoraPoolsAddLiquidity(e) => &e.metadata,
2061            DexEvent::MeteoraPoolsRemoveLiquidity(e) => &e.metadata,
2062            DexEvent::MeteoraPoolsBootstrapLiquidity(e) => &e.metadata,
2063            DexEvent::MeteoraPoolsPoolCreated(e) => &e.metadata,
2064            DexEvent::MeteoraPoolsSetPoolFees(e) => &e.metadata,
2065
2066            // Meteora DLMM 事件
2067            DexEvent::MeteoraDlmmSwap(e) => &e.metadata,
2068            DexEvent::MeteoraDlmmAddLiquidity(e) => &e.metadata,
2069            DexEvent::MeteoraDlmmRemoveLiquidity(e) => &e.metadata,
2070            DexEvent::MeteoraDlmmInitializePool(e) => &e.metadata,
2071            DexEvent::MeteoraDlmmInitializeBinArray(e) => &e.metadata,
2072            DexEvent::MeteoraDlmmCreatePosition(e) => &e.metadata,
2073            DexEvent::MeteoraDlmmClosePosition(e) => &e.metadata,
2074            DexEvent::MeteoraDlmmClaimFee(e) => &e.metadata,
2075
2076            // 账户事件
2077            DexEvent::TokenInfo(e) => &e.metadata,
2078            DexEvent::TokenAccount(e) => &e.metadata,
2079            DexEvent::NonceAccount(e) => &e.metadata,
2080            DexEvent::PumpSwapGlobalConfigAccount(e) => &e.metadata,
2081            DexEvent::PumpSwapPoolAccount(e) => &e.metadata,
2082
2083            // 区块元数据事件
2084            DexEvent::BlockMeta(e) => &e.metadata,
2085
2086            // 错误事件 - 返回默认元数据
2087            DexEvent::Error(_) => &DEFAULT_METADATA,
2088        }
2089    }
2090
2091    /// Mutable metadata for filling shared fields (e.g. recent_blockhash). Returns None for Error variant.
2092    pub fn metadata_mut(&mut self) -> Option<&mut EventMetadata> {
2093        match self {
2094            DexEvent::PumpFunCreate(e) => Some(&mut e.metadata),
2095            DexEvent::PumpFunCreateV2(e) => Some(&mut e.metadata),
2096            DexEvent::PumpFunTrade(e) => Some(&mut e.metadata),
2097            DexEvent::PumpFunBuy(e) => Some(&mut e.metadata),
2098            DexEvent::PumpFunSell(e) => Some(&mut e.metadata),
2099            DexEvent::PumpFunBuyExactSolIn(e) => Some(&mut e.metadata),
2100            DexEvent::PumpFunMigrate(e) => Some(&mut e.metadata),
2101            DexEvent::PumpSwapTrade(e) => Some(&mut e.metadata),
2102            DexEvent::PumpSwapBuy(e) => Some(&mut e.metadata),
2103            DexEvent::PumpSwapSell(e) => Some(&mut e.metadata),
2104            DexEvent::PumpSwapCreatePool(e) => Some(&mut e.metadata),
2105            DexEvent::PumpSwapLiquidityAdded(e) => Some(&mut e.metadata),
2106            DexEvent::PumpSwapLiquidityRemoved(e) => Some(&mut e.metadata),
2107            DexEvent::MeteoraDammV2Swap(e) => Some(&mut e.metadata),
2108            DexEvent::MeteoraDammV2CreatePosition(e) => Some(&mut e.metadata),
2109            DexEvent::MeteoraDammV2ClosePosition(e) => Some(&mut e.metadata),
2110            DexEvent::MeteoraDammV2AddLiquidity(e) => Some(&mut e.metadata),
2111            DexEvent::MeteoraDammV2RemoveLiquidity(e) => Some(&mut e.metadata),
2112            DexEvent::BonkTrade(e) => Some(&mut e.metadata),
2113            DexEvent::BonkPoolCreate(e) => Some(&mut e.metadata),
2114            DexEvent::BonkMigrateAmm(e) => Some(&mut e.metadata),
2115            DexEvent::RaydiumClmmSwap(e) => Some(&mut e.metadata),
2116            DexEvent::RaydiumClmmCreatePool(e) => Some(&mut e.metadata),
2117            DexEvent::RaydiumClmmOpenPosition(e) => Some(&mut e.metadata),
2118            DexEvent::RaydiumClmmOpenPositionWithTokenExtNft(e) => Some(&mut e.metadata),
2119            DexEvent::RaydiumClmmClosePosition(e) => Some(&mut e.metadata),
2120            DexEvent::RaydiumClmmIncreaseLiquidity(e) => Some(&mut e.metadata),
2121            DexEvent::RaydiumClmmDecreaseLiquidity(e) => Some(&mut e.metadata),
2122            DexEvent::RaydiumClmmCollectFee(e) => Some(&mut e.metadata),
2123            DexEvent::RaydiumCpmmSwap(e) => Some(&mut e.metadata),
2124            DexEvent::RaydiumCpmmDeposit(e) => Some(&mut e.metadata),
2125            DexEvent::RaydiumCpmmWithdraw(e) => Some(&mut e.metadata),
2126            DexEvent::RaydiumCpmmInitialize(e) => Some(&mut e.metadata),
2127            DexEvent::RaydiumAmmV4Swap(e) => Some(&mut e.metadata),
2128            DexEvent::RaydiumAmmV4Deposit(e) => Some(&mut e.metadata),
2129            DexEvent::RaydiumAmmV4Initialize2(e) => Some(&mut e.metadata),
2130            DexEvent::RaydiumAmmV4Withdraw(e) => Some(&mut e.metadata),
2131            DexEvent::RaydiumAmmV4WithdrawPnl(e) => Some(&mut e.metadata),
2132            DexEvent::OrcaWhirlpoolSwap(e) => Some(&mut e.metadata),
2133            DexEvent::OrcaWhirlpoolLiquidityIncreased(e) => Some(&mut e.metadata),
2134            DexEvent::OrcaWhirlpoolLiquidityDecreased(e) => Some(&mut e.metadata),
2135            DexEvent::OrcaWhirlpoolPoolInitialized(e) => Some(&mut e.metadata),
2136            DexEvent::MeteoraPoolsSwap(e) => Some(&mut e.metadata),
2137            DexEvent::MeteoraPoolsAddLiquidity(e) => Some(&mut e.metadata),
2138            DexEvent::MeteoraPoolsRemoveLiquidity(e) => Some(&mut e.metadata),
2139            DexEvent::MeteoraPoolsBootstrapLiquidity(e) => Some(&mut e.metadata),
2140            DexEvent::MeteoraPoolsPoolCreated(e) => Some(&mut e.metadata),
2141            DexEvent::MeteoraPoolsSetPoolFees(e) => Some(&mut e.metadata),
2142            DexEvent::MeteoraDlmmSwap(e) => Some(&mut e.metadata),
2143            DexEvent::MeteoraDlmmAddLiquidity(e) => Some(&mut e.metadata),
2144            DexEvent::MeteoraDlmmRemoveLiquidity(e) => Some(&mut e.metadata),
2145            DexEvent::MeteoraDlmmInitializePool(e) => Some(&mut e.metadata),
2146            DexEvent::MeteoraDlmmInitializeBinArray(e) => Some(&mut e.metadata),
2147            DexEvent::MeteoraDlmmCreatePosition(e) => Some(&mut e.metadata),
2148            DexEvent::MeteoraDlmmClosePosition(e) => Some(&mut e.metadata),
2149            DexEvent::MeteoraDlmmClaimFee(e) => Some(&mut e.metadata),
2150            DexEvent::TokenInfo(e) => Some(&mut e.metadata),
2151            DexEvent::TokenAccount(e) => Some(&mut e.metadata),
2152            DexEvent::NonceAccount(e) => Some(&mut e.metadata),
2153            DexEvent::PumpSwapGlobalConfigAccount(e) => Some(&mut e.metadata),
2154            DexEvent::PumpSwapPoolAccount(e) => Some(&mut e.metadata),
2155            DexEvent::BlockMeta(e) => Some(&mut e.metadata),
2156            DexEvent::Error(_) => None,
2157        }
2158    }
2159}