sol-parser-sdk 0.5.9

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 (190) hide show
  1. package/.env.example +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +236 -0
  4. package/README_CN.md +236 -0
  5. package/dist/accounts/mod.d.ts +15 -0
  6. package/dist/accounts/mod.js +173 -0
  7. package/dist/accounts/nonce.d.ts +5 -0
  8. package/dist/accounts/nonce.js +32 -0
  9. package/dist/accounts/pumpfun.d.ts +16 -0
  10. package/dist/accounts/pumpfun.js +538 -0
  11. package/dist/accounts/pumpswap.d.ts +8 -0
  12. package/dist/accounts/pumpswap.js +192 -0
  13. package/dist/accounts/raydium_orca.d.ts +26 -0
  14. package/dist/accounts/raydium_orca.js +453 -0
  15. package/dist/accounts/rpc_wallet.d.ts +5 -0
  16. package/dist/accounts/rpc_wallet.js +18 -0
  17. package/dist/accounts/rust_aliases.d.ts +10 -0
  18. package/dist/accounts/rust_aliases.js +21 -0
  19. package/dist/accounts/token.d.ts +5 -0
  20. package/dist/accounts/token.js +98 -0
  21. package/dist/accounts/types.d.ts +9 -0
  22. package/dist/accounts/types.js +2 -0
  23. package/dist/accounts/utils.d.ts +1 -0
  24. package/dist/accounts/utils.js +12 -0
  25. package/dist/accounts/wallet_resolve.d.ts +1 -0
  26. package/dist/accounts/wallet_resolve.js +28 -0
  27. package/dist/common/constants.d.ts +10 -0
  28. package/dist/common/constants.js +13 -0
  29. package/dist/core/account_dispatcher_rpc.d.ts +11 -0
  30. package/dist/core/account_dispatcher_rpc.js +155 -0
  31. package/dist/core/account_fill_bonk.d.ts +4 -0
  32. package/dist/core/account_fill_bonk.js +20 -0
  33. package/dist/core/account_fill_meteora.d.ts +15 -0
  34. package/dist/core/account_fill_meteora.js +27 -0
  35. package/dist/core/account_fill_orca.d.ts +5 -0
  36. package/dist/core/account_fill_orca.js +18 -0
  37. package/dist/core/account_fill_pumpfun.d.ts +7 -0
  38. package/dist/core/account_fill_pumpfun.js +167 -0
  39. package/dist/core/account_fill_pumpswap.d.ts +10 -0
  40. package/dist/core/account_fill_pumpswap.js +128 -0
  41. package/dist/core/account_fill_raydium.d.ts +20 -0
  42. package/dist/core/account_fill_raydium.js +104 -0
  43. package/dist/core/account_fill_raydium_launchlab.d.ts +4 -0
  44. package/dist/core/account_fill_raydium_launchlab.js +20 -0
  45. package/dist/core/account_pubkey_cache.d.ts +12 -0
  46. package/dist/core/account_pubkey_cache.js +26 -0
  47. package/dist/core/clock.d.ts +8 -0
  48. package/dist/core/clock.js +20 -0
  49. package/dist/core/common_filler_rpc.d.ts +6 -0
  50. package/dist/core/common_filler_rpc.js +21 -0
  51. package/dist/core/dex_event.d.ts +1704 -0
  52. package/dist/core/dex_event.js +14 -0
  53. package/dist/core/error.d.ts +43 -0
  54. package/dist/core/error.js +16 -0
  55. package/dist/core/json_utils.d.ts +8 -0
  56. package/dist/core/json_utils.js +18 -0
  57. package/dist/core/metadata.d.ts +11 -0
  58. package/dist/core/metadata.js +13 -0
  59. package/dist/core/pumpfun_fee_enrich.d.ts +6 -0
  60. package/dist/core/pumpfun_fee_enrich.js +159 -0
  61. package/dist/core/rpc_invoke_map.d.ts +23 -0
  62. package/dist/core/rpc_invoke_map.js +157 -0
  63. package/dist/core/unified_parser.d.ts +19 -0
  64. package/dist/core/unified_parser.js +50 -0
  65. package/dist/grpc/client.d.ts +83 -0
  66. package/dist/grpc/client.js +645 -0
  67. package/dist/grpc/client_stub.d.ts +5 -0
  68. package/dist/grpc/client_stub.js +5 -0
  69. package/dist/grpc/event_parser.d.ts +6 -0
  70. package/dist/grpc/event_parser.js +15 -0
  71. package/dist/grpc/geyser_connect.d.ts +30 -0
  72. package/dist/grpc/geyser_connect.js +40 -0
  73. package/dist/grpc/log_instr_dedup.d.ts +2 -0
  74. package/dist/grpc/log_instr_dedup.js +402 -0
  75. package/dist/grpc/order_buffer.d.ts +27 -0
  76. package/dist/grpc/order_buffer.js +166 -0
  77. package/dist/grpc/program_ids.d.ts +27 -0
  78. package/dist/grpc/program_ids.js +61 -0
  79. package/dist/grpc/rpc_to_grpc.d.ts +18 -0
  80. package/dist/grpc/rpc_to_grpc.js +127 -0
  81. package/dist/grpc/subscribe_builder.d.ts +13 -0
  82. package/dist/grpc/subscribe_builder.js +66 -0
  83. package/dist/grpc/transaction_meta.d.ts +29 -0
  84. package/dist/grpc/transaction_meta.js +208 -0
  85. package/dist/grpc/types.d.ts +195 -0
  86. package/dist/grpc/types.js +551 -0
  87. package/dist/grpc/yellowstone_parse.d.ts +16 -0
  88. package/dist/grpc/yellowstone_parse.js +62 -0
  89. package/dist/index.d.ts +50 -0
  90. package/dist/index.js +298 -0
  91. package/dist/instr/bonk_ix.d.ts +8 -0
  92. package/dist/instr/bonk_ix.js +131 -0
  93. package/dist/instr/inner.d.ts +4 -0
  94. package/dist/instr/inner.js +453 -0
  95. package/dist/instr/meteora_damm_ix.d.ts +8 -0
  96. package/dist/instr/meteora_damm_ix.js +601 -0
  97. package/dist/instr/meteora_dlmm_ix.d.ts +2 -0
  98. package/dist/instr/meteora_dlmm_ix.js +134 -0
  99. package/dist/instr/meteora_pools_ix.d.ts +2 -0
  100. package/dist/instr/meteora_pools_ix.js +78 -0
  101. package/dist/instr/mod.d.ts +18 -0
  102. package/dist/instr/mod.js +129 -0
  103. package/dist/instr/orca_whirlpool_ix.d.ts +8 -0
  104. package/dist/instr/orca_whirlpool_ix.js +119 -0
  105. package/dist/instr/program_ids.d.ts +4 -0
  106. package/dist/instr/program_ids.js +20 -0
  107. package/dist/instr/pump_fees_ix.d.ts +2 -0
  108. package/dist/instr/pump_fees_ix.js +168 -0
  109. package/dist/instr/pumpfun_ix.d.ts +6 -0
  110. package/dist/instr/pumpfun_ix.js +448 -0
  111. package/dist/instr/pumpswap_ix.d.ts +5 -0
  112. package/dist/instr/pumpswap_ix.js +270 -0
  113. package/dist/instr/raydium_amm_v4_ix.d.ts +6 -0
  114. package/dist/instr/raydium_amm_v4_ix.js +112 -0
  115. package/dist/instr/raydium_clmm_ix.d.ts +5 -0
  116. package/dist/instr/raydium_clmm_ix.js +184 -0
  117. package/dist/instr/raydium_cpmm_ix.d.ts +5 -0
  118. package/dist/instr/raydium_cpmm_ix.js +109 -0
  119. package/dist/instr/raydium_launchlab_ix.d.ts +8 -0
  120. package/dist/instr/raydium_launchlab_ix.js +125 -0
  121. package/dist/instr/rust_aliases.d.ts +10 -0
  122. package/dist/instr/rust_aliases.js +20 -0
  123. package/dist/instr/utils.d.ts +10 -0
  124. package/dist/instr/utils.js +35 -0
  125. package/dist/logs/discriminator_lut.d.ts +19 -0
  126. package/dist/logs/discriminator_lut.js +62 -0
  127. package/dist/logs/meteora_amm.d.ts +8 -0
  128. package/dist/logs/meteora_amm.js +113 -0
  129. package/dist/logs/meteora_damm.d.ts +5 -0
  130. package/dist/logs/meteora_damm.js +367 -0
  131. package/dist/logs/meteora_dbc.d.ts +11 -0
  132. package/dist/logs/meteora_dbc.js +142 -0
  133. package/dist/logs/meteora_dlmm.d.ts +6 -0
  134. package/dist/logs/meteora_dlmm.js +201 -0
  135. package/dist/logs/optimized_matcher.d.ts +11 -0
  136. package/dist/logs/optimized_matcher.js +941 -0
  137. package/dist/logs/orca.d.ts +6 -0
  138. package/dist/logs/orca.js +148 -0
  139. package/dist/logs/program_data.d.ts +2 -0
  140. package/dist/logs/program_data.js +20 -0
  141. package/dist/logs/program_log_discriminators.d.ts +80 -0
  142. package/dist/logs/program_log_discriminators.js +88 -0
  143. package/dist/logs/pump.d.ts +14 -0
  144. package/dist/logs/pump.js +378 -0
  145. package/dist/logs/pump_amm.d.ts +9 -0
  146. package/dist/logs/pump_amm.js +418 -0
  147. package/dist/logs/pump_fees.d.ts +23 -0
  148. package/dist/logs/pump_fees.js +364 -0
  149. package/dist/logs/raydium_amm.d.ts +9 -0
  150. package/dist/logs/raydium_amm.js +224 -0
  151. package/dist/logs/raydium_clmm.d.ts +17 -0
  152. package/dist/logs/raydium_clmm.js +624 -0
  153. package/dist/logs/raydium_cpmm.d.ts +7 -0
  154. package/dist/logs/raydium_cpmm.js +121 -0
  155. package/dist/logs/raydium_launchlab.d.ts +10 -0
  156. package/dist/logs/raydium_launchlab.js +84 -0
  157. package/dist/logs/raydium_launchpad.d.ts +12 -0
  158. package/dist/logs/raydium_launchpad.js +92 -0
  159. package/dist/logs/rust_aliases.d.ts +7 -0
  160. package/dist/logs/rust_aliases.js +16 -0
  161. package/dist/parser_alias.d.ts +3 -0
  162. package/dist/parser_alias.js +2 -0
  163. package/dist/rpc_parser.d.ts +17 -0
  164. package/dist/rpc_parser.js +39 -0
  165. package/dist/rpc_transaction.d.ts +27 -0
  166. package/dist/rpc_transaction.js +416 -0
  167. package/dist/shredstream/alt_lookup.d.ts +9 -0
  168. package/dist/shredstream/alt_lookup.js +70 -0
  169. package/dist/shredstream/client.d.ts +65 -0
  170. package/dist/shredstream/client.js +403 -0
  171. package/dist/shredstream/config.d.ts +30 -0
  172. package/dist/shredstream/config.js +34 -0
  173. package/dist/shredstream/entries_decode.d.ts +28 -0
  174. package/dist/shredstream/entries_decode.js +251 -0
  175. package/dist/shredstream/index.d.ts +17 -0
  176. package/dist/shredstream/index.js +33 -0
  177. package/dist/shredstream/instruction_parse.d.ts +34 -0
  178. package/dist/shredstream/instruction_parse.js +79 -0
  179. package/dist/shredstream/proto_types.d.ts +9 -0
  180. package/dist/shredstream/proto_types.js +2 -0
  181. package/dist/shredstream/shredstream.proto +15 -0
  182. package/dist/shredstream/wire_to_shred_tx.d.ts +2 -0
  183. package/dist/shredstream/wire_to_shred_tx.js +59 -0
  184. package/dist/util/binary.d.ts +14 -0
  185. package/dist/util/binary.js +82 -0
  186. package/dist/util/market.d.ts +18 -0
  187. package/dist/util/market.js +54 -0
  188. package/dist/warmup.d.ts +3 -0
  189. package/dist/warmup.js +23 -0
  190. package/package.json +61 -0
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseMeteoraDlmmInstruction = parseMeteoraDlmmInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const binary_js_1 = require("../util/binary.js");
6
+ const utils_js_1 = require("./utils.js");
7
+ const Z = (0, dex_event_js_1.defaultPubkey)();
8
+ function parseMeteoraDlmmInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
9
+ if (instructionData.length === 0)
10
+ return null;
11
+ const pool = (0, utils_js_1.getAccount)(accounts, 0);
12
+ if (!pool)
13
+ return null;
14
+ const metadata = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
15
+ const kind = instructionData[0];
16
+ if (kind === 0) {
17
+ if (instructionData.length < 1 + 4 + 2)
18
+ return null;
19
+ const active_bin_id = (0, binary_js_1.readI32LE)(instructionData, 1);
20
+ const bin_step = (0, binary_js_1.readU16LE)(instructionData, 5);
21
+ if (active_bin_id === null || bin_step === null)
22
+ return null;
23
+ return {
24
+ MeteoraDlmmInitializePool: {
25
+ metadata,
26
+ pool,
27
+ creator: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
28
+ active_bin_id,
29
+ bin_step,
30
+ },
31
+ };
32
+ }
33
+ if (kind === 1) {
34
+ if (instructionData.length < 1 + 8)
35
+ return null;
36
+ return {
37
+ MeteoraDlmmInitializeBinArray: {
38
+ metadata,
39
+ pool,
40
+ bin_array: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
41
+ index: (0, binary_js_1.readU64LE)(instructionData, 1) ?? 0n,
42
+ },
43
+ };
44
+ }
45
+ if (kind === 2) {
46
+ if (instructionData.length < 1 + 32)
47
+ return null;
48
+ return {
49
+ MeteoraDlmmAddLiquidity: {
50
+ metadata,
51
+ pool,
52
+ from: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
53
+ position: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
54
+ amounts: [0n, 0n],
55
+ active_bin_id: 0,
56
+ },
57
+ };
58
+ }
59
+ if (kind === 7) {
60
+ if (instructionData.length < 1 + 32)
61
+ return null;
62
+ return {
63
+ MeteoraDlmmRemoveLiquidity: {
64
+ metadata,
65
+ pool,
66
+ from: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
67
+ position: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
68
+ amounts: [0n, 0n],
69
+ active_bin_id: 0,
70
+ },
71
+ };
72
+ }
73
+ if (kind === 8) {
74
+ if (instructionData.length < 1 + 4 + 4)
75
+ return null;
76
+ const lower_bin_id = (0, binary_js_1.readI32LE)(instructionData, 1);
77
+ const width = (0, binary_js_1.readU32LE)(instructionData, 5);
78
+ if (lower_bin_id === null || width === null)
79
+ return null;
80
+ return {
81
+ MeteoraDlmmCreatePosition: {
82
+ metadata,
83
+ pool,
84
+ position: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
85
+ owner: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
86
+ lower_bin_id,
87
+ width,
88
+ },
89
+ };
90
+ }
91
+ if (kind === 11) {
92
+ if (instructionData.length < 1 + 8 + 8)
93
+ return null;
94
+ return {
95
+ MeteoraDlmmSwap: {
96
+ metadata,
97
+ pool,
98
+ from: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
99
+ start_bin_id: 0,
100
+ end_bin_id: 0,
101
+ amount_in: (0, binary_js_1.readU64LE)(instructionData, 1) ?? 0n,
102
+ amount_out: 0n,
103
+ swap_for_y: false,
104
+ fee: 0n,
105
+ protocol_fee: 0n,
106
+ fee_bps: 0n,
107
+ host_fee: 0n,
108
+ },
109
+ };
110
+ }
111
+ if (kind === 13) {
112
+ return {
113
+ MeteoraDlmmClaimFee: {
114
+ metadata,
115
+ pool,
116
+ position: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
117
+ owner: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
118
+ fee_x: 0n,
119
+ fee_y: 0n,
120
+ },
121
+ };
122
+ }
123
+ if (kind === 14) {
124
+ return {
125
+ MeteoraDlmmClosePosition: {
126
+ metadata,
127
+ pool,
128
+ position: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
129
+ owner: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
130
+ },
131
+ };
132
+ }
133
+ return null;
134
+ }
@@ -0,0 +1,2 @@
1
+ import type { DexEvent } from "../core/dex_event.js";
2
+ export declare function parseMeteoraPoolsInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseMeteoraPoolsInstruction = parseMeteoraPoolsInstruction;
4
+ const dex_event_js_1 = require("../core/dex_event.js");
5
+ const binary_js_1 = require("../util/binary.js");
6
+ const program_log_discriminators_js_1 = require("../logs/program_log_discriminators.js");
7
+ const utils_js_1 = require("./utils.js");
8
+ const Z = (0, dex_event_js_1.defaultPubkey)();
9
+ const DISC = {
10
+ SWAP: (0, program_log_discriminators_js_1.u64leDiscriminator)([248, 198, 158, 145, 225, 117, 135, 200]),
11
+ ADD_LIQUIDITY: (0, program_log_discriminators_js_1.u64leDiscriminator)([181, 157, 89, 67, 143, 182, 52, 72]),
12
+ REMOVE_LIQUIDITY: (0, program_log_discriminators_js_1.u64leDiscriminator)([80, 85, 209, 72, 24, 206, 177, 108]),
13
+ CREATE_POOL: (0, program_log_discriminators_js_1.u64leDiscriminator)([95, 180, 10, 172, 84, 174, 232, 40]),
14
+ };
15
+ function discEq(data, disc) {
16
+ if (data.length < 8)
17
+ return false;
18
+ return (0, binary_js_1.readU64LE)(data, 0) === disc;
19
+ }
20
+ function parseMeteoraPoolsInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
21
+ if (instructionData.length < 8)
22
+ return null;
23
+ const metadata = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
24
+ const pool = (0, utils_js_1.getAccount)(accounts, 0);
25
+ if (discEq(instructionData, DISC.SWAP)) {
26
+ if (!pool || instructionData.length < 24)
27
+ return null;
28
+ return {
29
+ MeteoraPoolsSwap: {
30
+ metadata,
31
+ in_amount: (0, binary_js_1.readU64LE)(instructionData, 8) ?? 0n,
32
+ out_amount: (0, binary_js_1.readU64LE)(instructionData, 16) ?? 0n,
33
+ trade_fee: 0n,
34
+ admin_fee: 0n,
35
+ host_fee: 0n,
36
+ },
37
+ };
38
+ }
39
+ if (discEq(instructionData, DISC.ADD_LIQUIDITY)) {
40
+ if (!pool || instructionData.length < 32)
41
+ return null;
42
+ return {
43
+ MeteoraPoolsAddLiquidity: {
44
+ metadata,
45
+ lp_mint_amount: (0, binary_js_1.readU64LE)(instructionData, 8) ?? 0n,
46
+ token_a_amount: (0, binary_js_1.readU64LE)(instructionData, 16) ?? 0n,
47
+ token_b_amount: (0, binary_js_1.readU64LE)(instructionData, 24) ?? 0n,
48
+ },
49
+ };
50
+ }
51
+ if (discEq(instructionData, DISC.REMOVE_LIQUIDITY)) {
52
+ if (!pool || instructionData.length < 32)
53
+ return null;
54
+ return {
55
+ MeteoraPoolsRemoveLiquidity: {
56
+ metadata,
57
+ lp_unmint_amount: (0, binary_js_1.readU64LE)(instructionData, 8) ?? 0n,
58
+ token_a_out_amount: (0, binary_js_1.readU64LE)(instructionData, 16) ?? 0n,
59
+ token_b_out_amount: (0, binary_js_1.readU64LE)(instructionData, 24) ?? 0n,
60
+ },
61
+ };
62
+ }
63
+ if (discEq(instructionData, DISC.CREATE_POOL)) {
64
+ if (instructionData.length < 8 + 1 + 6 * 8 || accounts.length <= 9)
65
+ return null;
66
+ return {
67
+ MeteoraPoolsPoolCreated: {
68
+ metadata,
69
+ lp_mint: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
70
+ token_a_mint: (0, utils_js_1.getAccount)(accounts, 8) ?? Z,
71
+ token_b_mint: (0, utils_js_1.getAccount)(accounts, 9) ?? Z,
72
+ pool_type: (0, binary_js_1.readU8)(instructionData, 8) ?? 0,
73
+ pool: pool ?? Z,
74
+ },
75
+ };
76
+ }
77
+ return null;
78
+ }
@@ -0,0 +1,18 @@
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 { parseMeteoraDlmmInstruction } from "./meteora_dlmm_ix.js";
10
+ export { parseMeteoraPoolsInstruction } from "./meteora_pools_ix.js";
11
+ export { parseRaydiumClmmInstruction } from "./raydium_clmm_ix.js";
12
+ export { parseRaydiumCpmmInstruction } from "./raydium_cpmm_ix.js";
13
+ export { parseRaydiumAmmV4Instruction } from "./raydium_amm_v4_ix.js";
14
+ export { parseOrcaWhirlpoolInstruction } from "./orca_whirlpool_ix.js";
15
+ export { parseRaydiumLaunchlabInstruction } from "./raydium_launchlab_ix.js";
16
+ export { parsePumpFeesInstruction } from "./pump_fees_ix.js";
17
+ export * from "./program_ids.js";
18
+ 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,129 @@
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.parsePumpFeesInstruction = exports.parseRaydiumLaunchlabInstruction = exports.parseOrcaWhirlpoolInstruction = exports.parseRaydiumAmmV4Instruction = exports.parseRaydiumCpmmInstruction = exports.parseRaydiumClmmInstruction = exports.parseMeteoraPoolsInstruction = exports.parseMeteoraDlmmInstruction = 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 meteora_dlmm_ix_js_1 = require("./meteora_dlmm_ix.js");
25
+ const meteora_pools_ix_js_1 = require("./meteora_pools_ix.js");
26
+ const raydium_clmm_ix_js_1 = require("./raydium_clmm_ix.js");
27
+ const raydium_cpmm_ix_js_1 = require("./raydium_cpmm_ix.js");
28
+ const raydium_amm_v4_ix_js_1 = require("./raydium_amm_v4_ix.js");
29
+ const orca_whirlpool_ix_js_1 = require("./orca_whirlpool_ix.js");
30
+ const raydium_launchlab_ix_js_1 = require("./raydium_launchlab_ix.js");
31
+ const pump_fees_ix_js_1 = require("./pump_fees_ix.js");
32
+ function isRaydiumLaunchlabProgram(programId) {
33
+ return programId === program_ids_js_1.RAYDIUM_LAUNCHLAB_PROGRAM_ID;
34
+ }
35
+ var pumpfun_ix_js_2 = require("./pumpfun_ix.js");
36
+ Object.defineProperty(exports, "parsePumpfunInstruction", { enumerable: true, get: function () { return pumpfun_ix_js_2.parsePumpfunInstruction; } });
37
+ var pumpswap_ix_js_2 = require("./pumpswap_ix.js");
38
+ Object.defineProperty(exports, "parsePumpswapInstruction", { enumerable: true, get: function () { return pumpswap_ix_js_2.parsePumpswapInstruction; } });
39
+ var meteora_damm_ix_js_2 = require("./meteora_damm_ix.js");
40
+ Object.defineProperty(exports, "parseMeteoraDammInstruction", { enumerable: true, get: function () { return meteora_damm_ix_js_2.parseMeteoraDammInstruction; } });
41
+ var meteora_dlmm_ix_js_2 = require("./meteora_dlmm_ix.js");
42
+ Object.defineProperty(exports, "parseMeteoraDlmmInstruction", { enumerable: true, get: function () { return meteora_dlmm_ix_js_2.parseMeteoraDlmmInstruction; } });
43
+ var meteora_pools_ix_js_2 = require("./meteora_pools_ix.js");
44
+ Object.defineProperty(exports, "parseMeteoraPoolsInstruction", { enumerable: true, get: function () { return meteora_pools_ix_js_2.parseMeteoraPoolsInstruction; } });
45
+ var raydium_clmm_ix_js_2 = require("./raydium_clmm_ix.js");
46
+ Object.defineProperty(exports, "parseRaydiumClmmInstruction", { enumerable: true, get: function () { return raydium_clmm_ix_js_2.parseRaydiumClmmInstruction; } });
47
+ var raydium_cpmm_ix_js_2 = require("./raydium_cpmm_ix.js");
48
+ Object.defineProperty(exports, "parseRaydiumCpmmInstruction", { enumerable: true, get: function () { return raydium_cpmm_ix_js_2.parseRaydiumCpmmInstruction; } });
49
+ var raydium_amm_v4_ix_js_2 = require("./raydium_amm_v4_ix.js");
50
+ Object.defineProperty(exports, "parseRaydiumAmmV4Instruction", { enumerable: true, get: function () { return raydium_amm_v4_ix_js_2.parseRaydiumAmmV4Instruction; } });
51
+ var orca_whirlpool_ix_js_2 = require("./orca_whirlpool_ix.js");
52
+ Object.defineProperty(exports, "parseOrcaWhirlpoolInstruction", { enumerable: true, get: function () { return orca_whirlpool_ix_js_2.parseOrcaWhirlpoolInstruction; } });
53
+ var raydium_launchlab_ix_js_2 = require("./raydium_launchlab_ix.js");
54
+ Object.defineProperty(exports, "parseRaydiumLaunchlabInstruction", { enumerable: true, get: function () { return raydium_launchlab_ix_js_2.parseRaydiumLaunchlabInstruction; } });
55
+ var pump_fees_ix_js_2 = require("./pump_fees_ix.js");
56
+ Object.defineProperty(exports, "parsePumpFeesInstruction", { enumerable: true, get: function () { return pump_fees_ix_js_2.parsePumpFeesInstruction; } });
57
+ __exportStar(require("./program_ids.js"), exports);
58
+ function filterParsedEvent(ev, eventTypeFilter) {
59
+ if (!ev || !eventTypeFilter)
60
+ return ev;
61
+ return (0, types_js_1.eventTypeFilterShouldIncludeDexEvent)(eventTypeFilter, ev)
62
+ ? (0, types_js_1.eventTypeFilterNormalizeDexEvent)(eventTypeFilter, ev)
63
+ : null;
64
+ }
65
+ function parseInstructionUnified(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs, eventTypeFilter, programId) {
66
+ if (instructionData.length === 0)
67
+ return null;
68
+ if (eventTypeFilter?.include_only) {
69
+ if (!(0, types_js_1.eventTypeFilterAllowsInstructionParsing)(eventTypeFilter.include_only)) {
70
+ return null;
71
+ }
72
+ }
73
+ if (programId === program_ids_js_1.PUMPFUN_PROGRAM_ID) {
74
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesPumpfun)(eventTypeFilter))
75
+ return null;
76
+ return filterParsedEvent((0, pumpfun_ix_js_1.parsePumpfunInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
77
+ }
78
+ if (programId === program_ids_js_1.PUMPSWAP_PROGRAM_ID) {
79
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesPumpswap)(eventTypeFilter))
80
+ return null;
81
+ return filterParsedEvent((0, pumpswap_ix_js_1.parsePumpswapInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
82
+ }
83
+ if (programId === program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID) {
84
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesMeteoraDammV2)(eventTypeFilter))
85
+ return null;
86
+ return filterParsedEvent((0, meteora_damm_ix_js_1.parseMeteoraDammInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
87
+ }
88
+ if (programId === program_ids_js_1.METEORA_POOLS_PROGRAM_ID) {
89
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesMeteoraPools)(eventTypeFilter))
90
+ return null;
91
+ return filterParsedEvent((0, meteora_pools_ix_js_1.parseMeteoraPoolsInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
92
+ }
93
+ if (programId === program_ids_js_1.METEORA_DLMM_PROGRAM_ID) {
94
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesMeteoraDlmm)(eventTypeFilter))
95
+ return null;
96
+ return filterParsedEvent((0, meteora_dlmm_ix_js_1.parseMeteoraDlmmInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
97
+ }
98
+ if (programId === program_ids_js_1.PUMP_FEES_PROGRAM_ID) {
99
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesPumpFees)(eventTypeFilter))
100
+ return null;
101
+ return filterParsedEvent((0, pump_fees_ix_js_1.parsePumpFeesInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
102
+ }
103
+ if (programId === program_ids_js_1.RAYDIUM_CLMM_PROGRAM_ID) {
104
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesRaydiumClmm)(eventTypeFilter))
105
+ return null;
106
+ return filterParsedEvent((0, raydium_clmm_ix_js_1.parseRaydiumClmmInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
107
+ }
108
+ if (programId === program_ids_js_1.RAYDIUM_CPMM_PROGRAM_ID) {
109
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesRaydiumCpmm)(eventTypeFilter))
110
+ return null;
111
+ return filterParsedEvent((0, raydium_cpmm_ix_js_1.parseRaydiumCpmmInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
112
+ }
113
+ if (programId === program_ids_js_1.RAYDIUM_AMM_V4_PROGRAM_ID) {
114
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesRaydiumAmmV4)(eventTypeFilter))
115
+ return null;
116
+ return filterParsedEvent((0, raydium_amm_v4_ix_js_1.parseRaydiumAmmV4Instruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
117
+ }
118
+ if (programId === program_ids_js_1.ORCA_WHIRLPOOL_PROGRAM_ID) {
119
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesOrcaWhirlpool)(eventTypeFilter))
120
+ return null;
121
+ return filterParsedEvent((0, orca_whirlpool_ix_js_1.parseOrcaWhirlpoolInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
122
+ }
123
+ if (isRaydiumLaunchlabProgram(programId)) {
124
+ if (eventTypeFilter && !(0, types_js_1.eventTypeFilterIncludesRaydiumLaunchlab)(eventTypeFilter))
125
+ return null;
126
+ return filterParsedEvent((0, raydium_launchlab_ix_js_1.parseRaydiumLaunchlabInstruction)(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs), eventTypeFilter);
127
+ }
128
+ return null;
129
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Orca Whirlpool 指令解析(Anchor swap / 增减流动性)
3
+ *
4
+ * 注意:链上指令 discriminator 与 `emit!` 的 Program data 日志 discriminator 不同;
5
+ * Whirlpool 的 `swap` / `increase_liquidity_v2` / `decrease_liquidity` 与 Raydium CLMM 同源,复用同一组 Anchor 前 8 字节。
6
+ */
7
+ import type { DexEvent } from "../core/dex_event.js";
8
+ export declare function parseOrcaWhirlpoolInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;
@@ -0,0 +1,119 @@
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 program_log_discriminators_js_1 = require("../logs/program_log_discriminators.js");
6
+ const utils_js_1 = require("./utils.js");
7
+ const Z = (0, dex_event_js_1.defaultPubkey)();
8
+ const DISC = {
9
+ SWAP: (0, program_log_discriminators_js_1.u64leDiscriminator)([248, 198, 158, 145, 225, 117, 135, 200]),
10
+ SWAP_V2: (0, program_log_discriminators_js_1.u64leDiscriminator)([43, 4, 237, 11, 26, 201, 30, 98]),
11
+ INCREASE_LIQUIDITY: (0, program_log_discriminators_js_1.u64leDiscriminator)([46, 156, 243, 118, 13, 205, 251, 178]),
12
+ DECREASE_LIQUIDITY: (0, program_log_discriminators_js_1.u64leDiscriminator)([160, 38, 208, 111, 104, 91, 44, 1]),
13
+ INITIALIZE_POOL: (0, program_log_discriminators_js_1.u64leDiscriminator)([17, 43, 80, 74, 168, 202, 6, 113]),
14
+ };
15
+ function discEq(data, disc) {
16
+ if (data.length < 8)
17
+ return false;
18
+ const v = (0, utils_js_1.readU64LE)(data, 0);
19
+ return v === disc;
20
+ }
21
+ function parseOrcaWhirlpoolInstruction(instructionData, accounts, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
22
+ if (instructionData.length < 8)
23
+ return null;
24
+ const meta = (0, utils_js_1.ixMeta)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
25
+ if (discEq(instructionData, DISC.SWAP) || discEq(instructionData, DISC.SWAP_V2)) {
26
+ if (instructionData.length < 42)
27
+ return null;
28
+ const amount = (0, utils_js_1.readU64LE)(instructionData, 8) ?? 0n;
29
+ const other_threshold = (0, utils_js_1.readU64LE)(instructionData, 16) ?? 0n;
30
+ const sqrt_price_limit = (0, utils_js_1.readU128LE)(instructionData, 24) ?? 0n;
31
+ const amount_specified_is_input = (0, utils_js_1.readBool)(instructionData, 40);
32
+ const a_to_b = (0, utils_js_1.readBool)(instructionData, 41);
33
+ if (amount_specified_is_input === null || a_to_b === null)
34
+ return null;
35
+ const input_amount = amount_specified_is_input ? amount : 0n;
36
+ const output_amount = amount_specified_is_input ? other_threshold : amount;
37
+ return {
38
+ OrcaWhirlpoolSwap: {
39
+ metadata: meta,
40
+ whirlpool: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
41
+ a_to_b,
42
+ pre_sqrt_price: sqrt_price_limit,
43
+ post_sqrt_price: 0n,
44
+ input_amount,
45
+ output_amount,
46
+ input_transfer_fee: 0n,
47
+ output_transfer_fee: 0n,
48
+ lp_fee: 0n,
49
+ protocol_fee: 0n,
50
+ },
51
+ };
52
+ }
53
+ if (discEq(instructionData, DISC.INCREASE_LIQUIDITY)) {
54
+ // increase_liquidity_v2:liquidity_amount (u128), token_max_a, token_max_b
55
+ if (instructionData.length < 8 + 16 + 8 + 8)
56
+ return null;
57
+ const liquidity = (0, utils_js_1.readU128LE)(instructionData, 8) ?? 0n;
58
+ const token_max_a = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
59
+ const token_max_b = (0, utils_js_1.readU64LE)(instructionData, 32) ?? 0n;
60
+ return {
61
+ OrcaWhirlpoolLiquidityIncreased: {
62
+ metadata: meta,
63
+ whirlpool: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
64
+ position: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
65
+ tick_lower_index: 0,
66
+ tick_upper_index: 0,
67
+ liquidity,
68
+ token_a_amount: token_max_a,
69
+ token_b_amount: token_max_b,
70
+ token_a_transfer_fee: 0n,
71
+ token_b_transfer_fee: 0n,
72
+ },
73
+ };
74
+ }
75
+ if (discEq(instructionData, DISC.DECREASE_LIQUIDITY)) {
76
+ // decrease_liquidity:liquidity_amount (u128), token_min_a, token_min_b
77
+ if (instructionData.length < 8 + 16 + 8 + 8)
78
+ return null;
79
+ const liquidity = (0, utils_js_1.readU128LE)(instructionData, 8) ?? 0n;
80
+ const token_min_a = (0, utils_js_1.readU64LE)(instructionData, 24) ?? 0n;
81
+ const token_min_b = (0, utils_js_1.readU64LE)(instructionData, 32) ?? 0n;
82
+ return {
83
+ OrcaWhirlpoolLiquidityDecreased: {
84
+ metadata: meta,
85
+ whirlpool: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
86
+ position: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
87
+ tick_lower_index: 0,
88
+ tick_upper_index: 0,
89
+ liquidity,
90
+ token_a_amount: token_min_a,
91
+ token_b_amount: token_min_b,
92
+ token_a_transfer_fee: 0n,
93
+ token_b_transfer_fee: 0n,
94
+ },
95
+ };
96
+ }
97
+ if (discEq(instructionData, DISC.INITIALIZE_POOL)) {
98
+ if (instructionData.length < 8 + 2 + 16)
99
+ return null;
100
+ const tick_spacing = (0, utils_js_1.readU16LE)(instructionData, 8) ?? 0;
101
+ const initial_sqrt_price = (0, utils_js_1.readU128LE)(instructionData, 10) ?? 0n;
102
+ return {
103
+ OrcaWhirlpoolPoolInitialized: {
104
+ metadata: meta,
105
+ whirlpool: (0, utils_js_1.getAccount)(accounts, 1) ?? Z,
106
+ whirlpools_config: (0, utils_js_1.getAccount)(accounts, 2) ?? Z,
107
+ token_mint_a: (0, utils_js_1.getAccount)(accounts, 3) ?? Z,
108
+ token_mint_b: (0, utils_js_1.getAccount)(accounts, 4) ?? Z,
109
+ tick_spacing,
110
+ token_program_a: (0, utils_js_1.getAccount)(accounts, 8) ?? Z,
111
+ token_program_b: (0, utils_js_1.getAccount)(accounts, 9) ?? Z,
112
+ decimals_a: 0,
113
+ decimals_b: 0,
114
+ initial_sqrt_price,
115
+ },
116
+ };
117
+ }
118
+ return null;
119
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 各 DEX 程序 ID(Base58)。与 Rust 对齐的常量来自 `grpc/program_ids.ts`。
3
+ */
4
+ export { PUMPFUN_PROGRAM_ID, PUMPSWAP_PROGRAM_ID, PUMPSWAP_FEES_PROGRAM_ID, PUMP_FEES_PROGRAM_ID, RAYDIUM_LAUNCHLAB_PROGRAM_ID, RAYDIUM_CPMM_PROGRAM_ID, RAYDIUM_CLMM_PROGRAM_ID, RAYDIUM_AMM_V4_PROGRAM_ID, ORCA_WHIRLPOOL_PROGRAM_ID, METEORA_POOLS_PROGRAM_ID, METEORA_DAMM_V2_PROGRAM_ID, METEORA_DLMM_PROGRAM_ID, METEORA_DBC_PROGRAM_ID, } from "../grpc/program_ids.js";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METEORA_DBC_PROGRAM_ID = exports.METEORA_DLMM_PROGRAM_ID = exports.METEORA_DAMM_V2_PROGRAM_ID = exports.METEORA_POOLS_PROGRAM_ID = exports.ORCA_WHIRLPOOL_PROGRAM_ID = exports.RAYDIUM_AMM_V4_PROGRAM_ID = exports.RAYDIUM_CLMM_PROGRAM_ID = exports.RAYDIUM_CPMM_PROGRAM_ID = exports.RAYDIUM_LAUNCHLAB_PROGRAM_ID = exports.PUMP_FEES_PROGRAM_ID = exports.PUMPSWAP_FEES_PROGRAM_ID = exports.PUMPSWAP_PROGRAM_ID = exports.PUMPFUN_PROGRAM_ID = void 0;
4
+ /**
5
+ * 各 DEX 程序 ID(Base58)。与 Rust 对齐的常量来自 `grpc/program_ids.ts`。
6
+ */
7
+ var program_ids_js_1 = require("../grpc/program_ids.js");
8
+ Object.defineProperty(exports, "PUMPFUN_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMPFUN_PROGRAM_ID; } });
9
+ Object.defineProperty(exports, "PUMPSWAP_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMPSWAP_PROGRAM_ID; } });
10
+ Object.defineProperty(exports, "PUMPSWAP_FEES_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMPSWAP_FEES_PROGRAM_ID; } });
11
+ Object.defineProperty(exports, "PUMP_FEES_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.PUMP_FEES_PROGRAM_ID; } });
12
+ Object.defineProperty(exports, "RAYDIUM_LAUNCHLAB_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_LAUNCHLAB_PROGRAM_ID; } });
13
+ Object.defineProperty(exports, "RAYDIUM_CPMM_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_CPMM_PROGRAM_ID; } });
14
+ Object.defineProperty(exports, "RAYDIUM_CLMM_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_CLMM_PROGRAM_ID; } });
15
+ Object.defineProperty(exports, "RAYDIUM_AMM_V4_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.RAYDIUM_AMM_V4_PROGRAM_ID; } });
16
+ Object.defineProperty(exports, "ORCA_WHIRLPOOL_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.ORCA_WHIRLPOOL_PROGRAM_ID; } });
17
+ Object.defineProperty(exports, "METEORA_POOLS_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_POOLS_PROGRAM_ID; } });
18
+ Object.defineProperty(exports, "METEORA_DAMM_V2_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_DAMM_V2_PROGRAM_ID; } });
19
+ Object.defineProperty(exports, "METEORA_DLMM_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_DLMM_PROGRAM_ID; } });
20
+ Object.defineProperty(exports, "METEORA_DBC_PROGRAM_ID", { enumerable: true, get: function () { return program_ids_js_1.METEORA_DBC_PROGRAM_ID; } });
@@ -0,0 +1,2 @@
1
+ import type { DexEvent } from "../core/dex_event.js";
2
+ export declare function parsePumpFeesInstruction(instructionData: Uint8Array, accounts: string[], signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;