four-flap-meme-sdk 1.4.59 → 1.4.62

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 (130) hide show
  1. package/dist/contracts/tm-bundle-merkle/core.js +13 -5
  2. package/dist/contracts/tm-bundle-merkle/internal.d.ts +5 -1
  3. package/dist/contracts/tm-bundle-merkle/internal.js +8 -1
  4. package/dist/contracts/tm-bundle-merkle/pancake-proxy.js +8 -2
  5. package/dist/contracts/tm-bundle-merkle/private.js +16 -4
  6. package/dist/contracts/tm-bundle-merkle/swap-buy-first.d.ts +2 -0
  7. package/dist/contracts/tm-bundle-merkle/swap-buy-first.js +3 -0
  8. package/dist/contracts/tm-bundle-merkle/types.d.ts +5 -2
  9. package/dist/contracts/tm-bundle-merkle/types.js +0 -3
  10. package/dist/contracts/tm-bundle-merkle/utils.js +14 -2
  11. package/dist/contracts/tm-bundle.d.ts +4 -0
  12. package/dist/contracts/tm-bundle.js +10 -3
  13. package/dist/dex/direct-router.d.ts +2 -0
  14. package/dist/dex/direct-router.js +22 -7
  15. package/dist/flap/portal-bundle-merkle/core.js +10 -1
  16. package/dist/flap/portal-bundle-merkle/pancake-proxy.js +8 -2
  17. package/dist/flap/portal-bundle-merkle/private.js +17 -7
  18. package/dist/flap/portal-bundle-merkle/swap-buy-first.d.ts +2 -0
  19. package/dist/flap/portal-bundle-merkle/swap-buy-first.js +8 -4
  20. package/dist/flap/portal-bundle-merkle/types.d.ts +3 -0
  21. package/dist/flap/portal-bundle-merkle/types.js +0 -3
  22. package/dist/flap/portal-bundle-merkle/utils.d.ts +5 -2
  23. package/dist/flap/portal-bundle-merkle/utils.js +22 -3
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +1 -0
  26. package/dist/pancake/bundle-buy-first.d.ts +2 -0
  27. package/dist/pancake/bundle-buy-first.js +8 -4
  28. package/dist/sol/constants.d.ts +126 -0
  29. package/dist/sol/constants.js +145 -0
  30. package/dist/sol/dex/index.d.ts +8 -0
  31. package/dist/sol/dex/index.js +12 -0
  32. package/dist/sol/dex/meteora/client.d.ts +76 -0
  33. package/dist/sol/dex/meteora/client.js +219 -0
  34. package/dist/sol/dex/meteora/damm-v1-bundle.d.ts +61 -0
  35. package/dist/sol/dex/meteora/damm-v1-bundle.js +112 -0
  36. package/dist/sol/dex/meteora/damm-v1.d.ts +118 -0
  37. package/dist/sol/dex/meteora/damm-v1.js +315 -0
  38. package/dist/sol/dex/meteora/damm-v2-bundle.d.ts +82 -0
  39. package/dist/sol/dex/meteora/damm-v2-bundle.js +242 -0
  40. package/dist/sol/dex/meteora/damm-v2.d.ts +172 -0
  41. package/dist/sol/dex/meteora/damm-v2.js +632 -0
  42. package/dist/sol/dex/meteora/dbc-bundle.d.ts +123 -0
  43. package/dist/sol/dex/meteora/dbc-bundle.js +304 -0
  44. package/dist/sol/dex/meteora/dbc.d.ts +192 -0
  45. package/dist/sol/dex/meteora/dbc.js +619 -0
  46. package/dist/sol/dex/meteora/dlmm-bundle.d.ts +39 -0
  47. package/dist/sol/dex/meteora/dlmm-bundle.js +189 -0
  48. package/dist/sol/dex/meteora/dlmm.d.ts +157 -0
  49. package/dist/sol/dex/meteora/dlmm.js +671 -0
  50. package/dist/sol/dex/meteora/index.d.ts +25 -0
  51. package/dist/sol/dex/meteora/index.js +65 -0
  52. package/dist/sol/dex/meteora/types.d.ts +787 -0
  53. package/dist/sol/dex/meteora/types.js +110 -0
  54. package/dist/sol/dex/orca/index.d.ts +10 -0
  55. package/dist/sol/dex/orca/index.js +16 -0
  56. package/dist/sol/dex/orca/orca-bundle.d.ts +41 -0
  57. package/dist/sol/dex/orca/orca-bundle.js +173 -0
  58. package/dist/sol/dex/orca/orca.d.ts +65 -0
  59. package/dist/sol/dex/orca/orca.js +474 -0
  60. package/dist/sol/dex/orca/types.d.ts +263 -0
  61. package/dist/sol/dex/orca/types.js +38 -0
  62. package/dist/sol/dex/orca/wavebreak-bundle.d.ts +34 -0
  63. package/dist/sol/dex/orca/wavebreak-bundle.js +198 -0
  64. package/dist/sol/dex/orca/wavebreak-types.d.ts +227 -0
  65. package/dist/sol/dex/orca/wavebreak-types.js +23 -0
  66. package/dist/sol/dex/orca/wavebreak.d.ts +78 -0
  67. package/dist/sol/dex/orca/wavebreak.js +497 -0
  68. package/dist/sol/dex/pump/index.d.ts +9 -0
  69. package/dist/sol/dex/pump/index.js +14 -0
  70. package/dist/sol/dex/pump/pump-bundle.d.ts +92 -0
  71. package/dist/sol/dex/pump/pump-bundle.js +383 -0
  72. package/dist/sol/dex/pump/pump-swap-bundle.d.ts +103 -0
  73. package/dist/sol/dex/pump/pump-swap-bundle.js +380 -0
  74. package/dist/sol/dex/pump/pump-swap.d.ts +46 -0
  75. package/dist/sol/dex/pump/pump-swap.js +199 -0
  76. package/dist/sol/dex/pump/pump.d.ts +35 -0
  77. package/dist/sol/dex/pump/pump.js +352 -0
  78. package/dist/sol/dex/pump/types.d.ts +215 -0
  79. package/dist/sol/dex/pump/types.js +5 -0
  80. package/dist/sol/dex/raydium/index.d.ts +8 -0
  81. package/dist/sol/dex/raydium/index.js +12 -0
  82. package/dist/sol/dex/raydium/launchlab.d.ts +68 -0
  83. package/dist/sol/dex/raydium/launchlab.js +210 -0
  84. package/dist/sol/dex/raydium/raydium-bundle.d.ts +64 -0
  85. package/dist/sol/dex/raydium/raydium-bundle.js +324 -0
  86. package/dist/sol/dex/raydium/raydium.d.ts +40 -0
  87. package/dist/sol/dex/raydium/raydium.js +366 -0
  88. package/dist/sol/dex/raydium/types.d.ts +240 -0
  89. package/dist/sol/dex/raydium/types.js +5 -0
  90. package/dist/sol/index.d.ts +10 -0
  91. package/dist/sol/index.js +16 -0
  92. package/dist/sol/jito/bundle.d.ts +90 -0
  93. package/dist/sol/jito/bundle.js +263 -0
  94. package/dist/sol/jito/index.d.ts +7 -0
  95. package/dist/sol/jito/index.js +7 -0
  96. package/dist/sol/jito/tip.d.ts +51 -0
  97. package/dist/sol/jito/tip.js +83 -0
  98. package/dist/sol/jito/types.d.ts +100 -0
  99. package/dist/sol/jito/types.js +5 -0
  100. package/dist/sol/token/create-complete.d.ts +115 -0
  101. package/dist/sol/token/create-complete.js +235 -0
  102. package/dist/sol/token/create-token.d.ts +57 -0
  103. package/dist/sol/token/create-token.js +230 -0
  104. package/dist/sol/token/index.d.ts +9 -0
  105. package/dist/sol/token/index.js +14 -0
  106. package/dist/sol/token/metadata-upload.d.ts +86 -0
  107. package/dist/sol/token/metadata-upload.js +173 -0
  108. package/dist/sol/token/metadata.d.ts +92 -0
  109. package/dist/sol/token/metadata.js +274 -0
  110. package/dist/sol/token/types.d.ts +153 -0
  111. package/dist/sol/token/types.js +5 -0
  112. package/dist/sol/types.d.ts +176 -0
  113. package/dist/sol/types.js +7 -0
  114. package/dist/sol/utils/balance.d.ts +160 -0
  115. package/dist/sol/utils/balance.js +638 -0
  116. package/dist/sol/utils/connection.d.ts +78 -0
  117. package/dist/sol/utils/connection.js +168 -0
  118. package/dist/sol/utils/index.d.ts +9 -0
  119. package/dist/sol/utils/index.js +9 -0
  120. package/dist/sol/utils/lp-inspect.d.ts +129 -0
  121. package/dist/sol/utils/lp-inspect.js +900 -0
  122. package/dist/sol/utils/transfer.d.ts +125 -0
  123. package/dist/sol/utils/transfer.js +220 -0
  124. package/dist/sol/utils/wallet.d.ts +107 -0
  125. package/dist/sol/utils/wallet.js +210 -0
  126. package/dist/utils/private-sale.d.ts +3 -0
  127. package/dist/utils/private-sale.js +3 -0
  128. package/package.json +38 -3
  129. package/dist/flap/portal-bundle-merkle/encryption.d.ts +0 -16
  130. package/dist/flap/portal-bundle-merkle/encryption.js +0 -146
