four-flap-meme-sdk 1.2.11 → 1.2.12

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.
@@ -417,27 +417,38 @@ export async function batchSellWithBundleMerkle(params) {
417
417
  type: getTxType(config)
418
418
  })));
419
419
  signedTxs.push(...signedList);
420
- // ✅ 提取利润
420
+ // ✅ 汇总所有利润,由收益最多的钱包一次性转出(节省交易数)
421
421
  const extractProfit = shouldExtractProfit(config);
422
422
  if (extractProfit && quotedOutputs.length > 0) {
423
+ let totalProfit = 0n;
424
+ let maxRevenueIndex = 0;
425
+ let maxRevenue = 0n;
426
+ // 计算总利润并找出收益最多的钱包
423
427
  for (let i = 0; i < sellers.length; i++) {
424
428
  if (quotedOutputs[i] > 0n) {
425
429
  const { profit } = calculateProfit(quotedOutputs[i], config);
426
- if (profit > 0n) {
427
- const profitNonce = await nonceManager.getNextNonce(sellers[i]);
428
- const profitTx = await sellers[i].signTransaction({
429
- to: config.profitRecipient,
430
- value: profit,
431
- nonce: profitNonce,
432
- gasPrice,
433
- gasLimit: 21000n,
434
- chainId: 56,
435
- type: getTxType(config)
436
- });
437
- signedTxs.push(profitTx);
430
+ totalProfit += profit;
431
+ // 记录收益最多的钱包索引
432
+ if (quotedOutputs[i] > maxRevenue) {
433
+ maxRevenue = quotedOutputs[i];
434
+ maxRevenueIndex = i;
438
435
  }
439
436
  }
440
437
  }
438
+ // ✅ 由收益最多的钱包一次性转出总利润(该钱包最有能力支付)
439
+ if (totalProfit > 0n && maxRevenue > 0n) {
440
+ const profitNonce = await nonceManager.getNextNonce(sellers[maxRevenueIndex]);
441
+ const profitTx = await sellers[maxRevenueIndex].signTransaction({
442
+ to: config.profitRecipient,
443
+ value: totalProfit,
444
+ nonce: profitNonce,
445
+ gasPrice,
446
+ gasLimit: 21000n,
447
+ chainId: 56,
448
+ type: getTxType(config)
449
+ });
450
+ signedTxs.push(profitTx);
451
+ }
441
452
  }
442
453
  // ✅ 清理临时 nonce 缓存
443
454
  nonceManager.clearTemp();
@@ -515,27 +515,38 @@ export async function fourPancakeProxyBatchSellMerkle(params) {
515
515
  type: getTxType(config),
516
516
  value: unsigned.value // ✅ 显式保留 value(手续费)
517
517
  })));
518
- // ✅ 基于预期收益为每个钱包添加利润转账
518
+ // ✅ 汇总所有利润,由收益最多的钱包一次性转出(节省交易数)
519
519
  const extractProfit = shouldExtractProfit(config);
520
520
  if (extractProfit && quotedOutputs.length > 0) {
521
+ let totalProfit = 0n;
522
+ let maxRevenueIndex = 0;
523
+ let maxRevenue = 0n;
524
+ // 计算总利润并找出收益最多的钱包
521
525
  for (let i = 0; i < sellers.length; i++) {
522
526
  if (quotedOutputs[i] > 0n) {
523
527
  const { profit } = calculateProfit(quotedOutputs[i], config);
524
- if (profit > 0n) {
525
- const profitNonce = await nonceManager.getNextNonce(sellers[i]);
526
- const profitTx = await sellers[i].signTransaction({
527
- to: config.profitRecipient,
528
- value: profit,
529
- nonce: profitNonce,
530
- gasPrice,
531
- gasLimit: 21000n,
532
- chainId: 56,
533
- type: getTxType(config)
534
- });
535
- signedTxs.push(profitTx);
528
+ totalProfit += profit;
529
+ // 记录收益最多的钱包索引
530
+ if (quotedOutputs[i] > maxRevenue) {
531
+ maxRevenue = quotedOutputs[i];
532
+ maxRevenueIndex = i;
536
533
  }
537
534
  }
538
535
  }
536
+ // ✅ 由收益最多的钱包一次性转出总利润(该钱包最有能力支付)
537
+ if (totalProfit > 0n && maxRevenue > 0n) {
538
+ const profitNonce = await nonceManager.getNextNonce(sellers[maxRevenueIndex]);
539
+ const profitTx = await sellers[maxRevenueIndex].signTransaction({
540
+ to: config.profitRecipient,
541
+ value: totalProfit,
542
+ nonce: profitNonce,
543
+ gasPrice,
544
+ gasLimit: 21000n,
545
+ chainId: 56,
546
+ type: getTxType(config)
547
+ });
548
+ signedTxs.push(profitTx);
549
+ }
539
550
  }
540
551
  // ✅ 清理临时 nonce 缓存
541
552
  nonceManager.clearTemp();
@@ -338,28 +338,38 @@ export async function batchSellWithBundleMerkle(params) {
338
338
  type: getTxType(config)
339
339
  })));
