sol-parser-sdk 0.7.9

A lightweight Rust library for real-time event streaming from Solana DEX trading programs. Supports PumpFun, PumpSwap, LaunchLab, and Raydium protocols with Yellowstone gRPC and ShredStream.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
//! Meteora 账户填充模块(包含 DAMM V2, Pools, DLMM)

use crate::core::events::*;
use solana_sdk::pubkey::Pubkey;

pub type AccountGetter<'a> = dyn Fn(usize) -> Pubkey + 'a;

// ============================================================================
// Meteora DAMM V2
// ============================================================================

/// Meteora DAMM V2 Swap 账户填充
///
/// swap/swap2 instruction account mapping (based on IDL):
/// 0: pool_authority
/// 1: pool
/// 2: input_token_account
/// 3: output_token_account
/// 4: token_a_vault
/// 5: token_b_vault
/// 6: token_a_mint
/// 7: token_b_mint
/// 8: payer
/// 9: token_a_program
/// 10: token_b_program
/// 11: optional referral_token_account (or program-id placeholder)
/// 12: event_authority (11 when optional account is omitted)
/// 13: program (12 when optional account is omitted)
pub fn fill_damm_v2_swap_accounts(
    e: &mut MeteoraDammV2SwapEvent,
    get: &AccountGetter<'_>,
    account_count: usize,
) {
    if !(13..=14).contains(&account_count) {
        return;
    }
    e.pool_authority = get(0);
    e.input_token_account = get(2);
    e.output_token_account = get(3);
    e.token_a_vault = get(4);
    e.token_b_vault = get(5);
    e.token_a_mint = get(6);
    e.token_b_mint = get(7);
    e.payer = get(8);
    e.token_a_program = get(9);
    e.token_b_program = get(10);
    let authority_index = account_count - 2;
    e.event_authority = get(authority_index);
    e.program = get(account_count - 1);
    e.referral_token_account = (account_count == 14 && get(11) != e.program).then(|| get(11));
}

#[cfg(test)]
mod damm_swap_tests {
    use super::*;

    #[test]
    fn optional_referral_is_not_the_program_placeholder() {
        let accounts: Vec<_> = (0..14).map(|_| Pubkey::new_unique()).collect();
        let mut event = MeteoraDammV2SwapEvent::default();
        fill_damm_v2_swap_accounts(
            &mut event,
            &|i| accounts.get(i).copied().unwrap_or_default(),
            14,
        );
        assert_eq!(event.token_a_mint, accounts[6]);
        assert_eq!(event.payer, accounts[8]);
        assert_eq!(event.referral_token_account, Some(accounts[11]));
        assert_eq!(event.event_authority, accounts[12]);
        assert_eq!(event.program, accounts[13]);

        let mut without_referral = accounts.clone();
        without_referral[11] = accounts[13];
        fill_damm_v2_swap_accounts(
            &mut event,
            &|i| without_referral.get(i).copied().unwrap_or_default(),
            14,
        );
        assert_eq!(event.referral_token_account, None);

        let mut omitted = MeteoraDammV2SwapEvent::default();
        fill_damm_v2_swap_accounts(
            &mut omitted,
            &|i| accounts.get(i).copied().unwrap_or_default(),
            13,
        );
        assert_eq!(omitted.referral_token_account, None);
        assert_eq!(omitted.event_authority, accounts[11]);
        assert_eq!(omitted.program, accounts[12]);
    }

    #[test]
    fn older_swap_json_defaults_new_accounts() {
        let mut json = serde_json::to_value(MeteoraDammV2SwapEvent::default()).unwrap();
        let map = json.as_object_mut().unwrap();
        for field in [
            "pool_authority",
            "input_token_account",
            "output_token_account",
            "payer",
            "referral_token_account",
            "event_authority",
            "program",
        ] {
            map.remove(field);
        }
        let decoded: MeteoraDammV2SwapEvent = serde_json::from_value(json).unwrap();
        assert_eq!(decoded.pool_authority, Pubkey::default());
        assert_eq!(decoded.referral_token_account, None);
    }