@@ -133,6 +133,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
133
133
  };
134
134
  signedTxs.push(await devWallet.signTransaction(createTxRequest));
135
135
  // ✅ 利润多跳转账(强制 2 跳中转)
136
+ let profitHopWallets;
136
137
  if (extractProfit && profitAmount > 0n) {
137
138
  const profitNonce = await nonceManager.getNextNonce(devWallet);
138
139
  const profitHopResult = await buildProfitHopTransactions({
@@ -147,6 +148,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
147
148
  startNonce: profitNonce
148
149
  });
149
150
  signedTxs.push(...profitHopResult.signedTransactions);
151
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
150
152
  }
151
153
  nonceManager.clearTemp();
152
154
  // ⚠️ 只返回签名交易,不提交
@@ -160,6 +162,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
160
162
  return {
161
163
  signedTransactions: signedTxs,
162
164
  tokenAddress: ZERO_ADDRESS, // ⚠️ 占位符,实际地址需要等交易确认后从事件解析
165
+ profitHopWallets, // ✅ 返回利润多跳钱包
163
166
  metadata
164
167
  };
165
168
  }
@@ -192,6 +195,7 @@ export async function batchBuyWithBundleMerkle(params) {
192
195
  nonceManager.clearTemp();
193
196
  return {
194
197
  signedTransactions: buyFlow.signedTxs,
198
+ profitHopWallets: buyFlow.profitHopWallets, // ✅ 返回利润多跳钱包
195
199
  metadata: buyFlow.metadata
196
200
  };
197
201
  }
@@ -224,7 +228,8 @@ export async function batchSellWithBundleMerkle(params) {
224
228
  });
