forgex-cli 1.0.58 → 1.0.61

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 (158) hide show
  1. package/README.md +375 -368
  2. package/dist/bin/forgex.d.ts +5 -5
  3. package/dist/bin/forgex.js +14 -14
  4. package/dist/bin/forgex.js.map +1 -1
  5. package/dist/src/adapters/codex-adapter.d.ts +90 -90
  6. package/dist/src/adapters/codex-adapter.d.ts.map +1 -1
  7. package/dist/src/adapters/codex-adapter.js +76 -76
  8. package/dist/src/adapters/codex-adapter.js.map +1 -1
  9. package/dist/src/adapters/connection.d.ts +6 -6
  10. package/dist/src/adapters/connection.js +8 -8
  11. package/dist/src/adapters/connection.js.map +1 -1
  12. package/dist/src/adapters/ipfs.d.ts +3 -3
  13. package/dist/src/adapters/ipfs.js +3 -3
  14. package/dist/src/adapters/jito-adapter.d.ts +85 -85
  15. package/dist/src/adapters/jito-adapter.d.ts.map +1 -1
  16. package/dist/src/adapters/jito-adapter.js +111 -111
  17. package/dist/src/adapters/jito-adapter.js.map +1 -1
  18. package/dist/src/adapters/rpc-adapter.d.ts +53 -53
  19. package/dist/src/adapters/rpc-adapter.d.ts.map +1 -1
  20. package/dist/src/adapters/rpc-adapter.js +69 -69
  21. package/dist/src/adapters/rpc-adapter.js.map +1 -1
  22. package/dist/src/adapters/sdk-adapter.d.ts +21 -21
  23. package/dist/src/adapters/sdk-adapter.d.ts.map +1 -1
  24. package/dist/src/adapters/sdk-adapter.js +79 -79
  25. package/dist/src/adapters/sdk-adapter.js.map +1 -1
  26. package/dist/src/commands/config/index.d.ts +1 -1
  27. package/dist/src/commands/config/index.js +15 -15
  28. package/dist/src/commands/config/index.js.map +1 -1
  29. package/dist/src/commands/query/index.d.ts +2 -2
  30. package/dist/src/commands/query/index.js +82 -82
  31. package/dist/src/commands/query/index.js.map +1 -1
  32. package/dist/src/commands/token/index.d.ts +8 -8
  33. package/dist/src/commands/token/index.js +73 -73
  34. package/dist/src/commands/token/index.js.map +1 -1
  35. package/dist/src/commands/tools/index.d.ts +9 -9
  36. package/dist/src/commands/tools/index.js +137 -137
  37. package/dist/src/commands/tools/index.js.map +1 -1
  38. package/dist/src/commands/trade/index.d.ts +2 -2
  39. package/dist/src/commands/trade/index.js +82 -82
  40. package/dist/src/commands/trade/index.js.map +1 -1
  41. package/dist/src/commands/transfer/index.d.ts +8 -8
  42. package/dist/src/commands/transfer/index.js +106 -106
  43. package/dist/src/commands/transfer/index.js.map +1 -1
  44. package/dist/src/commands/wallet/index.d.ts +1 -1
  45. package/dist/src/commands/wallet/index.js +175 -175
  46. package/dist/src/commands/wallet/index.js.map +1 -1
  47. package/dist/src/config.d.ts +26 -26
  48. package/dist/src/config.d.ts.map +1 -1
  49. package/dist/src/config.js +28 -28
  50. package/dist/src/config.js.map +1 -1
  51. package/dist/src/const/index.js +1 -1
  52. package/dist/src/const/index.js.map +1 -1
  53. package/dist/src/data-source.d.ts +81 -81
  54. package/dist/src/data-source.d.ts.map +1 -1
  55. package/dist/src/data-source.js +149 -149
  56. package/dist/src/data-source.js.map +1 -1
  57. package/dist/src/data-store/index.d.ts +22 -22
  58. package/dist/src/data-store/index.d.ts.map +1 -1
  59. package/dist/src/data-store/index.js +46 -46
  60. package/dist/src/data-store/index.js.map +1 -1
  61. package/dist/src/data-store/types.d.ts +3 -3
  62. package/dist/src/data-store/types.js +3 -3
  63. package/dist/src/index.d.ts +2 -2
  64. package/dist/src/index.js +10 -10
  65. package/dist/src/index.js.map +1 -1
  66. package/dist/src/output.d.ts +18 -18
  67. package/dist/src/output.d.ts.map +1 -1
  68. package/dist/src/output.js +34 -34
  69. package/dist/src/output.js.map +1 -1
  70. package/dist/src/shims/store.d.ts +3 -2
  71. package/dist/src/shims/store.d.ts.map +1 -1
  72. package/dist/src/shims/store.js +6 -5
  73. package/dist/src/shims/store.js.map +1 -1
  74. package/dist/src/sol-sdk/batch/create.d.ts +4 -1
  75. package/dist/src/sol-sdk/batch/create.d.ts.map +1 -1
  76. package/dist/src/sol-sdk/batch/create.js +44 -44
  77. package/dist/src/sol-sdk/batch/create.js.map +1 -1
  78. package/dist/src/sol-sdk/batch/index.js +135 -135
  79. package/dist/src/sol-sdk/batch/index.js.map +1 -1
  80. package/dist/src/sol-sdk/calc.d.ts +63 -63
  81. package/dist/src/sol-sdk/calc.d.ts.map +1 -1
  82. package/dist/src/sol-sdk/calc.js +120 -120
  83. package/dist/src/sol-sdk/calc.js.map +1 -1
  84. package/dist/src/sol-sdk/jito/index.js +12 -12
  85. package/dist/src/sol-sdk/jito/index.js.map +1 -1
  86. package/dist/src/sol-sdk/launchlab/instructions/create.js +10 -10
  87. package/dist/src/sol-sdk/launchlab/instructions/create.js.map +1 -1
  88. package/dist/src/sol-sdk/meteora/index.d.ts +5 -5
  89. package/dist/src/sol-sdk/meteora/index.js +11 -11
  90. package/dist/src/sol-sdk/meteora/index.js.map +1 -1
  91. package/dist/src/sol-sdk/meteora/instructions/buy.js +8 -8
  92. package/dist/src/sol-sdk/meteora/instructions/buy.js.map +1 -1
  93. package/dist/src/sol-sdk/meteora/instructions/sell.js +6 -6
  94. package/dist/src/sol-sdk/meteora/instructions/sell.js.map +1 -1
  95. package/dist/src/sol-sdk/pump/index.js +3 -3
  96. package/dist/src/sol-sdk/pump/index.js.map +1 -1
  97. package/dist/src/sol-sdk/pump/instructions/buy.d.ts +12 -12
  98. package/dist/src/sol-sdk/pump/instructions/buy.d.ts.map +1 -1
  99. package/dist/src/sol-sdk/pump/instructions/buy.js +26 -26
  100. package/dist/src/sol-sdk/pump/instructions/buy.js.map +1 -1
  101. package/dist/src/sol-sdk/pump/instructions/createAndBuy.d.ts +13 -13
  102. package/dist/src/sol-sdk/pump/instructions/createAndBuy.js +17 -17
  103. package/dist/src/sol-sdk/pump/instructions/createAndBuy.js.map +1 -1
  104. package/dist/src/sol-sdk/pump/instructions/sell.d.ts +2 -2
  105. package/dist/src/sol-sdk/pump/instructions/sell.d.ts.map +1 -1
  106. package/dist/src/sol-sdk/pump/instructions/sell.js +7 -7
  107. package/dist/src/sol-sdk/pump/instructions/sell.js.map +1 -1
  108. package/dist/src/sol-sdk/pumpswap/index.d.ts +4 -4
  109. package/dist/src/sol-sdk/pumpswap/index.js +5 -5
  110. package/dist/src/sol-sdk/pumpswap/index.js.map +1 -1
  111. package/dist/src/sol-sdk/pumpswap/instructions/buy.d.ts +8 -8
  112. package/dist/src/sol-sdk/pumpswap/instructions/buy.js +19 -19
  113. package/dist/src/sol-sdk/pumpswap/instructions/buy.js.map +1 -1
  114. package/dist/src/sol-sdk/pumpswap/instructions/migrate.js +2 -2
  115. package/dist/src/sol-sdk/pumpswap/instructions/migrate.js.map +1 -1
  116. package/dist/src/sol-sdk/pumpswap/instructions/sell.js +4 -4
  117. package/dist/src/sol-sdk/pumpswap/instructions/sell.js.map +1 -1
  118. package/dist/src/sol-sdk/pumpswap/rpc/index.js +1 -1
  119. package/dist/src/sol-sdk/pumpswap/rpc/index.js.map +1 -1
  120. package/dist/src/sol-sdk/raydium/instructions/cpmmSell.js +3 -3
  121. package/dist/src/sol-sdk/raydium/instructions/cpmmSell.js.map +1 -1
  122. package/dist/src/sol-sdk/raydium/instructions/sell.d.ts +40 -8520
  123. package/dist/src/sol-sdk/raydium/instructions/sell.d.ts.map +1 -1
  124. package/dist/src/sol-sdk/raydium/instructions/sell.js +6 -6
  125. package/dist/src/sol-sdk/raydium/instructions/sell.js.map +1 -1
  126. package/dist/src/sol-sdk/raydium/rpc/index.d.ts +4 -4
  127. package/dist/src/sol-sdk/rpc/index.d.ts +14 -14
  128. package/dist/src/sol-sdk/rpc/index.d.ts.map +1 -1
  129. package/dist/src/sol-sdk/rpc/index.js +17 -17
  130. package/dist/src/sol-sdk/rpc/index.js.map +1 -1
  131. package/dist/src/sol-sdk/transfer/index.js +5 -5
  132. package/dist/src/sol-sdk/transfer/index.js.map +1 -1
  133. package/dist/src/sol-sdk/turnover/index.d.ts +3 -3
  134. package/dist/src/sol-sdk/turnover/index.js +56 -56
  135. package/dist/src/sol-sdk/turnover/index.js.map +1 -1
  136. package/dist/src/telemetry.d.ts +8 -8
  137. package/dist/src/telemetry.d.ts.map +1 -1
  138. package/dist/src/telemetry.js +28 -27
  139. package/dist/src/telemetry.js.map +1 -1
  140. package/dist/src/tx-tracker/detail-adapter.d.ts +53 -53
  141. package/dist/src/tx-tracker/detail-adapter.d.ts.map +1 -1
  142. package/dist/src/tx-tracker/detail-adapter.js +68 -68
  143. package/dist/src/tx-tracker/detail-adapter.js.map +1 -1
  144. package/dist/src/tx-tracker/index.d.ts +67 -67
  145. package/dist/src/tx-tracker/index.d.ts.map +1 -1
  146. package/dist/src/tx-tracker/index.js +103 -103
  147. package/dist/src/tx-tracker/index.js.map +1 -1
  148. package/dist/src/types/index.d.ts +10 -10
  149. package/dist/src/types/index.d.ts.map +1 -1
  150. package/dist/src/types/websocket.js +1 -1
  151. package/dist/src/types/websocket.js.map +1 -1
  152. package/dist/src/utils/index.js +20 -20
  153. package/dist/src/utils/index.js.map +1 -1
  154. package/dist/src/wallet-store.d.ts +51 -51
  155. package/dist/src/wallet-store.d.ts.map +1 -1
  156. package/dist/src/wallet-store.js +104 -104
  157. package/dist/src/wallet-store.js.map +1 -1
  158. package/package.json +1 -1