340
340
  signedTxs.push(...signedList);
341
- // ✅ 基于报价金额为每个钱包添加利润转账
341
+ // ✅ 汇总所有利润,由收益最多的钱包一次性转出(节省交易数)
342
342
  const extractProfit = shouldExtractProfit(config);
343
343
  if (extractProfit && quotedOutputs.length > 0) {
344
- // 为每个钱包添加利润转账(基于完整报价金额,而非 minOut)
344
+ let totalProfit = 0n;
345
+ let maxRevenueIndex = 0;
346
+ let maxRevenue = 0n;
347
+ // 计算总利润并找出收益最多的钱包
345
348
  for (let i = 0; i < wallets.length; i++) {
346
- if (quotedOutputs[i] > 0n) { // 只对报价成功的交易提取利润
349
+ if (quotedOutputs[i] > 0n) {
347
350
  const { profit } = calculateProfit(quotedOutputs[i], config);
348
- if (profit > 0n) {
349
- const profitNonce = await nonceManager.getNextNonce(wallets[i]);
350
- const profitTx = await wallets[i].signTransaction({
351
- to: config.profitRecipient,
352
- value: profit,
353
- nonce: profitNonce,
354
- gasPrice,
355
- gasLimit: 21000n,
356
- chainId,
357
- type: getTxType(config)
358
- });
359
- signedTxs.push(profitTx);
351
+ totalProfit += profit;
352
+ // 记录收益最多的钱包索引
353
+ if (quotedOutputs[i] > maxRevenue) {
354
+ maxRevenue = quotedOutputs[i];
355
+ maxRevenueIndex = i;
360
356
  }
361
357
  }
362
358
  }
359
+ // ✅ 由收益最多的钱包一次性转出总利润(该钱包最有能力支付)
360
+ if (totalProfit > 0n && maxRevenue > 0n) {
361
+ const profitNonce = await nonceManager.getNextNonce(wallets[maxRevenueIndex]);
362
+ const profitTx = await wallets[maxRevenueIndex].signTransaction({
363
+ to: config.profitRecipient,
364
+ value: totalProfit,
365
+ nonce: profitNonce,
366
+ gasPrice,
367
+ gasLimit: 21000n,
368
+ chainId,
369
+ type: getTxType(config)
370
+ });
371
+ signedTxs.push(profitTx);
372
+ }
363
373
  }
364
374
  // ✅ 清理临时 nonce 缓存
365
375
  nonceManager.clearTemp();
@@ -508,27 +508,38 @@ export async function pancakeProxyBatchSellMerkle(params) {
508
508
  type: getTxType(config),
509
509
  value: unsigned.value // ✅ 显式保留 value(手续费)
510
510
  })));
511
- // ✅ 基于预期收益为每个钱包添加利润转账
511
+ // ✅ 汇总所有利润,由收益最多的钱包一次性转出(节省交易数)
512
512
  const extractProfit = shouldExtractProfit(config);
513
513
  if (extractProfit && quotedOutputs.length > 0) {
514
+ let totalProfit = 0n;
515
+ let maxRevenueIndex = 0;
516
+ let maxRevenue = 0n;
517
+ // 计算总利润并找出收益最多的钱包
514
518
  for (let i = 0; i < sellers.length; i++) {
515
519
  if (quotedOutputs[i] > 0n) {
516
520
  const { profit } = calculateProfit(quotedOutputs[i], config);
517
- if (profit > 0n) {
518
- const profitNonce = await nonceManager.getNextNonce(sellers[i]);
519
- const profitTx = await sellers[i].signTransaction({
520
- to: config.profitRecipient,
521
- value: profit,
522
- nonce: profitNonce,
523
- gasPrice,
524
- gasLimit: 21000n,
525
- chainId,
526
- type: getTxType(config)
527
- });
528
- signedTxs.push(profitTx);
521
+ totalProfit += profit;
522
+ // 记录收益最多的钱包索引
523
+ if (quotedOutputs[i] > maxRevenue) {
524
+ maxRevenue = quotedOutputs[i];
525
+ maxRevenueIndex = i;
529
526
  }
530
527
  }
531
528
  }
529
+ // ✅ 由收益最多的钱包一次性转出总利润(该钱包最有能力支付)
530
+ if (totalProfit > 0n && maxRevenue > 0n) {
531
+ const profitNonce = await nonceManager.getNextNonce(sellers[maxRevenueIndex]);
532
+ const profitTx = await sellers[maxRevenueIndex].signTransaction({
533
+ to: config.profitRecipient,
534
+ value: totalProfit,
535
+ nonce: profitNonce,
536
+ gasPrice,
537
+ gasLimit: 21000n,
538
+ chainId,
539
+ type: getTxType(config)
540
+ });
541
+ signedTxs.push(profitTx);
542
+ }
532
543
  }
533
544
  // ✅ 清理临时 nonce 缓存
534
545
  nonceManager.clearTemp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",