four-flap-meme-sdk 1.4.58 → 1.4.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 (38) 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/swap.d.ts +3 -0
  9. package/dist/contracts/tm-bundle-merkle/swap.js +10 -1
  10. package/dist/contracts/tm-bundle-merkle/types.d.ts +5 -2
  11. package/dist/contracts/tm-bundle-merkle/types.js +0 -3
  12. package/dist/contracts/tm-bundle-merkle/utils.js +14 -2
  13. package/dist/contracts/tm-bundle.d.ts +4 -0
  14. package/dist/contracts/tm-bundle.js +10 -3
  15. package/dist/dex/direct-router.d.ts +2 -0
  16. package/dist/dex/direct-router.js +22 -7
  17. package/dist/flap/portal-bundle-merkle/core.js +10 -1
  18. package/dist/flap/portal-bundle-merkle/pancake-proxy.js +8 -2
  19. package/dist/flap/portal-bundle-merkle/private.js +17 -7
  20. package/dist/flap/portal-bundle-merkle/swap-buy-first.d.ts +2 -0
  21. package/dist/flap/portal-bundle-merkle/swap-buy-first.js +8 -4
  22. package/dist/flap/portal-bundle-merkle/swap.d.ts +3 -0
  23. package/dist/flap/portal-bundle-merkle/swap.js +24 -12
  24. package/dist/flap/portal-bundle-merkle/types.d.ts +3 -0
  25. package/dist/flap/portal-bundle-merkle/types.js +0 -3
  26. package/dist/flap/portal-bundle-merkle/utils.d.ts +5 -2
  27. package/dist/flap/portal-bundle-merkle/utils.js +22 -3
  28. package/dist/pancake/bundle-buy-first.d.ts +2 -0
  29. package/dist/pancake/bundle-buy-first.js +8 -4
  30. package/dist/pancake/bundle-swap.d.ts +3 -0
  31. package/dist/pancake/bundle-swap.js +10 -1
  32. package/dist/utils/bundle-helpers.d.ts +2 -1
  33. package/dist/utils/bundle-helpers.js +5 -9
  34. package/dist/utils/holders-maker.d.ts +2 -0
  35. package/dist/utils/holders-maker.js +15 -2
  36. package/dist/utils/private-sale.d.ts +3 -0
  37. package/dist/utils/private-sale.js +3 -0
  38. package/package.json +1 -1
@@ -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,
@@ -47,6 +47,7 @@ export interface FourBundleSwapParams {
47
47
  */
48
48
  export type FourSwapResult = {
49
49
  signedTransactions: string[];
50
+ profitHopWallets?: GeneratedWallet[];
50
51
  metadata?: {
51
52
  sellerAddress: string;
52
53
  buyerAddress: string;
@@ -78,6 +79,7 @@ export interface FourBatchSwapSignParams {
78
79
  */
79
80
  export interface FourBatchSwapResult {
80
81
  signedTransactions: string[];
82
+ profitHopWallets?: GeneratedWallet[];
81
83
  metadata?: {
82
84
  sellerAddress: string;
83
85
  buyerAddresses: string[];
@@ -115,6 +117,7 @@ export interface FourQuickBatchSwapSignParams {
115
117
  export interface FourQuickBatchSwapResult {
116
118
  signedTransactions: string[];
117
119
  disperseHopWallets?: GeneratedWallet[];
120
+ profitHopWallets?: GeneratedWallet[];
118
121
  metadata?: {
119
122
  sellerAddress: string;
120
123
  buyerAddresses: string[];
@@ -252,6 +252,7 @@ export async function fourBundleSwapMerkle(params) {
252
252
  allTransactions.push(approvalTx);
253
253
  allTransactions.push(signedSell, signedBuy);
254
254
  // ✅ 利润多跳转账(强制 2 跳中转)
255
+ let profitHopWallets;
255
256
  if (extractProfit && profitAmount > 0n && profitNonce !== undefined) {
256
257
  const profitHopResult = await buildProfitHopTransactions({
257
258
  provider,
@@ -265,9 +266,11 @@ export async function fourBundleSwapMerkle(params) {
265
266
  startNonce: profitNonce
266
267
  });
267
268
  allTransactions.push(...profitHopResult.signedTransactions);
269
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
268
270
  }
269
271
  return {
270
272
  signedTransactions: allTransactions,
273
+ profitHopWallets, // ✅ 导出利润多跳钱包
271
274
  metadata: {
272
275
  sellerAddress: seller.address,
273
276
  buyerAddress: buyer.address,
@@ -474,6 +477,7 @@ export async function fourBatchSwapMerkle(params) {
474
477
  signedTransactions.push(signedSell);
475
478
  signedTransactions.push(...signedBuys);
476
479
  // ✅ 利润多跳转账(强制 2 跳中转)
480
+ let profitHopWallets;
477
481
  if (profitAmount > 0n) {
478
482
  const profitHopResult = await buildProfitHopTransactions({
479
483
  provider,
@@ -487,9 +491,11 @@ export async function fourBatchSwapMerkle(params) {
487
491
  startNonce: profitNonce
488
492
  });
489
493
  signedTransactions.push(...profitHopResult.signedTransactions);
494
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
490
495
  }
491
496
  return {
492
497
  signedTransactions,
498
+ profitHopWallets, // ✅ 导出利润多跳钱包
493
499
  metadata: {
494
500
  sellerAddress: seller.address,
495
501
  buyerAddresses: buyers.map(b => b.address),
@@ -709,6 +715,7 @@ export async function fourQuickBatchSwapMerkle(params) {
709
715
  signedTransactions.push(...transferTxs);
710
716
  signedTransactions.push(...signedBuys);
711
717
  // ==================== 5. 利润多跳转账(强制 2 跳中转)====================
718
+ let profitHopWallets;
712
719
  if (profitAmount > 0n) {
713
720
  const profitHopResult = await buildProfitHopTransactions({
714
721
  provider,
@@ -722,6 +729,7 @@ export async function fourQuickBatchSwapMerkle(params) {
722
729
  startNonce: sellerNonce++
723
730
  });
724
731
  signedTransactions.push(...profitHopResult.signedTransactions);
732
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
725
733
  console.log(`[fourQuickBatchSwapMerkle] 利润多跳交易已签名: ${profitHopResult.signedTransactions.length} 笔`);
726
734
  }
727
735
  console.log(`[fourQuickBatchSwapMerkle] 交易组装完成: ${signedTransactions.length} 笔`);
@@ -732,7 +740,8 @@ export async function fourQuickBatchSwapMerkle(params) {
732
740
  console.log(` - 利润多跳: ${profitAmount > 0n ? PROFIT_HOP_COUNT + 1 : 0}`);
733
741
  return {
734
742
  signedTransactions,
735
- disperseHopWallets: allHopWallets.length > 0 ? allHopWallets : undefined, // ✅ 返回中间钱包信息
743
+ disperseHopWallets: allHopWallets.length > 0 ? allHopWallets : undefined, // ✅ 返回转账多跳钱包
744
+ profitHopWallets, // ✅ 返回利润多跳钱包
736
745
  metadata: {
737
746
  sellerAddress: seller.address,
738
747
  buyerAddresses: buyers.map(b => b.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;