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,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseDlmmFromDecoded = parseDlmmFromDecoded;
4
+ exports.parseMeteoraDlmmLog = parseMeteoraDlmmLog;
5
+ /** Meteora DLMM 结构化日志解析 */
6
+ const metadata_js_1 = require("../core/metadata.js");
7
+ const program_data_js_1 = require("./program_data.js");
8
+ const binary_js_1 = require("../util/binary.js");
9
+ function disc(bytes) {
10
+ const u8 = new Uint8Array(8);
11
+ for (let i = 0; i < 8; i++)
12
+ u8[i] = bytes[i];
13
+ return new DataView(u8.buffer).getBigUint64(0, true);
14
+ }
15
+ const DLMM = {
16
+ SWAP: disc([143, 190, 90, 218, 196, 30, 51, 222]),
17
+ ADD_LIQ: disc([181, 157, 89, 67, 143, 182, 52, 72]),
18
+ REMOVE_LIQ: disc([80, 85, 209, 72, 24, 206, 35, 178]),
19
+ INIT_BIN_ARRAY: disc([11, 18, 155, 194, 33, 115, 238, 119]),
20
+ INIT_POOL: disc([95, 180, 10, 172, 84, 174, 232, 40]),
21
+ CREATE_POS: disc([123, 233, 11, 43, 146, 180, 97, 119]),
22
+ CLOSE_POS: disc([94, 168, 102, 45, 59, 122, 137, 54]),
23
+ CLAIM_FEE: disc([152, 70, 208, 111, 104, 91, 44, 1]),
24
+ };
25
+ function bn64(v) {
26
+ return v ?? 0n;
27
+ }
28
+ function parseDlmmFromDecoded(programData, metadata) {
29
+ if (programData.length < 8)
30
+ return null;
31
+ const dv = new DataView(programData.buffer, programData.byteOffset, 8);
32
+ const discriminator = dv.getBigUint64(0, true);
33
+ const data = programData.subarray(8);
34
+ if (discriminator === DLMM.SWAP) {
35
+ let o = 0;
36
+ const pool = (0, binary_js_1.readPubkey)(data, o);
37
+ o += 32;
38
+ const from = (0, binary_js_1.readPubkey)(data, o);
39
+ o += 32;
40
+ const start_bin_id = (0, binary_js_1.readI32LE)(data, o);
41
+ o += 4;
42
+ const end_bin_id = (0, binary_js_1.readI32LE)(data, o);
43
+ o += 4;
44
+ const amount_in = bn64((0, binary_js_1.readU64LE)(data, o));
45
+ o += 8;
46
+ const amount_out = bn64((0, binary_js_1.readU64LE)(data, o));
47
+ o += 8;
48
+ const swap_for_y = (0, binary_js_1.readBool)(data, o);
49
+ o += 1;
50
+ const fee = bn64((0, binary_js_1.readU64LE)(data, o));
51
+ o += 8;
52
+ const protocol_fee = bn64((0, binary_js_1.readU64LE)(data, o));
53
+ o += 8;
54
+ const fee_bps = (0, binary_js_1.readU128LE)(data, o);
55
+ o += 16;
56
+ const host_fee = bn64((0, binary_js_1.readU64LE)(data, o));
57
+ const ev = {
58
+ metadata,
59
+ pool,
60
+ from,
61
+ start_bin_id,
62
+ end_bin_id,
63
+ amount_in,
64
+ amount_out,
65
+ swap_for_y,
66
+ fee,
67
+ protocol_fee,
68
+ fee_bps,
69
+ host_fee,
70
+ };
71
+ return { MeteoraDlmmSwap: ev };
72
+ }
73
+ if (discriminator === DLMM.ADD_LIQ) {
74
+ let o = 0;
75
+ const pool = (0, binary_js_1.readPubkey)(data, o);
76
+ o += 32;
77
+ const from = (0, binary_js_1.readPubkey)(data, o);
78
+ o += 32;
79
+ const position = (0, binary_js_1.readPubkey)(data, o);
80
+ o += 32;
81
+ const a0 = bn64((0, binary_js_1.readU64LE)(data, o));
82
+ o += 8;
83
+ const a1 = bn64((0, binary_js_1.readU64LE)(data, o));
84
+ o += 8;
85
+ const active_bin_id = (0, binary_js_1.readI32LE)(data, o);
86
+ const ev = {
87
+ metadata,
88
+ pool,
89
+ from,
90
+ position,
91
+ amounts: [a0, a1],
92
+ active_bin_id,
93
+ };
94
+ return { MeteoraDlmmAddLiquidity: ev };
95
+ }
96
+ if (discriminator === DLMM.REMOVE_LIQ) {
97
+ let o = 0;
98
+ const pool = (0, binary_js_1.readPubkey)(data, o);
99
+ o += 32;
100
+ const from = (0, binary_js_1.readPubkey)(data, o);
101
+ o += 32;
102
+ const position = (0, binary_js_1.readPubkey)(data, o);
103
+ o += 32;
104
+ const a0 = bn64((0, binary_js_1.readU64LE)(data, o));
105
+ o += 8;
106
+ const a1 = bn64((0, binary_js_1.readU64LE)(data, o));
107
+ o += 8;
108
+ const active_bin_id = (0, binary_js_1.readI32LE)(data, o);
109
+ const ev = {
110
+ metadata,
111
+ pool,
112
+ from,
113
+ position,
114
+ amounts: [a0, a1],
115
+ active_bin_id,
116
+ };
117
+ return { MeteoraDlmmRemoveLiquidity: ev };
118
+ }
119
+ if (discriminator === DLMM.INIT_POOL) {
120
+ let o = 0;
121
+ const pool = (0, binary_js_1.readPubkey)(data, o);
122
+ o += 32;
123
+ const creator = (0, binary_js_1.readPubkey)(data, o);
124
+ o += 32;
125
+ const active_bin_id = (0, binary_js_1.readI32LE)(data, o);
126
+ o += 4;
127
+ const bin_step = (0, binary_js_1.readU16LE)(data, o);
128
+ const ev = {
129
+ metadata,
130
+ pool,
131
+ creator,
132
+ active_bin_id,
133
+ bin_step,
134
+ };
135
+ return { MeteoraDlmmInitializePool: ev };
136
+ }
137
+ if (discriminator === DLMM.INIT_BIN_ARRAY) {
138
+ let o = 0;
139
+ const pool = (0, binary_js_1.readPubkey)(data, o);
140
+ o += 32;
141
+ const bin_array = (0, binary_js_1.readPubkey)(data, o);
142
+ o += 32;
143
+ const index = bn64((0, binary_js_1.readU64LE)(data, o));
144
+ const ev = { metadata, pool, bin_array, index };
145
+ return { MeteoraDlmmInitializeBinArray: ev };
146
+ }
147
+ if (discriminator === DLMM.CREATE_POS) {
148
+ let o = 0;
149
+ const pool = (0, binary_js_1.readPubkey)(data, o);
150
+ o += 32;
151
+ const position = (0, binary_js_1.readPubkey)(data, o);
152
+ o += 32;
153
+ const owner = (0, binary_js_1.readPubkey)(data, o);
154
+ o += 32;
155
+ const lower_bin_id = (0, binary_js_1.readI32LE)(data, o);
156
+ o += 4;
157
+ const width = (0, binary_js_1.readU32LE)(data, o);
158
+ const ev = {
159
+ metadata,
160
+ pool,
161
+ position,
162
+ owner,
163
+ lower_bin_id,
164
+ width,
165
+ };
166
+ return { MeteoraDlmmCreatePosition: ev };
167
+ }
168
+ if (discriminator === DLMM.CLOSE_POS) {
169
+ let o = 0;
170
+ const pool = (0, binary_js_1.readPubkey)(data, o);
171
+ o += 32;
172
+ const position = (0, binary_js_1.readPubkey)(data, o);
173
+ o += 32;
174
+ const owner = (0, binary_js_1.readPubkey)(data, o);
175
+ const ev = { metadata, pool, position, owner };
176
+ return { MeteoraDlmmClosePosition: ev };
177
+ }
178
+ if (discriminator === DLMM.CLAIM_FEE) {
179
+ let o = 0;
180
+ const pool = (0, binary_js_1.readPubkey)(data, o);
181
+ o += 32;
182
+ const position = (0, binary_js_1.readPubkey)(data, o);
183
+ o += 32;
184
+ const owner = (0, binary_js_1.readPubkey)(data, o);
185
+ o += 32;
186
+ const fee_x = bn64((0, binary_js_1.readU64LE)(data, o));
187
+ o += 8;
188
+ const fee_y = bn64((0, binary_js_1.readU64LE)(data, o));
189
+ const ev = { metadata, pool, position, owner, fee_x, fee_y };
190
+ return { MeteoraDlmmClaimFee: ev };
191
+ }
192
+ return null;
193
+ }
194
+ /** 从整行日志解析 */
195
+ function parseMeteoraDlmmLog(log, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
196
+ const buf = (0, program_data_js_1.decodeProgramDataLine)(log);
197
+ if (!buf)
198
+ return null;
199
+ const meta = (0, metadata_js_1.makeMetadata)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
200
+ return parseDlmmFromDecoded(buf, meta);
201
+ }
@@ -0,0 +1,11 @@
1
+ import type { DexEvent } from "../core/dex_event.js";
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;
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;
7
+ export declare function parseInvokeInfo(log: string): {
8
+ programId: string;
9
+ depth: number;
10
+ } | null;
11
+ export declare function parseProgramCompleteInfo(log: string): string | null;