@@ -23,7 +23,7 @@ async function getMeteoraDLMM() {
23
23
  _MeteoraDLMM = mod.default;
24
24
  }
25
25
  catch {
26
- throw new Error('@meteora-ag/dlmm 未安装,请先执行: npm install @meteora-ag/dlmm');
26
+ throw new Error('@meteora-ag/dlmm is not installed. Please run: npm install @meteora-ag/dlmm');
27
27
  }
28
28
  }
29
29
  return _MeteoraDLMM;
@@ -34,25 +34,25 @@ let redis = {
34
34
  pumpSwapCache: {},
35
35
  pumpSwapAtaCache: {},
36
36
  };
37
- export const batchTrade = async ({ connection, exchangeName, // dex名称
38
- tokenAddress, // 代币地址
39
- poolId, // 池子ID
40
- tradeType, // 交易类型
41
- slippage, // 滑点
42
- priorityFee, // 优先费
43
- priceInSol, // 价格
44
- decimals, // 小数位
45
- poolInfo, // 池子信息
46
- ammReverseInfo = undefined, // 深度信息
47
- launchlabReverseInfo = undefined, // 深度信息
48
- meteoraDLMMReverseInfo = undefined, // meteora 池子信息
49
- creatorAddress, // 创建者地址
50
- walletAmounts, pumpfunReverseInfo, raydiumV4Keys = undefined, raydiumCpmmKeys = undefined, volumeType = VolumeType.ONE_BUY_ONE_SELL, // 刷量方式
51
- simulate = false, // 模拟交易
37
+ export const batchTrade = async ({ connection, exchangeName, // DEX name
38
+ tokenAddress, // Token address
39
+ poolId, // Pool ID
40
+ tradeType, // Trade type
41
+ slippage, // Slippage
42
+ priorityFee, // Priority fee
43
+ priceInSol, // Price
44
+ decimals, // Decimals
45
+ poolInfo, // Pool info
46
+ ammReverseInfo = undefined, // Depth info
47
+ launchlabReverseInfo = undefined, // Depth info
48
+ meteoraDLMMReverseInfo = undefined, // Meteora pool info
49
+ creatorAddress, // Creator address
50
+ walletAmounts, pumpfunReverseInfo, raydiumV4Keys = undefined, raydiumCpmmKeys = undefined, volumeType = VolumeType.ONE_BUY_ONE_SELL, // Volume trading mode
51
+ simulate = false, // Simulate transaction
52
52
  }) => {
53
53
  slippage = slippage / 100;
54
54
  if (!poolId || !tokenAddress || !priceInSol || !walletAmounts.length) {
55
- console.log('参数错误', {
55
+ console.log('Parameter error', {
56
56
  poolId,
57
57
  tokenAddress,
58
58
  priceInSol,
@@ -172,13 +172,13 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
172
172
  const provider = new AnchorProvider(connection, {
173
173
  publicKey: Keypair.generate().publicKey,
174
174
  signTransaction: async () => {
175
- throw new Error('不支持签名');
175
+ throw new Error('Signing not supported');
176
176
  },
177
177
  signAllTransactions: async () => {
178
- throw new Error('不支持签名');
178
+ throw new Error('Signing not supported');
179
179
  },
180
180
  }, {});
181
- // 使用getPumpCurveState方法解析池子数据
181
+ // Parse pool data using getPumpCurveState
182
182
  const poolData = reverseInfo || (await getLaunchlabReverseInfo({ connection, poolId }));
183
183
  console.log('poolData: ', poolData);
184
184
  const parsedPoolData = {
@@ -192,7 +192,7 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
192
192
  realBase: poolData.realBase.toString(),
193
193
  realQuote: poolData.realQuote.toString(),
194
194
  };
195
- // 创建计算器实例
195
+ // Create calculator instance
196
196
  const launchlabCalc = new LaunchlabAmmCalc({
197
197
  baseDecimals: parsedPoolData.baseDecimals,
198
198
  quoteDecimals: parsedPoolData.quoteDecimals,
@@ -208,7 +208,7 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
208
208
  const jito = getJitoAdapter();
209
209
  const blockhash = (await connection.getLatestBlockhash()).blockhash;
210
210
  const base64Txs = [];
211
- // 处理交易逻辑
211
+ // Process trade logic
212
212
  if (tradeType === 'buy') {
213
213
  try {
214
214
  for (const payer of walletAmounts) {
@@ -249,7 +249,7 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
249
249
  }
250
250
  catch (error) {
251
251
  const _errMsg = error instanceof Error ? error.stack || error.message : JSON.stringify(error, null, 2);
252
- throw new Error(`构造交易指令失败: ${_errMsg}`);
252
+ throw new Error(`Failed to build transaction instructions: ${_errMsg}`);
253
253
  }
254
254
  }
255
255
  else if (tradeType === 'sell') {
@@ -285,32 +285,32 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
285
285
  }
286
286
  catch (error) {
287
287
  const _errMsg = error instanceof Error ? error.stack || error.message : JSON.stringify(error, null, 2);
288
- throw new Error(`构造交易指令失败: ${_errMsg}`);
288
+ throw new Error(`Failed to build transaction instructions: ${_errMsg}`);
289
289
  }
290
290
  }
291
291
  else if (tradeType === 'buyWithSell') {
292
- // 实现 Pump 的多买多卖逻辑
292
+ // Implement Pump multi-buy multi-sell logic
293
293
  try {
294
294
  for (const payer of walletAmounts) {
295
295
  const currentPayer = getWalletKeypair(payer.privateKey);
296
296
  const currentAmount = new BigNumber(payer.amount).times(LAMPORTS_PER_SOL).toFixed(0);
297
- // 提前创建 wsolAccount
297
+ // Pre-create wsolAccount
298
298
  const { wsolAccount, createWsolAccount } = await getNewWsolAccount(currentPayer.publicKey, new BigNumber(currentAmount).times(1 + slippage).toFixed(0));
299
- // 创建组合交易
299
+ // Create combined transaction
300
300
  const tx = new Transaction();
301
301
  let totalBuyReceiveAmount = new BN(0);
302
- // 根据 volumeType 确定买入和卖出次数
302
+ // Determine buy and sell counts based on volumeType
303
303
  const { buyCount, sellCount } = getVolumeTypeConfig(volumeType);
304
- // 执行多次买入
304
+ // Execute multiple buys
305
305
  let remainingAmount = new BigNumber(currentAmount);
306
306
  for (let i = 0; i < buyCount; i++) {
307
307
  let buyAmount;
308
308
  if (i === buyCount - 1) {
309
- // 最后一次买入时,使用所有剩余资金
309
+ // Use all remaining funds on the last buy
310
310
  buyAmount = remainingAmount.toFixed(0);
311
311
  }
312
312
  else {
313
- // 前面几次按平均分配
313
+ // Distribute evenly for earlier iterations
314
314
  buyAmount = new BigNumber(currentAmount).div(buyCount).toFixed(0);
315
315
  remainingAmount = remainingAmount.minus(buyAmount);
316
316
  }
@@ -323,7 +323,7 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
323
323
  break;
324
324
  }
325
325
  totalBuyReceiveAmount = totalBuyReceiveAmount.add(new BN(buyReceiveAmount.toString()));
326
- // 添加买入指令
326
+ // Add buy instruction
327
327
  const buyTx = await launchlabBuyExactOutInstruction({
328
328
  provider,
329
329
  owner: currentPayer.publicKey,
@@ -338,21 +338,21 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
338
338
  });
339
339
  tx.add(buyTx);
340
340
  }
341
- // 执行多次卖出
341
+ // Execute multiple sells
342
342
  let remainingTokenAmount = totalBuyReceiveAmount;
343
343
  for (let i = 0; i < sellCount; i++) {
344
344
  let sellTokenAmount;
345
345
  if (i === sellCount - 1) {
346
- // 最后一次卖出时,卖出所有剩余代币
346
+ // On last sell, sell all remaining tokens
347
347
  sellTokenAmount = remainingTokenAmount.toString();
348
348
  }
349
349
  else {
350
- // 前面几次按平均分配
350
+ // Distribute evenly for earlier iterations
351
351
  sellTokenAmount = totalBuyReceiveAmount.div(new BN(sellCount)).toString();
352
352
  remainingTokenAmount = remainingTokenAmount.sub(new BN(sellTokenAmount));
353
353
  }
354
354
  const sellReceiveAmount = launchlabCalc.calculateSellAmountOut(sellTokenAmount);
355
- // 添加卖出指令
355
+ // Add sell instruction
356
356
  const sellTx = await launchlabSellExactInInstruction({
357
357
  provider,
358
358
  owner: currentPayer.publicKey,
@@ -383,7 +383,7 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
383
383
  }
384
384
  catch (error) {
385
385
  const _errMsg = error instanceof Error ? error.stack || error.message : JSON.stringify(error, null, 2);
386
- throw new Error(`构造交易指令失败: ${_errMsg}`);
386
+ throw new Error(`Failed to build transaction instructions: ${_errMsg}`);
387
387
  }
388
388
  }
389
389
  else if (tradeType === 'sniperBuy') {
@@ -428,8 +428,8 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
428
428
  for (const [index, tx] of txs.entries()) {
429
429
  const base64Tx = await getBase64Tx({
430
430
  tx,
431
- payer: signers[0][0], // 第一个交易者作为 fee payer
432
- signers: [...signers[index]], // 当前交易的所有签名者
431
+ payer: signers[0][0], // First trader as fee payer
432
+ signers: [...signers[index]], // All signers for the current transaction
433
433
  blockhash,
434
434
  connection,
435
435
  lutAccount,
@@ -440,7 +440,7 @@ export const launchlabBatchTrade = async ({ connection, snipers, tokenAddress, p
440
440
  return base64Txs;
441
441
  }
442
442
  else {
443
- throw new Error('snipers 不能为空');
443
+ throw new Error('snipers cannot be empty');
444
444
  }
445
445
  }
446
446
  };
@@ -491,10 +491,10 @@ export const pumpswapBatchTrade = async ({ connection, poolInfo, tradeType, slip
491
491
  slippage,
492
492
  creator,
493
493
  });
494
- // 检查 user_volume_accumulator 是否需要初始化
494
+ // Check if user_volume_accumulator needs initialization
495
495
  const initVolumeIx = await getInitUserVolumeAccumulatorIxIfNeeded(connection, currentPayer.publicKey, currentPayer.publicKey);
496
496
  if (initVolumeIx) {
497
- // 将初始化指令插入到买入交易的最前面
497
+ // Insert initialization instruction at the beginning of the buy transaction
498
498
  buyTx.instructions.unshift(initVolumeIx);
499
499
  }
500
500
  let tx = getTx(buyTx, currentPayer, priorityFee, jito);
@@ -556,31 +556,31 @@ export const pumpswapBatchTrade = async ({ connection, poolInfo, tradeType, slip
556
556
  }
557
557
  }
558
558
  else if (tradeType === 'buyWithSell') {
559
- // 实现多买多卖逻辑
559
+ // Implement multi-buy multi-sell logic
560
560
  for (const payer of walletAmounts) {
561
561
  const currentPayer = getWalletKeypair(payer.privateKey);
562
562
  const currentAmount = new BigNumber(payer.amount).times(10 ** 9).toFixed(0);
563
563
  if (Number(currentAmount) <= 0) {
564
564
  continue;
565
565
  }
566
- // 提前创建 wsolAccount
566
+ // Pre-create wsolAccount
567
567
  const { wsolAccount, createWsolAccount } = await getNewWsolAccount(currentPayer.publicKey, new BigNumber(currentAmount).times(1 + slippage).toFixed(0));
568
568
  try {
569
- // 创建组合交易
569
+ // Create combined transaction
570
570
  const tx = new Transaction();
571
571
  let totalBuyReceiveAmount = new BN(0);
572
- // 根据 volumeType 确定买入和卖出次数
572
+ // Determine buy and sell counts based on volumeType
573
573
  const { buyCount, sellCount } = getVolumeTypeConfig(volumeType);
574
- // 执行多次买入
574
+ // Execute multiple buys
575
575
  let remainingAmount = new BigNumber(currentAmount);
576
576
  for (let i = 0; i < buyCount; i++) {
577
577
  let buyAmount;
578
578
  if (i === buyCount - 1) {
579
- // 最后一次买入时,使用所有剩余资金
579
+ // Use all remaining funds on the last buy
580
580
  buyAmount = remainingAmount.toFixed(0);
581
581
  }
582
582
  else {
583
- // 前面几次按平均分配
583
+ // Distribute evenly for earlier iterations
584
584
  buyAmount = new BigNumber(currentAmount).div(buyCount).toFixed(0);
585
585
  remainingAmount = remainingAmount.minus(buyAmount);
586
586
  }
@@ -607,16 +607,16 @@ export const pumpswapBatchTrade = async ({ connection, poolInfo, tradeType, slip
607
607
  });
608
608
  tx.add(buyTx);
609
609
  }
610
- // 执行多次卖出
610
+ // Execute multiple sells
611
611
  let remainingTokenAmount = totalBuyReceiveAmount;
612
612
  for (let i = 0; i < sellCount; i++) {
613
613
  let sellTokenAmount;
614
614
  if (i === sellCount - 1) {
615
- // 最后一次卖出时,卖出所有剩余代币
615
+ // On last sell, sell all remaining tokens
616
616
  sellTokenAmount = remainingTokenAmount;
617
617
  }
618
618
  else {
619
- // 前面几次按平均分配
619
+ // Distribute evenly for earlier iterations
620
620
  sellTokenAmount = totalBuyReceiveAmount.div(new BN(sellCount));
621
621
  remainingTokenAmount = remainingTokenAmount.sub(sellTokenAmount);
622
622
  }
@@ -664,13 +664,13 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
664
664
  const provider = new AnchorProvider(connection, {
665
665
  publicKey: Keypair.generate().publicKey,
666
666
  signTransaction: async () => {
667
- throw new Error('不支持签名');
667
+ throw new Error('Signing not supported');
668
668
  },
669
669
  signAllTransactions: async () => {
670
- throw new Error('不支持签名');
670
+ throw new Error('Signing not supported');
671
671
  },
672
672
  }, {});
673
- // 使用getPumpCurveState方法解析池子数据
673
+ // Parse pool data using getPumpCurveState
674
674
  const poolData = initialPoolData || (await getPumpCurveState(connection, poolId));
675
675
  const parsedPoolData = {
676
676
  virtual_sol_reserves: poolData.virtualSolReserves.toString(),
@@ -681,7 +681,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
681
681
  complete: poolData.complete,
682
682
  };
683
683
  console.log('parsedPoolData: ', parsedPoolData);
684
- // 创建计算器实例
684
+ // Create calculator instance
685
685
  const pumpCalc = new PumpAmmCalc({
686
686
  initialVirtualSolReserves: new BN(parsedPoolData.virtual_sol_reserves),
687
687
  tokenTotalSupply: new BN(parsedPoolData.token_total_supply),
@@ -693,7 +693,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
693
693
  const jito = getJitoAdapter();
694
694
  const blockhash = (await connection.getLatestBlockhash()).blockhash;
695
695
  const base64Txs = [];
696
- // 处理交易逻辑
696
+ // Process trade logic
697
697
  if (tradeType === 'buy') {
698
698
  try {
699
699
  for (const payer of walletAmounts) {
@@ -708,7 +708,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
708
708
  continue;
709
709
  }
710
710
  const [_, buyTx] = await pumpBuySPLInstructions(provider, currentPayer.publicKey, tokenAddress, currentAmount, slippage, new BigNumber(priceInSol).toString(10), creator, receiveAmount.toString());
711
- // 添加 Jito tipJito Bundle 必需)
711
+ // Add Jito tip (required for Jito Bundle)
712
712
  buyTx.add(jito.getTipInstruction(currentPayer.publicKey, priorityFee));
713
713
  const base64Tx = await getBase64Tx({
714
714
  tx: buyTx,
@@ -725,7 +725,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
725
725
  }
726
726
  catch (error) {
727
727
  const _errMsg = error instanceof Error ? error.stack || error.message : JSON.stringify(error, null, 2);
728
- throw new Error(`构造交易指令失败: ${_errMsg}`);
728
+ throw new Error(`Failed to build transaction instructions: ${_errMsg}`);
729
729
  }
730
730
  }
731
731
  else if (tradeType === 'sell') {
@@ -742,7 +742,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
742
742
  continue;
743
743
  }
744
744
  const sellTx = await pumpSellSPLInstructions(provider, currentPayer, tokenAddress, new BigNumber(currentAmount).toString(10), slippage, receiveAmount, creator);
745
- // 添加 Jito tipJito Bundle 必需)
745
+ // Add Jito tip (required for Jito Bundle)
746
746
  sellTx.add(jito.getTipInstruction(currentPayer.publicKey, priorityFee));
747
747
  const base64Tx = await getBase64Tx({
748
748
  tx: sellTx,
@@ -758,30 +758,30 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
758
758
  }
759
759
  catch (error) {
760
760
  const _errMsg = error instanceof Error ? error.stack || error.message : JSON.stringify(error, null, 2);
761
- throw new Error(`构造交易指令失败: ${_errMsg}`);
761
+ throw new Error(`Failed to build transaction instructions: ${_errMsg}`);
762
762
  }
763
763
  }
764
764
  else if (tradeType === 'buyWithSell') {
765
- // 实现 Pump 的多买多卖逻辑
765
+ // Implement Pump multi-buy multi-sell logic
766
766
  try {
767
767
  for (const payer of walletAmounts) {
768
768
  const currentPayer = getWalletKeypair(payer.privateKey);
769
769
  const currentAmount = new BigNumber(payer.amount).times(LAMPORTS_PER_SOL).toFixed(0);
770
- // 创建组合交易
770
+ // Create combined transaction
771
771
  const tx = new Transaction();
772
772
  let totalBuyReceiveAmount = new BN(0);
773
- // 根据 volumeType 确定买入和卖出次数
773
+ // Determine buy and sell counts based on volumeType
774
774
  const { buyCount, sellCount } = getVolumeTypeConfig(volumeType);
775
- // 执行多次买入
775
+ // Execute multiple buys
776
776
  let remainingAmount = new BigNumber(currentAmount);
777
777
  for (let i = 0; i < buyCount; i++) {
778
778
  let buyAmount;
779
779
  if (i === buyCount - 1) {
780
- // 最后一次买入时,使用所有剩余资金
780
+ // Use all remaining funds on the last buy
781
781
  buyAmount = remainingAmount.toFixed(0);
782
782
  }
783
783
  else {
784
- // 前面几次按平均分配
784
+ // Distribute evenly for earlier iterations
785
785
  buyAmount = new BigNumber(currentAmount).div(buyCount).toFixed(0);
786
786
  remainingAmount = remainingAmount.minus(buyAmount);
787
787
  }
@@ -794,20 +794,20 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
794
794
  break;
795
795
  }
796
796
  totalBuyReceiveAmount = totalBuyReceiveAmount.add(new BN(buyReceiveAmount.toString()));
797
- // 添加买入指令
797
+ // Add buy instruction
798
798
  const [_, buyTx] = await pumpBuySPLInstructions(provider, currentPayer.publicKey, tokenAddress, buyAmount, slippage, new BigNumber(priceInSol).toString(10), creator, buyReceiveAmount.toString());
799
799
  tx.add(buyTx);
800
800
  }
801
- // 执行多次卖出
801
+ // Execute multiple sells
802
802
  let remainingTokenAmount = totalBuyReceiveAmount;
803
803
  for (let i = 0; i < sellCount; i++) {
804
804
  let sellTokenAmount;
805
805
  if (i === sellCount - 1) {
806
- // 最后一次卖出时,卖出所有剩余代币
806
+ // On last sell, sell all remaining tokens
807
807
  sellTokenAmount = remainingTokenAmount.toString();
808
808
  }
809
809
  else {
810
- // 前面几次按平均分配
810
+ // Distribute evenly for earlier iterations
811
811
  sellTokenAmount = totalBuyReceiveAmount.div(new BN(sellCount)).toString();
812
812
  remainingTokenAmount = remainingTokenAmount.sub(new BN(sellTokenAmount));
813
813
  }
@@ -819,7 +819,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
819
819
  console.log('err: ', err);
820
820
  break;
821
821
  }
822
- // 添加卖出指令
822
+ // Add sell instruction
823
823
  const sellTx = await pumpSellSPLInstructions(provider, currentPayer, tokenAddress, sellTokenAmount, slippage, sellReceiveAmount, creator);
824
824
  tx.add(sellTx);
825
825
  }
@@ -840,7 +840,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
840
840
  }
841
841
  catch (error) {
842
842
  const _errMsg = error instanceof Error ? error.stack || error.message : JSON.stringify(error, null, 2);
843
- throw new Error(`构造交易指令失败: ${_errMsg}`);
843
+ throw new Error(`Failed to build transaction instructions: ${_errMsg}`);
844
844
  }
845
845
  }
846
846
  else if (tradeType === 'sniperBuy') {
@@ -860,15 +860,15 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
860
860
  continue;
861
861
  }
862
862
  const [_, buyTx] = await pumpBuySPLInstructions(provider, currentPayer.publicKey, tokenAddress, currentAmount, slippage, new BigNumber(priceInSol).toString(10), creator, receiveAmount.toString());
863
- // T0 模式: 2 sniper 一笔交易(减少 Bundle 交易数,更容易被 Jito 打包)
864
- // T0: 3 个(或 4 个带 LUT)sniper 合并到同一笔交易
863
+ // T0 mode: 2 snipers per transaction (reduces Bundle tx count, easier for Jito to pack)
864
+ // Non-T0: 3 (or 4 with LUT) snipers merged into same transaction
865
865
  const groupSize = bundleBuyTime === BundleBuyTime.T0 ? 2 : (lutAccount ? 4 : 3);
866
866
  if (index % groupSize === 0) {
867
867
  txs.push(new Transaction());
868
868
  signers.push([]);
869
869
  }
870
- // T0 Bundle 不需要 ComputeBudget 优先费(通过 Jito tip 竞价),
871
- // 去掉所有 ComputeBudget 指令,节省交易空间
870
+ // T0 Bundle doesn't need ComputeBudget priority fee (bids via Jito tip),
871
+ // remove all ComputeBudget instructions to save transaction space
872
872
  if (bundleBuyTime === BundleBuyTime.T0) {
873
873
  const filteredInstructions = buyTx.instructions.filter(ix => !ix.programId.equals(ComputeBudgetProgram.programId));
874
874
  filteredInstructions.forEach(ix => txs[txs.length - 1].add(ix));
@@ -881,12 +881,12 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
881
881
  }
882
882
  signers[signers.length - 1].push(currentPayer);
883
883
  }
884
- // T0 模式: tip 作为独立交易放在 Bundle 最后,这里不加
884
+ // T0 mode: tip goes as a standalone transaction at end of Bundle, not added here
885
885
  for (const [index, tx] of txs.entries()) {
886
886
  const base64Tx = await getBase64Tx({
887
887
  tx,
888
- payer: signers[0][0], // 第一个交易者作为 fee payer
889
- signers: [...signers[index]], // 当前交易的所有签名者
888
+ payer: signers[0][0], // First trader as fee payer
889
+ signers: [...signers[index]], // All signers for the current transaction
890
890
  blockhash,
891
891
  connection,
892
892
  lutAccount,
@@ -897,7 +897,7 @@ export const pumpBatchTrade = async ({ connection, walletAmounts, snipers, token
897
897
  return base64Txs;
898
898
  }
899
899
  else {
900
- throw new Error('snipers 不能为空');
900
+ throw new Error('snipers cannot be empty');
901
901
  }
902
902
  }
903
903
  };
@@ -1001,37 +1001,37 @@ export const raydiumBatchTrade = async ({ connection, tokenAddress, poolId, trad
1001
1001
  }
1002
1002
  }
1003
1003
  else if (tradeType === 'buyWithSell') {
1004
- // 实现 Raydium 的多买多卖逻辑
1004
+ // Implement Raydium multi-buy multi-sell logic
1005
1005
  for (const payer of walletAmounts) {
1006
1006
  const currentPayer = getWalletKeypair(payer.privateKey);
1007
1007
  const currentAmount = new BigNumber(payer.amount).times(10 ** 9).toFixed(0);
1008
1008
  if (Number(currentAmount) <= 0) {
1009
1009
  continue;
1010
1010
  }
1011
- // 提前创建 wsolAccount
1011
+ // Pre-create wsolAccount
1012
1012
  const { wsolAccount, createWsolAccount } = await getNewWsolAccount(currentPayer.publicKey, new BigNumber(currentAmount).times(1 + slippage).toFixed(0));
1013
1013
  try {
1014
- // 创建组合交易
1014
+ // Create combined transaction
1015
1015
  const tx = new Transaction();
1016
1016
  let totalBuyReceiveAmount = new BigNumber(0);
1017
- // 根据 volumeType 确定买入和卖出次数
1017
+ // Determine buy and sell counts based on volumeType
1018
1018
  const { buyCount, sellCount } = getVolumeTypeConfig(volumeType);
1019
- // 执行多次买入
1019
+ // Execute multiple buys
1020
1020
  let remainingAmount = new BigNumber(currentAmount);
1021
1021
  for (let i = 0; i < buyCount; i++) {
1022
1022
  let buyAmount;
1023
1023
  if (i === buyCount - 1) {
1024
- // 最后一次买入时,使用所有剩余资金
1024
+ // Use all remaining funds on the last buy
1025
1025
  buyAmount = remainingAmount.toFixed(0);
1026
1026
  }
1027
1027
  else {
1028
- // 前面几次按平均分配
1028
+ // Distribute evenly for earlier iterations
1029
1029
  buyAmount = new BigNumber(currentAmount).div(buyCount).toFixed(0);
1030
1030
  remainingAmount = remainingAmount.minus(buyAmount);
1031
1031
  }
1032
1032
  let buyReceiveAmount = raydiumCalc.swap(buyAmount, mintA.toBase58() === NATIVE_MINT.toBase58() ? true : false);
1033
1033
  totalBuyReceiveAmount = totalBuyReceiveAmount.plus(buyReceiveAmount);
1034
- // 添加买入指令
1034
+ // Add buy instruction
1035
1035
  const buyTx = await raydiumBuyInstruction({
1036
1036
  amount: buyAmount,
1037
1037
  owner: currentPayer.publicKey,
@@ -1047,21 +1047,21 @@ export const raydiumBatchTrade = async ({ connection, tokenAddress, poolId, trad
1047
1047
  });
1048
1048
  tx.add(buyTx);
1049
1049
  }
1050
- // 执行多次卖出
1050
+ // Execute multiple sells
1051
1051
  let remainingTokenAmount = totalBuyReceiveAmount;
1052
1052
  for (let i = 0; i < sellCount; i++) {
1053
1053
  let sellTokenAmount;
1054
1054
  if (i === sellCount - 1) {
1055
- // 最后一次卖出时,卖出所有剩余代币
1055
+ // On last sell, sell all remaining tokens
1056
1056
  sellTokenAmount = remainingTokenAmount.toFixed(0);
1057
1057
  }
1058
1058
  else {
1059
- // 前面几次按平均分配
1059
+ // Distribute evenly for earlier iterations
1060
1060
  sellTokenAmount = totalBuyReceiveAmount.div(sellCount).toFixed(0);
1061
1061
  remainingTokenAmount = remainingTokenAmount.minus(sellTokenAmount);
1062
1062
  }
1063
1063
  let sellReceiveAmount = raydiumCalc.swap(sellTokenAmount, mintA.toBase58() === NATIVE_MINT.toBase58() ? false : true);
1064
- // 添加卖出指令
1064
+ // Add sell instruction
1065
1065
  const sellTx = await raydiumSellInstruction({
1066
1066
  amount: sellTokenAmount,
1067
1067
  owner: currentPayer.publicKey,
@@ -1203,37 +1203,37 @@ export const raydiumCpmmBatchTrade = async ({ connection, tokenAddress, poolId,
1203
1203
  }
1204
1204
  }
1205
1205
  else if (tradeType === 'buyWithSell') {
1206
- // 实现 Raydium 的多买多卖逻辑
1206
+ // Implement Raydium multi-buy multi-sell logic
1207
1207
  for (const payer of walletAmounts) {
1208
1208
  const currentPayer = getWalletKeypair(payer.privateKey);
1209
1209
  const currentAmount = new BigNumber(payer.amount).times(10 ** 9).toFixed(0);
1210
1210
  if (Number(currentAmount) <= 0) {
1211
1211
  continue;
1212
1212
  }
1213
- // 提前创建 wsolAccount
1213
+ // Pre-create wsolAccount
1214
1214
  const { wsolAccount, createWsolAccount } = await getNewWsolAccount(currentPayer.publicKey, new BigNumber(currentAmount).times(1 + slippage).toFixed(0));
1215
1215
  try {
1216
- // 创建组合交易
1216
+ // Create combined transaction
1217
1217
  const tx = new Transaction();
1218
1218
  let totalBuyReceiveAmount = new BigNumber(0);
1219
- // 根据 volumeType 确定买入和卖出次数
1219
+ // Determine buy and sell counts based on volumeType
1220
1220
  const { buyCount, sellCount } = getVolumeTypeConfig(volumeType);
1221
- // 执行多次买入
1221
+ // Execute multiple buys
1222
1222
  let remainingAmount = new BigNumber(currentAmount);
1223
1223
  for (let i = 0; i < buyCount; i++) {
1224
1224
  let buyAmount;
1225
1225
  if (i === buyCount - 1) {
1226
- // 最后一次买入时,使用所有剩余资金
1226
+ // Use all remaining funds on the last buy
1227
1227
  buyAmount = remainingAmount.toFixed(0);
1228
1228
  }
1229
1229
  else {
1230
- // 前面几次按平均分配
1230
+ // Distribute evenly for earlier iterations
1231
1231
  buyAmount = new BigNumber(currentAmount).div(buyCount).toFixed(0);
1232
1232
  remainingAmount = remainingAmount.minus(buyAmount);
1233
1233
  }
1234
1234
  let buyReceiveAmount = raydiumCalc.swap(buyAmount, mintA.toBase58() === NATIVE_MINT.toBase58() ? true : false);
1235
1235
  totalBuyReceiveAmount = totalBuyReceiveAmount.plus(buyReceiveAmount);
1236
- // 添加买入指令
1236
+ // Add buy instruction
1237
1237
  const buyTx = await raydiumCpmmSwapBaseOutBuyInstruction({
1238
1238
  amountInMax: new BigNumber(buyAmount).times(1 + slippage).toFixed(0),
1239
1239
  owner: currentPayer.publicKey,
@@ -1249,21 +1249,21 @@ export const raydiumCpmmBatchTrade = async ({ connection, tokenAddress, poolId,
1249
1249
  });
1250
1250
  tx.add(buyTx);
1251
1251
  }
1252
- // 执行多次卖出
1252
+ // Execute multiple sells
1253
1253
  let remainingTokenAmount = totalBuyReceiveAmount;
1254
1254
  for (let i = 0; i < sellCount; i++) {
1255
1255
  let sellTokenAmount;
1256
1256
  if (i === sellCount - 1) {
1257
- // 最后一次卖出时,卖出所有剩余代币
1257
+ // On last sell, sell all remaining tokens
1258
1258
  sellTokenAmount = remainingTokenAmount.toFixed(0);
1259
1259
  }
1260
1260
  else {
1261
- // 前面几次按平均分配
1261
+ // Distribute evenly for earlier iterations
1262
1262
  sellTokenAmount = totalBuyReceiveAmount.div(sellCount).toFixed(0);
1263
1263
  remainingTokenAmount = remainingTokenAmount.minus(sellTokenAmount);
1264
1264
  }
1265
1265
  let sellReceiveAmount = raydiumCalc.swap(sellTokenAmount, mintA.toBase58() === NATIVE_MINT.toBase58() ? false : true);
1266
- // 添加卖出指令
1266
+ // Add sell instruction
1267
1267
  const sellTx = await raydiumCpmmSellInstruction({
1268
1268
  amount: sellTokenAmount,
1269
1269
  owner: currentPayer.publicKey,
@@ -1299,7 +1299,7 @@ export const raydiumCpmmBatchTrade = async ({ connection, tokenAddress, poolId,
1299
1299
  }
1300
1300
  return base64Txs;
1301
1301
  };
1302
- // 获取刷量类型配置
1302
+ // Get volume type configuration
1303
1303
  const getVolumeTypeConfig = (volumeType) => {
1304
1304
  switch (volumeType) {
1305
1305
  case VolumeType.ONE_BUY_ONE_SELL:
@@ -1320,10 +1320,10 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1320
1320
  const provider = new AnchorProvider(connection, {
1321
1321
  publicKey: Keypair.generate().publicKey,
1322
1322
  signTransaction: async () => {
1323
- throw new Error('不支持签名');
1323
+ throw new Error('Signing not supported');
1324
1324
  },
1325
1325
  signAllTransactions: async () => {
1326
- throw new Error('不支持签名');
1326
+ throw new Error('Signing not supported');
1327
1327
  },
1328
1328
  }, {});
1329
1329
  const binArray = await getBinArray({
@@ -1334,9 +1334,9 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1334
1334
  const dlmmPool = await MeteoraDLMM.create(connection, new PublicKey(poolId), {
1335
1335
  programId: METEORA_DLMM_PROGRAM,
1336
1336
  });
1337
- // 使用传入的reverseInfo或获取池子数据
1337
+ // Use provided reverseInfo or fetch pool data
1338
1338
  if (!reverseInfo) {
1339
- throw new Error('缺少 Meteora DLMM 池子信息');
1339
+ throw new Error('Missing Meteora DLMM pool info');
1340
1340
  }
1341
1341
  console.log(' binStep:', typeof reverseInfo.binStep, reverseInfo.binStep);
1342
1342
  console.log(' activeId:', typeof reverseInfo.activeId, reverseInfo.activeId);
@@ -1344,13 +1344,13 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1344
1344
  const jito = getJitoAdapter();
1345
1345
  const blockhash = (await connection.getLatestBlockhash()).blockhash;
1346
1346
  const base64Txs = [];
1347
- // 处理交易逻辑
1347
+ // Process trade logic
1348
1348
  if (tradeType === 'buy') {
1349
1349
  // try {
1350
1350
  for (const payer of walletAmounts) {
1351
1351
  const currentPayer = getWalletKeypair(payer.privateKey);
1352
1352
  const currentAmount = new BigNumber(payer.amount).times(LAMPORTS_PER_SOL).toFixed(0);
1353
- // 计算预期获得的代币数量
1353
+ // Calculate expected token amount received
1354
1354
  const swapQuote = dlmmPool.swapQuote(new BN(currentAmount), reverseInfo.reserveY == NATIVE_MINT.toBase58(), new BN(slippage), binArray);
1355
1355
  const buyTx = await meteoraDlmmBuyInstructions({
1356
1356
  provider,
@@ -1384,7 +1384,7 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1384
1384
  }
1385
1385
  return base64Txs;
1386
1386
  // } catch (error: any) {
1387
- // throw new Error(`构造买入交易指令失败: ${error.message}`);
1387
+ // throw new Error(`Failed to build buy transaction instructions: ${error.message}`);
1388
1388
  // }
1389
1389
  }
1390
1390
  else if (tradeType === 'sell') {
@@ -1392,7 +1392,7 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1392
1392
  for (const payer of walletAmounts) {
1393
1393
  const currentPayer = getWalletKeypair(payer.privateKey);
1394
1394
  const currentAmount = new BigNumber(payer.amount).times(10 ** decimals).toFixed(0);
1395
- // 计算预期获得的SOL数量
1395
+ // Calculate expected SOL amount received
1396
1396
  const swapQuote = dlmmPool.swapQuote(new BN(currentAmount), reverseInfo.mintA == NATIVE_MINT.toBase58(), new BN(slippage), binArray);
1397
1397
  const swapQuote2 = dlmmPool.swapQuote(new BN(currentAmount), reverseInfo.mintA == NATIVE_MINT.toBase58(), new BN(10), binArray);
1398
1398
  const sellTx = await meteoraDlmmSellInstructions({
@@ -1427,38 +1427,38 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1427
1427
  return base64Txs;
1428
1428
  }
1429
1429
  catch (error) {
1430
- throw new Error(`构造卖出交易指令失败: ${error.message}`);
1430
+ throw new Error(`Failed to build sell transaction instructions: ${error.message}`);
1431
1431
  }
1432
1432
  }
1433
1433
  else if (tradeType === 'buyWithSell') {
1434
- // 实现 Meteora DLMM 的多买多卖逻辑
1434
+ // Implement Meteora DLMM multi-buy multi-sell logic
1435
1435
  try {
1436
1436
  for (const payer of walletAmounts) {
1437
1437
  const currentPayer = getWalletKeypair(payer.privateKey);
1438
1438
  const currentAmount = new BigNumber(payer.amount).times(LAMPORTS_PER_SOL).toFixed(0);
1439
- // 提前创建 wsolAccount
1439
+ // Pre-create wsolAccount
1440
1440
  const { wsolAccount, createWsolAccount } = await getNewWsolAccount(currentPayer.publicKey, new BigNumber(currentAmount).times(1 + slippage).toFixed(0));
1441
- // 创建组合交易
1441
+ // Create combined transaction
1442
1442
  const tx = new Transaction();
1443
1443
  let totalBuyReceiveAmount = new BN(0);
1444
- // 根据 volumeType 确定买入和卖出次数
1444
+ // Determine buy and sell counts based on volumeType
1445
1445
  const { buyCount, sellCount } = getVolumeTypeConfig(volumeType);
1446
- // 执行多次买入
1446
+ // Execute multiple buys
1447
1447
  let remainingAmount = new BigNumber(currentAmount);
1448
1448
  for (let i = 0; i < buyCount; i++) {
1449
1449
  let buyAmount;
1450
1450
  if (i === buyCount - 1) {
1451
- // 最后一次买入时,使用所有剩余资金
1451
+ // Use all remaining funds on the last buy
1452
1452
  buyAmount = remainingAmount.toFixed(0);
1453
1453
  }
1454
1454
  else {
1455
- // 前面几次按平均分配
1455
+ // Distribute evenly for earlier iterations
1456
1456
  buyAmount = new BigNumber(currentAmount).div(buyCount).toFixed(0);
1457
1457
  remainingAmount = remainingAmount.minus(buyAmount);
1458
1458
  }
1459
1459
  const swapQuote = dlmmPool.swapQuote(new BN(buyAmount), reverseInfo.reserveY == NATIVE_MINT.toBase58(), new BN(slippage), binArray);
1460
1460
  totalBuyReceiveAmount = totalBuyReceiveAmount.add(new BN(swapQuote.minOutAmount.toString()));
1461
- // 添加买入指令
1461
+ // Add buy instruction
1462
1462
  const buyTx = await meteoraDlmmBuyExactOutInstructions({
1463
1463
  provider,
1464
1464
  owner: currentPayer,
@@ -1473,22 +1473,22 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1473
1473
  },
1474
1474
  amountInMax: BigInt(buyAmount),
1475
1475
  tokenAmount: BigInt(swapQuote.minOutAmount.toString()),
1476
- needCreateAtaAccount: i === 0, // 只在第一次创建ATA
1476
+ needCreateAtaAccount: i === 0, // Only create ATA on the first iteration
1477
1477
  needCloseTokenAccount: false,
1478
1478
  needCloseWsolAccount: false,
1479
1479
  initialWsolAccount: wsolAccount,
1480
1480
  createWsolAccountInstruction: i === 0 ? createWsolAccount : undefined,
1481
1481
  binArraysPubkey: swapQuote.binArraysPubkey,
1482
1482
  });
1483
- // 添加买入交易指令
1483
+ // Add buy transaction instructions
1484
1484
  tx.add(...buyTx.instructions);
1485
1485
  }
1486
- // 执行多次卖出
1486
+ // Execute multiple sells
1487
1487
  const avgSellAmount = totalBuyReceiveAmount.div(new BN(sellCount));
1488
1488
  for (let i = 0; i < sellCount; i++) {
1489
1489
  let sellAmount;
1490
1490
  if (i === sellCount - 1) {
1491
- // 最后一次卖出时,卖出所有剩余代币
1491
+ // On last sell, sell all remaining tokens
1492
1492
  sellAmount = totalBuyReceiveAmount;
1493
1493
  }
1494
1494
  else {
@@ -1496,7 +1496,7 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1496
1496
  totalBuyReceiveAmount = totalBuyReceiveAmount.sub(avgSellAmount);
1497
1497
  }
1498
1498
  const swapQuote = dlmmPool.swapQuote(new BN(sellAmount), reverseInfo.mintA == NATIVE_MINT.toBase58(), new BN(10), binArray);
1499
- // 添加卖出指令
1499
+ // Add sell instruction
1500
1500
  const sellTx = await meteoraDlmmSellInstructions({
1501
1501
  provider,
1502
1502
  owner: currentPayer,
@@ -1512,12 +1512,12 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1512
1512
  amount: BigInt(sellAmount.toString()),
1513
1513
  minAmountOut: BigInt(0),
1514
1514
  needCreateAtaAccount: false,
1515
- needCloseTokenAccount: i === sellCount - 1, // 只在最后一次关闭Token账户
1516
- needCloseWsolAccount: i === sellCount - 1, // 只在最后一次关闭WSOL账户
1515
+ needCloseTokenAccount: i === sellCount - 1, // Only close Token account on the last iteration
1516
+ needCloseWsolAccount: i === sellCount - 1, // Only close WSOL account on the last iteration
1517
1517
  initialWsolAccount: wsolAccount,
1518
1518
  binArraysPubkey: swapQuote.binArraysPubkey,
1519
1519
  });
1520
- // 添加卖出交易指令
1520
+ // Add sell transaction instructions
1521
1521
  tx.add(...sellTx.instructions);
1522
1522
  }
1523
1523
  const finalTx = getTx(tx, currentPayer, priorityFee, jito);
@@ -1534,13 +1534,13 @@ export const meteoraDlmmBatchTrade = async ({ connection, tokenAddress, poolId,
1534
1534
  return base64Txs;
1535
1535
  }
1536
1536
  catch (error) {
1537
- throw new Error(`构造买卖组合交易指令失败: ${error.message}`);
1537
+ throw new Error(`Failed to build buy+sell combo transaction instructions: ${error.message}`);
1538
1538
  }
1539
1539
  }
1540
- throw new Error(`不支持的交易类型: ${tradeType}`);
1540
+ throw new Error(`Unsupported trade type: ${tradeType}`);
1541
1541
  };
1542
1542
  const getBase64Tx = async ({ tx, payer, signers, blockhash, connection, lutAccount, simulate = false, }) => {
1543
- // 使用 LUT 时走 VersionedTransaction,否则直接用 legacy Transaction(格式更稳定)
1543
+ // Use VersionedTransaction when LUT is available, otherwise use legacy Transaction (more stable format)
1544
1544
  if (lutAccount) {
1545
1545
  const messageV0 = new TransactionMessage({
1546
1546
  payerKey: signers[0].publicKey,
@@ -1558,7 +1558,7 @@ const getBase64Tx = async ({ tx, payer, signers, blockhash, connection, lutAccou
1558
1558
  const serializedTx = versionedTx.serialize();
1559
1559
  return Buffer.from(serializedTx).toString('base64');
1560
1560
  }
1561
- // Legacy transaction(无 LUT
1561
+ // Legacy transaction (no LUT)
1562
1562
  tx.recentBlockhash = blockhash;
1563
1563
  tx.feePayer = signers[0].publicKey;
1564
1564
  tx.sign(...signers);