four-flap-meme-sdk 1.4.14 → 1.4.15

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.
@@ -693,12 +693,10 @@ export async function pancakeQuickBatchSwapMerkle(params) {
693
693
  // ✅ 判断是否使用原生代币
694
694
  const useNativeToken = !quoteToken || quoteToken === ZERO_ADDRESS;
695
695
  const WBNB = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c'.toLowerCase();
696
- // ✅ 校验买方数量(已移除授权交易)
696
+ // ✅ 校验买方数量(子钱包已预留 BNB,不需要主钱包转 Gas)
697
697
  // BNB 模式:贿赂(1) + 卖出(1) + 转账(N) + 买入(N) + 利润(1) ≤ 50 → 2N + 3 ≤ 50 → N ≤ 23
698
- // ERC20 模式:贿赂(1) + 卖出(1) + ERC20转账(N) + BNB Gas转账(N) + 买入(N) + 利润(1) ≤ 50 → 3N + 3 ≤ 50 → N ≤ 15
699
- const MAX_BUYERS_NATIVE = 23;
700
- const MAX_BUYERS_ERC20 = 15;
701
- const MAX_BUYERS = useNativeToken ? MAX_BUYERS_NATIVE : MAX_BUYERS_ERC20;
698
+ // ERC20 模式:贿赂(1) + 卖出(1) + ERC20转账(N) + 买入(N) + 利润(1) ≤ 50 → 2N + 3 ≤ 50 → N ≤ 23
699
+ const MAX_BUYERS = 23;
702
700
  if (buyerPrivateKeys.length === 0) {
703
701
  throw new Error('至少需要一个买方钱包');
704
702
  }
@@ -833,12 +831,10 @@ export async function pancakeQuickBatchSwapMerkle(params) {
833
831
  sellerRequired = bribeAmount + sellerGasCost;
834
832
  }
835
833
  else {
836
- // ERC20 模式(已移除授权):
837
- // - 卖方 Gas: 贿赂(21000) + 卖出(gasLimit) + N个ERC20转账(65000 each) + N个BNB Gas转账(21000 each) + 利润(21000)
838
- // - 买方 Gas: N个买入(gasLimit each) + N个FLAT_FEE
839
- sellerGasCost = gasPrice * (21000n + finalGasLimit + (ERC20_TRANSFER_GAS + 21000n) * BigInt(buyers.length) + 21000n);
840
- const buyerGasNeeded = gasPrice * finalGasLimit * BigInt(buyers.length) + FLAT_FEE * BigInt(buyers.length);
841
- sellerRequired = bribeAmount + sellerGasCost + buyerGasNeeded;
834
+ // ERC20 模式:子钱包已预留 BNB,不需要主钱包转 Gas
835
+ // 卖方 Gas: 贿赂(21000) + 卖出(gasLimit) + N个ERC20转账(65000 each) + 利润(21000)
836
+ sellerGasCost = gasPrice * (21000n + finalGasLimit + ERC20_TRANSFER_GAS * BigInt(buyers.length) + 21000n);
837
+ sellerRequired = bribeAmount + sellerGasCost;
842
838
  }
843
839
  if (sellerBalance < sellerRequired) {
844
840
  throw new Error(`主钱包 BNB 余额不足: 需要约 ${ethers.formatEther(sellerRequired)} BNB (贿赂: ${ethers.formatEther(bribeAmount)}, Gas: ${ethers.formatEther(sellerGasCost)}), 实际 ${ethers.formatEther(sellerBalance)} BNB`);
@@ -905,7 +901,7 @@ export async function pancakeQuickBatchSwapMerkle(params) {
905
901
  }
906
902
  }
907
903
  else {
908
- // ✅ ERC20 模式:ERC20 transfer 调用
904
+ // ✅ ERC20 模式:ERC20 transfer 调用(子钱包已预留 BNB,不需要转 Gas)
909
905
  const erc20Interface = new ethers.Interface([
910
906
  'function transfer(address to, uint256 amount) returns (bool)'
911
907
  ]);
@@ -926,20 +922,6 @@ export async function pancakeQuickBatchSwapMerkle(params) {
926
922
  });
927
923
  transferTxs.push(transferTx);
928
924
  }
929
- // ERC20 模式:额外转账 Gas 费用给买家(用于支付买入 Gas 和 FLAT_FEE)
930
- for (let i = 0; i < buyers.length; i++) {
931
- const buyerGasCost = gasPrice * finalGasLimit + FLAT_FEE;
932
- const gasTx = await seller.signTransaction({
933
- to: buyers[i].address,
934
- value: buyerGasCost,
935
- nonce: sellerNonce++,
936
- gasPrice,
937
- gasLimit: 21000n,
938
- chainId: context.chainId,
939
- type: txType
940
- });
941
- transferTxs.push(gasTx);
942
- }
943
925
  }
944
926
  console.log(`[pancakeQuickBatchSwapMerkle] ${transferTxs.length} 笔转账交易已签名`);
945
927
  // ==================== 4. 买入交易 ====================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.14",
3
+ "version": "1.4.15",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",