225
229
  nonceManager.clearTemp();
226
230
  return {
227
- signedTransactions: sellFlow.signedTxs
231
+ signedTransactions: sellFlow.signedTxs,
232
+ profitHopWallets: sellFlow.profitHopWallets // ✅ 返回利润多跳钱包
228
233
  };
229
234
  }
230
235
  function createChainContext(rpcUrl) {
@@ -317,6 +322,7 @@ async function executeBuyFlow(options) {
317
322
  })));
318
323
  signedTxs.push(...signedBuys);
319
324
  // ✅ 利润多跳转账(强制 2 跳中转)
325
+ let profitHopWallets;
320
326
  if (extractProfit && analysis.totalProfit > 0n && profitMode.type === 'aggregated') {
321
327
  const profitNonce = await nonceManager.getNextNonce(payer);
322
328
  const profitHopResult = await buildProfitHopTransactions({
@@ -331,9 +337,10 @@ async function executeBuyFlow(options) {
331
337
  startNonce: profitNonce
332
338
  });
333
339
  signedTxs.push(...profitHopResult.signedTransactions);
340
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
334
341
  }
335
342
  const metadata = buildBuyMetadata(extractProfit, analysis.totalBuyAmount, analysis.totalProfit, wallets.length);
336
- return { signedTxs, metadata };
343
+ return { signedTxs, metadata, profitHopWallets }; // ✅ 返回利润多跳钱包
337
344
  }
338
345
  async function executeSellFlow(options) {
339
346
  const { wallets, sellAmounts, tokenAddress, minOutputAmounts, config, provider, nonceManager, contractAddress, gasPrice, chainId, rpcUrl, txType } = options;
@@ -398,7 +405,7 @@ async function executeSellFlow(options) {
398
405
  })));
399
406
  signedTxs.push(...signedSells);
400
407
  // ✅ 利润多跳转账(强制 2 跳中转)
