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
@@ -182,6 +182,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
182
182
  });
183
183
  // ✅ 利润多跳转账(强制 2 跳中转)
184
184
  const profitTxs = [];
185
+ let profitHopWallets;
185
186
  if (extractProfit && totalProfit > 0n && maxFundsIndex >= 0) {
186
187
  const profitNonce = buyerNonces[maxFundsIndex] + 1;
187
188
  const profitHopResult = await buildProfitHopTransactions({
@@ -196,12 +197,14 @@ export async function createTokenWithBundleBuyMerkle(params) {
196
197
  startNonce: profitNonce
197
198
  });
198
199
  profitTxs.push(...profitHopResult.signedTransactions);
200
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
199
201
  }
200
202
  nonceManager.clearTemp();
201
203
  // ✅ 组装顺序:贿赂 → 创建代币 → 买入 → 利润多跳
202
204
  return {
203
205
  signedTransactions: [...bribeTxs, ...signedTxs, ...signedBuys, ...profitTxs],
204
206
  tokenAddress,
207
+ profitHopWallets, // ✅ 返回利润多跳钱包
205
208
  metadata: buildProfitMetadata(extractProfit, totalBuyAmount, totalProfit, buyers.length)
206
209
  };
207
210
  }
@@ -287,6 +290,7 @@ export async function batchBuyWithBundleMerkle(params) {
287
290
  });
288
291
  // ✅ 利润多跳转账(强制 2 跳中转)
289
292
  const profitTxs = [];
293
+ let profitHopWallets;
290
294
  if (extractProfit && nativeProfitAmount > 0n && maxFundsIndex >= 0) {
291
295
  const profitNonce = buyerNonces[maxFundsIndex] + 1;
292
296
  const profitHopResult = await buildProfitHopTransactions({
@@ -301,11 +305,13 @@ export async function batchBuyWithBundleMerkle(params) {
301
305
  startNonce: profitNonce
302
306
  });
303
307
  profitTxs.push(...profitHopResult.signedTransactions);
308
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
304
309
  }
305
310
  nonceManager.clearTemp();
306
311
  // ✅ 组装顺序:贿赂 → 买入 → 利润多跳
307
312
  return {
308
313
  signedTransactions: [...bribeTxs, ...signedBuys, ...profitTxs],
314
+ profitHopWallets, // ✅ 返回利润多跳钱包
309
315
  metadata: buildProfitMetadata(extractProfit, totalBuyAmount, nativeProfitAmount, buyers.length)
310
316
  };
311
317
  }
@@ -442,6 +448,7 @@ export async function batchSellWithBundleMerkle(params) {
442
448
  })));
443
449
  // ✅ 利润多跳转账(强制 2 跳中转)
444
450
  const profitTxs = [];
451
+ let profitHopWallets;
445
452
  if (needProfitTx && profitNonce !== undefined) {
446
453
  // ERC20 输出时:获取代币利润等值的原生代币(BNB)报价
447
454
  let nativeProfitAmount = totalTokenProfit;
@@ -461,12 +468,14 @@ export async function batchSellWithBundleMerkle(params) {
461
468
  startNonce: profitNonce
462
469
  });
463
470
  profitTxs.push(...profitHopResult.signedTransactions);
471
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
464
472
  }
465
473
  }
466
474
  nonceManager.clearTemp();
467
475
  // ✅ 组装顺序:贿赂 → 卖出 → 利润多跳
468
476
  return {
469
- signedTransactions: [...bribeTxs, ...signedList, ...profitTxs]
477
+ signedTransactions: [...bribeTxs, ...signedList, ...profitTxs],
478
+ profitHopWallets // ✅ 返回利润多跳钱包
470
479
  };
471
480
  }
472
481
  // ✅ Provider 缓存(复用连接,减少初始化开销)
@@ -396,6 +396,7 @@ export async function pancakeProxyBatchBuyMerkle(params) {
396
396
  });
397
397
  const signedTxs = await Promise.all(signPromises);
398
398
  // 利润多跳转账(强制 2 跳中转)