    #[test]
    fn invalid_account_count_does_not_panic_or_fill() {
        let mut event = MeteoraDammV2SwapEvent::default();
        fill_damm_v2_swap_accounts(&mut event, &|_| Pubkey::new_unique(), 0);
        assert_eq!(event.token_a_mint, Pubkey::default());
    }
}

pub fn fill_damm_v2_create_position_accounts(
    _e: &mut MeteoraDammV2CreatePositionEvent,
    _get: &AccountGetter<'_>,
) {
    // DAMM V2 是动态 AMM,没有传统的 position 概念
    // 此事件类型可能不适用
}

pub fn fill_damm_v2_close_position_accounts(
    _e: &mut MeteoraDammV2ClosePositionEvent,
    _get: &AccountGetter<'_>,
) {
    // DAMM V2 是动态 AMM,没有传统的 position 概念
    // 此事件类型可能不适用
}

pub fn fill_damm_v2_add_liquidity_accounts(
    _e: &mut MeteoraDammV2AddLiquidityEvent,
    _get: &AccountGetter<'_>,
) {
    // DAMM V2 流动性操作通过 initialize_virtual_pool 等指令
    // 事件数据已包含主要信息
}

pub fn fill_damm_v2_remove_liquidity_accounts(
    _e: &mut MeteoraDammV2RemoveLiquidityEvent,
    _get: &AccountGetter<'_>,
) {
    // DAMM V2 流动性移除操作
    // 事件数据已包含主要信息
}

pub fn fill_damm_v2_initialize_pool_accounts(
    e: &mut MeteoraDammV2InitializePoolEvent,
    get: &AccountGetter<'_>,
) {
    if e.creator == Pubkey::default() {
        e.creator = get(0);
    }
    if e.position_nft_mint == Pubkey::default() {
        e.position_nft_mint = get(1);
    }
    if e.pool == Pubkey::default() {
        e.pool = get(6);
    }
    if e.position == Pubkey::default() {
        e.position = get(7);
    }
    if e.token_a_mint == Pubkey::default() {
        e.token_a_mint = get(8);
    }
    if e.token_b_mint == Pubkey::default() {
        e.token_b_mint = get(9);
    }
}

// ============================================================================
// Meteora Pools
// ============================================================================

/// Meteora Pools Swap 账户填充
///
/// swap instruction account mapping (based on IDL):
/// 0: pool
/// 1: userSourceToken
/// 2: userDestinationToken
/// 3: aVault
/// 4: bVault
/// 5: aTokenVault
/// 6: bTokenVault
/// 7: aVaultLpMint
/// 8: bVaultLpMint
/// 9: aVaultLp
/// 10: bVaultLp
/// 11: protocolTokenFee
/// 12: user
/// 13: vaultProgram
/// 14: tokenProgram
pub fn fill_pools_swap_accounts(e: &mut MeteoraPoolsSwapEvent, get: &AccountGetter<'_>) {
    if e.pool == Pubkey::default() {
        e.pool = get(0);
    }
    if e.user_source_token == Pubkey::default() {
        e.user_source_token = get(1);
    }
    if e.user_destination_token == Pubkey::default() {
        e.user_destination_token = get(2);
    }
    if e.a_vault == Pubkey::default() {
        e.a_vault = get(3);
    }
    if e.b_vault == Pubkey::default() {
        e.b_vault = get(4);
    }
    if e.a_token_vault == Pubkey::default() {
        e.a_token_vault = get(5);
    }
    if e.b_token_vault == Pubkey::default() {
        e.b_token_vault = get(6);
    }
    if e.a_vault_lp_mint == Pubkey::default() {
        e.a_vault_lp_mint = get(7);
    }
    if e.b_vault_lp_mint == Pubkey::default() {
        e.b_vault_lp_mint = get(8);
    }
    if e.a_vault_lp == Pubkey::default() {
        e.a_vault_lp = get(9);
    }
    if e.b_vault_lp == Pubkey::default() {
        e.b_vault_lp = get(10);
    }
    if e.protocol_token_fee == Pubkey::default() {
        e.protocol_token_fee = get(11);
    }
    if e.user == Pubkey::default() {
        e.user = get(12);
    }
    if e.vault_program == Pubkey::default() {
        e.vault_program = get(13);
    }
    if e.token_program == Pubkey::default() {
        e.token_program = get(14);
    }
}

