sol-parser-sdk 0.5.14 → 0.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/NATIVE_ALIGNMENT.md +312 -0
  2. package/NATIVE_DAMM_FACTORY_ALIGNMENT_20261004.md +16 -0
  3. package/NATIVE_DAMM_FACTORY_EVIDENCE_20261004.json +55 -0
  4. package/NATIVE_MIGRATION.md +38 -0
  5. package/NATIVE_PUMPFUN_NATIVE_DEBIT_ALIGNMENT_20261004.md +18 -0
  6. package/NATIVE_PUMPFUN_NATIVE_DEBIT_EVIDENCE_20261004.json +57 -0
  7. package/NATIVE_PUMPFUN_SETTLEMENT_ALIGNMENT_20261004.md +11 -0
  8. package/NATIVE_PUMPFUN_SETTLEMENT_EVIDENCE_20261004.json +70 -0
  9. package/README.md +24 -1
  10. package/README_CN.md +21 -1
  11. package/dist/accounts/mod.js +7 -0
  12. package/dist/accounts/pumpfun.js +17 -0
  13. package/dist/accounts/pumpswap.js +18 -3
  14. package/dist/core/account_dispatcher_rpc.js +24 -4
  15. package/dist/core/account_fill_meteora.d.ts +1 -1
  16. package/dist/core/account_fill_meteora.js +12 -1
  17. package/dist/core/account_fill_raydium.js +12 -2
  18. package/dist/core/account_fill_raydium_launchlab.js +54 -0
  19. package/dist/core/clock.js +1 -1
  20. package/dist/core/common_filler_rpc.d.ts +2 -2
  21. package/dist/core/common_filler_rpc.js +66 -0
  22. package/dist/core/dex_event.d.ts +157 -0
  23. package/dist/core/metadata.d.ts +9 -5
  24. package/dist/core/metadata.js +28 -4
  25. package/dist/core/unified_parser.d.ts +7 -7
  26. package/dist/grpc/block_meta.d.ts +9 -0
  27. package/dist/grpc/block_meta.js +26 -0
  28. package/dist/grpc/client.d.ts +24 -9
  29. package/dist/grpc/client.js +129 -67
  30. package/dist/grpc/geyser_connect.d.ts +3 -3
  31. package/dist/grpc/geyser_connect.js +13 -15
  32. package/dist/grpc/log_instr_dedup.js +6 -0
  33. package/dist/grpc/native_client.d.ts +26 -0
  34. package/dist/grpc/native_client.js +101 -0
  35. package/dist/grpc/order_buffer.d.ts +1 -1
  36. package/dist/grpc/order_buffer.js +10 -9
  37. package/dist/grpc/program_ids.js +2 -0
  38. package/dist/grpc/protocol/LICENSE +202 -0
  39. package/dist/grpc/protocol/NOTICE +4 -0
  40. package/dist/grpc/protocol/geyser.d.ts +342 -0
  41. package/dist/grpc/protocol/geyser.js +37 -0
  42. package/dist/grpc/protocol/geyser.proto +326 -0
  43. package/dist/grpc/protocol/solana-storage.d.ts +139 -0
  44. package/dist/grpc/protocol/solana-storage.js +14 -0
  45. package/dist/grpc/protocol/solana-storage.proto +151 -0
  46. package/dist/grpc/rpc_to_grpc.d.ts +1 -1
  47. package/dist/grpc/subscribe_builder.d.ts +5 -3
  48. package/dist/grpc/subscribe_builder.js +11 -3
  49. package/dist/grpc/transaction_meta.d.ts +1 -1
  50. package/dist/grpc/types.d.ts +8 -8
  51. package/dist/grpc/types.js +15 -2
  52. package/dist/grpc/yellowstone_parse.d.ts +3 -3
  53. package/dist/grpc/yellowstone_parse.js +6 -8
  54. package/dist/grpc/yellowstone_transaction_adapter.d.ts +1 -1
  55. package/dist/index.d.ts +11 -1
  56. package/dist/index.js +23 -5
  57. package/dist/instr/inner.d.ts +2 -2
  58. package/dist/instr/inner.js +1 -1
  59. package/dist/instr/meteora_damm_ix.d.ts +1 -1
  60. package/dist/instr/meteora_damm_ix.js +41 -79
  61. package/dist/instr/meteora_dlmm_ix.d.ts +1 -1
  62. package/dist/instr/meteora_dlmm_ix.js +10 -0
  63. package/dist/instr/meteora_pools_ix.d.ts +1 -1
  64. package/dist/instr/mod.d.ts +1 -1
  65. package/dist/instr/orca_whirlpool_ix.d.ts +1 -1
  66. package/dist/instr/pump_fees_ix.d.ts +1 -1
  67. package/dist/instr/pumpfun_ix.d.ts +1 -1
  68. package/dist/instr/pumpfun_ix.js +16 -0
  69. package/dist/instr/pumpswap_ix.d.ts +1 -1
  70. package/dist/instr/pumpswap_ix.js +13 -5
  71. package/dist/instr/raydium_amm_v4_ix.d.ts +1 -1
  72. package/dist/instr/raydium_amm_v4_ix.js +9 -5
  73. package/dist/instr/raydium_clmm_ix.d.ts +1 -1
  74. package/dist/instr/raydium_cpmm_ix.d.ts +1 -1
  75. package/dist/instr/raydium_launchlab_ix.d.ts +1 -1
  76. package/dist/instr/raydium_launchlab_ix.js +62 -2
  77. package/dist/instr/utils.d.ts +2 -2
  78. package/dist/instr/utils.js +2 -7
  79. package/dist/liquidity_snapshot.d.ts +54 -0
  80. package/dist/liquidity_snapshot.js +85 -0
  81. package/dist/logs/meteora_damm.d.ts +17 -1
  82. package/dist/logs/meteora_damm.js +386 -12
  83. package/dist/logs/meteora_dlmm.d.ts +1 -1
  84. package/dist/logs/meteora_dlmm.js +10 -0
  85. package/dist/logs/optimized_matcher.d.ts +3 -3
  86. package/dist/logs/optimized_matcher.js +35 -1
  87. package/dist/logs/program_log_discriminators.d.ts +5 -0
  88. package/dist/logs/program_log_discriminators.js +5 -0
  89. package/dist/logs/pump.js +10 -0
  90. package/dist/logs/pump_amm.js +22 -1
  91. package/dist/logs/raydium_launchlab.js +19 -1
  92. package/dist/rpc_transaction.d.ts +4 -3
  93. package/dist/rpc_transaction.js +3 -2
  94. package/dist/shredstream/client.js +3 -7
  95. package/dist/shredstream/entries_decode.js +9 -85
  96. package/dist/shredstream/instruction_parse.d.ts +3 -3
  97. package/dist/shredstream/proto_types.d.ts +1 -1
  98. package/dist/shredstream/wire_to_shred_tx.d.ts +1 -1
  99. package/dist/shredstream/wire_to_shred_tx.js +9 -44
  100. package/dist/simulation_route.d.ts +6 -0
  101. package/dist/simulation_route.js +242 -0
  102. package/dist/stonkfun_registry.d.ts +30 -0
  103. package/dist/stonkfun_registry.js +137 -0
  104. package/dist/transaction_route.d.ts +84 -0
  105. package/dist/transaction_route.js +477 -0
  106. package/dist/wire_transaction.d.ts +35 -0
  107. package/dist/wire_transaction.js +191 -0
  108. package/package.json +7 -4