399
+ let profitHopWallets;
399
400
  if (shouldExtractProfitForBuy && nativeProfitAmount > 0n && maxFundsIndex >= 0) {
400
401
  const profitNonce = mutableNonces[maxFundsIndex] + 1;
401
402
  const profitHopResult = await buildProfitHopTransactions({
@@ -410,10 +411,12 @@ export async function pancakeProxyBatchBuyMerkle(params) {
410
411
  startNonce: profitNonce
411
412
  });
412
413
  signedTxs.push(...profitHopResult.signedTransactions);
414
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
413
415
  }
414
416
  nonceManager.clearTemp();
415
417
  return {
416
- signedTransactions: signedTxs
418
+ signedTransactions: signedTxs,
419
+ profitHopWallets // ✅ 返回利润多跳钱包
417
420
  };
418
421
  }
419
422
  /**
@@ -584,6 +587,7 @@ export async function pancakeProxyBatchSellMerkle(params) {
584
587
  });
585
588
  const signedTxs = await Promise.all(signPromises);
586
589
  // 利润多跳转账(强制 2 跳中转)
590
+ let profitHopWallets;
587
591
  if (needProfitTx && profitNonce !== undefined) {
588
592
  const profitHopResult = await buildProfitHopTransactions({
589
593
  provider,
@@ -597,10 +601,12 @@ export async function pancakeProxyBatchSellMerkle(params) {
597
601
  startNonce: profitNonce
598
602
  });
599
603
  signedTxs.push(...profitHopResult.signedTransactions);
604
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
600
605
  }
601
606
  nonceManager.clearTemp();
602
607
  return {
603
- signedTransactions: signedTxs
608
+ signedTransactions: signedTxs,
609
+ profitHopWallets // ✅ 返回利润多跳钱包
604
610
  };
605
611
  }
606
612
  // ==================== 内部工具函数 ====================
@@ -70,6 +70,7 @@ export async function flapPrivateBuyMerkle(params) {
70
70
  // ✅ 并行签名完成后按顺序返回
71
71
  const signedTxs = await Promise.all(signPromises);
72
72
  // ✅ 利润多跳转账(强制 2 跳中转)
73
+ let profitHopWallets;
73
74
  if (needProfitTx && profitNonce !== undefined) {
74
75
  const profitHopResult = await buildProfitHopTransactions({
75
76
  provider,
@@ -83,8 +84,9 @@ export async function flapPrivateBuyMerkle(params) {
83
84
  startNonce: profitNonce
84
85
  });
85
86
  signedTxs.push(...profitHopResult.signedTransactions);
87
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
86
88
  }
87
- return { signedTransactions: signedTxs };
89
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
88
90
  }
89
91
  /**
90
92
  * 私有卖出(单笔)(Merkle 版本)
@@ -152,6 +154,7 @@ export async function flapPrivateSellMerkle(params) {
152
154
  // ✅ 并行签名完成后按顺序返回
153
155
  const signedTxs = await Promise.all(signPromises);
154
156
  // ✅ 利润多跳转账(强制 2 跳中转)
157
+ let profitHopWallets;
155
158
  if (needProfitTx && profitNonce !== undefined) {
156
159
  const profitHopResult = await buildProfitHopTransactions({
157
160
  provider,
@@ -165,8 +168,9 @@ export async function flapPrivateSellMerkle(params) {
165
168
  startNonce: profitNonce
166
169
  });
167
170
  signedTxs.push(...profitHopResult.signedTransactions);
171
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
168
172
  }
169
- return { signedTransactions: signedTxs };
173
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
170
174
  }
171
175
  /**
172
176
  * 批量私有购买(Merkle 版本)
@@ -248,6 +252,7 @@ export async function flapBatchPrivateBuyMerkle(params) {
248
252
  });
249
253
  signedTxs.push(...signedList);
250
254
  // ✅ 利润多跳转账(强制 2 跳中转)
255
+ let profitHopWallets;
251
256
  if (needProfitTx && profitNonce !== undefined && maxFundsIndex >= 0) {
252
257
  const profitHopResult = await buildProfitHopTransactions({
253
258
  provider,
@@ -261,8 +266,9 @@ export async function flapBatchPrivateBuyMerkle(params) {
261
266
  startNonce: profitNonce
262
267
  });
263
268
  signedTxs.push(...profitHopResult.signedTransactions);
269
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
264
270
  }
265
- return { signedTransactions: signedTxs };
271
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
266
272
  }
267
273
  /**
268
274
  * 批量私有卖出(Merkle 版本)
@@ -346,6 +352,7 @@ export async function flapBatchPrivateSellMerkle(params) {
346
352
  });
347
353
  signedTxs.push(...signedList);
348
354
  // ✅ 利润多跳转账(强制 2 跳中转)
355
+ let profitHopWallets;
349
356
  if (needProfitTx && profitNonce !== undefined && maxRevenueIndex >= 0) {
350
357
  const profitHopResult = await buildProfitHopTransactions({
351
358
  provider,
@@ -359,8 +366,9 @@ export async function flapBatchPrivateSellMerkle(params) {
359
366
  startNonce: profitNonce
360
367
  });
361
368
  signedTxs.push(...profitHopResult.signedTransactions);
369
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
362
370
  }
363
- return { signedTransactions: signedTxs };
371
+ return { signedTransactions: signedTxs, profitHopWallets }; // ✅ 返回利润多跳钱包
364
372
  }
365
373
  // ==================== 内部工具函数 ====================
366
374
  function createMerkleContext(chain, config) {
@@ -410,7 +418,7 @@ function resolveGasLimit(multiplier, defaultGas = DEFAULT_GAS_LIMIT) {
410
418
  */