401
- await appendAggregatedProfitTransfer({
408
+ const profitHopWallets = await appendAggregatedProfitTransfer({
402
409
  extractProfit,
403
410
  totalProfit,
404
411
  payer: payerWallet,
@@ -410,7 +417,7 @@ async function executeSellFlow(options) {
410
417
  signedTxs,
411
418
  baseNonce: adjustedNonces[payerIndex] + 1 // ✅ 传入基础 nonce
412
419
  });
413
- return { signedTxs };
420
+ return { signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
414
421
  }
415
422
  function analyzeBuyFunds(buyAmounts, config, extractProfit) {
416
423
  const fundsList = [];
@@ -556,7 +563,7 @@ function summarizeSellProfits(quotedOutputs, sellers, config) {
556
563
  async function appendAggregatedProfitTransfer(params) {
557
564
  const { extractProfit, totalProfit, payer, nonceManager, provider, gasPrice, chainId, txType, signedTxs, baseNonce } = params;
558
565
  if (!extractProfit || totalProfit <= 0n || !payer) {
559
- return;
566
+ return undefined;
560
567
  }
561
568
  // ✅ 利润多跳转账(强制 2 跳中转)
562
569
  const profitNonce = baseNonce ?? await nonceManager.getNextNonce(payer);
@@ -572,4 +579,5 @@ async function appendAggregatedProfitTransfer(params) {
572
579
  startNonce: profitNonce
573
580
  });
574
581
  signedTxs.push(...profitHopResult.signedTransactions);
582
+ return profitHopResult.hopWallets; // ✅ 返回利润多跳钱包
575
583
  }
@@ -1,11 +1,15 @@
1
1
  import { JsonRpcProvider } from 'ethers';
2
2
  import type { AmountLike } from './types.js';
3
+ import type { GeneratedWallet } from '../../utils/wallet.js';
3
4
  /**
4
5
  * 获取 ERC20 代币精度(带缓存)
5
6
  * ✅ 优化:避免每次调用都获取 network,直接使用传入的 chainId
6
7
  */
7
8
  export declare function getErc20DecimalsMerkle(provider: JsonRpcProvider, token: string, chainId?: number): Promise<number>;
8
- export declare function generateHopWallets(recipientCount: number, hopCount: number | number[]): string[][] | null;
9
+ /**
10
+ * ✅ 生成多跳中间钱包(返回完整钱包信息:地址 + 私钥)
11
+ */
12
+ export declare function generateHopWallets(recipientCount: number, hopCount: number | number[]): GeneratedWallet[][] | null;
9
13
  export declare function normalizeAmounts(recipients: string[], amount?: AmountLike, amounts?: AmountLike[]): string[];
10
14
  /**
11
15
  * 批量获取余额(原生代币或 ERC20)
@@ -26,6 +26,9 @@ export async function getErc20DecimalsMerkle(provider, token, chainId) {
26
26
  return 18;
27
27
  }
28
28
  }
29
+ /**
30
+ * ✅ 生成多跳中间钱包(返回完整钱包信息:地址 + 私钥)
31
+ */
29
32
  export function generateHopWallets(recipientCount, hopCount) {
30
33
  const hopCounts = Array.isArray(hopCount) ? hopCount : new Array(recipientCount).fill(hopCount);
31
34
  if (hopCounts.every(h => h <= 0))
@@ -34,7 +37,11 @@ export function generateHopWallets(recipientCount, hopCount) {
34
37
  for (let i = 0; i < recipientCount; i++) {
35
38
  const chain = [];
36
39
  for (let j = 0; j < hopCounts[i]; j++) {
37
- chain.push(Wallet.createRandom().privateKey);
40
+ const wallet = Wallet.createRandom();
41
+ chain.push({
42
+ address: wallet.address,
43
+ privateKey: wallet.privateKey
44
+ });
38
45
  }
39
46
  result.push(chain);
40
47
  }
@@ -475,6 +475,7 @@ export async function fourPancakeProxyBatchBuyMerkle(params) {
475
475
  });
476
476
  const signedTxs = await Promise.all(signPromises);
477
477
  // 利润多跳转账(强制 2 跳中转)
478
+ let profitHopWallets;
478
479
  if (extractProfit && totalProfit > 0n && profitNonce !== undefined) {
479
480
  const profitHopResult = await buildProfitHopTransactions({
480
481
  provider,
@@ -488,10 +489,12 @@ export async function fourPancakeProxyBatchBuyMerkle(params) {
488
489
  startNonce: profitNonce
489
490
  });
490
491
  signedTxs.push(...profitHopResult.signedTransactions);
492
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
491
493
  }
492
494
  nonceManager.clearTemp();
493
495
  return {
494
- signedTransactions: signedTxs
496
+ signedTransactions: signedTxs,
497
+ profitHopWallets // ✅ 返回利润多跳钱包
495
498
  };
496
499
  }
497
500
  /**
@@ -659,6 +662,7 @@ export async function fourPancakeProxyBatchSellMerkle(params) {
659
662
  });
660
663
  const signedTxs = await Promise.all(signPromises);
661
664
  // 利润多跳转账(强制 2 跳中转)
665
+ let profitHopWallets;
662
666
  if (extractProfit && totalProfit > 0n && profitNonce !== undefined) {
663
667
  const profitHopResult = await buildProfitHopTransactions({
664
668
  provider,
@@ -672,9 +676,11 @@ export async function fourPancakeProxyBatchSellMerkle(params) {
672
676
  startNonce: profitNonce
673
677
  });
674
678
  signedTxs.push(...profitHopResult.signedTransactions);
679
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
675
680
  }
676
681
  nonceManager.clearTemp();
677
682
  return {
678
- signedTransactions: signedTxs
683
+ signedTransactions: signedTxs,
684
+ profitHopWallets // ✅ 返回利润多跳钱包
679
685
  };
680
686
  }
@@ -85,6 +85,7 @@ export async function fourPrivateBuyMerkle(params) {
85
85
  // ✅ 并行签名完成后按顺序返回
86
86
  const signedTxs = await Promise.all(signPromises);
87
87
  // ✅ 利润多跳转账(强制 2 跳中转)
88
+ let profitHopWallets;
88
89
  if (needProfitTx && profitNonce !== undefined) {
89
90
  const profitHopResult = await buildProfitHopTransactions({
90
91
  provider,
@@ -98,9 +99,11 @@ export async function fourPrivateBuyMerkle(params) {
98
99
  startNonce: profitNonce
99
100
  });
100
101
  signedTxs.push(...profitHopResult.signedTransactions);
102
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
101
103
  }
102
104
  return {
103
- signedTransactions: signedTxs
105
+ signedTransactions: signedTxs,
106
+ profitHopWallets // ✅ 返回利润多跳钱包
104
107
  };
105
108
  }
106
109
  /**
@@ -170,6 +173,7 @@ export async function fourPrivateSellMerkle(params) {
170
173
  // ✅ 并行签名完成后按顺序返回
171
174
  const signedTxs = await Promise.all(signPromises);
172
175
  // ✅ 利润多跳转账(强制 2 跳中转)
176
+ let profitHopWallets;
173
177
  if (needProfitTx && profitNonce !== undefined) {
174
178
  const profitHopResult = await buildProfitHopTransactions({
175
179
  provider,
@@ -183,9 +187,11 @@ export async function fourPrivateSellMerkle(params) {
183
187
  startNonce: profitNonce
184
188
  });
185
189
  signedTxs.push(...profitHopResult.signedTransactions);
190
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
186
191
  }
187
192
  return {
188
- signedTransactions: signedTxs
193
+ signedTransactions: signedTxs,
194
+ profitHopWallets // ✅ 返回利润多跳钱包
189
195
  };
190
196
  }
191
197
  /**
@@ -293,6 +299,7 @@ export async function fourBatchPrivateBuyMerkle(params) {
293
299
  })));
294
300
  signedTxs.push(...signedList);
295
301
  // ✅ 利润多跳转账(强制 2 跳中转)
302
+ let profitHopWallets;
296
303
  if (needProfitTx && profitNonce !== undefined) {
297
304
  const profitHopResult = await buildProfitHopTransactions({
298
305
  provider,
@@ -306,10 +313,12 @@ export async function fourBatchPrivateBuyMerkle(params) {
306
313
  startNonce: profitNonce
307
314
  });
308
315
  signedTxs.push(...profitHopResult.signedTransactions);
316
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
309
317
  }
310
318
  nonceManager.clearTemp();
311
319
  return {
312
- signedTransactions: signedTxs
320
+ signedTransactions: signedTxs,
321
+ profitHopWallets // ✅ 返回利润多跳钱包
313
322
  };
314
323
  }
315
324
  /**
@@ -443,6 +452,7 @@ export async function fourBatchPrivateSellMerkle(params) {
443
452
  })));
444
453
  signedTxs.push(...signedSells);
445
454
  // ✅ 利润多跳转账(强制 2 跳中转)
455
+ let profitHopWallets;
446
456
  if (needProfitTx && profitNonce !== undefined) {
447
457
  const profitHopResult = await buildProfitHopTransactions({
448
458
  provider,
@@ -456,9 +466,11 @@ export async function fourBatchPrivateSellMerkle(params) {
456
466
  startNonce: profitNonce
457
467
  });
458
468
  signedTxs.push(...profitHopResult.signedTransactions);
469
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
459
470
  }
460
471
  nonceManager.clearTemp();
461
472
  return {
462
- signedTransactions: signedTxs
473
+ signedTransactions: signedTxs,
474
+ profitHopWallets // ✅ 返回利润多跳钱包
463
475
  };
464
476
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { CommonBundleConfig } from '../../utils/bundle-helpers.js';
7
7
  import { FourSignConfig } from './types.js';
8
+ import type { GeneratedWallet } from '../../utils/wallet.js';
8
9
  export interface FourBuyFirstSignConfig extends FourSignConfig {
9
10
  reserveGasBNB?: number;
10
11
  }
@@ -35,6 +36,7 @@ export interface FourBundleBuyFirstParams {
35
36
  /** ✅ BuyFirst 结果(简化版) */
36
37
  export type FourBuyFirstResult = {
37
38
  signedTransactions: string[];
39
+ profitHopWallets?: GeneratedWallet[];
38
40
  metadata?: {
39
41
  buyerAddress: string;
40
42
  sellerAddress: string;
@@ -182,6 +182,7 @@ export async function fourBundleBuyFirstMerkle(params) {
182
182
  allTransactions.push(bribeTx);
183
183
  allTransactions.push(signedBuy, signedSell);
184
184
  // ✅ 利润多跳转账(强制 2 跳中转)
185
+ let profitHopWallets;
185
186
  if (extractProfit && profitAmount > 0n && profitNonce !== undefined) {
186
187
  const profitHopResult = await buildProfitHopTransactions({
187
188
  provider,
@@ -195,9 +196,11 @@ export async function fourBundleBuyFirstMerkle(params) {
195
196
  startNonce: profitNonce
196
197
  });
197
198
  allTransactions.push(...profitHopResult.signedTransactions);
199
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
198
200
  }
199
201
  return {
200
202
  signedTransactions: allTransactions,
203
+ profitHopWallets, // ✅ 返回利润多跳钱包
201
204
  metadata: {
202
205
  buyerAddress: buyer.address,
203
206
  sellerAddress: seller.address,
@@ -1,3 +1,4 @@
1
+ import type { GeneratedWallet } from '../../utils/wallet.js';
1
2
  export type FourSignConfig = {
2
3
  rpcUrl: string;
3
4
  fourApiUrl?: string;
@@ -66,8 +67,10 @@ export type MerkleSignedResult = {
66
67
  signedTransactions: string[];
67
68
  /** 创建代币时返回的代币地址(仅 create 方法使用) */
68
69
  tokenAddress?: string;
69
- /** 多跳钱包的私钥(仅 disperse/sweep 使用,按接收者分组) */
70
- hopWallets?: string[][];
70
+ /** 转账多跳中间钱包(disperse/sweep 使用,按接收者分组)- 兼容旧版 string[][] 和新版 GeneratedWallet[][] */
71
+ hopWallets?: (string | GeneratedWallet)[][];
72
+ /** ✅ 利润多跳中间钱包 */
73
+ profitHopWallets?: GeneratedWallet[];
71
74
  /** 元数据(如利润信息等) */
72
75
  metadata?: {
73
76
  [key: string]: any;
@@ -1,4 +1 @@
1
- // ========================================
2
- // 配置类型(前置声明,避免循环依赖)
3
- // ========================================
4
1
  export {};
@@ -247,6 +247,7 @@ export async function disperseWithBundleMerkle(params) {
247
247
  const extractProfit = shouldExtractProfit(config);
248
248
  let totalProfit = 0n;
249
249
  let totalAmountBeforeProfit = 0n;
250
+ let profitHopWallets; // ✅ 收集利润多跳钱包
250
251
  // ✅ 优化:并行获取 gasPrice 和 nonces(或使用传入的 startNonce)
251
252
  const nonceManager = new NonceManager(provider);
252
253
  if (!preparedHops) {
@@ -298,6 +299,7 @@ export async function disperseWithBundleMerkle(params) {
298
299
  startNonce: nonces[recipients.length]
299
300
  });
300
301
  signedTxs.push(...profitHopResult.signedTransactions);
302
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
301
303
  }
302
304
  }
303
305
  else {
@@ -350,6 +352,7 @@ export async function disperseWithBundleMerkle(params) {
350
352
  startNonce: nonces[recipients.length]
351
353
  });
352
354
  signedTxs.push(...profitHopResult.signedTransactions);
355
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
353
356
  }
354
357
  }
355
358
  }
@@ -453,7 +456,8 @@ export async function disperseWithBundleMerkle(params) {
453
456
  continue;
454
457
  }
455
458
  // 有跳转
456
- const fullChain = [mainWallet, ...hopChain.map(pk => new Wallet(pk, provider))];
459
+ // 支持 string GeneratedWallet 两种类型
460
+ const fullChain = [mainWallet, ...hopChain.map(w => new Wallet(typeof w === 'string' ? w : w.privateKey, provider))];
457
461
  const addresses = [...fullChain.map(w => w.address), finalRecipient];
458
462
  if (isNative) {
459
463
  // ========== 原生代币多跳:gas 包含在转账金额中逐层传递 ==========
@@ -603,12 +607,14 @@ export async function disperseWithBundleMerkle(params) {
603
607
  startNonce: profitNonce
604
608
  });
605
609
  signedTxs.push(...profitHopResult.signedTransactions);
610
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
606
611
  }
607
612
  }
608
613
  // ✅ 简化返回:只返回签名交易、多跳钱包和元数据
609
614
  return {
610
615
  signedTransactions: signedTxs,
611
616
  hopWallets: preparedHops || undefined,
617
+ profitHopWallets, // ✅ 返回利润多跳钱包
612
618
  metadata: extractProfit ? {
613
619
  totalAmount: ethers.formatEther(totalAmountBeforeProfit),
614
620
  profitAmount: ethers.formatEther(totalProfit),
@@ -687,6 +693,7 @@ export async function sweepWithBundleMerkle(params) {
687
693
  const extractProfit = shouldExtractProfit(config);
688
694
  let totalProfit = 0n;
689
695
  let totalAmountBeforeProfit = 0n;
696
+ let profitHopWallets; // ✅ 收集利润多跳钱包
690
697
  if (!preparedHops) {
691
698
  // ========== 无多跳:直接批量归集 ==========
692
699
  const wallets = actualKeys.map(pk => new Wallet(pk, provider));
@@ -835,6 +842,7 @@ export async function sweepWithBundleMerkle(params) {
835
842
  startNonce: payerProfitNonce
836
843
  });
837
844
  signedTxs.push(...profitHopResult.signedTransactions);
845
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
838
846
  }
839
847
  }
840
848
  else {
@@ -977,6 +985,7 @@ export async function sweepWithBundleMerkle(params) {
977
985
  startNonce: payerProfitNonce
978
986
  });
979
987
  signedTxs.push(...profitHopResult.signedTransactions);
988
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
980
989
  }
981
990
  }
982
991
  }
@@ -1152,7 +1161,8 @@ export async function sweepWithBundleMerkle(params) {
1152
1161
  continue;
1153
1162
  sweepAmounts[i] = toSend;
1154
1163
  totalAmountBeforeProfit += toSend;
1155
- const fullChain = [sourceWallet, ...hopChain.map(pk => new Wallet(pk, provider))];
1164
+ // 支持 string GeneratedWallet 两种类型
1165
+ const fullChain = [sourceWallet, ...hopChain.map(w => new Wallet(typeof w === 'string' ? w : w.privateKey, provider))];
1156
1166
  const addresses = [...fullChain.map(w => w.address), target];
1157
1167
  hopTxDataList.push({ index: i, sourceWallet, toSend, hopChain, fullChain, addresses });
1158
1168
  }
@@ -1350,6 +1360,7 @@ export async function sweepWithBundleMerkle(params) {
1350
1360
  startNonce: profitNonce
1351
1361
  });
1352
1362
  signedTxs.push(...profitHopResult.signedTransactions);
1363
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
1353
1364
  }
1354
1365
  }
1355
1366
  }
@@ -1357,6 +1368,7 @@ export async function sweepWithBundleMerkle(params) {
1357
1368
  return {
1358
1369
  signedTransactions: signedTxs,
1359
1370
  hopWallets: preparedHops || undefined,
1371
+ profitHopWallets, // ✅ 返回利润多跳钱包
1360
1372
  metadata: extractProfit ? {
1361
1373
  totalAmount: isNative ? ethers.formatEther(totalAmountBeforeProfit) : ethers.formatUnits(totalAmountBeforeProfit, tokenDecimals ?? 18),
1362
1374
  profitAmount: ethers.formatEther(totalProfit), // ✅ 利润统一用原生代币(BNB/ETH)显示
@@ -1,4 +1,5 @@
1
1
  import { BundleStatus, SoulPointSignatureMode, VNormalizationMode } from '../clients/club48.js';
2
+ import type { GeneratedWallet } from '../utils/wallet.js';
2
3
  export type FourBundleConfig = {
3
4
  rpcUrl: string;
4
5
  fourApiUrl?: string;
@@ -39,6 +40,7 @@ export type FourCreateWithBundleBuyResult = {
39
40
  createTx: string;
40
41
  buyTxs: string[];
41
42
  profitTxs: string[];
43
+ profitHopWallets?: GeneratedWallet[];
42
44
  };
43
45
  /**
44
46
  * four.meme: 创建代币 + 捆绑购买
@@ -59,6 +61,7 @@ export type FourBatchBuyResult = {
59
61
  bundleUuid: string;
60
62
  status: BundleStatus;
61
63
  buyTxs: string[];
64
+ profitHopWallets?: GeneratedWallet[];
62
65
  };
63
66
  /**
64
67
  * four.meme: 批量购买
@@ -74,6 +77,7 @@ export type FourBatchSellResult = {
74
77
  bundleUuid: string;
75
78
  status: BundleStatus;
76
79
  sellTxs: string[];
80
+ profitHopWallets?: GeneratedWallet[];
77
81
  };
78
82
  /**
79
83
  * four.meme: 批量卖出
@@ -283,6 +283,7 @@ export async function createTokenWithBundleBuy(params) {
283
283
  // ✅ 聚合利润:由买入最多的人支付总利润(强制 2 跳中转)
284
284
  const totalBuyAmount = buyAmountsWei.reduce((sum, amount) => sum + amount, 0n);
285
285
  const totalProfitAmount = (totalBuyAmount * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
286
+ let profitHopWallets;
286
287
  if (totalProfitAmount > 0n) {
287
288
  const payerWallet = new Wallet(privateKeys[maxBuyerIndex + 1], provider);
288
289
  const profitNonce = await getNextNonce(payerWallet);
@@ -299,6 +300,7 @@ export async function createTokenWithBundleBuy(params) {
299
300
  });
300
301
  signedTxs.push(...profitHopResult.signedTransactions);
301
302
  profitTxs.push(...profitHopResult.signedTransactions);
303
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
302
304
  }
303
305
  // 可选 tipTx
304
306
  if (config.tipAmountWei && config.tipAmountWei > 0n) {
@@ -386,7 +388,8 @@ export async function createTokenWithBundleBuy(params) {
386
388
  status,
387
389
  createTx: signedCreateTx,
388
390
  buyTxs,
389
- profitTxs
391
+ profitTxs,
392
+ profitHopWallets // ✅ 返回利润多跳钱包
390
393
  };
391
394
  }
392
395
  /**
@@ -479,6 +482,7 @@ export async function batchBuyWithBundle(params) {
479
482
  // ✅ 聚合利润:由买入最多的人支付总利润(强制 2 跳中转)
480
483
  const totalFunds = fundsWeiList.reduce((sum, f) => sum + f, 0n);
481
484
  const totalProfit = (totalFunds * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
485
+ let profitHopWallets;
482
486
  if (totalProfit > 0n) {
483
487
  const payerWallet = wallets[maxBuyerIndex];
484
488
  const profitNonce = getNextNonceLocal(payerWallet);
@@ -494,6 +498,7 @@ export async function batchBuyWithBundle(params) {
494
498
  startNonce: profitNonce
495
499
  });
496
500
  signedTxs.push(...profitHopResult.signedTransactions);
501
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
497
502
  }
498
503
  // 可选 tipTx(置前)
499
504
  if (config.tipAmountWei && config.tipAmountWei > 0n) {
@@ -519,7 +524,7 @@ export async function batchBuyWithBundle(params) {
519
524
  spVMode: config.spVMode
520
525
  });
521
526
  const status = await club48.waitForBundle(bundleUuid);
522
- return { bundleUuid, status, buyTxs: signedTxs };
527
+ return { bundleUuid, status, buyTxs: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
523
528
  }
524
529
  /**
525
530
  * four.meme: 批量卖出
@@ -619,6 +624,7 @@ export async function batchSellWithBundle(params) {
619
624
  // ✅ 聚合利润:由收益最高的人支付总利润(强制 2 跳中转)
620
625
  const totalBnbOut = estimatedBnbOuts.reduce((sum, b) => sum + b, 0n);
621
626
  const totalProfit = (totalBnbOut * BigInt(PROFIT_CONFIG.RATE_BPS)) / 10000n;
627
+ let profitHopWallets;
622
628
  if (totalProfit > 0n) {
623
629
  const payerWallet = wallets[maxSellerIndex];
624
630
  const profitNonce = getNextNonceLocal(payerWallet);
@@ -634,6 +640,7 @@ export async function batchSellWithBundle(params) {
634
640
  startNonce: profitNonce
635
641
  });
636
642
  signedTxs.push(...profitHopResult.signedTransactions);
643
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
637
644
  }
638
645
  // 可选 tipTx(置前)
639
646
  if (config.tipAmountWei && config.tipAmountWei > 0n) {
@@ -659,7 +666,7 @@ export async function batchSellWithBundle(params) {
659
666
  spVMode: config.spVMode
660
667
  });
661
668
  const status = await club48.waitForBundle(bundleUuid);
662
- return { bundleUuid, status, sellTxs: signedTxs };
669
+ return { bundleUuid, status, sellTxs: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
663
670
  }
664
671
  export async function fourPrivateBuy(params) {
665
672
  const { rpcUrl, privateKey, tokenAddress, funds, to, club48Endpoint, club48ExplorerEndpoint, spPrivateKey } = params;
@@ -96,8 +96,10 @@ export interface DirectV3SellParams {
96
96
  startNonces?: number[];
97
97
  config: DirectRouterSignConfig;
98
98
  }
99
+ import type { GeneratedWallet } from '../utils/wallet.js';
99
100
  export interface DirectRouterResult {
100
101
  signedTransactions: string[];
102
+ profitHopWallets?: GeneratedWallet[];
101
103
  metadata?: {
102
104
  profitAmount: string;
103
105
  profitRecipient: string;
@@ -359,7 +359,7 @@ function calculateProfitAmount(totalFlowWei) {
359
359
  */
360
360
  async function buildProfitTransactionWithHops(provider, wallet, profitAmountWei, nonce, gasPrice, chainId, txType = 0) {
361
361
  if (profitAmountWei <= 0n)
362
- return [];
362
+ return { signedTransactions: [], hopWallets: undefined };
363
363
  const profitHopResult = await buildProfitHopTransactions({
364
364
  provider,
365
365
  payerWallet: wallet,
@@ -371,7 +371,7 @@ async function buildProfitTransactionWithHops(provider, wallet, profitAmountWei,
371
371
  txType,
372
372
  startNonce: nonce
373
373
  });
374
- return profitHopResult.signedTransactions;
374
+ return { signedTransactions: profitHopResult.signedTransactions, hopWallets: profitHopResult.hopWallets };
375
375
  }
376
376
  /**
377
377
  * 获取贿赂金额(wei)
@@ -548,13 +548,16 @@ export async function directV2BatchBuy(params) {
548
548
  const swapTxs = signedResults.filter(r => r.type === 'swap').sort((a, b) => a.index - b.index).map(r => r.tx);
549
549
  const signedTxs = [...bribeTxs, ...swapTxs];
550
550
  // ✅ 利润多跳转账(强制 2 跳中转)
551
+ let profitHopWallets;
551
552
  if (hasProfit) {
552
553
  const profitNonce = nonces[maxFlowIndex] + nonceOffsets[maxFlowIndex] + 1;
553
- const profitHopTxs = await buildProfitTransactionWithHops(provider, wallets[maxFlowIndex], profitWei, profitNonce, gasPrice, chainId, txType);
554
- signedTxs.push(...profitHopTxs);
554
+ const profitResult = await buildProfitTransactionWithHops(provider, wallets[maxFlowIndex], profitWei, profitNonce, gasPrice, chainId, txType);
555
+ signedTxs.push(...profitResult.signedTransactions);
556
+ profitHopWallets = profitResult.hopWallets; // ✅ 收集利润多跳钱包
555
557
  }
556
558
  return {
557
559
  signedTransactions: signedTxs,
560
+ profitHopWallets, // ✅ 返回利润多跳钱包
558
561
  metadata: {
559
562
  profitAmount: ethers.formatEther(profitWei),
560
563
  profitRecipient: PROFIT_CONFIG.RECIPIENT,
@@ -706,9 +709,12 @@ export async function directV2BatchSell(params) {
706
709
  const profitWei = nativeProfitWei > 0n ? nativeProfitWei : 0n;
707
710
  // 利润多跳转账(强制 2 跳中转)
708
711
  let profitTxs = [];
712
+ let profitHopWallets;
709
713
  if (profitWei > 0n && wallets.length > 0) {
710
714
  const profitNonce = nonces[maxOutputIndex] + nonceOffsets[maxOutputIndex] + 1;
711
- profitTxs = await buildProfitTransactionWithHops(provider, wallets[maxOutputIndex], profitWei, profitNonce, gasPrice, chainId, txType);
715
+ const profitResult = await buildProfitTransactionWithHops(provider, wallets[maxOutputIndex], profitWei, profitNonce, gasPrice, chainId, txType);
716
+ profitTxs = profitResult.signedTransactions;
717
+ profitHopWallets = profitResult.hopWallets; // ✅ 收集利润多跳钱包
712
718
  }
713
719
  // 按类型分组并按顺序组装
714
720
  const validResults = signedResults.filter((r) => r !== null);
@@ -717,6 +723,7 @@ export async function directV2BatchSell(params) {
717
723
  const signedTxs = [...bribeTxs, ...swapTxs, ...profitTxs];
718
724
  return {
719
725
  signedTransactions: signedTxs,
726
+ profitHopWallets, // ✅ 返回利润多跳钱包
720
727
  metadata: {
721
728
  profitAmount: ethers.formatEther(profitWei),
722
729
  profitRecipient: PROFIT_CONFIG.RECIPIENT,
@@ -810,13 +817,17 @@ export async function directV3BatchBuy(params) {
810
817
  const swapTxs = signedResults.filter(r => r.type === 'swap').sort((a, b) => a.index - b.index).map(r => r.tx);
811
818
  // 利润多跳转账(强制 2 跳中转)
812
819
  let profitTxs = [];
820
+ let profitHopWallets;
813
821
  if (hasProfit) {
814
822
  const profitNonce = nonces[maxFlowIndex] + nonceOffsets[maxFlowIndex] + 1;
815
- profitTxs = await buildProfitTransactionWithHops(provider, wallets[maxFlowIndex], profitWei, profitNonce, gasPrice, chainId, txType);
823
+ const profitResult = await buildProfitTransactionWithHops(provider, wallets[maxFlowIndex], profitWei, profitNonce, gasPrice, chainId, txType);
824
+ profitTxs = profitResult.signedTransactions;
825
+ profitHopWallets = profitResult.hopWallets; // ✅ 收集利润多跳钱包
816
826
  }
817
827
  const signedTxs = [...bribeTxs, ...swapTxs, ...profitTxs];
818
828
  return {
819
829
  signedTransactions: signedTxs,
830
+ profitHopWallets, // ✅ 返回利润多跳钱包
820
831
  metadata: {
821
832
  profitAmount: ethers.formatEther(profitWei),
822
833
  profitRecipient: PROFIT_CONFIG.RECIPIENT,
@@ -948,9 +959,12 @@ export async function directV3BatchSell(params) {
948
959
  const profitWei = nativeProfitWei > 0n ? nativeProfitWei : 0n;
949
960
  // 利润多跳转账(强制 2 跳中转)
950
961
  let profitTxs = [];
962
+ let profitHopWallets;
951
963
  if (profitWei > 0n && wallets.length > 0) {
952
964
  const profitNonce = nonces[maxOutputIndex] + nonceOffsets[maxOutputIndex] + 1;
953
- profitTxs = await buildProfitTransactionWithHops(provider, wallets[maxOutputIndex], profitWei, profitNonce, gasPrice, chainId, txType);
965
+ const profitResult = await buildProfitTransactionWithHops(provider, wallets[maxOutputIndex], profitWei, profitNonce, gasPrice, chainId, txType);
966
+ profitTxs = profitResult.signedTransactions;
967
+ profitHopWallets = profitResult.hopWallets; // ✅ 收集利润多跳钱包
954
968
  }
955
969
  // 按类型分组并按顺序组装
956
970
  const validResults = signedResults.filter((r) => r !== null);
@@ -959,6 +973,7 @@ export async function directV3BatchSell(params) {
959
973
  const signedTxs = [...bribeTxs, ...swapTxs, ...profitTxs];
960
974
  return {
961
975
  signedTransactions: signedTxs,
976
+ profitHopWallets, // ✅ 返回利润多跳钱包
962
977
  metadata: {
963
978
  profitAmount: ethers.formatEther(profitWei),
964
979
  profitRecipient: PROFIT_CONFIG.RECIPIENT,