@@ -1,7 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.COMPOUNDING_FEE_LAYOUT_ACTIVATION_SLOT = void 0;
4
+ exports.parseSwap2FromData = parseSwap2FromData;
5
+ exports.parseAddLiquidityFromData = parseAddLiquidityFromData;
6
+ exports.parseRemoveLiquidityFromData = parseRemoveLiquidityFromData;
7
+ exports.parseLiquidityChangeFromData = parseLiquidityChangeFromData;
8
+ exports.parseUpdateDelegatePermissionFromData = parseUpdateDelegatePermissionFromData;
9
+ exports.parseWithdrawDeadLiquidityRewardFromData = parseWithdrawDeadLiquidityRewardFromData;
10
+ exports.parseCreateConfigFromData = parseCreateConfigFromData;
11
+ exports.parseCreateDynamicConfigFromData = parseCreateDynamicConfigFromData;
3
12
  exports.parseMeteoraDammLog = parseMeteoraDammLog;
4
13
  const metadata_js_1 = require("../core/metadata.js");
14
+ const metadata_js_2 = require("../core/metadata.js");
5
15
  const dex_event_js_1 = require("../core/dex_event.js");
6
16
  const program_data_js_1 = require("./program_data.js");
7
17
  const binary_js_1 = require("../util/binary.js");
@@ -15,9 +25,23 @@ const SWAP = discOf([27, 60, 21, 213, 138, 170, 187, 147]);
15
25
  const SWAP2 = discOf([189, 66, 51, 168, 38, 80, 117, 153]);
16
26
  const ADD_LIQUIDITY = discOf([175, 242, 8, 157, 30, 247, 185, 169]);
17
27
  const REMOVE_LIQUIDITY = discOf([87, 46, 88, 98, 175, 96, 34, 91]);
28
+ const LIQUIDITY_CHANGE = discOf([197, 171, 78, 127, 224, 211, 87, 13]);
18
29
  const INITIALIZE_POOL = discOf([228, 50, 246, 85, 203, 66, 134, 37]);
19
30
  const CREATE_POSITION = discOf([156, 15, 119, 198, 29, 181, 221, 55]);
20
31
  const CLOSE_POSITION = discOf([20, 145, 144, 68, 143, 142, 214, 178]);
32
+ const UPDATE_DELEGATE_PERMISSION = discOf([66, 188, 75, 151, 150, 232, 87, 93]);
33
+ const WITHDRAW_DEAD_LIQUIDITY_REWARD = discOf([228, 66, 150, 195, 42, 62, 163, 13]);
34
+ const CREATE_CONFIG = discOf([131, 207, 180, 174, 180, 73, 165, 54]);
35
+ const CREATE_DYNAMIC_CONFIG = discOf([231, 197, 13, 164, 248, 213, 133, 152]);
36
+ /**
37
+ * Mainnet upgrade that replaced `trading_fee/partner_fee` in `EvtSwap2` with
38
+ * `claiming_fee/compounding_fee` without changing discriminator or size.
39
+ */
40
+ exports.COMPOUNDING_FEE_LAYOUT_ACTIVATION_SLOT = 406_048_752;
41
+ function usesCompoundingFeeLayout(slot) {
42
+ const n = (0, metadata_js_1.exactU64)(slot);
43
+ return n === 0n || n >= BigInt(exports.COMPOUNDING_FEE_LAYOUT_ACTIVATION_SLOT);
44
+ }
21
45
  function bn64(v) {
22
46
  return v ?? 0n;
23
47
  }
