Skip to main content

sol_parser_sdk/core/
events.rs

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