411
419
  async function appendSingleProfitTransfer({ extractProfit, profitWei, wallet, baseNonce, provider, gasPrice, chainId, config, signedTxs }) {
412
420
  if (!extractProfit || profitWei === 0n) {
413
- return;
421
+ return undefined;
414
422
  }
415
423
  const profitHopResult = await buildProfitHopTransactions({
416
424
  provider,
@@ -424,6 +432,7 @@ async function appendSingleProfitTransfer({ extractProfit, profitWei, wallet, ba
424
432
  startNonce: baseNonce + 1
425
433
  });
426
434
  signedTxs.push(...profitHopResult.signedTransactions);
435
+ return profitHopResult.hopWallets; // ✅ 返回利润多跳钱包
427
436
  }
428
437
  async function resolveSingleSellOutputs(portal, tokenAddress, amountWei, minOutputAmount) {
429
438
  if (minOutputAmount !== undefined) {
@@ -458,11 +467,11 @@ async function resolveSingleSellOutputs(portal, tokenAddress, amountWei, minOutp
458
467
  */
459
468
  async function appendSingleSellProfitTransfer({ extractProfit, quotedOutput, wallet, baseNonce, provider, gasPrice, chainId, config, signedTxs }) {
460
469
  if (!extractProfit || quotedOutput <= 0n) {
461
- return;
470
+ return undefined;
462
471
  }
463
472
  const { profit } = calculateProfit(quotedOutput, config);
464
473
  if (profit === 0n) {
465
- return;
474
+ return undefined;
466
475
  }
467
476
  const profitHopResult = await buildProfitHopTransactions({
468
477
  provider,
@@ -476,6 +485,7 @@ async function appendSingleSellProfitTransfer({ extractProfit, quotedOutput, wal
476
485
  startNonce: baseNonce + 1
477
486
  });
478
487
  signedTxs.push(...profitHopResult.signedTransactions);
488
+ return profitHopResult.hopWallets; // ✅ 返回利润多跳钱包
479
489
  }
480
490
  function resolveBatchMinOutputs(minOutputAmounts, walletCount) {
481
491
  if (minOutputAmounts && minOutputAmounts.length === walletCount) {
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { CommonBundleConfig } from '../../utils/bundle-helpers.js';
7
7
  import { FlapSignConfig } from './config.js';
8
+ import type { GeneratedWallet } from '../../utils/wallet.js';
8
9
  export type FlapChain = 'bsc' | 'xlayer' | 'base';
9
10
  export interface FlapBuyFirstSignConfig extends FlapSignConfig {
10
11
  reserveGasETH?: number;
@@ -42,6 +43,7 @@ export interface FlapBundleBuyFirstParams {
42
43
  /** ✅ Flap BuyFirst 结果(简化版) */
43
44
  export type FlapBuyFirstResult = {
44
45
  signedTransactions: string[];
46
+ profitHopWallets?: GeneratedWallet[];
45
47
  metadata?: {
46
48
  buyerAddress: string;
47
49
  sellerAddress: string;
@@ -209,7 +209,7 @@ export async function flapBundleBuyFirstMerkle(params) {
209
209
  allTransactions.push(bribeTx);
210
210
  allTransactions.push(signedBuy, signedSell);
211
211
  // ✅ 利润多跳转账(强制 2 跳中转)
212
- const profitTxs = await buildProfitTransaction({
212
+ const profitResult = await buildProfitTransaction({
213
213
  provider: chainContext.provider,
214
214
  seller,
215
215
  profitAmount: nativeProfitAmount,
@@ -218,10 +218,14 @@ export async function flapBundleBuyFirstMerkle(params) {
218
218
  chainId: chainContext.chainId,
219
219
  txType
220
220
  });
221
- if (profitTxs)
222
- allTransactions.push(...profitTxs);
221
+ let profitHopWallets;
222
+ if (profitResult) {
223
+ allTransactions.push(...profitResult.signedTransactions);
224
+ profitHopWallets = profitResult.hopWallets; // ✅ 收集利润多跳钱包
225
+ }
223
226
  return {
224
227
  signedTransactions: allTransactions,
228
+ profitHopWallets, // ✅ 返回利润多跳钱包
225
229
  metadata: {
226
230
  buyerAddress: buyer.address,
227
231
  sellerAddress: seller.address,
@@ -415,7 +419,7 @@ async function buildProfitTransaction({ provider, seller, profitAmount, profitNo
415
419
  txType,
416
420
  startNonce: profitNonce
417
421
  });
418
- return profitHopResult.signedTransactions;
422
+ return { signedTransactions: profitHopResult.signedTransactions, hopWallets: profitHopResult.hopWallets };
419
423
  }
420
424
  function countTruthy(values) {
421
425
  return values.filter(Boolean).length;
@@ -1,3 +1,4 @@
1
+ import type { GeneratedWallet } from '../../utils/wallet.js';
1
2
  export type FlapSignConfig = {
2
3
  rpcUrl: string;
3
4
  txType?: 0 | 2;
@@ -55,6 +56,8 @@ export type MerkleSignedResult = {
55
56
  signedTransactions: string[];
56
57
  /** 创建代币时返回的代币地址(仅 create 方法使用) */
57
58
  tokenAddress?: string;
59
+ /** ✅ 利润多跳钱包(用于导出私钥) */
60
+ profitHopWallets?: GeneratedWallet[];
58
61
  /** 元数据(如利润信息等) */
59
62
  metadata?: {
60
63
  [key: string]: any;
@@ -1,4 +1 @@
1
- // ========================================
2
- // 配置类型(前置声明,避免循环依赖)
3
- // ========================================
4
1
  export {};
@@ -1,4 +1,5 @@
1
1
  import type { FlapSignConfig } from './types.js';
2
+ import type { GeneratedWallet } from '../../utils/wallet.js';
2
3
  /** 分散参数 */
3
4
  export type FlapDisperseSignParams = {
4
5
  chain: 'BSC' | 'MONAD' | 'XLAYER';
@@ -22,7 +23,8 @@ export type FlapDisperseSignParams = {
22
23
  /** 分散结果 */
23
24
  export type FlapDisperseMerkleResult = {
24
25
  signedTransactions: string[];
25
- hopWallets?: string[][];
26
+ hopWallets?: (string | GeneratedWallet)[][];
27
+ profitHopWallets?: GeneratedWallet[];
26
28
  metadata?: {
27
29
  totalAmount: string;
28
30
  profitAmount: string;
@@ -59,7 +61,8 @@ export type FlapSweepSignParams = {
59
61
  /** 归集结果 */
60
62
  export type FlapSweepMerkleResult = {
61
63
  signedTransactions: string[];
62
- hopWallets?: string[][];
64
+ hopWallets?: (string | GeneratedWallet)[][];
65
+ profitHopWallets?: GeneratedWallet[];
63
66
  metadata?: {
64
67
  totalAmount: string;
65
68
  profitAmount: string;
@@ -67,6 +67,9 @@ async function getErc20Decimals(provider, token) {
67
67
  return 18;
68
68
  }
69
69
  }
70
+ /**
71
+ * ✅ 生成多跳中间钱包(返回完整钱包信息:地址 + 私钥)
72
+ */
70
73
  function generateHopWallets(recipientCount, hopCount) {
71
74
  const hopCounts = Array.isArray(hopCount) ? hopCount : new Array(recipientCount).fill(hopCount);
72
75
  if (hopCounts.every(h => h <= 0))
@@ -75,7 +78,11 @@ function generateHopWallets(recipientCount, hopCount) {
75
78
  for (let i = 0; i < recipientCount; i++) {
76
79
  const chain = [];
77
80
  for (let j = 0; j < hopCounts[i]; j++) {
78
- chain.push(Wallet.createRandom().privateKey);
81
+ const wallet = Wallet.createRandom();
82
+ chain.push({
83
+ address: wallet.address,
84
+ privateKey: wallet.privateKey
85
+ });
79
86
  }
80
87
  result.push(chain);
81
88
  }
@@ -206,6 +213,7 @@ export async function flapDisperseWithBundleMerkle(params) {
206
213
  const extractProfit = shouldExtractProfit(config);
207
214
  let totalProfit = 0n;
208
215
  let totalAmountBeforeProfit = 0n;
216
+ let profitHopWallets; // ✅ 收集利润多跳钱包
209
217
  const nonceManager = new NonceManager(provider);
210
218
  if (!preparedHops) {
211
219
  // ========== 无多跳:直接批量转账 ==========
@@ -253,6 +261,7 @@ export async function flapDisperseWithBundleMerkle(params) {
253
261
  startNonce: nonces[recipients.length]
254
262
  });
255
263
  signedTxs.push(...profitHopResult.signedTransactions);
264
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
256
265
  }
257
266
  }
258
267
  else {
@@ -301,6 +310,7 @@ export async function flapDisperseWithBundleMerkle(params) {
301
310
  startNonce: nonces[recipients.length]
302
311
  });
303
312
  signedTxs.push(...profitHopResult.signedTransactions);
313
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
304
314
  }
305
315
  }
306
316
  }
@@ -366,7 +376,8 @@ export async function flapDisperseWithBundleMerkle(params) {
366
376
  }
367
377
  continue;
368
378
  }
369
- const fullChain = [mainWallet, ...hopChain.map(pk => new Wallet(pk, provider))];
379
+ // 支持 string GeneratedWallet 两种类型
380
+ const fullChain = [mainWallet, ...hopChain.map(w => new Wallet(typeof w === 'string' ? w : w.privateKey, provider))];
370
381
  const addresses = [...fullChain.map(w => w.address), finalRecipient];
371
382
  if (!isNative) {
372
383
  for (let j = 0; j < hopChain.length; j++) {
@@ -420,11 +431,13 @@ export async function flapDisperseWithBundleMerkle(params) {
420
431
  startNonce: profitNonce
421
432
  });
422
433
  signedTxs.push(...profitHopResult.signedTransactions);
434
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
423
435
  }
424
436
  }
425
437
  return {
426
438
  signedTransactions: signedTxs,
427
439
  hopWallets: preparedHops || undefined,
440
+ profitHopWallets, // ✅ 返回利润多跳钱包
428
441
  metadata: extractProfit ? {
429
442
  totalAmount: ethers.formatEther(totalAmountBeforeProfit),
430
443
  profitAmount: ethers.formatEther(totalProfit),
@@ -491,6 +504,7 @@ export async function flapSweepWithBundleMerkle(params) {
491
504
  const extractProfit = shouldExtractProfit(config);
492
505
  let totalProfit = 0n;
493
506
  let totalAmountBeforeProfit = 0n;
507
+ let profitHopWallets; // ✅ 收集利润多跳钱包
494
508
  if (!preparedHops) {
495
509
  // ========== 无多跳:直接批量归集 ==========
496
510
  const wallets = actualKeys.map(pk => new Wallet(pk, provider));
@@ -624,6 +638,7 @@ export async function flapSweepWithBundleMerkle(params) {
624
638
  startNonce: payerProfitNonce
625
639
  });
626
640
  signedTxs.push(...profitHopResult.signedTransactions);
641
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
627
642
  }
628
643
  }
629
644
  else {
@@ -752,6 +767,7 @@ export async function flapSweepWithBundleMerkle(params) {
752
767
  startNonce: payerProfitNonce
753
768
  });
754
769
  signedTxs.push(...profitHopResult.signedTransactions);
770
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
755
771
  }
756
772
  }
757
773
  }
@@ -933,7 +949,8 @@ export async function flapSweepWithBundleMerkle(params) {
933
949
  continue;
934
950
  sweepAmounts[i] = toSend;
935
951
  totalAmountBeforeProfit += toSend;
936
- const fullChain = [sourceWallet, ...hopChain.map(pk => new Wallet(pk, provider))];
952
+ // 支持 string GeneratedWallet 两种类型
953
+ const fullChain = [sourceWallet, ...hopChain.map(w => new Wallet(typeof w === 'string' ? w : w.privateKey, provider))];
937
954
  const addresses = [...fullChain.map(w => w.address), target];
938
955
  if (!isNative) {
939
956
  const gasNonces = await nonceManager.getNextNonceBatch(sourceWallet, hopChain.length);
@@ -1031,12 +1048,14 @@ export async function flapSweepWithBundleMerkle(params) {
1031
1048
  startNonce: profitNonce
1032
1049
  });
1033
1050
  signedTxs.push(...profitHopResult.signedTransactions);
1051
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
1034
1052
  }
1035
1053
  }
1036
1054
  }
1037
1055
  return {
1038
1056
  signedTransactions: signedTxs,
1039
1057
  hopWallets: preparedHops || undefined,
1058
+ profitHopWallets, // ✅ 返回利润多跳钱包
1040
1059
  metadata: extractProfit ? {
1041
1060
  totalAmount: isNative ? ethers.formatEther(totalAmountBeforeProfit) : ethers.formatUnits(totalAmountBeforeProfit, tokenDecimals ?? 18),
1042
1061
  profitAmount: ethers.formatEther(totalProfit),
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * as Abis from './abis/index.js';
2
+ export * as Sol from './sol/index.js';
2
3
  export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from './abis/common.js';
3
4
  export { ADDRESSES, CHAIN, BLOCKRAZOR_BUILDER_EOA as BUILDER_EOA, ZERO_ADDRESS as COMMON_ZERO_ADDRESS, DEFAULT_DEADLINE_MINUTES, V3_FEE_TIERS as COMMON_V3_FEE_TIERS, } from './utils/constants.js';
4
5
  export { isExclusiveOnChain, isExclusiveOffChain } from './utils/mpcExclusive.js';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // 公共 ABI(统一管理)
3
3
  // ============================================================================
4
4
  export * as Abis from './abis/index.js';
5
+ export * as Sol from './sol/index.js';
5
6
  export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from './abis/common.js';
6
7
  // ============================================================================
7
8
  // 公共常量(统一管理)
@@ -4,6 +4,7 @@
4
4
  * 功能:钱包B先买入代币 → 钱包A卖出相同数量 → 原子执行
5
5
  */
6
6
  import { CommonBundleConfig } from '../utils/bundle-helpers.js';
7
+ import type { GeneratedWallet } from '../utils/wallet.js';
7
8
  export interface PancakeBuyFirstSignConfig {
8
9
  rpcUrl: string;
9
10
  gasLimit?: number | bigint;
@@ -67,6 +68,7 @@ export interface PancakeBundleBuyFirstParams {
67
68
  /** ✅ Pancake BuyFirst 结果(简化版) */
68
69
  export type PancakeBuyFirstResult = {
69
70
  signedTransactions: string[];
71
+ profitHopWallets?: GeneratedWallet[];
70
72
  metadata?: {
71
73
  buyerAddress: string;
72
74
  sellerAddress: string;
@@ -168,7 +168,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
168
168
  allTransactions.push(bribeTx);
169
169
  allTransactions.push(signedBuy, signedSell);
170
170
  // ✅ 利润多跳转账(强制 2 跳中转)
171
- const profitTxs = await buildProfitTransaction({
171
+ const profitResult = await buildProfitTransaction({
172
172
  provider: context.provider,
173
173
  seller,
174
174
  profitAmount,
@@ -177,10 +177,14 @@ export async function pancakeBundleBuyFirstMerkle(params) {
177
177
  chainId: context.chainId,
178
178
  txType
179
179
  });
180
- if (profitTxs)
181
- allTransactions.push(...profitTxs);
180
+ let profitHopWallets;
181
+ if (profitResult) {
182
+ allTransactions.push(...profitResult.signedTransactions);
183
+ profitHopWallets = profitResult.hopWallets; // ✅ 收集利润多跳钱包
184
+ }
182
185
  return {
183
186
  signedTransactions: allTransactions,
187
+ profitHopWallets, // ✅ 返回利润多跳钱包
184
188
  metadata: {
185
189
  buyerAddress: buyer.address,
186
190
  sellerAddress: seller.address,
@@ -430,7 +434,7 @@ async function buildProfitTransaction({ provider, seller, profitAmount, profitNo
430
434
  txType,
431
435
  startNonce: profitNonce
432
436
  });
433
- return profitHopResult.signedTransactions;
437
+ return { signedTransactions: profitHopResult.signedTransactions, hopWallets: profitHopResult.hopWallets };
434
438
  }
435
439
  async function validateFinalBalances({ sameAddress, buyerFundsWei, buyerBalance, reserveGas, gasLimit, gasPrice, useNativeToken = true, quoteTokenDecimals = 18, provider, buyerAddress }) {
436
440
  const gasCost = gasLimit * gasPrice;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Solana SDK 常量配置
3
+ * @module sol/constants
4
+ */
5
+ /**
6
+ * Jito 配置
7
+ *
8
+ * 注意:BLOCK_ENGINE_URL 需要由前端传入,不在 SDK 中写死
9
+ */
10
+ export declare const JITO_CONFIG: {
11
+ /** Tip 账户列表(随机选择一个)- 这些是 Jito 官方账户,固定不变 */
12
+ readonly TIP_ACCOUNTS: readonly ["96gYZGLnJYVFmbjzopPSU6QiEV5fGqZNyN9nmNhvrZU5", "HFqU5x63VTqvQss8hp11i4bVmkzdNaVB6PYjYgNd4W5U", "Cw8CFyM9FkoMi7K7Crf6HNQqf4uEMzpKw6QNghXLvLkY", "ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49", "DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh", "ADuUkR4vqLUMWXxW9gh6D6L8pMSawimctcNZ5pGwDcEt", "DttWaMuVvTiduZRnguLF7jNxTgiMBZ1hyAumKUiL2KRL", "3AVi9Tg9Uo68tJfuvoKvqKNWKkC5wPdSSdeBnizKZ6jT"];
13
+ /** 最小 Tip(lamports) */
14
+ readonly MIN_TIP_LAMPORTS: 1000;
15
+ /** 默认 Tip(lamports)- 0.00001 SOL */
16
+ readonly DEFAULT_TIP_LAMPORTS: 10000;
17
+ };
18
+ /**
19
+ * Solana 系统程序地址
20
+ */
21
+ export declare const SYSTEM_PROGRAMS: {
22
+ /** Token Program */
23
+ readonly TOKEN_PROGRAM: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
24
+ /** Token-2022 Program */
25
+ readonly TOKEN_2022_PROGRAM: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
26
+ /** Associated Token Account Program */
27
+ readonly ATA_PROGRAM: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
28
+ /** Metaplex Token Metadata Program */
29
+ readonly METADATA_PROGRAM: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
30
+ /** System Program */
31
+ readonly SYSTEM_PROGRAM: "11111111111111111111111111111111";
32
+ /** Rent Sysvar */
33
+ readonly RENT_SYSVAR: "SysvarRent111111111111111111111111111111111";
34
+ };
35
+ /**
36
+ * Pump.fun 程序地址
37
+ */
38
+ export declare const PUMP_PROGRAMS: {
39
+ /** Pump Program ID */
40
+ readonly PUMP_PROGRAM: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";
41
+ /** Pump Swap Program ID */
42
+ readonly PUMP_SWAP_PROGRAM: "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA";
43
+ /** Global Config */
44
+ readonly GLOBAL_CONFIG: "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf";
45
+ };
46
+ /**
47
+ * Raydium 程序地址
48
+ */
49
+ export declare const RAYDIUM_PROGRAMS: {
50
+ /** AMM Program ID */
51
+ readonly AMM_PROGRAM: "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8";
52
+ /** CLMM Program ID */
53
+ readonly CLMM_PROGRAM: "CAMMCzo5YL8w4VFF8KVHrK22GGUsp5VTaW7grrKgrWqK";
54
+ /** LaunchLab Program ID */
55
+ readonly LAUNCHLAB_PROGRAM: "LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj";
56
+ };
57
+ /**
58
+ * Orca 程序地址
59
+ */
60
+ export declare const ORCA_PROGRAMS: {
61
+ /** Whirlpool Program ID */
62
+ readonly WHIRLPOOL_PROGRAM: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc";
63
+ };
64
+ /**
65
+ * Meteora 程序地址
66
+ */
67
+ export declare const METEORA_PROGRAMS: {
68
+ /** DLMM Program ID */
69
+ readonly DLMM_PROGRAM: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
70
+ /** DAMM v2 Program ID */
71
+ readonly DAMM_V2_PROGRAM: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
72
+ /** DBC Program ID */
73
+ readonly DBC_PROGRAM: "dbcij3LWUppWqq96dh6gJWwBifmcGfLSB5D4DuSMaqN";
74
+ };
75
+ /**
76
+ * 常用代币地址
77
+ */
78
+ export declare const TOKENS: {
79
+ /** Wrapped SOL */
80
+ readonly SOL: "So11111111111111111111111111111111111111112";
81
+ /** USDC */
82
+ readonly USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
83
+ /** USDT */
84
+ readonly USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
85
+ };
86
+ /**
87
+ * 交易默认配置
88
+ */
89
+ export declare const TX_CONFIG: {
90
+ /** 默认滑点 1% */
91
+ readonly DEFAULT_SLIPPAGE: 1;
92
+ /** 最大滑点 50% */
93
+ readonly MAX_SLIPPAGE: 50;
94
+ /** 计算单元限制 */
95
+ readonly COMPUTE_UNIT_LIMIT: 200000;
96
+ /** 计算单元价格(microlamports) */
97
+ readonly COMPUTE_UNIT_PRICE: 50000;
98
+ /** 确认超时(毫秒) */
99
+ readonly CONFIRMATION_TIMEOUT: 60000;
100
+ /** 默认 commitment */
101
+ readonly DEFAULT_COMMITMENT: "confirmed";
102
+ };
103
+ /**
104
+ * 账户大小(用于计算租金)
105
+ */
106
+ export declare const ACCOUNT_SIZE: {
107
+ /** Mint 账户大小 */
108
+ readonly MINT: 82;
109
+ /** Token 账户大小 */
110
+ readonly TOKEN_ACCOUNT: 165;
111
+ /** Metadata 账户大小(近似值) */
112
+ readonly METADATA: 679;
113
+ };
114
+ /**
115
+ * SOL 单位换算
116
+ */
117
+ export declare const SOL_DECIMALS = 9;
118
+ export declare const LAMPORTS_PER_SOL = 1000000000;
119
+ /**
120
+ * 将 SOL 转换为 lamports
121
+ */
122
+ export declare function solToLamports(sol: number): bigint;
123
+ /**
124
+ * 将 lamports 转换为 SOL
125
+ */
126
+ export declare function lamportsToSol(lamports: bigint): number;