@@ -35,11 +59,17 @@ function emptyVaults() {
35
59
  function parseSwapEvent(data, meta) {
36
60
  let o = 0;
37
61
  const pool = (0, binary_js_1.readPubkey)(data, o);
62
+ if (!pool)
63
+ return null;
38
64
  o += 32;
39
65
  o += 32;
40
66
  const trade_direction = (0, binary_js_1.readU8)(data, o);
67
+ if (trade_direction === null)
68
+ return null;
41
69
  o += 1;
42
70
  const has_referral = (0, binary_js_1.readBool)(data, o);
71
+ if (has_referral === null)
72
+ return null;
43
73
  o += 1;
44
74
  const amount_in = bn64((0, binary_js_1.readU64LE)(data, o));
45
75
  o += 8;
@@ -50,6 +80,8 @@ function parseSwapEvent(data, meta) {
50
80
  const output_amount = bn64((0, binary_js_1.readU64LE)(data, o));
51
81
  o += 8;
52
82
  const next_sqrt_price = (0, binary_js_1.readU128LE)(data, o);
83
+ if (next_sqrt_price === null)
84
+ return null;
53
85
  o += 16;
54
86
  const lp_fee = bn64((0, binary_js_1.readU64LE)(data, o));
55
87
  o += 8;
@@ -78,54 +110,123 @@ function parseSwapEvent(data, meta) {
78
110
  };
79
111
  return { MeteoraDammV2Swap: ev };
80
112
  }
81
- function parseSwap2Event(data, meta) {
113
+ /** Aligns with Rust `parse_swap2_from_data` (full 180-byte EvtSwap2 layout). */
114
+ function parseSwap2FromData(data, meta) {
82
115
  let o = 0;
83
116
  const pool = (0, binary_js_1.readPubkey)(data, o);
117
+ if (!pool)
118
+ return null;
84
119
  o += 32;
85
120
  const trade_direction = (0, binary_js_1.readU8)(data, o);
121
+ if (trade_direction === null)
122
+ return null;
86
123
  o += 1;
124
+ const collect_fee_mode = (0, binary_js_1.readU8)(data, o);
125
+ if (collect_fee_mode === null)
126
+ return null;
87
127
  o += 1;
88
128
  const has_referral = (0, binary_js_1.readBool)(data, o);
129
+ if (has_referral === null)
130
+ return null;
89
131
  o += 1;
90
132
  const amount_0 = bn64((0, binary_js_1.readU64LE)(data, o));
91
133
  o += 8;
92
134
  const amount_1 = bn64((0, binary_js_1.readU64LE)(data, o));
93
135
  o += 8;
94
136
  const swap_mode = (0, binary_js_1.readU8)(data, o);
137
+ if (swap_mode === null)
138
+ return null;
95
139
  o += 1;
96
140
  const included_fee_input_amount = bn64((0, binary_js_1.readU64LE)(data, o));
97
141
  o += 8;
142
+ const excluded_fee_input_amount = bn64((0, binary_js_1.readU64LE)(data, o));
98
143
  o += 8;
144
+ const amount_left = bn64((0, binary_js_1.readU64LE)(data, o));
99
145
  o += 8;
100
146
  const output_amount = bn64((0, binary_js_1.readU64LE)(data, o));
101
147
  o += 8;
102
148
  const next_sqrt_price = (0, binary_js_1.readU128LE)(data, o);
149
+ if (next_sqrt_price === null)
150
+ return null;
103
151
  o += 16;
104
- const lp_fee = bn64((0, binary_js_1.readU64LE)(data, o));
152
+ const claiming_or_trading_fee = bn64((0, binary_js_1.readU64LE)(data, o));
105
153
  o += 8;
106
154
  const protocol_fee = bn64((0, binary_js_1.readU64LE)(data, o));
107
155
  o += 8;
156
+ const compounding_or_partner_fee = bn64((0, binary_js_1.readU64LE)(data, o));
157
+ o += 8;
108
158
  const referral_fee = bn64((0, binary_js_1.readU64LE)(data, o));
109
159
  o += 8;
160
+ const included_transfer_fee_amount_in = bn64((0, binary_js_1.readU64LE)(data, o));
161
+ o += 8;
162
+ const included_transfer_fee_amount_out = bn64((0, binary_js_1.readU64LE)(data, o));
110
163
  o += 8;
164
+ const excluded_transfer_fee_amount_out = bn64((0, binary_js_1.readU64LE)(data, o));
111
165
  o += 8;
112
166
  const current_timestamp = bn64((0, binary_js_1.readU64LE)(data, o));
113
- const [amount_in, minimum_amount_out] = swap_mode === 0 ? [amount_0, amount_1] : [amount_1, amount_0];
167
+ o += 8;
168
+ const reserve_a_amount = bn64((0, binary_js_1.readU64LE)(data, o));
169
+ o += 8;
170
+ const reserve_b_amount = bn64((0, binary_js_1.readU64LE)(data, o));
171
+ // ExactIn (0) / PartialFill (1): amount_0=in, amount_1=min_out.
172
+ // ExactOut (2): amount_0=out, amount_1=max_in.
173
+ let amount_in;
174
+ let minimum_amount_out;
175
+ if (swap_mode === 0 || swap_mode === 1) {
176
+ amount_in = amount_0;
177
+ minimum_amount_out = amount_1;
178
+ }
179
+ else if (swap_mode === 2) {
180
+ amount_in = amount_1;
181
+ minimum_amount_out = amount_0;
182
+ }
183
+ else {
184
+ return null;
185
+ }
186
+ let lp_fee;
187
+ let partner_fee;
188
+ let claiming_fee;
189
+ let compounding_fee;
190
+ if (usesCompoundingFeeLayout(meta.slot)) {
191
+ lp_fee = claiming_or_trading_fee + compounding_or_partner_fee;
192
+ partner_fee = compounding_or_partner_fee;
193
+ claiming_fee = claiming_or_trading_fee;
194
+ compounding_fee = compounding_or_partner_fee;
195
+ }
196
+ else {
197
+ lp_fee = claiming_or_trading_fee;
198
+ partner_fee = compounding_or_partner_fee;
199
+ claiming_fee = 0n;
200
+ compounding_fee = 0n;
201
+ }
114
202
  const ev = {
115
203
  metadata: meta,
116
204
  pool,
117
- amount_in,
118
- output_amount,
119
205
  trade_direction,
206
+ collect_fee_mode,
120
207
  has_referral,
208
+ amount_0,
209
+ amount_1,
210
+ swap_mode,
211
+ amount_in,
121
212
  minimum_amount_out,
213
+ output_amount,
122
214
  next_sqrt_price,
123
215
  lp_fee,
124
216
  protocol_fee,
125
- partner_fee: 0n,
217
+ partner_fee,
126
218
  referral_fee,
127
219
  actual_amount_in: included_fee_input_amount,
220
+ excluded_fee_input_amount,
221
+ amount_left,
222
+ claiming_fee,
223
+ compounding_fee,
224
+ included_transfer_fee_amount_in,
225
+ included_transfer_fee_amount_out,
226
+ excluded_transfer_fee_amount_out,
128
227
  current_timestamp,
228
+ reserve_a_amount,
229
+ reserve_b_amount,
129
230
  ...emptyVaults(),
130
231
  };
131
232
  return { MeteoraDammV2Swap: ev };
@@ -170,7 +271,7 @@ function parseClosePositionEvent(data, meta) {
170
271
  };
171
272
  return { MeteoraDammV2ClosePosition: ev };
172
273
  }
173
- function parseAddLiquidityEvent(data, meta) {
274
+ function parseAddLiquidityFromData(data, meta) {
174
275
  if (data.length < 32 * 3 + 16 + 8 * 6)
175
276
  return null;
176
277
  let o = 0;
@@ -208,7 +309,7 @@ function parseAddLiquidityEvent(data, meta) {
208
309
  };
209
310
  return { MeteoraDammV2AddLiquidity: ev };
210
311
  }
211
- function parseRemoveLiquidityEvent(data, meta) {
312
+ function parseRemoveLiquidityFromData(data, meta) {
212
313
  if (data.length < 32 * 3 + 16 + 8 * 4)
213
314
  return null;
214
315
  let o = 0;
@@ -240,6 +341,66 @@ function parseRemoveLiquidityEvent(data, meta) {
240
341
  };
241
342
  return { MeteoraDammV2RemoveLiquidity: ev };
242
343
  }
344
+ /** Parse current `EvtLiquidityChange`; `change_type` 0 = add, 1 = remove. */
345
+ function parseLiquidityChangeFromData(data, meta) {
346
+ const LEN = 177;
347
+ if (data.length < LEN)
348
+ return null;
349
+ const pool = (0, binary_js_1.readPubkey)(data, 0);
350
+ const position = (0, binary_js_1.readPubkey)(data, 32);
351
+ const owner = (0, binary_js_1.readPubkey)(data, 64);
352
+ if (!pool || !position || !owner)
353
+ return null;
354
+ const token_a_amount = bn64((0, binary_js_1.readU64LE)(data, 96));
355
+ const token_b_amount = bn64((0, binary_js_1.readU64LE)(data, 104));
356
+ const total_amount_a = bn64((0, binary_js_1.readU64LE)(data, 112));
357
+ const total_amount_b = bn64((0, binary_js_1.readU64LE)(data, 120));
358
+ const reserve_a_amount = bn64((0, binary_js_1.readU64LE)(data, 128));
359
+ const reserve_b_amount = bn64((0, binary_js_1.readU64LE)(data, 136));
360
+ const liquidity_delta = (0, binary_js_1.readU128LE)(data, 144);
361
+ if (liquidity_delta === null)
362
+ return null;
363
+ const token_a_amount_threshold = bn64((0, binary_js_1.readU64LE)(data, 160));
364
+ const token_b_amount_threshold = bn64((0, binary_js_1.readU64LE)(data, 168));
365
+ const change_type = (0, binary_js_1.readU8)(data, 176);
366
+ if (change_type === 0) {
367
+ const ev = {
368
+ metadata: meta,
369
+ pool,
370
+ position,
371
+ owner,
372
+ token_a_amount,
373
+ token_b_amount,
374
+ liquidity_delta,
375
+ token_a_amount_threshold,
376
+ token_b_amount_threshold,
377
+ total_amount_a,
378
+ total_amount_b,
379
+ reserve_a_amount,
380
+ reserve_b_amount,
381
+ };
382
+ return { MeteoraDammV2AddLiquidity: ev };
383
+ }
384
+ if (change_type === 1) {
385
+ const ev = {
386
+ metadata: meta,
387
+ pool,
388
+ position,
389
+ owner,
390
+ token_a_amount,
391
+ token_b_amount,
392
+ liquidity_delta,
393
+ token_a_amount_threshold,
394
+ token_b_amount_threshold,
395
+ total_amount_a,
396
+ total_amount_b,
397
+ reserve_a_amount,
398
+ reserve_b_amount,
399
+ };
400
+ return { MeteoraDammV2RemoveLiquidity: ev };
401
+ }
402
+ return null;
403
+ }
243
404
  function skipPoolFees(data, offset) {
244
405
  if (offset + 31 > data.length)
245
406
  return null;
@@ -339,6 +500,208 @@ function parseInitializePoolEvent(data, meta) {
339
500
  };
340
501
  return { MeteoraDammV2InitializePool: ev };
341
502
  }
503
+ function parseUpdateDelegatePermissionFromData(data, meta) {
504
+ let o = 0;
505
+ const position = (0, binary_js_1.readPubkey)(data, o);
506
+ if (!position)
507
+ return null;
508
+ o += 32;
509
+ const owner = (0, binary_js_1.readPubkey)(data, o);
510
+ if (!owner)
511
+ return null;
512
+ o += 32;
513
+ const permission = (0, binary_js_1.readU32LE)(data, o);
514
+ if (permission === null)
515
+ return null;
516
+ o += 4;
517
+ const has_delegate = (0, binary_js_1.readBool)(data, o);
518
+ if (has_delegate === null)
519
+ return null;
520
+ o += 1;
521
+ let delegate = null;
522
+ if (has_delegate) {
523
+ delegate = (0, binary_js_1.readPubkey)(data, o);
524
+ if (!delegate)
525
+ return null;
526
+ }
527
+ const ev = {
528
+ metadata: meta,
529
+ position,
530
+ owner,
531
+ permission,
532
+ delegate,
533
+ };
534
+ return { MeteoraDammV2UpdateDelegatePermission: ev };
535
+ }
536
+ function parseWithdrawDeadLiquidityRewardFromData(data, meta) {
537
+ let o = 0;
538
+ const pool = (0, binary_js_1.readPubkey)(data, o);
539
+ if (!pool)
540
+ return null;
541
+ o += 32;
542
+ const reward_mint = (0, binary_js_1.readPubkey)(data, o);
543
+ if (!reward_mint)
544
+ return null;
545
+ o += 32;
546
+ const amount = (0, binary_js_1.readU64LE)(data, o);
547
+ if (amount === null)
548
+ return null;
549
+ const ev = {
550
+ metadata: meta,
551
+ pool,
552
+ reward_mint,
553
+ amount,
554
+ };
555
+ return { MeteoraDammV2WithdrawDeadLiquidityReward: ev };
556
+ }
557
+ function parseDynamicFeeParameters(data, offset) {
558
+ let o = offset;
559
+ const bin_step = (0, binary_js_1.readU16LE)(data, o);
560
+ if (bin_step === null)
561
+ return null;
562
+ o += 2;
563
+ const bin_step_u128 = (0, binary_js_1.readU128LE)(data, o);
564
+ if (bin_step_u128 === null)
565
+ return null;
566
+ o += 16;
567
+ const filter_period = (0, binary_js_1.readU16LE)(data, o);
568
+ if (filter_period === null)
569
+ return null;
570
+ o += 2;
571
+ const decay_period = (0, binary_js_1.readU16LE)(data, o);
572
+ if (decay_period === null)
573
+ return null;
574
+ o += 2;
575
+ const reduction_factor = (0, binary_js_1.readU16LE)(data, o);
576
+ if (reduction_factor === null)
577
+ return null;
578
+ o += 2;
579
+ const max_volatility_accumulator = (0, binary_js_1.readU32LE)(data, o);
580
+ if (max_volatility_accumulator === null)
581
+ return null;
582
+ o += 4;
583
+ const variable_fee_control = (0, binary_js_1.readU32LE)(data, o);
584
+ if (variable_fee_control === null)
585
+ return null;
586
+ o += 4;
587
+ return {
588
+ params: {
589
+ bin_step,
590
+ bin_step_u128,
591
+ filter_period,
592
+ decay_period,
593
+ reduction_factor,
594
+ max_volatility_accumulator,
595
+ variable_fee_control,
596
+ },
597
+ next: o,
598
+ };
599
+ }
600
+ function parseCreateConfigFromData(data, meta) {
601
+ let o = 0;
602
+ if (data.length < o + 27)
603
+ return null;
604
+ const base_fee_data = Array.from(data.subarray(o, o + 27));
605
+ o += 27;
606
+ const compounding_fee_bps = (0, binary_js_1.readU16LE)(data, o);
607
+ if (compounding_fee_bps === null)
608
+ return null;
609
+ o += 2;
610
+ const padding = (0, binary_js_1.readU8)(data, o);
611
+ if (padding === null)
612
+ return null;
613
+ o += 1;
614
+ const has_dynamic_fee = (0, binary_js_1.readBool)(data, o);
615
+ if (has_dynamic_fee === null)
616
+ return null;
617
+ o += 1;
618
+ let dynamic_fee = null;
619
+ if (has_dynamic_fee) {
620
+ const parsed = parseDynamicFeeParameters(data, o);
621
+ if (!parsed)
622
+ return null;
623
+ dynamic_fee = parsed.params;
624
+ o = parsed.next;
625
+ }
626
+ const vault_config_key = (0, binary_js_1.readPubkey)(data, o);
627
+ if (!vault_config_key)
628
+ return null;
629
+ o += 32;
630
+ const pool_creator_authority = (0, binary_js_1.readPubkey)(data, o);
631
+ if (!pool_creator_authority)
632
+ return null;
633
+ o += 32;
634
+ const activation_type = (0, binary_js_1.readU8)(data, o);
635
+ if (activation_type === null)
636
+ return null;
637
+ o += 1;
638
+ const sqrt_min_price = (0, binary_js_1.readU128LE)(data, o);
639
+ if (sqrt_min_price === null)
640
+ return null;
641
+ o += 16;
642
+ const sqrt_max_price = (0, binary_js_1.readU128LE)(data, o);
643
+ if (sqrt_max_price === null)
644
+ return null;
645
+ o += 16;
646
+ const collect_fee_mode = (0, binary_js_1.readU8)(data, o);
647
+ if (collect_fee_mode === null)
648
+ return null;
649
+ o += 1;
650
+ const index = (0, binary_js_1.readU64LE)(data, o);
651
+ if (index === null)
652
+ return null;
653
+ o += 8;
654
+ const config = (0, binary_js_1.readPubkey)(data, o);
655
+ if (!config)
656
+ return null;
657
+ o += 32;
658
+ const permission = (0, binary_js_1.readU128LE)(data, o);
659
+ if (permission === null)
660
+ return null;
661
+ const ev = {
662
+ metadata: meta,
663
+ base_fee_data,
664
+ compounding_fee_bps,
665
+ padding,
666
+ dynamic_fee,
667
+ vault_config_key,
668
+ pool_creator_authority,
669
+ activation_type,
670
+ sqrt_min_price,
671
+ sqrt_max_price,
672
+ collect_fee_mode,
673
+ index,
674
+ config,
675
+ permission,
676
+ };
677
+ return { MeteoraDammV2CreateConfig: ev };
678
+ }
679
+ function parseCreateDynamicConfigFromData(data, meta) {
680
+ let o = 0;
681
+ const config = (0, binary_js_1.readPubkey)(data, o);
682
+ if (!config)
683
+ return null;
684
+ o += 32;
685
+ const pool_creator_authority = (0, binary_js_1.readPubkey)(data, o);
686
+ if (!pool_creator_authority)
687
+ return null;
688
+ o += 32;
689
+ const index = (0, binary_js_1.readU64LE)(data, o);
690
+ if (index === null)
691
+ return null;
692
+ o += 8;
693
+ const permission = (0, binary_js_1.readU128LE)(data, o);
694
+ if (permission === null)
695
+ return null;
696
+ const ev = {
697
+ metadata: meta,
698
+ config,
699
+ pool_creator_authority,
700
+ index,
701
+ permission,
702
+ };
703
+ return { MeteoraDammV2CreateDynamicConfig: ev };
704
+ }
342
705
  /**
343
706
  * Meteora DAMM Program data 入口;与 Rust `logs/meteora_damm.rs` 一致。
344
707
  */
@@ -348,20 +711,31 @@ function parseMeteoraDammLog(log, signature, slot, txIndex, blockTimeUs, grpcRec
348
711
  return null;
349
712
  const disc = new DataView(programData.buffer, programData.byteOffset, 8).getBigUint64(0, true);
350
713
  const data = programData.subarray(8);
351
- const meta = (0, metadata_js_1.makeMetadata)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
714
+ const meta = (0, metadata_js_2.makeMetadata)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
352
715
  if (disc === SWAP)
353
716
  return parseSwapEvent(data, meta);
354
717
  if (disc === SWAP2)
355
- return parseSwap2Event(data, meta);
718
+ return parseSwap2FromData(data, meta);
356
719
  if (disc === ADD_LIQUIDITY)
357
- return parseAddLiquidityEvent(data, meta);
720
+ return parseAddLiquidityFromData(data, meta);
358
721
  if (disc === REMOVE_LIQUIDITY)
359
- return parseRemoveLiquidityEvent(data, meta);
722
+ return parseRemoveLiquidityFromData(data, meta);
723
+ if (disc === LIQUIDITY_CHANGE)
724
+ return parseLiquidityChangeFromData(data, meta);
360
725
  if (disc === INITIALIZE_POOL)
361
726
  return parseInitializePoolEvent(data, meta);
362
727
  if (disc === CREATE_POSITION)
363
728
  return parseCreatePositionEvent(data, meta);
364
729
  if (disc === CLOSE_POSITION)
365
730
  return parseClosePositionEvent(data, meta);
731
+ if (disc === UPDATE_DELEGATE_PERMISSION)
732
+ return parseUpdateDelegatePermissionFromData(data, meta);
733
+ if (disc === WITHDRAW_DEAD_LIQUIDITY_REWARD) {
734
+ return parseWithdrawDeadLiquidityRewardFromData(data, meta);
735
+ }
736
+ if (disc === CREATE_CONFIG)
737
+ return parseCreateConfigFromData(data, meta);
738
+ if (disc === CREATE_DYNAMIC_CONFIG)
739
+ return parseCreateDynamicConfigFromData(data, meta);
366
740
  return null;
367
741
  }
@@ -4,4 +4,4 @@ import type { DexEvent } from "../core/dex_event.js";
4
4
  export declare function parseDlmmFromDecoded(programData: Uint8Array, metadata: EventMetadata): DexEvent | null;
5
5
  export declare function parseDlmmEventFromData(discriminator: bigint, data: Uint8Array, metadata: EventMetadata): DexEvent | null;
6
6
  /** 从整行日志解析 */
7
- export declare function parseMeteoraDlmmLog(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
7
+ export declare function parseMeteoraDlmmLog(log: string, signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string): DexEvent | null;
@@ -72,6 +72,11 @@ function parseDlmmEventFromData(discriminator, data, metadata) {
72
72
  const host_fee = bn64((0, binary_js_1.readU64LE)(data, o));
73
73
  const ev = {
74
74
  metadata,
75
+ token_x_mint: (0, dex_event_js_1.defaultPubkey)(),
76
+ token_y_mint: (0, dex_event_js_1.defaultPubkey)(),
77
+ user_token_in: (0, dex_event_js_1.defaultPubkey)(),
78
+ user_token_out: (0, dex_event_js_1.defaultPubkey)(),
79
+ min_amount_out: 0n,
75
80
  pool,
76
81
  from,
77
82
  start_bin_id,
@@ -115,6 +120,11 @@ function parseDlmmEventFromData(discriminator, data, metadata) {
115
120
  const host_fee = bn64((0, binary_js_1.readU64LE)(data, o));
116
121
  const ev = {
117
122
  metadata,
123
+ token_x_mint: (0, dex_event_js_1.defaultPubkey)(),
124
+ token_y_mint: (0, dex_event_js_1.defaultPubkey)(),
125
+ user_token_in: (0, dex_event_js_1.defaultPubkey)(),
126
+ user_token_out: (0, dex_event_js_1.defaultPubkey)(),
127
+ min_amount_out: 0n,
118
128
  pool,
119
129
  from,
120
130
  start_bin_id,
@@ -1,9 +1,9 @@
1
1
  import type { DexEvent } from "../core/dex_event.js";
2
2
  import type { EventTypeFilter } from "../grpc/types.js";
3
- export declare function parseLogOptimized(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, eventTypeFilter: EventTypeFilter | undefined, isCreatedBuy: boolean, recentBlockhash?: Uint8Array, programId?: string): DexEvent | null;
3
+ export declare function parseLogOptimized(log: string, signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string, eventTypeFilter: EventTypeFilter | undefined, isCreatedBuy: boolean, recentBlockhash?: Uint8Array, programId?: string): DexEvent | null;
4
4
  /** 单行日志统一解析;`txIndex` 与 Rust gRPC `parse_logs(..., tx_idx, ...)` / `info.index` 对齐。 */
5
- export declare function parseLogUnified(log: string, signature: string, slot: number, blockTimeUs: number | undefined, txIndex?: number): DexEvent | null;
6
- export declare function parseLogOptimizedWithProgramId(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, eventTypeFilter: EventTypeFilter | undefined, isCreatedBuy: boolean, recentBlockhash: Uint8Array | undefined, programId: string | undefined): DexEvent | null;
5
+ export declare function parseLogUnified(log: string, signature: string, slot: number | bigint | string, blockTimeUs: number | bigint | string | undefined, txIndex?: number | bigint | string): DexEvent | null;
6
+ export declare function parseLogOptimizedWithProgramId(log: string, signature: string, slot: number | bigint | string, txIndex: number | bigint | string, blockTimeUs: number | bigint | string | undefined, grpcRecvUs: number | bigint | string, eventTypeFilter: EventTypeFilter | undefined, isCreatedBuy: boolean, recentBlockhash: Uint8Array | undefined, programId: string | undefined): DexEvent | null;
7
7
  export declare function parseInvokeInfo(log: string): {
8
8
  programId: string;
9
9
  depth: number;
@@ -155,12 +155,25 @@ function discriminatorToEventType(disc) {
155
155
  return "MeteoraDammV2AddLiquidity";
156
156
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_REMOVE_LIQUIDITY)
157
157
  return "MeteoraDammV2RemoveLiquidity";
158
+ // Unified add/remove disc; public type selected after decode via change_type.
159
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_LIQUIDITY_CHANGE)
160
+ return null;
158
161
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_INITIALIZE_POOL)
159
162
  return "MeteoraDammV2InitializePool";
160
163
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_POSITION)
161
164
  return "MeteoraDammV2CreatePosition";
162
165
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CLOSE_POSITION)
163
166
  return "MeteoraDammV2ClosePosition";
167
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_UPDATE_DELEGATE_PERMISSION) {
168
+ return "MeteoraDammV2UpdateDelegatePermission";
169
+ }
170
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_WITHDRAW_DEAD_LIQUIDITY_REWARD) {
171
+ return "MeteoraDammV2WithdrawDeadLiquidityReward";
172
+ }
173
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_CONFIG)
174
+ return "MeteoraDammV2CreateConfig";
175
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_DYNAMIC_CONFIG)
176
+ return "MeteoraDammV2CreateDynamicConfig";
164
177
  return null;
165
178
  }
166
179
  function programScopedDiscriminatorToEventType(programId, disc) {
@@ -307,12 +320,24 @@ function programScopedDiscriminatorToEventType(programId, disc) {
307
320
  return "MeteoraDammV2AddLiquidity";
308
321
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_REMOVE_LIQUIDITY)
309
322
  return "MeteoraDammV2RemoveLiquidity";
323
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_LIQUIDITY_CHANGE)
324
+ return null;
310
325
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_INITIALIZE_POOL)
311
326
  return "MeteoraDammV2InitializePool";
312
327
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_POSITION)
313
328
  return "MeteoraDammV2CreatePosition";
