sol-parser-sdk-nodejs 0.3.0

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +449 -0
  3. package/README_CN.md +343 -0
  4. package/dist/accounts/mod.d.ts +11 -0
  5. package/dist/accounts/mod.js +53 -0
  6. package/dist/accounts/nonce.d.ts +5 -0
  7. package/dist/accounts/nonce.js +32 -0
  8. package/dist/accounts/pumpswap.d.ts +8 -0
  9. package/dist/accounts/pumpswap.js +192 -0
  10. package/dist/accounts/token.d.ts +5 -0
  11. package/dist/accounts/token.js +98 -0
  12. package/dist/accounts/types.d.ts +9 -0
  13. package/dist/accounts/types.js +2 -0
  14. package/dist/accounts/utils.d.ts +1 -0
  15. package/dist/accounts/utils.js +12 -0
  16. package/dist/core/account_dispatcher_rpc.d.ts +11 -0
  17. package/dist/core/account_dispatcher_rpc.js +155 -0
  18. package/dist/core/account_fill_bonk.d.ts +4 -0
  19. package/dist/core/account_fill_bonk.js +20 -0
  20. package/dist/core/account_fill_meteora.d.ts +14 -0
  21. package/dist/core/account_fill_meteora.js +26 -0
  22. package/dist/core/account_fill_orca.d.ts +5 -0
  23. package/dist/core/account_fill_orca.js +18 -0
  24. package/dist/core/account_fill_pumpfun.d.ts +7 -0
  25. package/dist/core/account_fill_pumpfun.js +75 -0
  26. package/dist/core/account_fill_pumpswap.d.ts +10 -0
  27. package/dist/core/account_fill_pumpswap.js +78 -0
  28. package/dist/core/account_fill_raydium.d.ts +20 -0
  29. package/dist/core/account_fill_raydium.js +104 -0
  30. package/dist/core/clock.d.ts +2 -0
  31. package/dist/core/clock.js +7 -0
  32. package/dist/core/common_filler_rpc.d.ts +6 -0
  33. package/dist/core/common_filler_rpc.js +21 -0
  34. package/dist/core/dex_event.d.ts +1009 -0
  35. package/dist/core/dex_event.js +14 -0
  36. package/dist/core/error.d.ts +43 -0
  37. package/dist/core/error.js +16 -0
  38. package/dist/core/json_utils.d.ts +8 -0
  39. package/dist/core/json_utils.js +18 -0
  40. package/dist/core/metadata.d.ts +10 -0
  41. package/dist/core/metadata.js +13 -0
  42. package/dist/core/rpc_invoke_map.d.ts +23 -0
  43. package/dist/core/rpc_invoke_map.js +157 -0
  44. package/dist/core/unified_parser.d.ts +19 -0
  45. package/dist/core/unified_parser.js +48 -0
  46. package/dist/grpc/client.d.ts +52 -0
  47. package/dist/grpc/client.js +309 -0
  48. package/dist/grpc/client_stub.d.ts +5 -0
  49. package/dist/grpc/client_stub.js +5 -0
  50. package/dist/grpc/types.d.ts +132 -0
  51. package/dist/grpc/types.js +304 -0
  52. package/dist/grpc/yellowstone_parse.d.ts +9 -0
  53. package/dist/grpc/yellowstone_parse.js +46 -0
  54. package/dist/index.d.ts +18 -0
  55. package/dist/index.js +99 -0
  56. package/dist/instr/bonk_ix.d.ts +5 -0
  57. package/dist/instr/bonk_ix.js +52 -0
  58. package/dist/instr/meteora_damm_ix.d.ts +6 -0
  59. package/dist/instr/meteora_damm_ix.js +349 -0
  60. package/dist/instr/mod.d.ts +15 -0
  61. package/dist/instr/mod.js +95 -0
  62. package/dist/instr/orca_whirlpool_ix.d.ts +5 -0
  63. package/dist/instr/orca_whirlpool_ix.js +73 -0
  64. package/dist/instr/program_ids.d.ts +14 -0
  65. package/dist/instr/program_ids.js +18 -0
  66. package/dist/instr/pumpfun_ix.d.ts +5 -0
  67. package/dist/instr/pumpfun_ix.js +167 -0
  68. package/dist/instr/pumpswap_ix.d.ts +5 -0
  69. package/dist/instr/pumpswap_ix.js +215 -0
  70. package/dist/instr/raydium_amm_v4_ix.d.ts +6 -0
  71. package/dist/instr/raydium_amm_v4_ix.js +46 -0
  72. package/dist/instr/raydium_clmm_ix.d.ts +5 -0
  73. package/dist/instr/raydium_clmm_ix.js +85 -0
  74. package/dist/instr/raydium_cpmm_ix.d.ts +5 -0
  75. package/dist/instr/raydium_cpmm_ix.js +63 -0
  76. package/dist/instr/utils.d.ts +10 -0
  77. package/dist/instr/utils.js +33 -0
  78. package/dist/logs/meteora_amm.d.ts +8 -0
  79. package/dist/logs/meteora_amm.js +113 -0
  80. package/dist/logs/meteora_damm.d.ts +6 -0
  81. package/dist/logs/meteora_damm.js +509 -0
  82. package/dist/logs/meteora_dlmm.d.ts +6 -0
  83. package/dist/logs/meteora_dlmm.js +201 -0
  84. package/dist/logs/optimized_matcher.d.ts +5 -0
  85. package/dist/logs/optimized_matcher.js +194 -0
  86. package/dist/logs/orca.d.ts +6 -0
  87. package/dist/logs/orca.js +148 -0
  88. package/dist/logs/program_data.d.ts +2 -0
  89. package/dist/logs/program_data.js +22 -0
  90. package/dist/logs/program_log_discriminators.d.ts +59 -0
  91. package/dist/logs/program_log_discriminators.js +67 -0
  92. package/dist/logs/pump.d.ts +12 -0
  93. package/dist/logs/pump.js +251 -0
  94. package/dist/logs/pump_amm.d.ts +9 -0
  95. package/dist/logs/pump_amm.js +418 -0
  96. package/dist/logs/raydium_amm.d.ts +9 -0
  97. package/dist/logs/raydium_amm.js +224 -0
  98. package/dist/logs/raydium_clmm.d.ts +8 -0
  99. package/dist/logs/raydium_clmm.js +141 -0
  100. package/dist/logs/raydium_cpmm.d.ts +7 -0
  101. package/dist/logs/raydium_cpmm.js +121 -0
  102. package/dist/logs/raydium_launchpad.d.ts +12 -0
  103. package/dist/logs/raydium_launchpad.js +92 -0
  104. package/dist/parser_alias.d.ts +3 -0
  105. package/dist/parser_alias.js +2 -0
  106. package/dist/rpc_parser.d.ts +16 -0
  107. package/dist/rpc_parser.js +36 -0
  108. package/dist/rpc_transaction.d.ts +25 -0
  109. package/dist/rpc_transaction.js +111 -0
  110. package/dist/util/binary.d.ts +14 -0
  111. package/dist/util/binary.js +82 -0
  112. package/dist/warmup.d.ts +3 -0
  113. package/dist/warmup.js +23 -0
  114. package/package.json +44 -0
