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.
- package/dist/pancake/bundle-swap.js +8 -26
- package/package.json +1 -1
|
@@ -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) +
|
|
699
|
-
const
|
|
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
|
-
//
|
|
838
|
-
|
|
839
|
-
|
|
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. 买入交易 ====================
|