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
@@ -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;
@@ -62,6 +62,7 @@ export interface PancakeBundleSwapParams {
62
62
  /** ✅ Pancake Swap 结果(简化版) */
63
63
  export type PancakeSwapResult = {
64
64
  signedTransactions: string[];
65
+ profitHopWallets?: GeneratedWallet[];
65
66
  metadata?: {
66
67
  sellerAddress: string;
67
68
  buyerAddress: string;
@@ -97,6 +98,7 @@ export interface PancakeBatchSwapSignParams {
97
98
  */
98
99
  export interface PancakeBatchSwapResult {
99
100
  signedTransactions: string[];
101
+ profitHopWallets?: GeneratedWallet[];
100
102
  metadata?: {
101
103
  sellerAddress: string;
102
104
  buyerAddresses: string[];
@@ -139,6 +141,7 @@ export interface PancakeQuickBatchSwapParams {
139
141
  export interface PancakeQuickBatchSwapResult {
140
142
  signedTransactions: string[];
141
143
  disperseHopWallets?: GeneratedWallet[];
144
+ profitHopWallets?: GeneratedWallet[];
142
145
  metadata?: {
143
146
  sellerAddress: string;
144
147
  buyerAddresses: string[];
@@ -709,6 +709,7 @@ export async function pancakeBundleSwapMerkle(params) {
709
709
  signedTransactions.push(bribeTx);
710
710
  signedTransactions.push(signedSell, signedBuy);
711
711
  // ✅ 利润多跳转账(强制 2 跳中转)
712
+ let profitHopWallets;
712
713
  if (profitAmount > 0n && noncePlan.profitNonce !== undefined) {
713
714
  const profitHopResult = await buildProfitHopTransactions({
714
715
  provider: context.provider,
@@ -722,9 +723,11 @@ export async function pancakeBundleSwapMerkle(params) {
722
723
  startNonce: noncePlan.profitNonce
723
724
  });
724
725
  signedTransactions.push(...profitHopResult.signedTransactions);
726
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
725
727
  }
726
728
  return {
727
729
  signedTransactions,
730
+ profitHopWallets, // ✅ 导出利润多跳钱包
728
731
  metadata: {
729
732
  sellerAddress: seller.address,
730
733
  buyerAddress: buyer.address,
@@ -985,6 +988,7 @@ export async function pancakeBatchSwapMerkle(params) {
985
988
  signedTransactions.push(signedSell); // 卖出
986
989
  signedTransactions.push(...signedBuys); // 多个买入
987
990
  // ✅ 利润多跳转账(强制 2 跳中转)
991
+ let profitHopWallets;
988
992
  if (profitAmount > 0n && profitNonce !== undefined) {
989
993
  const profitHopResult = await buildProfitHopTransactions({
990
994
  provider: context.provider,
@@ -998,9 +1002,11 @@ export async function pancakeBatchSwapMerkle(params) {
998
1002
  startNonce: profitNonce
999
1003
  });
1000
1004
  signedTransactions.push(...profitHopResult.signedTransactions);
1005
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
1001
1006
  }
1002
1007
  return {
1003
1008
  signedTransactions,
1009
+ profitHopWallets, // ✅ 导出利润多跳钱包
1004
1010
  metadata: {
1005
1011
  sellerAddress: seller.address,
1006
1012
  buyerAddresses: buyers.map(b => b.address),
@@ -1410,6 +1416,7 @@ export async function pancakeQuickBatchSwapMerkle(params) {
1410
1416
  signedTransactions.push(...transferTxs);
1411
1417
  signedTransactions.push(...signedBuys);
1412
1418
  // ==================== 5. 利润多跳转账(强制 2 跳中转)====================
1419
+ let profitHopWallets;
1413
1420
  if (profitAmount > 0n) {
1414
1421
  const profitHopResult = await buildProfitHopTransactions({
1415
1422
  provider: context.provider,
@@ -1423,6 +1430,7 @@ export async function pancakeQuickBatchSwapMerkle(params) {
1423
1430
  startNonce: sellerNonce++
1424
1431
  });
1425
1432
  signedTransactions.push(...profitHopResult.signedTransactions);
1433
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
1426
1434
  console.log(`[pancakeQuickBatchSwapMerkle] 利润多跳交易已签名: ${profitHopResult.signedTransactions.length} 笔`);
1427
1435
  }
1428
1436
  console.log(`[pancakeQuickBatchSwapMerkle] 交易组装完成: ${signedTransactions.length} 笔`);
@@ -1434,7 +1442,8 @@ export async function pancakeQuickBatchSwapMerkle(params) {
1434
1442
  const outputUnit = useNativeToken ? 'BNB' : 'ERC20';
1435
1443
  return {
1436
1444
  signedTransactions,
1437
- disperseHopWallets: allHopWallets.length > 0 ? allHopWallets : undefined, // ✅ 返回中间钱包信息
1445
+ disperseHopWallets: allHopWallets.length > 0 ? allHopWallets : undefined, // ✅ 返回转账多跳钱包
1446
+ profitHopWallets, // ✅ 返回利润多跳钱包
1438
1447
  metadata: {
1439
1448
  sellerAddress: seller.address,
1440
1449
  buyerAddresses: buyers.map(b => b.address),
@@ -3,6 +3,7 @@
3
3
  * 提供可复用的 nonce 管理、gas 估算等功能
4
4
  */
5
5
  import { JsonRpcProvider, Wallet } from 'ethers';
6
+ import { type GeneratedWallet } from './wallet.js';
6
7
  /**
7
8
  * Nonce 管理器
8
9
  * 用于在 bundle 交易中管理多个钱包的 nonce
@@ -207,7 +208,7 @@ export interface ProfitHopConfig {
207
208
  */
208
209
  export interface ProfitHopResult {
209
210
  signedTransactions: string[];
210
- hopWallets: string[];
211
+ hopWallets: GeneratedWallet[];
211
212
  totalNonceUsed: number;
212
213
  }
213
214
  /**
@@ -3,6 +3,7 @@
3
3
  * 提供可复用的 nonce 管理、gas 估算等功能
4
4
  */
5
5
  import { ethers, Wallet } from 'ethers';
6
+ import { generateWallets } from './wallet.js';
6
7
  /**
7
8
  * Nonce 管理器
8
9
  * 用于在 bundle 交易中管理多个钱包的 nonce
@@ -389,14 +390,9 @@ export async function buildProfitHopTransactions(config) {
389
390
  // 固定 gas limit(原生代币转账,预留少量缓冲)
390
391
  const nativeTransferGasLimit = 21055n;
391
392
  const gasFeePerHop = nativeTransferGasLimit * gasPrice;
392
- // 生成中转钱包
393
- const hopWallets = [];
394
- const hopPrivateKeys = [];
395
- for (let i = 0; i < hopCount; i++) {
396
- const wallet = Wallet.createRandom();
397
- hopWallets.push(new Wallet(wallet.privateKey, provider));
398
- hopPrivateKeys.push(wallet.privateKey);
399
- }
393
+ // ✅ 生成中转钱包(使用统一的 generateWallets 函数)
394
+ const hopWalletsInfo = generateWallets(hopCount);
395
+ const hopWallets = hopWalletsInfo.map(w => new Wallet(w.privateKey, provider));
400
396
  // 计算每个中转钱包需要的金额(从后往前)
401
397
  // 最后一个中转钱包:只需要利润 + 自己的 gas
402
398
  // 其他中转钱包:利润 + 自己的 gas + 下一个钱包需要的金额
@@ -445,7 +441,7 @@ export async function buildProfitHopTransactions(config) {
445
441
  }
446
442
  return {
447
443
  signedTransactions: signedTxs,
448
- hopWallets: hopPrivateKeys,
444
+ hopWallets: hopWalletsInfo, // ✅ 返回完整的钱包信息(privateKey + address)
449
445
  totalNonceUsed: 1 // 支付者只用了 1 个 nonce
450
446
  };
451
447
  }
@@ -83,6 +83,8 @@ export type HoldersMakerResult = {
83
83
  newWallets: GeneratedWallet[];
84
84
  /** 分发多跳中间钱包(可选,用于导出) */
85
85
  disperseHopWallets?: GeneratedWallet[];
86
+ /** 利润多跳中间钱包(可选,用于导出) */
87
+ profitHopWallets?: GeneratedWallet[];
86
88
  /** 签名交易(每批一个数组) */
87
89
  signedTransactions: string[][];
88
90
  /** 批次结果 */
@@ -551,7 +551,8 @@ export async function holdersMaker(params) {
551
551
  const result = {
552
552
  success: false,
553
553
  newWallets: [],
554
- disperseHopWallets: [], // ✅ 中间钱包列表
554
+ disperseHopWallets: [], // ✅ 分发多跳中间钱包
555
+ profitHopWallets: [], // ✅ 利润多跳中间钱包
555
556
  signedTransactions: [],
556
557
  batchResults: [],
557
558
  successBatchCount: 0,
@@ -723,6 +724,7 @@ export async function holdersMaker(params) {
723
724
  signedTxs.push(buyTx);
724
725
  }
725
726
  // (6) 利润多跳
727
+ let profitHopWallets;
726
728
  if (profitPerBatch > 0n) {
727
729
  const profitHopResult = await buildProfitHopTransactions({
728
730
  provider,
@@ -736,12 +738,14 @@ export async function holdersMaker(params) {
736
738
  startNonce: payerNonces[payerNonceIdx]
737
739
  });
738
740
  signedTxs.push(...profitHopResult.signedTransactions);
741
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
739
742
  }
740
743
  return {
741
744
  batchIndex: batchIdx,
742
745
  success: true,
743
746
  signedTransactions: signedTxs,
744
- walletCount: batch.length
747
+ walletCount: batch.length,
748
+ profitHopWallets // ✅ 返回利润多跳钱包
745
749
  };
746
750
  }
747
751
  catch (error) {
@@ -755,10 +759,15 @@ export async function holdersMaker(params) {
755
759
  });
756
760
  const batchResults = await Promise.all(batchPromises);
757
761
  // 7. 处理结果
762
+ const allProfitHopWallets = [];
758
763
  for (const res of batchResults) {
759
764
  if (res.success && res.signedTransactions) {
760
765
  result.signedTransactions.push(res.signedTransactions);
761
766
  result.successBatchCount++;
767
+ // ✅ 收集利润多跳钱包
768
+ if (res.profitHopWallets) {
769
+ allProfitHopWallets.push(...res.profitHopWallets);
770
+ }
762
771
  }
763
772
  result.batchResults.push({
764
773
  batchIndex: res.batchIndex,
@@ -768,6 +777,10 @@ export async function holdersMaker(params) {
768
777
  walletCount: res.walletCount
769
778
  });
770
779
  }
780
+ // ✅ 添加利润多跳钱包到结果
781
+ if (allProfitHopWallets.length > 0) {
782
+ result.profitHopWallets = allProfitHopWallets;
783
+ }
771
784
  result.success = result.successBatchCount > 0;
772
785
  console.log(`[HoldersMaker] 完成: ${result.successBatchCount}/${result.totalBatchCount} 批成功`);
773
786
  }
@@ -5,6 +5,7 @@
5
5
  * - 贿赂交易:向 BlockRazor Builder EOA 转账 BNB 提高优先级
6
6
  * - 利润提取:千分之三(30 bps)
7
7
  */
8
+ import type { GeneratedWallet } from './wallet.js';
8
9
  /** 私募签名配置 */
9
10
  export interface PrivateSaleSignConfig {
10
11
  /** RPC URL */
@@ -42,6 +43,8 @@ export interface BatchPrivateSaleParams {
42
43
  export interface PrivateSaleResult {
43
44
  /** 签名交易数组(包含贿赂 + 转账 + 利润) */
44
45
  signedTransactions: string[];
46
+ /** ✅ 利润多跳钱包 */
47
+ profitHopWallets?: GeneratedWallet[];
45
48
  /** 元数据 */
46
49
  metadata: {
47
50
  /** 总交易数 */
@@ -126,6 +126,7 @@ export async function batchPrivateSaleMerkle(params) {
126
126
  const transferTxs = await Promise.all(transferPromises);
127
127
  signedTransactions.push(...transferTxs);
128
128
  // 3. 利润多跳转账(强制 2 跳中转)
129
+ let profitHopWallets;
129
130
  if (hasProfit) {
130
131
  const profitHopResult = await buildProfitHopTransactions({
131
132
  provider,
@@ -139,9 +140,11 @@ export async function batchPrivateSaleMerkle(params) {
139
140
  startNonce: profitNonce
140
141
  });
141
142
  signedTransactions.push(...profitHopResult.signedTransactions);
143
+ profitHopWallets = profitHopResult.hopWallets; // ✅ 收集利润多跳钱包
142
144
  }
143
145
  return {
144
146
  signedTransactions,
147
+ profitHopWallets, // ✅ 返回利润多跳钱包
145
148
  metadata: {
146
149
  totalCount: signedTransactions.length,
147
150
  bribeCount: 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.58",
3
+ "version": "1.4.61",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",