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,367 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseMeteoraDammLog = parseMeteoraDammLog;
4
+ const metadata_js_1 = require("../core/metadata.js");
5
+ const dex_event_js_1 = require("../core/dex_event.js");
6
+ const program_data_js_1 = require("./program_data.js");
7
+ const binary_js_1 = require("../util/binary.js");
8
+ function discOf(bytes) {
9
+ const u8 = new Uint8Array(8);
10
+ for (let i = 0; i < 8; i++)
11
+ u8[i] = bytes[i];
12
+ return new DataView(u8.buffer).getBigUint64(0, true);
13
+ }
14
+ const SWAP = discOf([27, 60, 21, 213, 138, 170, 187, 147]);
15
+ const SWAP2 = discOf([189, 66, 51, 168, 38, 80, 117, 153]);
16
+ const ADD_LIQUIDITY = discOf([175, 242, 8, 157, 30, 247, 185, 169]);
17
+ const REMOVE_LIQUIDITY = discOf([87, 46, 88, 98, 175, 96, 34, 91]);
18
+ const INITIALIZE_POOL = discOf([228, 50, 246, 85, 203, 66, 134, 37]);
19
+ const CREATE_POSITION = discOf([156, 15, 119, 198, 29, 181, 221, 55]);
20
+ const CLOSE_POSITION = discOf([20, 145, 144, 68, 143, 142, 214, 178]);
21
+ function bn64(v) {
22
+ return v ?? 0n;
23
+ }
24
+ function emptyVaults() {
25
+ const z = (0, dex_event_js_1.defaultPubkey)();
26
+ return {
27
+ token_a_vault: z,
28
+ token_b_vault: z,
29
+ token_a_mint: z,
30
+ token_b_mint: z,
31
+ token_a_program: z,
32
+ token_b_program: z,
33
+ };
34
+ }
35
+ function parseSwapEvent(data, meta) {
36
+ let o = 0;
37
+ const pool = (0, binary_js_1.readPubkey)(data, o);
38
+ o += 32;
39
+ o += 32;
40
+ const trade_direction = (0, binary_js_1.readU8)(data, o);
41
+ o += 1;
42
+ const has_referral = (0, binary_js_1.readBool)(data, o);
43
+ o += 1;
44
+ const amount_in = bn64((0, binary_js_1.readU64LE)(data, o));
45
+ o += 8;
46
+ const minimum_amount_out = bn64((0, binary_js_1.readU64LE)(data, o));
47
+ o += 8;
48
+ const actual_input_amount = bn64((0, binary_js_1.readU64LE)(data, o));
49
+ o += 8;
50
+ const output_amount = bn64((0, binary_js_1.readU64LE)(data, o));
51
+ o += 8;
52
+ const next_sqrt_price = (0, binary_js_1.readU128LE)(data, o);
53
+ o += 16;
54
+ const lp_fee = bn64((0, binary_js_1.readU64LE)(data, o));
55
+ o += 8;
56
+ const protocol_fee = bn64((0, binary_js_1.readU64LE)(data, o));
57
+ o += 8;
58
+ const referral_fee = bn64((0, binary_js_1.readU64LE)(data, o));
59
+ o += 8;
60
+ o += 8;
61
+ const current_timestamp = bn64((0, binary_js_1.readU64LE)(data, o));
62
+ const ev = {
63
+ metadata: meta,
64
+ pool,
65
+ amount_in,
66
+ output_amount,
67
+ trade_direction,
68
+ has_referral,
69
+ minimum_amount_out,
70
+ next_sqrt_price,
71
+ lp_fee,
72
+ protocol_fee,
73
+ partner_fee: 0n,
74
+ referral_fee,
75
+ actual_amount_in: actual_input_amount,
76
+ current_timestamp,
77
+ ...emptyVaults(),
78
+ };
79
+ return { MeteoraDammV2Swap: ev };
80
+ }
81
+ function parseSwap2Event(data, meta) {
82
+ let o = 0;
83
+ const pool = (0, binary_js_1.readPubkey)(data, o);
84
+ o += 32;
85
+ const trade_direction = (0, binary_js_1.readU8)(data, o);
86
+ o += 1;
87
+ o += 1;
88
+ const has_referral = (0, binary_js_1.readBool)(data, o);
89
+ o += 1;
90
+ const amount_0 = bn64((0, binary_js_1.readU64LE)(data, o));
91
+ o += 8;
92
+ const amount_1 = bn64((0, binary_js_1.readU64LE)(data, o));
93
+ o += 8;
94
+ const swap_mode = (0, binary_js_1.readU8)(data, o);
95
+ o += 1;
96
+ const included_fee_input_amount = bn64((0, binary_js_1.readU64LE)(data, o));
97
+ o += 8;
98
+ o += 8;
99
+ o += 8;
100
+ const output_amount = bn64((0, binary_js_1.readU64LE)(data, o));
101
+ o += 8;
102
+ const next_sqrt_price = (0, binary_js_1.readU128LE)(data, o);
103
+ o += 16;
104
+ const lp_fee = bn64((0, binary_js_1.readU64LE)(data, o));
105
+ o += 8;
106
+ const protocol_fee = bn64((0, binary_js_1.readU64LE)(data, o));
107
+ o += 8;
108
+ const referral_fee = bn64((0, binary_js_1.readU64LE)(data, o));
109
+ o += 8;
110
+ o += 8;
111
+ o += 8;
112
+ 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];
114
+ const ev = {
115
+ metadata: meta,
116
+ pool,
117
+ amount_in,
118
+ output_amount,
119
+ trade_direction,
120
+ has_referral,
121
+ minimum_amount_out,
122
+ next_sqrt_price,
123
+ lp_fee,
124
+ protocol_fee,
125
+ partner_fee: 0n,
126
+ referral_fee,
127
+ actual_amount_in: included_fee_input_amount,
128
+ current_timestamp,
129
+ ...emptyVaults(),
130
+ };
131
+ return { MeteoraDammV2Swap: ev };
132
+ }
133
+ function parseCreatePositionEvent(data, meta) {
134
+ if (data.length < 32 * 4)
135
+ return null;
136
+ let o = 0;
137
+ const pool = (0, binary_js_1.readPubkey)(data, o);
138
+ o += 32;
139
+ const owner = (0, binary_js_1.readPubkey)(data, o);
140
+ o += 32;
141
+ const position = (0, binary_js_1.readPubkey)(data, o);
142
+ o += 32;
143
+ const position_nft_mint = (0, binary_js_1.readPubkey)(data, o);
144
+ const ev = {
145
+ metadata: meta,
146
+ pool,
147
+ owner,
148
+ position,
149
+ position_nft_mint,
150
+ };
151
+ return { MeteoraDammV2CreatePosition: ev };
152
+ }
153
+ function parseClosePositionEvent(data, meta) {
154
+ if (data.length < 32 * 4)
155
+ return null;
156
+ let o = 0;
157
+ const pool = (0, binary_js_1.readPubkey)(data, o);
158
+ o += 32;
159
+ const owner = (0, binary_js_1.readPubkey)(data, o);
160
+ o += 32;
161
+ const position = (0, binary_js_1.readPubkey)(data, o);
162
+ o += 32;
163
+ const position_nft_mint = (0, binary_js_1.readPubkey)(data, o);
164
+ const ev = {
165
+ metadata: meta,
166
+ pool,
167
+ owner,
168
+ position,
169
+ position_nft_mint,
170
+ };
171
+ return { MeteoraDammV2ClosePosition: ev };
172
+ }
173
+ function parseAddLiquidityEvent(data, meta) {
174
+ if (data.length < 32 * 3 + 16 + 8 * 6)
175
+ return null;
176
+ let o = 0;
177
+ const pool = (0, binary_js_1.readPubkey)(data, o);
178
+ o += 32;
179
+ const position = (0, binary_js_1.readPubkey)(data, o);
180
+ o += 32;
181
+ const owner = (0, binary_js_1.readPubkey)(data, o);
182
+ o += 32;
183
+ const liquidity_delta = (0, binary_js_1.readU128LE)(data, o);
184
+ o += 16;
185
+ const token_a_amount_threshold = bn64((0, binary_js_1.readU64LE)(data, o));
186
+ o += 8;
187
+ const token_b_amount_threshold = bn64((0, binary_js_1.readU64LE)(data, o));
188
+ o += 8;
189
+ const token_a_amount = bn64((0, binary_js_1.readU64LE)(data, o));
190
+ o += 8;
191
+ const token_b_amount = bn64((0, binary_js_1.readU64LE)(data, o));
192
+ o += 8;
193
+ const total_amount_a = bn64((0, binary_js_1.readU64LE)(data, o));
194
+ o += 8;
195
+ const total_amount_b = bn64((0, binary_js_1.readU64LE)(data, o));
196
+ const ev = {
197
+ metadata: meta,
198
+ pool,
199
+ position,
200
+ owner,
201
+ liquidity_delta,
202
+ token_a_amount_threshold,
203
+ token_b_amount_threshold,
204
+ token_a_amount,
205
+ token_b_amount,
206
+ total_amount_a,
207
+ total_amount_b,
208
+ };
209
+ return { MeteoraDammV2AddLiquidity: ev };
210
+ }
211
+ function parseRemoveLiquidityEvent(data, meta) {
212
+ if (data.length < 32 * 3 + 16 + 8 * 4)
213
+ return null;
214
+ let o = 0;
215
+ const pool = (0, binary_js_1.readPubkey)(data, o);
216
+ o += 32;
217
+ const position = (0, binary_js_1.readPubkey)(data, o);
218
+ o += 32;
219
+ const owner = (0, binary_js_1.readPubkey)(data, o);
220
+ o += 32;
221
+ const liquidity_delta = (0, binary_js_1.readU128LE)(data, o);
222
+ o += 16;
223
+ const token_a_amount_threshold = bn64((0, binary_js_1.readU64LE)(data, o));
224
+ o += 8;
225
+ const token_b_amount_threshold = bn64((0, binary_js_1.readU64LE)(data, o));
226
+ o += 8;
227
+ const token_a_amount = bn64((0, binary_js_1.readU64LE)(data, o));
228
+ o += 8;
229
+ const token_b_amount = bn64((0, binary_js_1.readU64LE)(data, o));
230
+ const ev = {
231
+ metadata: meta,
232
+ pool,
233
+ position,
234
+ owner,
235
+ liquidity_delta,
236
+ token_a_amount_threshold,
237
+ token_b_amount_threshold,
238
+ token_a_amount,
239
+ token_b_amount,
240
+ };
241
+ return { MeteoraDammV2RemoveLiquidity: ev };
242
+ }
243
+ function skipPoolFees(data, offset) {
244
+ if (offset + 31 > data.length)
245
+ return null;
246
+ offset += 27;
247
+ if ((0, binary_js_1.readU16LE)(data, offset) === null)
248
+ return null;
249
+ offset += 2;
250
+ if ((0, binary_js_1.readU8)(data, offset) === null)
251
+ return null;
252
+ offset += 1;
253
+ const tag = (0, binary_js_1.readU8)(data, offset);
254
+ if (tag === null)
255
+ return null;
256
+ offset += 1;
257
+ if (tag === 1) {
258
+ if (offset + 32 > data.length)
259
+ return null;
260
+ offset += 32;
261
+ }
262
+ else if (tag !== 0) {
263
+ return null;
264
+ }
265
+ return offset;
266
+ }
267
+ function parseInitializePoolEvent(data, meta) {
268
+ if (data.length < 32 * 6 + 31 + 109)
269
+ return null;
270
+ let o = 0;
271
+ const pool = (0, binary_js_1.readPubkey)(data, o);
272
+ o += 32;
273
+ const token_a_mint = (0, binary_js_1.readPubkey)(data, o);
274
+ o += 32;
275
+ const token_b_mint = (0, binary_js_1.readPubkey)(data, o);
276
+ o += 32;
277
+ const creator = (0, binary_js_1.readPubkey)(data, o);
278
+ o += 32;
279
+ const payer = (0, binary_js_1.readPubkey)(data, o);
280
+ o += 32;
281
+ const alpha_vault = (0, binary_js_1.readPubkey)(data, o);
282
+ o += 32;
283
+ const poolFeesEnd = skipPoolFees(data, o);
284
+ if (poolFeesEnd === null)
285
+ return null;
286
+ o = poolFeesEnd;
287
+ if (o + 109 > data.length)
288
+ return null;
289
+ const sqrt_min_price = (0, binary_js_1.readU128LE)(data, o);
290
+ o += 16;
291
+ const sqrt_max_price = (0, binary_js_1.readU128LE)(data, o);
292
+ o += 16;
293
+ const activation_type = (0, binary_js_1.readU8)(data, o);
294
+ o += 1;
295
+ const collect_fee_mode = (0, binary_js_1.readU8)(data, o);
296
+ o += 1;
297
+ const liquidity = (0, binary_js_1.readU128LE)(data, o);
298
+ o += 16;
299
+ const sqrt_price = (0, binary_js_1.readU128LE)(data, o);
300
+ o += 16;
301
+ const activation_point = bn64((0, binary_js_1.readU64LE)(data, o));
302
+ o += 8;
303
+ const token_a_flag = (0, binary_js_1.readU8)(data, o);
304
+ o += 1;
305
+ const token_b_flag = (0, binary_js_1.readU8)(data, o);
306
+ o += 1;
307
+ const token_a_amount = bn64((0, binary_js_1.readU64LE)(data, o));
308
+ o += 8;
309
+ const token_b_amount = bn64((0, binary_js_1.readU64LE)(data, o));
310
+ o += 8;
311
+ const total_amount_a = bn64((0, binary_js_1.readU64LE)(data, o));
312
+ o += 8;
313
+ const total_amount_b = bn64((0, binary_js_1.readU64LE)(data, o));
314
+ o += 8;
315
+ const pool_type = (0, binary_js_1.readU8)(data, o);
316
+ const ev = {
317
+ metadata: meta,
318
+ pool,
319
+ token_a_mint,
320
+ token_b_mint,
321
+ creator,
322
+ payer,
323
+ alpha_vault,
324
+ pool_fees: null,
325
+ sqrt_min_price,
326
+ sqrt_max_price,
327
+ activation_type,
328
+ collect_fee_mode,
329
+ liquidity,
330
+ sqrt_price,
331
+ activation_point,
332
+ token_a_flag,
333
+ token_b_flag,
334
+ token_a_amount,
335
+ token_b_amount,
336
+ total_amount_a,
337
+ total_amount_b,
338
+ pool_type,
339
+ };
340
+ return { MeteoraDammV2InitializePool: ev };
341
+ }
342
+ /**
343
+ * Meteora DAMM Program data 入口;与 Rust `logs/meteora_damm.rs` 一致。
344
+ */
345
+ function parseMeteoraDammLog(log, signature, slot, txIndex, blockTimeUs, grpcRecvUs) {
346
+ const programData = (0, program_data_js_1.decodeProgramDataLine)(log);
347
+ if (!programData)
348
+ return null;
349
+ const disc = new DataView(programData.buffer, programData.byteOffset, 8).getBigUint64(0, true);
350
+ const data = programData.subarray(8);
351
+ const meta = (0, metadata_js_1.makeMetadata)(signature, slot, txIndex, blockTimeUs, grpcRecvUs);
352
+ if (disc === SWAP)
353
+ return parseSwapEvent(data, meta);
354
+ if (disc === SWAP2)
355
+ return parseSwap2Event(data, meta);
356
+ if (disc === ADD_LIQUIDITY)
357
+ return parseAddLiquidityEvent(data, meta);
358
+ if (disc === REMOVE_LIQUIDITY)
359
+ return parseRemoveLiquidityEvent(data, meta);
360
+ if (disc === INITIALIZE_POOL)
361
+ return parseInitializePoolEvent(data, meta);
362
+ if (disc === CREATE_POSITION)
363
+ return parseCreatePositionEvent(data, meta);
364
+ if (disc === CLOSE_POSITION)
365
+ return parseClosePositionEvent(data, meta);
366
+ return null;
367
+ }
@@ -0,0 +1,11 @@
1
+ import type { DexEvent } from "../core/dex_event.js";
2
+ import type { EventMetadata } from "../core/metadata.js";
3
+ export declare const METEORA_DBC_DISC: {
4
+ readonly SWAP: bigint;
5
+ readonly INITIALIZE_POOL: bigint;
6
+ readonly CURVE_COMPLETE: bigint;
7
+ };
8
+ export declare function parseMeteoraDbcSwapFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
9
+ export declare function parseMeteoraDbcInitializePoolFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
10
+ export declare function parseMeteoraDbcCurveCompleteFromData(data: Uint8Array, metadata: EventMetadata): DexEvent | null;
11
+ export declare function parseMeteoraDbcFromDiscriminator(discriminator: bigint, data: Uint8Array, metadata: EventMetadata): DexEvent | null;
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METEORA_DBC_DISC = void 0;
4
+ exports.parseMeteoraDbcSwapFromData = parseMeteoraDbcSwapFromData;
5
+ exports.parseMeteoraDbcInitializePoolFromData = parseMeteoraDbcInitializePoolFromData;
6
+ exports.parseMeteoraDbcCurveCompleteFromData = parseMeteoraDbcCurveCompleteFromData;
7
+ exports.parseMeteoraDbcFromDiscriminator = parseMeteoraDbcFromDiscriminator;
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
+ exports.METEORA_DBC_DISC = {
16
+ SWAP: disc([27, 60, 21, 213, 138, 170, 187, 147]),
17
+ INITIALIZE_POOL: disc([228, 50, 246, 85, 203, 66, 134, 37]),
18
+ CURVE_COMPLETE: disc([229, 231, 86, 84, 156, 134, 75, 24]),
19
+ };
20
+ function bn64(v) {
21
+ return v ?? 0n;
22
+ }
23
+ function parseMeteoraDbcSwapFromData(data, metadata) {
24
+ let o = 0;
25
+ const pool = (0, binary_js_1.readPubkey)(data, o);
26
+ o += 32;
27
+ const config = (0, binary_js_1.readPubkey)(data, o);
28
+ o += 32;
29
+ const trade_direction = (0, binary_js_1.readU8)(data, o);
30
+ o += 1;
31
+ const has_referral = (0, binary_js_1.readBool)(data, o);
32
+ o += 1;
33
+ const params_amount_in = (0, binary_js_1.readU64LE)(data, o);
34
+ o += 8;
35
+ const minimum_amount_out = (0, binary_js_1.readU64LE)(data, o);
36
+ o += 8;
37
+ const actual_input_amount = (0, binary_js_1.readU64LE)(data, o);
38
+ o += 8;
39
+ const output_amount = (0, binary_js_1.readU64LE)(data, o);
40
+ o += 8;
41
+ const next_sqrt_price = (0, binary_js_1.readU128LE)(data, o);
42
+ o += 16;
43
+ const trading_fee = (0, binary_js_1.readU64LE)(data, o);
44
+ o += 8;
45
+ const protocol_fee = (0, binary_js_1.readU64LE)(data, o);
46
+ o += 8;
47
+ const referral_fee = (0, binary_js_1.readU64LE)(data, o);
48
+ o += 8;
49
+ const amount_in = (0, binary_js_1.readU64LE)(data, o) ?? params_amount_in;
50
+ o += 8;
51
+ const current_timestamp = (0, binary_js_1.readU64LE)(data, o);
52
+ if (!pool ||
53
+ !config ||
54
+ trade_direction === null ||
55
+ has_referral === null ||
56
+ params_amount_in === null ||
57
+ minimum_amount_out === null ||
58
+ actual_input_amount === null ||
59
+ output_amount === null ||
60
+ next_sqrt_price === null ||
61
+ trading_fee === null ||
62
+ protocol_fee === null ||
63
+ referral_fee === null ||
64
+ current_timestamp === null) {
65
+ return null;
66
+ }
67
+ const ev = {
68
+ metadata,
69
+ pool,
70
+ config,
71
+ trade_direction,
72
+ has_referral,
73
+ amount_in: bn64(amount_in),
74
+ minimum_amount_out: bn64(minimum_amount_out),
75
+ actual_input_amount: bn64(actual_input_amount),
76
+ output_amount: bn64(output_amount),
77
+ next_sqrt_price,
78
+ trading_fee: bn64(trading_fee),
79
+ protocol_fee: bn64(protocol_fee),
80
+ referral_fee: bn64(referral_fee),
81
+ current_timestamp: bn64(current_timestamp),
82
+ };
83
+ return { MeteoraDbcSwap: ev };
84
+ }
85
+ function parseMeteoraDbcInitializePoolFromData(data, metadata) {
86
+ let o = 0;
87
+ const pool = (0, binary_js_1.readPubkey)(data, o);
88
+ o += 32;
89
+ const config = (0, binary_js_1.readPubkey)(data, o);
90
+ o += 32;
91
+ const creator = (0, binary_js_1.readPubkey)(data, o);
92
+ o += 32;
93
+ const base_mint = (0, binary_js_1.readPubkey)(data, o);
94
+ o += 32;
95
+ const pool_type = (0, binary_js_1.readU8)(data, o);
96
+ o += 1;
97
+ const activation_point = (0, binary_js_1.readU64LE)(data, o);
98
+ if (!pool || !config || !creator || !base_mint || pool_type === null || activation_point === null) {
99
+ return null;
100
+ }
101
+ const ev = {
102
+ metadata,
103
+ pool,
104
+ config,
105
+ creator,
106
+ base_mint,
107
+ pool_type,
108
+ activation_point: bn64(activation_point),
109
+ };
110
+ return { MeteoraDbcInitializePool: ev };
111
+ }
112
+ function parseMeteoraDbcCurveCompleteFromData(data, metadata) {
113
+ let o = 0;
114
+ const pool = (0, binary_js_1.readPubkey)(data, o);
115
+ o += 32;
116
+ const config = (0, binary_js_1.readPubkey)(data, o);
117
+ o += 32;
118
+ const base_reserve = (0, binary_js_1.readU64LE)(data, o);
119
+ o += 8;
120
+ const quote_reserve = (0, binary_js_1.readU64LE)(data, o);
121
+ if (!pool || !config || base_reserve === null || quote_reserve === null)
122
+ return null;
123
+ const ev = {
124
+ metadata,
125
+ pool,
126
+ config,
127
+ base_reserve: bn64(base_reserve),
128
+ quote_reserve: bn64(quote_reserve),
129
+ };
130
+ return { MeteoraDbcCurveComplete: ev };
131
+ }
132
+ function parseMeteoraDbcFromDiscriminator(discriminator, data, metadata) {
133
+ if (discriminator === exports.METEORA_DBC_DISC.SWAP)
134
+ return parseMeteoraDbcSwapFromData(data, metadata);
135
+ if (discriminator === exports.METEORA_DBC_DISC.INITIALIZE_POOL) {
136
+ return parseMeteoraDbcInitializePoolFromData(data, metadata);
137
+ }
138
+ if (discriminator === exports.METEORA_DBC_DISC.CURVE_COMPLETE) {
139
+ return parseMeteoraDbcCurveCompleteFromData(data, metadata);
140
+ }
141
+ return null;
142
+ }
@@ -0,0 +1,6 @@
1
+ /** Meteora DLMM 结构化日志解析 */
2
+ import { type EventMetadata } from "../core/metadata.js";
3
+ import type { DexEvent } from "../core/dex_event.js";
4
+ export declare function parseDlmmFromDecoded(programData: Uint8Array, metadata: EventMetadata): DexEvent | null;
5
+ /** 从整行日志解析 */
6
+ export declare function parseMeteoraDlmmLog(log: string, signature: string, slot: number, txIndex: number, blockTimeUs: number | undefined, grpcRecvUs: number): DexEvent | null;