/// Meteora Pools Add Liquidity 账户填充
///
/// addBalanceLiquidity/addImbalanceLiquidity instruction account mapping:
/// 0: pool
/// 1: lpMint
/// 2: userPoolLp
/// 3: aVaultLp
/// 4: bVaultLp
/// 5: aVault
/// 6: bVault
/// 7: aVaultLpMint
/// 8: bVaultLpMint
/// 9: aTokenVault
/// 10: bTokenVault
/// 11: userAToken
/// 12: userBToken
/// 13: user
/// 14: vaultProgram
/// 15: tokenProgram
pub fn fill_pools_add_liquidity_accounts(
    e: &mut MeteoraPoolsAddLiquidityEvent,
    get: &AccountGetter<'_>,
) {
    if e.pool == Pubkey::default() {
        e.pool = get(0);
    }
    if e.lp_mint == Pubkey::default() {
        e.lp_mint = get(1);
    }
    if e.user_pool_lp == Pubkey::default() {
        e.user_pool_lp = get(2);
    }
    if e.a_vault_lp == Pubkey::default() {
        e.a_vault_lp = get(3);
    }
    if e.b_vault_lp == Pubkey::default() {
        e.b_vault_lp = get(4);
    }
    if e.a_vault == Pubkey::default() {
        e.a_vault = get(5);
    }
    if e.b_vault == Pubkey::default() {
        e.b_vault = get(6);
    }
    if e.a_vault_lp_mint == Pubkey::default() {
        e.a_vault_lp_mint = get(7);
    }
    if e.b_vault_lp_mint == Pubkey::default() {
        e.b_vault_lp_mint = get(8);
    }
    if e.a_token_vault == Pubkey::default() {
        e.a_token_vault = get(9);
    }
    if e.b_token_vault == Pubkey::default() {
        e.b_token_vault = get(10);
    }
    if e.user_a_token == Pubkey::default() {
        e.user_a_token = get(11);
    }
    if e.user_b_token == Pubkey::default() {
        e.user_b_token = get(12);
    }
    if e.user == Pubkey::default() {
        e.user = get(13);
    }
    if e.vault_program == Pubkey::default() {
        e.vault_program = get(14);
    }
    if e.token_program == Pubkey::default() {
        e.token_program = get(15);
    }
}

/// Meteora Pools Remove Liquidity 账户填充
///
/// Balance removal uses 16 accounts. Single-side removal shares indices 0..10,
/// then destination token 11, user 12, vault program 13, token program 14.
/// `ix_name` selects the layout; the dispatcher derives it from the discriminator.
/// removeBalanceLiquidity instruction account mapping:
/// 0: pool
/// 1: lpMint
/// 2: userPoolLp
/// 3: aVaultLp
/// 4: bVaultLp
/// 5: aVault
/// 6: bVault
/// ...
pub fn fill_pools_remove_liquidity_accounts(
    e: &mut MeteoraPoolsRemoveLiquidityEvent,
    get: &AccountGetter<'_>,
) {
    if e.pool == Pubkey::default() {
        e.pool = get(0);
    }
    if e.lp_mint == Pubkey::default() {
        e.lp_mint = get(1);
    }
    if e.user_pool_lp == Pubkey::default() {
        e.user_pool_lp = get(2);
    }
    if e.a_vault_lp == Pubkey::default() {
        e.a_vault_lp = get(3);
    }
    if e.b_vault_lp == Pubkey::default() {
        e.b_vault_lp = get(4);
    }
    if e.a_vault == Pubkey::default() {
        e.a_vault = get(5);
    }
    if e.b_vault == Pubkey::default() {
        e.b_vault = get(6);
    }
    if e.a_vault_lp_mint == Pubkey::default() {
        e.a_vault_lp_mint = get(7);
    }
    if e.b_vault_lp_mint == Pubkey::default() {
        e.b_vault_lp_mint = get(8);
    }
    if e.a_token_vault == Pubkey::default() {
        e.a_token_vault = get(9);
    }
    if e.b_token_vault == Pubkey::default() {
        e.b_token_vault = get(10);
    }
    let single_side = e.ix_name == "remove_liquidity_single_side";
    if single_side {
        if e.user_destination_token == Pubkey::default() {
            e.user_destination_token = get(11);
        }
    } else {
        if e.user_a_token == Pubkey::default() {
            e.user_a_token = get(11);
        }
        if e.user_b_token == Pubkey::default() {
            e.user_b_token = get(12);
        }
    }
    if e.user == Pubkey::default() {
        e.user = get(if single_side { 12 } else { 13 });
    }
    if e.vault_program == Pubkey::default() {
        e.vault_program = get(if single_side { 13 } else { 14 });
    }
    if e.token_program == Pubkey::default() {
        e.token_program = get(if single_side { 14 } else { 15 });
    }
}