314
329
  if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CLOSE_POSITION)
315
330
  return "MeteoraDammV2ClosePosition";
331
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_UPDATE_DELEGATE_PERMISSION) {
332
+ return "MeteoraDammV2UpdateDelegatePermission";
333
+ }
334
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_WITHDRAW_DEAD_LIQUIDITY_REWARD) {
335
+ return "MeteoraDammV2WithdrawDeadLiquidityReward";
336
+ }
337
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_CONFIG)
338
+ return "MeteoraDammV2CreateConfig";
339
+ if (disc === program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_DYNAMIC_CONFIG)
340
+ return "MeteoraDammV2CreateDynamicConfig";
316
341
  return null;
317
342
  }
318
343
  if (programId === program_ids_js_1.METEORA_DBC_PROGRAM_ID) {
@@ -476,6 +501,10 @@ function filterIncludesProgram(programId, filter) {
476
501
  "MeteoraDammV2InitializePool",
477
502
  "MeteoraDammV2CreatePosition",
478
503
  "MeteoraDammV2ClosePosition",
504
+ "MeteoraDammV2UpdateDelegatePermission",
505
+ "MeteoraDammV2WithdrawDeadLiquidityReward",
506
+ "MeteoraDammV2CreateConfig",
507
+ "MeteoraDammV2CreateDynamicConfig",
479
508
  ]);
