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,551 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALL_EVENT_TYPES = void 0;
4
+ exports.defaultClientConfig = defaultClientConfig;
5
+ exports.lowLatencyClientConfig = lowLatencyClientConfig;
6
+ exports.highThroughputClientConfig = highThroughputClientConfig;
7
+ exports.newTransactionFilter = newTransactionFilter;
8
+ exports.transactionFilterFromProgramIds = transactionFilterFromProgramIds;
9
+ exports.newAccountFilter = newAccountFilter;
10
+ exports.newSlotFilter = newSlotFilter;
11
+ exports.slotFilterMinSlot = slotFilterMinSlot;
12
+ exports.slotFilterMaxSlot = slotFilterMaxSlot;
13
+ exports.accountFilterFromProgramOwners = accountFilterFromProgramOwners;
14
+ exports.accountFilterMemcmp = accountFilterMemcmp;
15
+ exports.eventTypeFromDexEvent = eventTypeFromDexEvent;
16
+ exports.eventTypeFilterShouldIncludeDexEvent = eventTypeFilterShouldIncludeDexEvent;
17
+ exports.eventTypeFilterNormalizeDexEvent = eventTypeFilterNormalizeDexEvent;
18
+ exports.eventTypeFilterIncludeOnly = eventTypeFilterIncludeOnly;
19
+ exports.eventTypeFilterExclude = eventTypeFilterExclude;
20
+ exports.eventTypeFilterIncludesPumpfun = eventTypeFilterIncludesPumpfun;
21
+ exports.eventTypeFilterIncludesPumpFees = eventTypeFilterIncludesPumpFees;
22
+ exports.eventTypeFilterIncludesPumpswap = eventTypeFilterIncludesPumpswap;
23
+ exports.eventTypeFilterIncludesMeteoraDammV2 = eventTypeFilterIncludesMeteoraDammV2;
24
+ exports.eventTypeFilterIncludesMeteoraDbc = eventTypeFilterIncludesMeteoraDbc;
25
+ exports.eventTypeFilterIncludesMeteoraPools = eventTypeFilterIncludesMeteoraPools;
26
+ exports.eventTypeFilterIncludesMeteoraDlmm = eventTypeFilterIncludesMeteoraDlmm;
27
+ exports.eventTypeFilterIncludesRaydiumClmm = eventTypeFilterIncludesRaydiumClmm;
28
+ exports.eventTypeFilterIncludesRaydiumCpmm = eventTypeFilterIncludesRaydiumCpmm;
29
+ exports.eventTypeFilterIncludesRaydiumAmmV4 = eventTypeFilterIncludesRaydiumAmmV4;
30
+ exports.eventTypeFilterIncludesOrcaWhirlpool = eventTypeFilterIncludesOrcaWhirlpool;
31
+ exports.eventTypeFilterIncludesRaydiumLaunchlab = eventTypeFilterIncludesRaydiumLaunchlab;
32
+ exports.eventTypeFilterAllowsInstructionParsing = eventTypeFilterAllowsInstructionParsing;
33
+ function defaultClientConfig() {
34
+ return {
35
+ enable_metrics: false,
36
+ connection_timeout_ms: 8000,
37
+ request_timeout_ms: 15000,
38
+ enable_tls: true,
39
+ max_retries: 3,
40
+ retry_delay_ms: 1000,
41
+ max_concurrent_streams: 100,
42
+ keep_alive_interval_ms: 30000,
43
+ keep_alive_timeout_ms: 5000,
44
+ buffer_size: 8192,
45
+ order_mode: "Unordered",
46
+ order_timeout_ms: 100,
47
+ micro_batch_us: 100,
48
+ };
49
+ }
50
+ /** 与 Rust `ClientConfig::low_latency` 一致 */
51
+ function lowLatencyClientConfig() {
52
+ return {
53
+ enable_metrics: false,
54
+ connection_timeout_ms: 5000,
55
+ request_timeout_ms: 10_000,
56
+ enable_tls: true,
57
+ max_retries: 1,
58
+ retry_delay_ms: 100,
59
+ max_concurrent_streams: 200,
60
+ keep_alive_interval_ms: 10_000,
61
+ keep_alive_timeout_ms: 2000,
62
+ buffer_size: 16384,
63
+ order_mode: "Unordered",
64
+ order_timeout_ms: 50,
65
+ micro_batch_us: 50,
66
+ };
67
+ }
68
+ /** 与 Rust `ClientConfig::high_throughput` 一致 */
69
+ function highThroughputClientConfig() {
70
+ return {
71
+ enable_metrics: true,
72
+ connection_timeout_ms: 10_000,
73
+ request_timeout_ms: 30_000,
74
+ enable_tls: true,
75
+ max_retries: 5,
76
+ retry_delay_ms: 2000,
77
+ max_concurrent_streams: 500,
78
+ keep_alive_interval_ms: 60_000,
79
+ keep_alive_timeout_ms: 10_000,
80
+ buffer_size: 32768,
81
+ order_mode: "Unordered",
82
+ order_timeout_ms: 200,
83
+ micro_batch_us: 200,
84
+ };
85
+ }
86
+ function newTransactionFilter() {
87
+ return { account_include: [], account_exclude: [], account_required: [] };
88
+ }
89
+ /** 与 Rust `TransactionFilter::from_program_ids` 一致 */
90
+ function transactionFilterFromProgramIds(programIds) {
91
+ return {
92
+ account_include: [...programIds],
93
+ account_exclude: [],
94
+ account_required: [],
95
+ };
96
+ }
97
+ function newAccountFilter() {
98
+ return { account: [], owner: [], filters: [] };
99
+ }
100
+ function newSlotFilter() {
101
+ return {};
102
+ }
103
+ function slotFilterMinSlot(filter, slot) {
104
+ return { ...filter, min_slot: slot };
105
+ }
106
+ function slotFilterMaxSlot(filter, slot) {
107
+ return { ...filter, max_slot: slot };
108
+ }
109
+ /** 与 Rust `AccountFilter::from_program_owners` 一致 */
110
+ function accountFilterFromProgramOwners(programIds) {
111
+ return { account: [], owner: [...programIds], filters: [] };
112
+ }
113
+ /**
114
+ * 构造 memcmp 账户过滤器(与 Rust `account_filter_memcmp` 一致)。
115
+ * ATA 常在 offset 0 放 mint;PumpSwap 池子等常在 offset 32。
116
+ */
117
+ function accountFilterMemcmp(offset, bytes) {
118
+ return {
119
+ memcmp: {
120
+ offset: String(offset),
121
+ bytes,
122
+ },
123
+ };
124
+ }
125
+ /** 所有事件类型列表 */
126
+ exports.ALL_EVENT_TYPES = [
127
+ // Block
128
+ "BlockMeta",
129
+ // RaydiumLaunchlab
130
+ "RaydiumLaunchlabTrade",
131
+ "RaydiumLaunchlabPoolCreate",
132
+ "RaydiumLaunchlabMigrateAmm",
133
+ // PumpFun
134
+ "PumpFunTrade",
135
+ "PumpFunBuy",
136
+ "PumpFunSell",
137
+ "PumpFunBuyExactSolIn",
138
+ "PumpFunCreate",
139
+ "PumpFunCreateV2",
140
+ "PumpFunComplete",
141
+ "PumpFunMigrate",
142
+ "PumpFeesCreateFeeSharingConfig",
143
+ "PumpFeesInitializeFeeConfig",
144
+ "PumpFeesResetFeeSharingConfig",
145
+ "PumpFeesRevokeFeeSharingAuthority",
146
+ "PumpFeesTransferFeeSharingAuthority",
147
+ "PumpFeesUpdateAdmin",
148
+ "PumpFeesUpdateFeeConfig",
149
+ "PumpFeesUpdateFeeShares",
150
+ "PumpFeesUpsertFeeTiers",
151
+ "PumpFunMigrateBondingCurveCreator",
152
+ // PumpSwap
153
+ "PumpSwapTrade",
154
+ "PumpSwapBuy",
155
+ "PumpSwapSell",
156
+ "PumpSwapCreatePool",
157
+ "PumpSwapLiquidityAdded",
158
+ "PumpSwapLiquidityRemoved",
159
+ // Raydium CPMM
160
+ "RaydiumCpmmSwap",
161
+ "RaydiumCpmmDeposit",
162
+ "RaydiumCpmmWithdraw",
163
+ "RaydiumCpmmInitialize",
164
+ // Raydium CLMM
165
+ "RaydiumClmmSwap",
166
+ "RaydiumClmmCreatePool",
167
+ "RaydiumClmmOpenPosition",
168
+ "RaydiumClmmClosePosition",
169
+ "RaydiumClmmIncreaseLiquidity",
170
+ "RaydiumClmmDecreaseLiquidity",
171
+ "RaydiumClmmLiquidityChange",
172
+ "RaydiumClmmConfigChange",
173
+ "RaydiumClmmCreatePersonalPosition",
174
+ "RaydiumClmmLiquidityCalculate",
175
+ "RaydiumClmmOpenLimitOrder",
176
+ "RaydiumClmmIncreaseLimitOrder",
177
+ "RaydiumClmmDecreaseLimitOrder",
178
+ "RaydiumClmmSettleLimitOrder",
179
+ "RaydiumClmmUpdateRewardInfos",
180
+ "RaydiumClmmOpenPositionWithTokenExtNft",
181
+ "RaydiumClmmCollectFee",
182
+ // Raydium AMM V4
183
+ "RaydiumAmmV4Swap",
184
+ "RaydiumAmmV4Deposit",
185
+ "RaydiumAmmV4Withdraw",
186
+ "RaydiumAmmV4Initialize2",
187
+ "RaydiumAmmV4WithdrawPnl",
188
+ // Orca Whirlpool
189
+ "OrcaWhirlpoolSwap",
190
+ "OrcaWhirlpoolLiquidityIncreased",
191
+ "OrcaWhirlpoolLiquidityDecreased",
192
+ "OrcaWhirlpoolPoolInitialized",
193
+ // Meteora Pools
194
+ "MeteoraPoolsSwap",
195
+ "MeteoraPoolsAddLiquidity",
196
+ "MeteoraPoolsRemoveLiquidity",
197
+ "MeteoraPoolsBootstrapLiquidity",
198
+ "MeteoraPoolsPoolCreated",
199
+ "MeteoraPoolsSetPoolFees",
200
+ // Meteora DAMM V2
201
+ "MeteoraDammV2Swap",
202
+ "MeteoraDammV2AddLiquidity",
203
+ "MeteoraDammV2RemoveLiquidity",
204
+ "MeteoraDammV2InitializePool",
205
+ "MeteoraDammV2CreatePosition",
206
+ "MeteoraDammV2ClosePosition",
207
+ // Meteora DBC
208
+ "MeteoraDbcSwap",
209
+ "MeteoraDbcInitializePool",
210
+ "MeteoraDbcCurveComplete",
211
+ // Meteora DLMM
212
+ "MeteoraDlmmSwap",
213
+ "MeteoraDlmmAddLiquidity",
214
+ "MeteoraDlmmRemoveLiquidity",
215
+ "MeteoraDlmmInitializePool",
216
+ "MeteoraDlmmInitializeBinArray",
217
+ "MeteoraDlmmCreatePosition",
218
+ "MeteoraDlmmClosePosition",
219
+ "MeteoraDlmmClaimFee",
220
+ // Account types
221
+ "TokenAccount",
222
+ "TokenInfo",
223
+ "NonceAccount",
224
+ "AccountPumpFunGlobal",
225
+ "AccountPumpFunBondingCurve",
226
+ "AccountPumpFunFeeConfig",
227
+ "AccountPumpFunSharingConfig",
228
+ "AccountPumpFunGlobalVolumeAccumulator",
229
+ "AccountPumpFunUserVolumeAccumulator",
230
+ "AccountPumpSwapGlobalConfig",
231
+ "AccountPumpSwapPool",
232
+ "AccountRaydiumClmmAmmConfig",
233
+ "AccountRaydiumClmmPoolState",
234
+ "AccountRaydiumClmmTickArrayState",
235
+ "AccountRaydiumCpmmAmmConfig",
236
+ "AccountRaydiumCpmmPoolState",
237
+ "AccountOrcaWhirlpool",
238
+ "AccountOrcaPosition",
239
+ "AccountOrcaTickArray",
240
+ "AccountOrcaFeeTier",
241
+ "AccountOrcaWhirlpoolsConfig",
242
+ ];
243
+ const ALL_EVENT_TYPE_SET = new Set(exports.ALL_EVENT_TYPES);
244
+ const PUMPFUN_BUY_FAMILY = ["PumpFunBuy", "PumpFunBuyExactSolIn"];
245
+ const PUMPFUN_TRADE_FAMILY = [
246
+ "PumpFunBuy",
247
+ "PumpFunSell",
248
+ "PumpFunBuyExactSolIn",
249
+ ];
250
+ const PUMPFUN_CREATE_FAMILY = ["PumpFunCreate", "PumpFunCreateV2"];
251
+ const PUMPSWAP_TRADE_FAMILY = ["PumpSwapBuy", "PumpSwapSell"];
252
+ const PUMP_FEES_EVENT_TYPES = [
253
+ "PumpFeesCreateFeeSharingConfig",
254
+ "PumpFeesInitializeFeeConfig",
255
+ "PumpFeesResetFeeSharingConfig",
256
+ "PumpFeesRevokeFeeSharingAuthority",
257
+ "PumpFeesTransferFeeSharingAuthority",
258
+ "PumpFeesUpdateAdmin",
259
+ "PumpFeesUpdateFeeConfig",
260
+ "PumpFeesUpdateFeeShares",
261
+ "PumpFeesUpsertFeeTiers",
262
+ ];
263
+ const PUMPFUN_FILTER_TYPES = [
264
+ "PumpFunTrade",
265
+ "PumpFunBuy",
266
+ "PumpFunSell",
267
+ "PumpFunBuyExactSolIn",
268
+ "PumpFunCreate",
269
+ "PumpFunCreateV2",
270
+ "PumpFunComplete",
271
+ "PumpFunMigrate",
272
+ "PumpFunMigrateBondingCurveCreator",
273
+ ];
274
+ const PUMPSWAP_FILTER_TYPES = [
275
+ "PumpSwapTrade",
276
+ "PumpSwapBuy",
277
+ "PumpSwapSell",
278
+ "PumpSwapCreatePool",
279
+ "PumpSwapLiquidityAdded",
280
+ "PumpSwapLiquidityRemoved",
281
+ ];
282
+ const METEORA_DAMM_V2_FILTER_TYPES = [
283
+ "MeteoraDammV2Swap",
284
+ "MeteoraDammV2AddLiquidity",
285
+ "MeteoraDammV2RemoveLiquidity",
286
+ "MeteoraDammV2CreatePosition",
287
+ "MeteoraDammV2InitializePool",
288
+ "MeteoraDammV2ClosePosition",
289
+ ];
290
+ const METEORA_DBC_FILTER_TYPES = [
291
+ "MeteoraDbcSwap",
292
+ "MeteoraDbcInitializePool",
293
+ "MeteoraDbcCurveComplete",
294
+ ];
295
+ const METEORA_POOLS_FILTER_TYPES = [
296
+ "MeteoraPoolsSwap",
297
+ "MeteoraPoolsAddLiquidity",
298
+ "MeteoraPoolsRemoveLiquidity",
299
+ "MeteoraPoolsBootstrapLiquidity",
300
+ "MeteoraPoolsPoolCreated",
301
+ "MeteoraPoolsSetPoolFees",
302
+ ];
303
+ const METEORA_DLMM_FILTER_TYPES = [
304
+ "MeteoraDlmmSwap",
305
+ "MeteoraDlmmAddLiquidity",
306
+ "MeteoraDlmmRemoveLiquidity",
307
+ "MeteoraDlmmInitializePool",
308
+ "MeteoraDlmmInitializeBinArray",
309
+ "MeteoraDlmmCreatePosition",
310
+ "MeteoraDlmmClosePosition",
311
+ "MeteoraDlmmClaimFee",
312
+ ];
313
+ const RAYDIUM_CLMM_FILTER_TYPES = [
314
+ "RaydiumClmmSwap",
315
+ "RaydiumClmmIncreaseLiquidity",
316
+ "RaydiumClmmDecreaseLiquidity",
317
+ "RaydiumClmmLiquidityChange",
318
+ "RaydiumClmmConfigChange",
319
+ "RaydiumClmmCreatePersonalPosition",
320
+ "RaydiumClmmLiquidityCalculate",
321
+ "RaydiumClmmOpenLimitOrder",
322
+ "RaydiumClmmIncreaseLimitOrder",
323
+ "RaydiumClmmDecreaseLimitOrder",
324
+ "RaydiumClmmSettleLimitOrder",
325
+ "RaydiumClmmUpdateRewardInfos",
326
+ "RaydiumClmmCreatePool",
327
+ "RaydiumClmmOpenPosition",
328
+ "RaydiumClmmOpenPositionWithTokenExtNft",
329
+ "RaydiumClmmClosePosition",
330
+ "RaydiumClmmCollectFee",
331
+ ];
332
+ const RAYDIUM_CPMM_FILTER_TYPES = [
333
+ "RaydiumCpmmSwap",
334
+ "RaydiumCpmmDeposit",
335
+ "RaydiumCpmmWithdraw",
336
+ "RaydiumCpmmInitialize",
337
+ ];
338
+ const RAYDIUM_AMM_V4_FILTER_TYPES = [
339
+ "RaydiumAmmV4Swap",
340
+ "RaydiumAmmV4Deposit",
341
+ "RaydiumAmmV4Withdraw",
342
+ "RaydiumAmmV4WithdrawPnl",
343
+ "RaydiumAmmV4Initialize2",
344
+ ];
345
+ const ORCA_WHIRLPOOL_FILTER_TYPES = [
346
+ "OrcaWhirlpoolSwap",
347
+ "OrcaWhirlpoolLiquidityIncreased",
348
+ "OrcaWhirlpoolLiquidityDecreased",
349
+ "OrcaWhirlpoolPoolInitialized",
350
+ ];
351
+ const RAYDIUM_LAUNCHLAB_FILTER_TYPES = [
352
+ "RaydiumLaunchlabTrade",
353
+ "RaydiumLaunchlabPoolCreate",
354
+ "RaydiumLaunchlabMigrateAmm",
355
+ ];
356
+ const INSTRUCTION_EVENT_TYPES = [
357
+ ...PUMPFUN_FILTER_TYPES,
358
+ ...PUMP_FEES_EVENT_TYPES,
359
+ ...PUMPSWAP_FILTER_TYPES,
360
+ ...METEORA_DAMM_V2_FILTER_TYPES,
361
+ ...METEORA_POOLS_FILTER_TYPES,
362
+ ...METEORA_DLMM_FILTER_TYPES,
363
+ ...RAYDIUM_CLMM_FILTER_TYPES,
364
+ ...RAYDIUM_CPMM_FILTER_TYPES,
365
+ ...RAYDIUM_AMM_V4_FILTER_TYPES,
366
+ ...ORCA_WHIRLPOOL_FILTER_TYPES,
367
+ ...RAYDIUM_LAUNCHLAB_FILTER_TYPES,
368
+ ];
369
+ const INSTRUCTION_EVENT_TYPE_SET = new Set(INSTRUCTION_EVENT_TYPES);
370
+ const DEX_EVENT_TYPE_BY_VARIANT = {
371
+ PumpFunGlobalAccount: "AccountPumpFunGlobal",
372
+ PumpFunBondingCurveAccount: "AccountPumpFunBondingCurve",
373
+ PumpFunFeeConfigAccount: "AccountPumpFunFeeConfig",
374
+ PumpFunSharingConfigAccount: "AccountPumpFunSharingConfig",
375
+ PumpFunGlobalVolumeAccumulatorAccount: "AccountPumpFunGlobalVolumeAccumulator",
376
+ PumpFunUserVolumeAccumulatorAccount: "AccountPumpFunUserVolumeAccumulator",
377
+ PumpSwapGlobalConfigAccount: "AccountPumpSwapGlobalConfig",
378
+ PumpSwapPoolAccount: "AccountPumpSwapPool",
379
+ RaydiumClmmAmmConfigAccount: "AccountRaydiumClmmAmmConfig",
380
+ RaydiumClmmPoolStateAccount: "AccountRaydiumClmmPoolState",
381
+ RaydiumClmmTickArrayStateAccount: "AccountRaydiumClmmTickArrayState",
382
+ RaydiumCpmmAmmConfigAccount: "AccountRaydiumCpmmAmmConfig",
383
+ RaydiumCpmmPoolStateAccount: "AccountRaydiumCpmmPoolState",
384
+ OrcaWhirlpoolAccount: "AccountOrcaWhirlpool",
385
+ OrcaPositionAccount: "AccountOrcaPosition",
386
+ OrcaTickArrayAccount: "AccountOrcaTickArray",
387
+ OrcaFeeTierAccount: "AccountOrcaFeeTier",
388
+ OrcaWhirlpoolsConfigAccount: "AccountOrcaWhirlpoolsConfig",
389
+ };
390
+ function eventTypeFromDexEvent(event) {
391
+ const variant = Object.keys(event)[0];
392
+ if (!variant || variant === "Error")
393
+ return null;
394
+ const mapped = DEX_EVENT_TYPE_BY_VARIANT[variant];
395
+ if (mapped)
396
+ return mapped;
397
+ return ALL_EVENT_TYPE_SET.has(variant) ? variant : null;
398
+ }
399
+ function eventTypeFilterShouldIncludeDexEvent(filter, event) {
400
+ const eventType = eventTypeFromDexEvent(event);
401
+ return eventType === null || filter.shouldInclude(eventType);
402
+ }
403
+ function eventTypeFilterNormalizeDexEvent(filter, event) {
404
+ const includeOnly = filter.include_only;
405
+ if (!includeOnly || !includeOnly.includes("PumpFunTrade"))
406
+ return event;
407
+ const hasSpecificTradeFilter = includeOnly.some((t) => isPumpfunTradeConcrete(t));
408
+ if (hasSpecificTradeFilter)
409
+ return event;
410
+ if ("PumpFunBuy" in event)
411
+ return { PumpFunTrade: event.PumpFunBuy };
412
+ if ("PumpFunSell" in event)
413
+ return { PumpFunTrade: event.PumpFunSell };
414
+ if ("PumpFunBuyExactSolIn" in event)
415
+ return { PumpFunTrade: event.PumpFunBuyExactSolIn };
416
+ return event;
417
+ }
418
+ function eventTypeFilterIncludeOnly(types) {
419
+ const include_only = types;
420
+ return {
421
+ include_only,
422
+ shouldInclude(eventType) {
423
+ if (include_only.includes(eventType))
424
+ return true;
425
+ if (eventType === "PumpFunTrade") {
426
+ return eventTypesIntersect(include_only, PUMPFUN_TRADE_FAMILY);
427
+ }
428
+ if (isPumpfunTradeConcrete(eventType)) {
429
+ if (include_only.includes("PumpFunTrade"))
430
+ return true;
431
+ if (isPumpfunBuyFamily(eventType)) {
432
+ return eventTypesIntersect(include_only, PUMPFUN_BUY_FAMILY);
433
+ }
434
+ return false;
435
+ }
436
+ if (isPumpfunCreateFamily(eventType)) {
437
+ return eventTypesIntersect(include_only, PUMPFUN_CREATE_FAMILY);
438
+ }
439
+ if (isPumpswapTradeConcrete(eventType)) {
440
+ return include_only.includes("PumpSwapTrade");
441
+ }
442
+ return false;
443
+ },
444
+ };
445
+ }
446
+ function eventTypeFilterExclude(types) {
447
+ const exclude_types = types;
448
+ return {
449
+ exclude_types,
450
+ shouldInclude(eventType) {
451
+ if (exclude_types.includes(eventType))
452
+ return false;
453
+ if (isPumpfunTradeConcrete(eventType) && exclude_types.includes("PumpFunTrade")) {
454
+ return false;
455
+ }
456
+ if (isPumpfunBuyFamily(eventType) &&
457
+ eventTypesIntersect(exclude_types, PUMPFUN_BUY_FAMILY)) {
458
+ return false;
459
+ }
460
+ if (isPumpfunCreateFamily(eventType) &&
461
+ eventTypesIntersect(exclude_types, PUMPFUN_CREATE_FAMILY)) {
462
+ return false;
463
+ }
464
+ if (isPumpswapTradeConcrete(eventType) && exclude_types.includes("PumpSwapTrade")) {
465
+ return false;
466
+ }
467
+ return true;
468
+ },
469
+ };
470
+ }
471
+ function eventTypesIntersect(types, candidates) {
472
+ return types.some((t) => candidates.includes(t));
473
+ }
474
+ function isPumpfunTradeConcrete(eventType) {
475
+ return (eventType === "PumpFunBuy" ||
476
+ eventType === "PumpFunSell" ||
477
+ eventType === "PumpFunBuyExactSolIn");
478
+ }
479
+ function isPumpfunBuyFamily(eventType) {
480
+ return eventType === "PumpFunBuy" || eventType === "PumpFunBuyExactSolIn";
481
+ }
482
+ function isPumpfunCreateFamily(eventType) {
483
+ return eventType === "PumpFunCreate" || eventType === "PumpFunCreateV2";
484
+ }
485
+ function isPumpswapTradeConcrete(eventType) {
486
+ return eventType === "PumpSwapBuy" || eventType === "PumpSwapSell";
487
+ }
488
+ function eventTypeFilterIncludesAny(filter, types) {
489
+ if (filter.include_only) {
490
+ return eventTypesIntersect(filter.include_only, types);
491
+ }
492
+ if (filter.exclude_types) {
493
+ return types.some((t) => filter.shouldInclude(t));
494
+ }
495
+ return types.some((t) => filter.shouldInclude(t));
496
+ }
497
+ /** 过滤器是否包含 PumpFun 相关类型 */
498
+ function eventTypeFilterIncludesPumpfun(filter) {
499
+ return eventTypeFilterIncludesAny(filter, PUMPFUN_FILTER_TYPES);
500
+ }
501
+ /** 过滤器是否包含 Pump Fees (`pfeeUx...`) 相关类型 */
502
+ function eventTypeFilterIncludesPumpFees(filter) {
503
+ return eventTypeFilterIncludesAny(filter, PUMP_FEES_EVENT_TYPES);
504
+ }
505
+ /** 过滤器是否包含 PumpSwap 相关类型 */
506
+ function eventTypeFilterIncludesPumpswap(filter) {
507
+ return eventTypeFilterIncludesAny(filter, PUMPSWAP_FILTER_TYPES);
508
+ }
509
+ /** 过滤器是否包含 Meteora DAMM V2 相关类型 */
510
+ function eventTypeFilterIncludesMeteoraDammV2(filter) {
511
+ return eventTypeFilterIncludesAny(filter, METEORA_DAMM_V2_FILTER_TYPES);
512
+ }
513
+ /** 过滤器是否包含 Meteora DBC 相关类型 */
514
+ function eventTypeFilterIncludesMeteoraDbc(filter) {
515
+ return eventTypeFilterIncludesAny(filter, METEORA_DBC_FILTER_TYPES);
516
+ }
517
+ /** 过滤器是否包含 Meteora Pools 相关类型 */
518
+ function eventTypeFilterIncludesMeteoraPools(filter) {
519
+ return eventTypeFilterIncludesAny(filter, METEORA_POOLS_FILTER_TYPES);
520
+ }
521
+ /** 过滤器是否包含 Meteora DLMM 相关类型 */
522
+ function eventTypeFilterIncludesMeteoraDlmm(filter) {
523
+ return eventTypeFilterIncludesAny(filter, METEORA_DLMM_FILTER_TYPES);
524
+ }
525
+ /** 过滤器是否包含 Raydium CLMM 相关类型 */
526
+ function eventTypeFilterIncludesRaydiumClmm(filter) {
527
+ return eventTypeFilterIncludesAny(filter, RAYDIUM_CLMM_FILTER_TYPES);
528
+ }
529
+ /** 过滤器是否包含 Raydium CPMM 相关类型 */
530
+ function eventTypeFilterIncludesRaydiumCpmm(filter) {
531
+ return eventTypeFilterIncludesAny(filter, RAYDIUM_CPMM_FILTER_TYPES);
532
+ }
533
+ /** 过滤器是否包含 Raydium AMM V4 相关类型 */
534
+ function eventTypeFilterIncludesRaydiumAmmV4(filter) {
535
+ return eventTypeFilterIncludesAny(filter, RAYDIUM_AMM_V4_FILTER_TYPES);
536
+ }
537
+ /** 过滤器是否包含 Orca Whirlpool 相关类型 */
538
+ function eventTypeFilterIncludesOrcaWhirlpool(filter) {
539
+ return eventTypeFilterIncludesAny(filter, ORCA_WHIRLPOOL_FILTER_TYPES);
540
+ }
541
+ /** 过滤器是否包含 Raydium LaunchLab 相关类型(与 Rust `includes_raydium_launchlab` 集合一致) */
542
+ function eventTypeFilterIncludesRaydiumLaunchlab(filter) {
543
+ return eventTypeFilterIncludesAny(filter, RAYDIUM_LAUNCHLAB_FILTER_TYPES);
544
+ }
545
+ /**
546
+ * `parseInstructionUnified` 前置白名单:仅当 `include_only` 与下列指令相关类型有交集时才解析指令。
547
+ * 若白名单中不含下列任一类型,则整条指令解析入口返回 null。
548
+ */
549
+ function eventTypeFilterAllowsInstructionParsing(includeOnly) {
550
+ return includeOnly.some((t) => INSTRUCTION_EVENT_TYPE_SET.has(t));
551
+ }
@@ -0,0 +1,16 @@
1
+ import type { DexEvent } from "../core/dex_event.js";
2
+ import type { EventTypeFilter, SubscribeUpdateTransactionInfo } from "./types.js";
3
+ /**
4
+ * Yellowstone `SubscribeUpdateTransactionInfo.index` → `EventMetadata.tx_index`。
5
+ * 与 Rust `sol-parser-sdk` gRPC 路径中 `let idx = info.index` 传入 `parse_logs(..., idx, ...)` 一致。
6
+ */
7
+ export declare function grpcTxIndexFromInfo(info: Pick<SubscribeUpdateTransactionInfo, "index">): number;
8
+ /**
9
+ * 从 gRPC 回调中的 `SubscribeUpdateTransactionInfo`(须含 `transactionRaw` + `metaRaw` 原始 proto)
10
+ * 解析 `DexEvent[]`,并对 PumpSwap/PumpFun 等补齐 mint、池子 ATA 等(与 Rust 订阅路径一致)。
11
+ */
12
+ export declare function parseDexEventsFromGrpcTransactionInfo(info: SubscribeUpdateTransactionInfo, slot: string | bigint, options?: {
13
+ blockTimeUs?: number;
14
+ grpcRecvUs?: number;
15
+ eventTypeFilter?: EventTypeFilter;
16
+ }): DexEvent[];
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.grpcTxIndexFromInfo = grpcTxIndexFromInfo;
7
+ exports.parseDexEventsFromGrpcTransactionInfo = parseDexEventsFromGrpcTransactionInfo;
8
+ /**
9
+ * Yellowstone gRPC 单笔交易:统一交易解析(指令 + 日志 + 与 Rust 相同的账户/数据填充)。
10
+ * 依赖 `@triton-one/yellowstone-grpc` 的 `txEncode`(Binary)得到与 web3 兼容的 meta + 反序列化交易。
11
+ */
12
+ const yellowstone_grpc_1 = require("@triton-one/yellowstone-grpc");
13
+ const yellowstone_grpc_solana_encoding_wasm_js_1 = require("@triton-one/yellowstone-grpc/dist/encoding/yellowstone_grpc_solana_encoding_wasm.js");
14
+ const bs58_1 = __importDefault(require("bs58"));
15
+ const web3_js_1 = require("@solana/web3.js");
16
+ const rpc_transaction_js_1 = require("../rpc_transaction.js");
17
+ /**
18
+ * Yellowstone `SubscribeUpdateTransactionInfo.index` → `EventMetadata.tx_index`。
19
+ * 与 Rust `sol-parser-sdk` gRPC 路径中 `let idx = info.index` 传入 `parse_logs(..., idx, ...)` 一致。
20
+ */
21
+ function grpcTxIndexFromInfo(info) {
22
+ const index = info.index;
23
+ if (index === undefined)
24
+ return 0;
25
+ const n = typeof index === "bigint" ? Number(index) : Number(index);
26
+ return Number.isFinite(n) && n >= 0 ? Math.floor(n) : 0;
27
+ }
28
+ /**
29
+ * 从 gRPC 回调中的 `SubscribeUpdateTransactionInfo`(须含 `transactionRaw` + `metaRaw` 原始 proto)
30
+ * 解析 `DexEvent[]`,并对 PumpSwap/PumpFun 等补齐 mint、池子 ATA 等(与 Rust 订阅路径一致)。
31
+ */
32
+ function parseDexEventsFromGrpcTransactionInfo(info, slot, options) {
33
+ const tr = info.transactionRaw;
34
+ const mr = info.metaRaw;
35
+ if (!tr || !mr)
36
+ return [];
37
+ const y = {
38
+ signature: info.signature,
39
+ isVote: info.isVote,
40
+ transaction: tr,
41
+ meta: mr,
42
+ index: String(info.index),
43
+ };
44
+ const enc = yellowstone_grpc_1.txEncode.encode(y, yellowstone_grpc_solana_encoding_wasm_js_1.WasmUiTransactionEncoding.Binary, 0, false);
45
+ const vt = web3_js_1.VersionedTransaction.deserialize(bs58_1.default.decode(enc.transaction));
46
+ const meta = enc.meta;
47
+ const slotNum = typeof slot === "bigint" ? Number(slot) : Number(slot);
48
+ const signatureBase58 = bs58_1.default.encode(Uint8Array.from(info.signature));
49
+ const txIndex = grpcTxIndexFromInfo(info);
50
+ const blockTime = options?.blockTimeUs == null ? null : Math.floor(options.blockTimeUs / 1_000_000);
51
+ const parsed = (0, rpc_transaction_js_1.parseRpcTransaction)({
52
+ slot: slotNum,
53
+ blockTime,
54
+ meta,
55
+ transaction: vt,
56
+ }, signatureBase58, options?.eventTypeFilter, {
57
+ blockTimeUs: options?.blockTimeUs,
58
+ grpcRecvUs: options?.grpcRecvUs,
59
+ txIndex,
60
+ });
61
+ return parsed.ok ? parsed.events : [];
62
+ }