pub fn fill_pools_bootstrap_liquidity_accounts(
    e: &mut MeteoraPoolsBootstrapLiquidityEvent,
    get: &AccountGetter<'_>,
) {
    if e.pool == Pubkey::default() {
        e.pool = get(0);
    }
    if e.lp_mint == Pubkey::default() {
        e.lp_mint = get(1);
    }
    if e.user_pool_lp == Pubkey::default() {
        e.user_pool_lp = get(2);
    }
    if e.a_vault_lp == Pubkey::default() {
        e.a_vault_lp = get(3);
    }
    if e.b_vault_lp == Pubkey::default() {
        e.b_vault_lp = get(4);
    }
    if e.a_vault == Pubkey::default() {
        e.a_vault = get(5);
    }
    if e.b_vault == Pubkey::default() {
        e.b_vault = get(6);
    }
    if e.a_vault_lp_mint == Pubkey::default() {
        e.a_vault_lp_mint = get(7);
    }
    if e.b_vault_lp_mint == Pubkey::default() {
        e.b_vault_lp_mint = get(8);
    }
    if e.a_token_vault == Pubkey::default() {
        e.a_token_vault = get(9);
    }
    if e.b_token_vault == Pubkey::default() {
        e.b_token_vault = get(10);
    }
    if e.user_a_token == Pubkey::default() {
        e.user_a_token = get(11);
    }
    if e.user_b_token == Pubkey::default() {
        e.user_b_token = get(12);
    }
    if e.user == Pubkey::default() {
        e.user = get(13);
    }
    if e.vault_program == Pubkey::default() {
        e.vault_program = get(14);
    }
    if e.token_program == Pubkey::default() {
        e.token_program = get(15);
    }
}

// ============================================================================
// Meteora DLMM
// ============================================================================

/// Meteora DLMM Swap 账户填充
///
/// `swap` (v1) fixed accounts (IDL):
/// 0..12 shared, 13: eventAuthority, 14: program, remaining: bin arrays
///
/// `swap2` fixed accounts (IDL):
/// 0: lbPair, 1: binArrayBitmapExtension (optional), 2: reserveX, 3: reserveY,
/// 4: userTokenIn, 5: userTokenOut, 6: tokenXMint, 7: tokenYMint,
/// 8: oracle, 9: hostFeeIn (optional), 10: user, 11: tokenXProgram, 12: tokenYProgram,
/// 13: memoProgram, 14: eventAuthority, 15: program, remaining: bin arrays
/// Without instruction data, v2 hook boundaries are unknown; leave bin arrays unset.
pub fn fill_dlmm_swap_accounts(e: &mut MeteoraDlmmSwapEvent, get: &AccountGetter<'_>) {
    const MEMO_PROGRAM: Pubkey = solana_sdk::pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
    let v2 = get(13) == MEMO_PROGRAM;
    let start = if v2 { 16 } else { 15 };
    fill_dlmm_swap_accounts_with_layout(e, get, start, if v2 { start } else { start + 16 }, v2);
}