480
509
  }
481
510
  if (programId === program_ids_js_1.METEORA_DBC_PROGRAM_ID) {
@@ -897,10 +926,15 @@ function parseLogOptimized(log, signature, slot, txIndex, blockTimeUs, grpcRecvU
897
926
  case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_SWAP2:
898
927
  case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_ADD_LIQUIDITY:
899
928
  case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_REMOVE_LIQUIDITY:
929
+ case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_LIQUIDITY_CHANGE:
900
930
  case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_INITIALIZE_POOL:
901
931
  case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_POSITION:
902
932
  case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CLOSE_POSITION:
903
- return (0, meteora_damm_js_1.parseMeteoraDammLog)(log, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
933
+ case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_UPDATE_DELEGATE_PERMISSION:
934
+ case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_WITHDRAW_DEAD_LIQUIDITY_REWARD:
935
+ case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_CONFIG:
936
+ case program_log_discriminators_js_1.PROGRAM_LOG_DISC.METEORA_DAMM_CREATE_DYNAMIC_CONFIG:
937
+ return applyActualEventTypeFilter((0, meteora_damm_js_1.parseMeteoraDammLog)(log, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
904
938
  default: {
905
939
  const raydium_launchlab = (0, raydium_launchlab_js_1.parseRaydiumLaunchlabFromDiscriminator)(disc, data, metadata);
906
940
  if (raydium_launchlab)
@@ -74,8 +74,13 @@ export declare const PROGRAM_LOG_DISC: {
74
74
  readonly METEORA_DAMM_SWAP2: bigint;
75
75
  readonly METEORA_DAMM_ADD_LIQUIDITY: bigint;
76
76
  readonly METEORA_DAMM_REMOVE_LIQUIDITY: bigint;
77
+ readonly METEORA_DAMM_LIQUIDITY_CHANGE: bigint;
77
78
  readonly METEORA_DAMM_INITIALIZE_POOL: bigint;
78
79
  readonly METEORA_DAMM_CREATE_POSITION: bigint;
79
80
  readonly METEORA_DAMM_CLOSE_POSITION: bigint;
81
+ readonly METEORA_DAMM_UPDATE_DELEGATE_PERMISSION: bigint;
82
+ readonly METEORA_DAMM_WITHDRAW_DEAD_LIQUIDITY_REWARD: bigint;
83
+ readonly METEORA_DAMM_CREATE_CONFIG: bigint;
84
+ readonly METEORA_DAMM_CREATE_DYNAMIC_CONFIG: bigint;
80
85
  };
81
86
  export type ProgramLogDiscriminatorKey = keyof typeof PROGRAM_LOG_DISC;
@@ -84,7 +84,12 @@ exports.PROGRAM_LOG_DISC = {
84
84
  METEORA_DAMM_SWAP2: u64leDiscriminator([189, 66, 51, 168, 38, 80, 117, 153]),
85
85
  METEORA_DAMM_ADD_LIQUIDITY: u64leDiscriminator([175, 242, 8, 157, 30, 247, 185, 169]),
86
86
  METEORA_DAMM_REMOVE_LIQUIDITY: u64leDiscriminator([87, 46, 88, 98, 175, 96, 34, 91]),
87
+ METEORA_DAMM_LIQUIDITY_CHANGE: u64leDiscriminator([197, 171, 78, 127, 224, 211, 87, 13]),
87
88
  METEORA_DAMM_INITIALIZE_POOL: u64leDiscriminator([228, 50, 246, 85, 203, 66, 134, 37]),
88
89
  METEORA_DAMM_CREATE_POSITION: u64leDiscriminator([156, 15, 119, 198, 29, 181, 221, 55]),
89
90
  METEORA_DAMM_CLOSE_POSITION: u64leDiscriminator([20, 145, 144, 68, 143, 142, 214, 178]),
91
+ METEORA_DAMM_UPDATE_DELEGATE_PERMISSION: u64leDiscriminator([66, 188, 75, 151, 150, 232, 87, 93]),
92
+ METEORA_DAMM_WITHDRAW_DEAD_LIQUIDITY_REWARD: u64leDiscriminator([228, 66, 150, 195, 42, 62, 163, 13]),
93
+ METEORA_DAMM_CREATE_CONFIG: u64leDiscriminator([131, 207, 180, 174, 180, 73, 165, 54]),
94
+ METEORA_DAMM_CREATE_DYNAMIC_CONFIG: u64leDiscriminator([231, 197, 13, 164, 248, 213, 133, 152]),
90
95
  };