@@ -0,0 +1,349 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseMeteoraDammInstruction = parseMeteoraDammInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const meteora_damm_js_1 = require("../logs/meteora_damm.js");
6
+ const utils_js_1 = require("./utils.js");
7
+ const Z = (0, dex_event_js_1.defaultPubkey)();
8
+ function disc8(a) {
9
+ return Uint8Array.from(a);
10
+ }
11
+ const CPI = {
12
+ SWAP_LOG: disc8([27, 60, 21, 213, 138, 170, 187, 147]),
13
+ SWAP2_LOG: disc8([189, 66, 51, 168, 38, 80, 117, 153]),
14
+ CREATE_POSITION_LOG: disc8([156, 15, 119, 198, 29, 181, 221, 55]),
15
+ CLOSE_POSITION_LOG: disc8([20, 145, 144, 68, 143, 142, 214, 178]),
16
+ ADD_LIQUIDITY_LOG: disc8([175, 242, 8, 157, 30, 247, 185, 169]),
17
+ REMOVE_LIQUIDITY_LOG: disc8([87, 46, 88, 98, 175, 96, 34, 91]),
18
+ INITIALIZE_POOL_LOG: disc8([228, 50, 246, 85, 203, 66, 134, 37]),
19
+ };
20
+ function discEq(h, d) {
21
+ for (let i = 0; i < 8; i++)
22
+ if (h[i] !== d[i])
23
+ return false;
24
+ return true;
25
+ }
26
+ function vaults() {
27
+ return {
28
+ token_a_vault: Z,
29
+ token_b_vault: Z,
30
+ token_a_mint: Z,
31
+ token_b_mint: Z,
32
+ token_a_program: Z,
33
+ token_b_program: Z,
34
+ };
35
+ }
36
+ function parseSwapCpi(data, meta) {
37
+ let o = 0;
38
+ const pool = (0, utils_js_1.readPubkeyIx)(data, o);
39
+ if (!pool)
40
+ return null;
41
+ o += 32;
42
+ const trade_direction = (0, utils_js_1.readU8)(data, o);
43
+ if (trade_direction === null)
44
+ return null;
45
+ o += 1;
46
+ const has_referral = (0, utils_js_1.readBool)(data, o);
47
+ if (has_referral === null)
48
+ return null;
49
+ o += 1;
50
+ const amount_in = (0, utils_js_1.readU64LE)(data, o);
51
+ if (amount_in === null)
52
+ return null;
53
+ o += 8;
54
+ const min_out = (0, utils_js_1.readU64LE)(data, o);
55
+ if (min_out === null)
56
+ return null;
57
+ o += 8;
58
+ const output_amount = (0, utils_js_1.readU64LE)(data, o);
59
+ if (output_amount === null)
60
+ return null;
61
+ o += 8;
62
+ const next_sqrt_price = (0, utils_js_1.readU128LE)(data, o);
63
+ if (next_sqrt_price === null)
64
+ return null;
65
+ o += 16;
66
+ const lp_fee = (0, utils_js_1.readU64LE)(data, o);
67
+ if (lp_fee === null)
68
+ return null;
69
+ o += 8;
70
+ const protocol_fee = (0, utils_js_1.readU64LE)(data, o);
71
+ if (protocol_fee === null)
72
+ return null;
73
+ o += 8;
74
+ const partner_fee = (0, utils_js_1.readU64LE)(data, o);
75
+ if (partner_fee === null)
76
+ return null;
77
+ o += 8;
78
+ const referral_fee = (0, utils_js_1.readU64LE)(data, o);
79
+ if (referral_fee === null)
80
+ return null;
81
+ o += 8;
82
+ const actual_amount_in = (0, utils_js_1.readU64LE)(data, o);
83
+ if (actual_amount_in === null)
84
+ return null;
85
+ o += 8;
86
+ const current_timestamp = (0, utils_js_1.readU64LE)(data, o);
87
+ if (current_timestamp === null)
88
+ return null;
89
+ const ev = {
90
+ metadata: meta,
91
+ pool,
92
+ trade_direction,
93
+ has_referral,
94
+ amount_in,
95
+ minimum_amount_out: min_out,
96
+ output_amount,
97
+ next_sqrt_price,
98
+ lp_fee,
99
+ protocol_fee,
100
+ partner_fee,
101
+ referral_fee,
102
+ actual_amount_in,
103
+ current_timestamp,
104
+ ...vaults(),
105
+ };
106
+ return { MeteoraDammV2Swap: ev };
107
+ }
108
+ function parseSwap2Cpi(data, meta) {
109
+ let o = 0;
110
+ const pool = (0, utils_js_1.readPubkeyIx)(data, o);
111
+ if (!pool)
112
+ return null;
113
+ o += 32;
114
+ const trade_direction = (0, utils_js_1.readU8)(data, o);
115
+ if (trade_direction === null)
116
+ return null;
117
+ o += 1;
118
+ const _cfm = (0, utils_js_1.readU8)(data, o);
119
+ if (_cfm === null)
120
+ return null;
121
+ o += 1;
122
+ const has_referral = (0, utils_js_1.readBool)(data, o);
123
+ if (has_referral === null)
124
+ return null;
125
+ o += 1;
126
+ const amount_0 = (0, utils_js_1.readU64LE)(data, o);
127
+ if (amount_0 === null)
128
+ return null;
129
+ o += 8;
130
+ const amount_1 = (0, utils_js_1.readU64LE)(data, o);
131
+ if (amount_1 === null)
132
+ return null;
133
+ o += 8;
134
+ const swap_mode = (0, utils_js_1.readU8)(data, o);
135
+ if (swap_mode === null)
136
+ return null;
137
+ o += 1;
138
+ const included_fee_input_amount = (0, utils_js_1.readU64LE)(data, o);
139
+ if (included_fee_input_amount === null)
140
+ return null;
141
+ o += 8;
142
+ o += 8;
143
+ o += 8;
144
+ const output_amount = (0, utils_js_1.readU64LE)(data, o);
145
+ if (output_amount === null)
146
+ return null;
147
+ o += 8;
148
+ const next_sqrt_price = (0, utils_js_1.readU128LE)(data, o);
149
+ if (next_sqrt_price === null)
150
+ return null;
151
+ o += 16;
152
+ const lp_fee = (0, utils_js_1.readU64LE)(data, o);
153
+ if (lp_fee === null)
154
+ return null;
155
+ o += 8;
156
+ const protocol_fee = (0, utils_js_1.readU64LE)(data, o);
157
+ if (protocol_fee === null)
158
+ return null;
159
+ o += 8;
160
+ const referral_fee = (0, utils_js_1.readU64LE)(data, o);
161
+ if (referral_fee === null)
162
+ return null;
163
+ o += 8;
164
+ o += 8;
165
+ o += 8;
166
+ const current_timestamp = (0, utils_js_1.readU64LE)(data, o);
167
+ if (current_timestamp === null)
168
+ return null;
169
+ const [amount_in, minimum_amount_out] = swap_mode === 0 ? [amount_0, amount_1] : [amount_1, amount_0];
170
+ const ev = {
171
+ metadata: meta,
172
+ pool,
173
+ trade_direction,
174
+ has_referral,
175
+ amount_in,
176
+ minimum_amount_out,
177
+ output_amount,
178
+ next_sqrt_price,
179
+ lp_fee,
180
+ protocol_fee,
181
+ partner_fee: 0n,
182
+ referral_fee,
183
+ actual_amount_in: included_fee_input_amount,
184
+ current_timestamp,
185
+ ...vaults(),
186
+ };
187
+ return { MeteoraDammV2Swap: ev };
188
+ }
189
+ function parseMeteoraDammInstruction(instructionData, _accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
190
+ if (instructionData.length < 16)
191
+ return null;
192
+ const cpiHead = instructionData.subarray(8, 16);
193
+ const cpiData = instructionData.subarray(16);
194
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
195
+ if (discEq(cpiHead, CPI.SWAP_LOG))
196
+ return parseSwapCpi(cpiData, meta);
197
+ if (discEq(cpiHead, CPI.SWAP2_LOG))
198
+ return parseSwap2Cpi(cpiData, meta);
199
+ if (discEq(cpiHead, CPI.CREATE_POSITION_LOG)) {
200
+ let o = 0;
201
+ const pool = (0, utils_js_1.readPubkeyIx)(cpiData, o);
202
+ if (!pool)
203
+ return null;
204
+ o += 32;
205
+ const owner = (0, utils_js_1.readPubkeyIx)(cpiData, o);
206
+ if (!owner)
207
+ return null;
208
+ o += 32;
209
+ const position = (0, utils_js_1.readPubkeyIx)(cpiData, o);
210
+ if (!position)
211
+ return null;
212
+ o += 32;
213
+ const position_nft_mint = (0, utils_js_1.readPubkeyIx)(cpiData, o);
214
+ if (!position_nft_mint)
215
+ return null;
216
+ return {
217
+ MeteoraDammV2CreatePosition: { metadata: meta, pool, owner, position, position_nft_mint },
218
+ };
219
+ }
220
+ if (discEq(cpiHead, CPI.CLOSE_POSITION_LOG)) {
221
+ let o = 0;
222
+ const pool = (0, utils_js_1.readPubkeyIx)(cpiData, o);
223
+ if (!pool)
224
+ return null;
225
+ o += 32;
226
+ const owner = (0, utils_js_1.readPubkeyIx)(cpiData, o);
227
+ if (!owner)
228
+ return null;
229
+ o += 32;
230
+ const position = (0, utils_js_1.readPubkeyIx)(cpiData, o);
231
+ if (!position)
232
+ return null;
233
+ o += 32;
234
+ const position_nft_mint = (0, utils_js_1.readPubkeyIx)(cpiData, o);
235
+ if (!position_nft_mint)
236
+ return null;
237
+ return {
238
+ MeteoraDammV2ClosePosition: { metadata: meta, pool, owner, position, position_nft_mint },
239
+ };
240
+ }
241
+ if (discEq(cpiHead, CPI.ADD_LIQUIDITY_LOG)) {
242
+ let o = 0;
243
+ const pool = (0, utils_js_1.readPubkeyIx)(cpiData, o);
244
+ if (!pool)
245
+ return null;
246
+ o += 32;
247
+ const position = (0, utils_js_1.readPubkeyIx)(cpiData, o);
248
+ if (!position)
249
+ return null;
250
+ o += 32;
251
+ const owner = (0, utils_js_1.readPubkeyIx)(cpiData, o);
252
+ if (!owner)
253
+ return null;
254
+ o += 32;
255
+ const liquidity_delta = (0, utils_js_1.readU128LE)(cpiData, o);
256
+ if (liquidity_delta === null)
257
+ return null;
258
+ o += 16;
259
+ const token_a_amount_threshold = (0, utils_js_1.readU64LE)(cpiData, o);
260
+ if (token_a_amount_threshold === null)
261
+ return null;
262
+ o += 8;
263
+ const token_b_amount_threshold = (0, utils_js_1.readU64LE)(cpiData, o);
264
+ if (token_b_amount_threshold === null)
265
+ return null;
266
+ o += 8;
267
+ const token_a_amount = (0, utils_js_1.readU64LE)(cpiData, o);
268
+ if (token_a_amount === null)
269
+ return null;
270
+ o += 8;
271
+ const token_b_amount = (0, utils_js_1.readU64LE)(cpiData, o);
272
+ if (token_b_amount === null)
273
+ return null;
274
+ o += 8;
275
+ const total_amount_a = (0, utils_js_1.readU64LE)(cpiData, o);
276
+ if (total_amount_a === null)
277
+ return null;
278
+ o += 8;
279
+ const total_amount_b = (0, utils_js_1.readU64LE)(cpiData, o);
280
+ if (total_amount_b === null)
281
+ return null;
282
+ return {
283
+ MeteoraDammV2AddLiquidity: {
284
+ metadata: meta,
285
+ pool,
286
+ position,
287
+ owner,
288
+ liquidity_delta,
289
+ token_a_amount_threshold,
290
+ token_b_amount_threshold,
291
+ token_a_amount,
292
+ token_b_amount,
293
+ total_amount_a,
294
+ total_amount_b,
295
+ },
296
+ };
297
+ }
298
+ if (discEq(cpiHead, CPI.REMOVE_LIQUIDITY_LOG)) {
299
+ let o = 0;
300
+ const pool = (0, utils_js_1.readPubkeyIx)(cpiData, o);
301
+ if (!pool)
302
+ return null;
303
+ o += 32;
304
+ const position = (0, utils_js_1.readPubkeyIx)(cpiData, o);
305
+ if (!position)
306
+ return null;
307
+ o += 32;
308
+ const owner = (0, utils_js_1.readPubkeyIx)(cpiData, o);
309
+ if (!owner)
310
+ return null;
311
+ o += 32;
312
+ const liquidity_delta = (0, utils_js_1.readU128LE)(cpiData, o);
313
+ if (liquidity_delta === null)
314
+ return null;
315
+ o += 16;
316
+ const token_a_amount_threshold = (0, utils_js_1.readU64LE)(cpiData, o);
317
+ if (token_a_amount_threshold === null)
318
+ return null;
319
+ o += 8;
320
+ const token_b_amount_threshold = (0, utils_js_1.readU64LE)(cpiData, o);
321
+ if (token_b_amount_threshold === null)
322
+ return null;
323
+ o += 8;
324
+ const token_a_amount = (0, utils_js_1.readU64LE)(cpiData, o);
325
+ if (token_a_amount === null)
326
+ return null;
327
+ o += 8;
328
+ const token_b_amount = (0, utils_js_1.readU64LE)(cpiData, o);
329
+ if (token_b_amount === null)
330
+ return null;
331
+ return {
332
+ MeteoraDammV2RemoveLiquidity: {
333
+ metadata: meta,
334
+ pool,
335
+ position,
336
+ owner,
337
+ liquidity_delta,
338
+ token_a_amount_threshold,
339
+ token_b_amount_threshold,
340
+ token_a_amount,
341
+ token_b_amount,
342
+ },
343
+ };
344
+ }
345
+ if (discEq(cpiHead, CPI.INITIALIZE_POOL_LOG)) {
346
+ return (0, meteora_damm_js_1.parseInitializePoolEvent)(cpiData, meta);
347
+ }
348
+ return null;
349
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 指令解析统一入口
3
+ */
4
+ import type { DexEvent } from "../core/dex_event.js";
5
+ import type { EventTypeFilter } from "../grpc/types.js";
6
+ export { parsePumpfunInstruction } from "./pumpfun_ix.js";
7
+ export { parsePumpswapInstruction } from "./pumpswap_ix.js";
8
+ export { parseMeteoraDammInstruction } from "./meteora_damm_ix.js";
9
+ export { parseRaydiumClmmInstruction } from "./raydium_clmm_ix.js";
10
+ export { parseRaydiumCpmmInstruction } from "./raydium_cpmm_ix.js";
11
+ export { parseRaydiumAmmV4Instruction } from "./raydium_amm_v4_ix.js";
12
+ export { parseOrcaWhirlpoolInstruction } from "./orca_whirlpool_ix.js";
13
+ export { parseBonkInstruction } from "./bonk_ix.js";
14
+ export * from "./program_ids.js";
15
+ export declare function parseInstructionUnified(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number, eventTypeFilter: EventTypeFilter | undefined, programId: string): DexEvent | null;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.parseBonkInstruction = exports.parseOrcaWhirlpoolInstruction = exports.parseRaydiumAmmV4Instruction = exports.parseRaydiumCpmmInstruction = exports.parseRaydiumClmmInstruction = exports.parseMeteoraDammInstruction = exports.parsePumpswapInstruction = exports.parsePumpfunInstruction = void 0;
18
+ exports.parseInstructionUnified = parseInstructionUnified;
19
+ const types_js_1 = require("../grpc/types.js");
20
+ const program_ids_js_1 = require("./program_ids.js");
21
+ const pumpfun_ix_js_1 = require("./pumpfun_ix.js");
22
+ const pumpswap_ix_js_1 = require("./pumpswap_ix.js");
23
+ const meteora_damm_ix_js_1 = require("./meteora_damm_ix.js");
24
+ const raydium_clmm_ix_js_1 = require("./raydium_clmm_ix.js");
25
+ const raydium_cpmm_ix_js_1 = require("./raydium_cpmm_ix.js");
26
+ const raydium_amm_v4_ix_js_1 = require("./raydium_amm_v4_ix.js");
27
+ const orca_whirlpool_ix_js_1 = require("./orca_whirlpool_ix.js");
28
+ const bonk_ix_js_1 = require("./bonk_ix.js");
29
+ var pumpfun_ix_js_2 = require("./pumpfun_ix.js");
30
+ Object.defineProperty(exports, "parsePumpfunInstruction", { enumerable: true, get: function () { return pumpfun_ix_js_2.parsePumpfunInstruction; } });
31
+ var pumpswap_ix_js_2 = require("./pumpswap_ix.js");
32
+ Object.defineProperty(exports, "parsePumpswapInstruction", { enumerable: true, get: function () { return pumpswap_ix_js_2.parsePumpswapInstruction; } });
33
+ var meteora_damm_ix_js_2 = require("./meteora_damm_ix.js");
34
+ Object.defineProperty(exports, "parseMeteoraDammInstruction", { enumerable: true, get: function () { return meteora_damm_ix_js_2.parseMeteoraDammInstruction; } });
35
+ var raydium_clmm_ix_js_2 = require("./raydium_clmm_ix.js");
36
+ Object.defineProperty(exports, "parseRaydiumClmmInstruction", { enumerable: true, get: function () { return raydium_clmm_ix_js_2.parseRaydiumClmmInstruction; } });
37
+ var raydium_cpmm_ix_js_2 = require("./raydium_cpmm_ix.js");
38
+ Object.defineProperty(exports, "parseRaydiumCpmmInstruction", { enumerable: true, get: function () { return raydium_cpmm_ix_js_2.parseRaydiumCpmmInstruction; } });
39
+ var raydium_amm_v4_ix_js_2 = require("./raydium_amm_v4_ix.js");
40
+ Object.defineProperty(exports, "parseRaydiumAmmV4Instruction", { enumerable: true, get: function () { return raydium_amm_v4_ix_js_2.parseRaydiumAmmV4Instruction; } });
41
+ var orca_whirlpool_ix_js_2 = require("./orca_whirlpool_ix.js");
42
+ Object.defineProperty(exports, "parseOrcaWhirlpoolInstruction", { enumerable: true, get: function () { return orca_whirlpool_ix_js_2.parseOrcaWhirlpoolInstruction; } });
43
+ var bonk_ix_js_2 = require("./bonk_ix.js");
44
+ Object.defineProperty(exports, "parseBonkInstruction", { enumerable: true, get: function () { return bonk_ix_js_2.parseBonkInstruction; } });
45
+ __exportStar(require("./program_ids.js"), exports);
46
+ function parseInstructionUnified(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs, eventTypeFilter, programId) {
47
+ if (instructionData.length === 0)
48
+ return null;
49
+ if (eventTypeFilter?.include_only) {
50
+ if (!(0, types_js_1.eventTypeFilterAllowsInstructionParsing)(eventTypeFilter.include_only)) {
51
+ return null;
52
+ }
53
+ }
54
+ if (programId === program_ids_js_1.PUMPFUN_PROGRAM_ID) {
55
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesPumpfun)(eventTypeFilter))
56
+ return null;
57
+ return (0, pumpfun_ix_js_1.parsePumpfunInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
58
+ }
59
+ if (programId === program_ids_js_1.PUMPSWAP_PROGRAM_ID) {
60
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesPumpswap)(eventTypeFilter))
61
+ return null;
62
+ return (0, pumpswap_ix_js_1.parsePumpswapInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs);
63
+ }
64
+ if (programId === program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID) {
65
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesMeteoraDammV2)(eventTypeFilter))
66
+ return null;
67
+ return (0, meteora_damm_ix_js_1.parseMeteoraDammInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
68
+ }
69
+ if (programId === program_ids_js_1.RAYDIUM_CLMM_PROGRAM_ID) {
70
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesRaydiumClmm)(eventTypeFilter))
71
+ return null;
72
+ return (0, raydium_clmm_ix_js_1.parseRaydiumClmmInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
73
+ }
74
+ if (programId === program_ids_js_1.RAYDIUM_CPMM_PROGRAM_ID) {
75
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesRaydiumCpmm)(eventTypeFilter))
76
+ return null;
77
+ return (0, raydium_cpmm_ix_js_1.parseRaydiumCpmmInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
78
+ }
79
+ if (programId === program_ids_js_1.RAYDIUM_AMM_V4_PROGRAM_ID) {
80
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesRaydiumAmmV4)(eventTypeFilter))
81
+ return null;
82
+ return (0, raydium_amm_v4_ix_js_1.parseRaydiumAmmV4Instruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
83
+ }
84
+ if (programId === program_ids_js_1.ORCA_WHIRLPOOL_PROGRAM_ID) {
85
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesOrcaWhirlpool)(eventTypeFilter))
86
+ return null;
87
+ return (0, orca_whirlpool_ix_js_1.parseOrcaWhirlpoolInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
88
+ }
89
+ if (programId === program_ids_js_1.BONK_LAUNCHPAD_PROGRAM_ID) {
90
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesBonk)(eventTypeFilter))
91
+ return null;
92
+ return (0, bonk_ix_js_1.parseBonkInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs);
93
+ }
94
+ return null;
95
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Orca Whirlpool 指令解析
3
+ */
4
+ import type { DexEvent } from "../core/dex_event.js";
5
+ export declare function parseOrcaWhirlpoolInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOrcaWhirlpoolInstruction = parseOrcaWhirlpoolInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const utils_js_1 = require("./utils.js");
6
+ const Z = (0, dex_event_js_1.defaultPubkey)();
7
+ // Discriminators (little-endian u64)
8
+ const DISC = {
9
+ SWAP: 10853759504616839521n, // disc8(225, 202, 73, 175, 147, 43, 160, 150)
10
+ INCREASE_LIQUIDITY: 11605574446925869086n, // disc8(30, 7, 144, 181, 102, 254, 155, 161)
11
+ DECREASE_LIQUIDITY: 12404363784710077478n, // disc8(166, 1, 36, 71, 112, 202, 181, 171)
12
+ };
13
+ function discEq(data, disc) {
14
+ if (data.length < 8)
15
+ return false;
16
+ const v = (0, utils_js_1.readU64LE)(data, 0);
17
+ return v === disc;
18
+ }
19
+ function parseOrcaWhirlpoolInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
20
+ if (instructionData.length < 8)
21
+ return null;
22
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
23
+ if (discEq(instructionData, DISC.SWAP)) {
24
+ return {
25
+ OrcaWhirlpoolSwap: {
26
+ metadata: meta,
27
+ whirlpool: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
28
+ a_to_b: true,
29
+ pre_sqrt_price: 0n,
30
+ post_sqrt_price: 0n,
31
+ input_amount: 0n,
32
+ output_amount: 0n,
33
+ input_transfer_fee: 0n,
34
+ output_transfer_fee: 0n,
35
+ lp_fee: 0n,
36
+ protocol_fee: 0n,
37
+ },
38
+ };
39
+ }
40
+ if (discEq(instructionData, DISC.INCREASE_LIQUIDITY)) {
41
+ return {
42
+ OrcaWhirlpoolLiquidityIncreased: {
43
+ metadata: meta,
44
+ whirlpool: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
45
+ position: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
46
+ tick_lower_index: 0,
47
+ tick_upper_index: 0,
48
+ liquidity: 0n,
49
+ token_a_amount: 0n,
50
+ token_b_amount: 0n,
51
+ token_a_transfer_fee: 0n,
52
+ token_b_transfer_fee: 0n,
53
+ },
54
+ };
55
+ }
56
+ if (discEq(instructionData, DISC.DECREASE_LIQUIDITY)) {
57
+ return {
58
+ OrcaWhirlpoolLiquidityDecreased: {
59
+ metadata: meta,
60
+ whirlpool: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
61
+ position: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
62
+ tick_lower_index: 0,
63
+ tick_upper_index: 0,
64
+ liquidity: 0n,
65
+ token_a_amount: 0n,
66
+ token_b_amount: 0n,
67
+ token_a_transfer_fee: 0n,
68
+ token_b_transfer_fee: 0n,
69
+ },
70
+ };
71
+ }
72
+ return null;
73
+ }
@@ -0,0 +1,14 @@
1
+ /** 各 DEX 程序 ID(Base58) */
2
+ export declare const PUMPFUN_PROGRAM_ID = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
3
+ /** Pump AMM(PumpSwap),与 `sol-parser-sdk` / `pump_amm.json` 一致 */
4
+ export declare const PUMPSWAP_PROGRAM_ID = "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
5
+ export declare const METEORA_DAMM_V2_PROGRAM_ID = "cpamdpZCGKUy5JxQXB2MWgCm3hcnGjEJbYTJgfm4E8a";
6
+ export declare const RAYDIUM_CLMM_PROGRAM_ID = "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK";
7
+ export declare const RAYDIUM_CPMM_PROGRAM_ID = "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C";
8
+ export declare const RAYDIUM_AMM_V4_PROGRAM_ID = "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8";
9
+ export declare const ORCA_WHIRLPOOL_PROGRAM_ID = "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
10
+ export declare const BONK_LAUNCHPAD_PROGRAM_ID = "LanCh3hDdY7M6x8urBSLJhsQBgPNGKHNqJqGwzAEmBm";
11
+ export declare const BONK_PROGRAM_ID = "DjVE6JNiYqPL2QXyCUUh8rNjHrbz9hXHNYt99MQ59qw1";
12
+ export declare const PUMPSWAP_FEES_PROGRAM_ID = "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";
13
+ export declare const METEORA_POOLS_PROGRAM_ID = "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB";
14
+ export declare const METEORA_DLMM_PROGRAM_ID = "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METEORA_DLMM_PROGRAM_ID = exports.METEORA_POOLS_PROGRAM_ID = exports.PUMPSWAP_FEES_PROGRAM_ID = exports.BONK_PROGRAM_ID = exports.BONK_LAUNCHPAD_PROGRAM_ID = exports.ORCA_WHIRLPOOL_PROGRAM_ID = exports.RAYDIUM_AMM_V4_PROGRAM_ID = exports.RAYDIUM_CPMM_PROGRAM_ID = exports.RAYDIUM_CLMM_PROGRAM_ID = exports.METEORA_DAMM_V2_PROGRAM_ID = exports.PUMPSWAP_PROGRAM_ID = exports.PUMPFUN_PROGRAM_ID = void 0;
4
+ /** 各 DEX 程序 ID(Base58) */
5
+ exports.PUMPFUN_PROGRAM_ID = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
6
+ /** Pump AMM(PumpSwap),与 `sol-parser-sdk` / `pump_amm.json` 一致 */
7
+ exports.PUMPSWAP_PROGRAM_ID = "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
8
+ exports.METEORA_DAMM_V2_PROGRAM_ID = "cpamdpZCGKUy5JxQXB2MWgCm3hcnGjEJbYTJgfm4E8a";
9
+ exports.RAYDIUM_CLMM_PROGRAM_ID = "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK";
10
+ exports.RAYDIUM_CPMM_PROGRAM_ID = "CPMMoo8L3F4NbTegBCKVNunggL7H1ZpdTHKxQB5qKP1C";
11
+ exports.RAYDIUM_AMM_V4_PROGRAM_ID = "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8";
12
+ exports.ORCA_WHIRLPOOL_PROGRAM_ID = "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
13
+ exports.BONK_LAUNCHPAD_PROGRAM_ID = "LanCh3hDdY7M6x8urBSLJhsQBgPNGKHNqJqGwzAEmBm";
14
+ // Legacy/alternative program IDs (kept for compatibility)
15
+ exports.BONK_PROGRAM_ID = "DjVE6JNiYqPL2QXyCUUh8rNjHrbz9hXHNYt99MQ59qw1";
16
+ exports.PUMPSWAP_FEES_PROGRAM_ID = "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";
17
+ exports.METEORA_POOLS_PROGRAM_ID = "Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB";
18
+ exports.METEORA_DLMM_PROGRAM_ID = "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * PumpFun 指令解析
3
+ */
4
+ import type { DexEvent } from "../core/dex_event.js";
5
+ export declare function parsePumpfunInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;