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