pub(crate) fn fill_dlmm_swap_accounts_with_layout(
    e: &mut MeteoraDlmmSwapEvent, get: &AccountGetter<'_>, bins_start: usize, bins_end: usize, is_swap2: bool,
) {

    if e.pool == Pubkey::default() {
        e.pool = get(0);
    }
    if e.user_token_in == Pubkey::default() {
        e.user_token_in = get(4);
    }
    if e.user_token_out == Pubkey::default() {
        e.user_token_out = get(5);
    }
    if e.token_x_mint == Pubkey::default() {
        e.token_x_mint = get(6);
    }
    if e.token_y_mint == Pubkey::default() {
        e.token_y_mint = get(7);
    }
    if e.reserve_x == Pubkey::default() {
        e.reserve_x = get(2);
    }
    if e.reserve_y == Pubkey::default() {
        e.reserve_y = get(3);
    }
    if e.oracle == Pubkey::default() {
        e.oracle = get(8);
    }
    if e.token_x_program == Pubkey::default() {
        e.token_x_program = get(11);
    }
    if e.token_y_program == Pubkey::default() {
        e.token_y_program = get(12);
    }

    // swap2 inserts memo_program at index 13; swap (v1) has event_authority there.
    let program_idx = if is_swap2 { 15 } else { 14 };

    if e.bitmap_extension.is_none() {
        let ext = get(1);
        // Unused optional accounts are often the program id placeholder.
        let program = get(program_idx);
        if ext != Pubkey::default() && ext != e.pool && ext != program {
            e.bitmap_extension = Some(ext);
        }
    }
    if e.bin_arrays.is_empty() {
        if bins_start >= bins_end || get(bins_start) == Pubkey::default() { return; }
        let mut bins = Vec::with_capacity(bins_end.saturating_sub(bins_start));
        let mut idx = bins_start;
        while idx < bins_end {
            let key = get(idx);
            if key == Pubkey::default() {
                break;
            }
            bins.push(key);
            idx += 1;
        }
        e.bin_arrays = bins;
    }
}

/// Meteora DLMM Add Liquidity 账户填充
///
/// addLiquidity instruction account mapping (based on IDL):
/// 0: position
/// 1: lbPair
/// 2: binArrayBitmapExtension
/// 3: userTokenX
/// 4: userTokenY
/// 5: reserveX
/// 6: reserveY
/// 7: tokenXMint
/// 8: tokenYMint
/// 9: binArrayLower
/// 10: binArrayUpper
/// 11: sender
/// ...
pub fn fill_dlmm_add_liquidity_accounts(
    _e: &mut MeteoraDlmmAddLiquidityEvent,
    _get: &AccountGetter<'_>,
) {
    // 事件数据已包含主要信息
}

/// Meteora DLMM Remove Liquidity 账户填充
///
/// removeLiquidity instruction account mapping (based on IDL):
/// 0: position
/// 1: lbPair
/// 2: binArrayBitmapExtension
/// 3: userTokenX
/// 4: userTokenY
/// 5: reserveX
/// 6: reserveY
/// 7: tokenXMint
/// 8: tokenYMint
/// 9: binArrayLower
/// 10: binArrayUpper
/// 11: sender
/// ...
pub fn fill_dlmm_remove_liquidity_accounts(
    _e: &mut MeteoraDlmmRemoveLiquidityEvent,
    _get: &AccountGetter<'_>,
) {
    // 事件数据已包含主要信息
}

#[cfg(test)]
mod dlmm_swap_tests {
    use super::*;

    #[test]
    fn swap2_bin_arrays_start_after_memo_and_program() {
        let memo = solana_sdk::pubkey!("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
        let mut accounts: Vec<_> = (0..18).map(|_| Pubkey::new_unique()).collect();
        accounts[13] = memo;
        let bin0 = accounts[16];
        let bin1 = accounts[17];
        let mut e = MeteoraDlmmSwapEvent::default();
        fill_dlmm_swap_accounts_with_layout(&mut e, &|i| accounts.get(i).copied().unwrap_or_default(), 16, accounts.len(), true);
        assert_eq!(e.bin_arrays, vec![bin0, bin1]);
        assert_eq!(e.reserve_x, accounts[2]);
        assert_eq!(e.oracle, accounts[8]);
    }

    #[test]
    fn swap_v1_bin_arrays_start_at_15() {
        let accounts: Vec<_> = (0..17).map(|_| Pubkey::new_unique()).collect();
        // index 13 is NOT memo → v1 layout
        let bin0 = accounts[15];
        let bin1 = accounts[16];
        let mut e = MeteoraDlmmSwapEvent::default();
        fill_dlmm_swap_accounts(&mut e, &|i| accounts.get(i).copied().unwrap_or_default());
        assert_eq!(e.bin_arrays, vec![bin0, bin1]);
    }
}

/// IDL initialization layouts selected by the instruction name.
/// The dispatcher supplies this name from the matched discriminator.
pub fn fill_pools_pool_created_accounts(
    e: &mut MeteoraPoolsPoolCreatedEvent,
    get: &AccountGetter<'_>,
) {
    macro_rules! fill {
        ($($field:ident = $index:expr),* $(,)?) => {
            $(if e.$field == Pubkey::default() { e.$field = get($index); })*
        };
    }
    match e.ix_name.as_str() {
        "initialize_permissioned_pool" => {
            fill!(
                pool = 0,
                lp_mint = 1,
                token_a_mint = 2,
                token_b_mint = 3,
                a_vault = 4,
                b_vault = 5,
                a_vault_lp_mint = 6,
                b_vault_lp_mint = 7,
                a_vault_lp = 8,
                b_vault_lp = 9,
                admin_token_a = 10,
                admin_token_b = 11,
                admin_pool_lp = 12,
                protocol_token_a_fee = 13,
                protocol_token_b_fee = 14,
                admin = 15,
                fee_owner = 16,
                rent = 17,
                mint_metadata = 18,
                metadata_program = 19,
                vault_program = 20,
                token_program = 21,
                associated_token_program = 22,
                system_program = 23
            );
        }
        "initialize_permissionless_pool" | "initialize_permissionless_pool_with_fee_tier" => {
            fill!(
                pool = 0,
                lp_mint = 1,
                token_a_mint = 2,
                token_b_mint = 3,
                a_vault = 4,
                b_vault = 5,
                a_token_vault = 6,
                b_token_vault = 7,
                a_vault_lp_mint = 8,
                b_vault_lp_mint = 9,
                a_vault_lp = 10,
                b_vault_lp = 11,
                payer_token_a = 12,
                payer_token_b = 13,
                payer_pool_lp = 14,
                protocol_token_a_fee = 15,
                protocol_token_b_fee = 16,
                payer = 17,
                fee_owner = 18,
                rent = 19,
                mint_metadata = 20,
                metadata_program = 21,
                vault_program = 22,
                token_program = 23,
                associated_token_program = 24,
                system_program = 25
            );
        }
        "initialize_customizable_permissionless_constant_product_pool" => {
            fill!(
                pool = 0,
                lp_mint = 1,
                token_a_mint = 2,
                token_b_mint = 3,
                a_vault = 4,
                b_vault = 5,
                a_token_vault = 6,
                b_token_vault = 7,
                a_vault_lp_mint = 8,
                b_vault_lp_mint = 9,
                a_vault_lp = 10,
                b_vault_lp = 11,
                payer_token_a = 12,
                payer_token_b = 13,
                payer_pool_lp = 14,
                protocol_token_a_fee = 15,
                protocol_token_b_fee = 16,
                payer = 17,
                rent = 18,
                mint_metadata = 19,
                metadata_program = 20,
                vault_program = 21,
                token_program = 22,
                associated_token_program = 23,
                system_program = 24
            );
        }
        _ => {
            fill!(
                pool = 0,
                config = 1,
                lp_mint = 2,
                token_a_mint = 3,
                token_b_mint = 4,
                a_vault = 5,
                b_vault = 6,
                a_token_vault = 7,
                b_token_vault = 8,
                a_vault_lp_mint = 9,
                b_vault_lp_mint = 10,
                a_vault_lp = 11,
                b_vault_lp = 12,
                payer_token_a = 13,
                payer_token_b = 14,
                payer_pool_lp = 15,
                protocol_token_a_fee = 16,
                protocol_token_b_fee = 17,
                payer = 18,
                rent = 19,
                mint_metadata = 20,
                metadata_program = 21,
                vault_program = 22,
                token_program = 23,
                associated_token_program = 24,
                system_program = 25
            );
        }
    }
}

pub fn fill_pools_set_pool_fees_accounts(
    e: &mut MeteoraPoolsSetPoolFeesEvent,
    get: &AccountGetter<'_>,
) {
    if e.pool == Pubkey::default() {
        e.pool = get(0);
    }
    if e.fee_operator == Pubkey::default() {
        e.fee_operator = get(1);
    }
}