four-flap-meme-sdk 1.4.73 → 1.4.74
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.
|
@@ -139,17 +139,8 @@ export async function fourBundleBuyFirstMerkle(params) {
|
|
|
139
139
|
if (!estimatedTokenAmount || estimatedTokenAmount <= 0n) {
|
|
140
140
|
throw new Error('报价失败:无法估算可买入的代币数量');
|
|
141
141
|
}
|
|
142
|
-
// ✅
|
|
143
|
-
|
|
144
|
-
// 单笔买入+单笔卖出时不需要安全系数(与普通捆绑换手一致)
|
|
145
|
-
let sellAmountWei = estimatedTokenAmount;
|
|
146
|
-
if (buyCount > 1 || sellCount > 1) {
|
|
147
|
-
// 根据买入笔数动态调整安全系数:2% + 每多一笔额外 0.5%
|
|
148
|
-
const baseSafetyBps = 200n; // 2% 基础安全系数
|
|
149
|
-
const extraSafetyBps = BigInt((buyCount - 1) * 50); // 每多一笔买入额外 0.5%
|
|
150
|
-
const totalSafetyBps = baseSafetyBps + extraSafetyBps;
|
|
151
|
-
sellAmountWei = estimatedTokenAmount * (10000n - totalSafetyBps) / 10000n;
|
|
152
|
-
}
|
|
142
|
+
// ✅ 直接使用报价数量(不添加滑点保护)
|
|
143
|
+
const sellAmountWei = estimatedTokenAmount;
|
|
153
144
|
// 卖方余额检查
|
|
154
145
|
if (!sameAddress && sellerTokenBal < sellAmountWei) {
|
|
155
146
|
throw new Error(`卖方代币余额不足: 需要 ${ethers.formatUnits(sellAmountWei, decimals)},实际 ${ethers.formatUnits(sellerTokenBal, decimals)}`);
|
|
@@ -140,17 +140,8 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
140
140
|
buyerFundsWei: buyerFundsInfo.buyerFundsWei,
|
|
141
141
|
provider: context.provider
|
|
142
142
|
});
|
|
143
|
-
// ✅
|
|
144
|
-
|
|
145
|
-
// 单笔买入+单笔卖出时不需要安全系数(与普通捆绑换手一致)
|
|
146
|
-
let adjustedSellAmount = quoteResult.quotedTokenOut;
|
|
147
|
-
if (buyCount > 1 || sellCount > 1) {
|
|
148
|
-
// 根据买入笔数动态调整安全系数:2% + 每多一笔额外 0.5%
|
|
149
|
-
const baseSafetyBps = 200n; // 2% 基础安全系数
|
|
150
|
-
const extraSafetyBps = BigInt((buyCount - 1) * 50); // 每多一笔买入额外 0.5%
|
|
151
|
-
const totalSafetyBps = baseSafetyBps + extraSafetyBps;
|
|
152
|
-
adjustedSellAmount = quoteResult.quotedTokenOut * (10000n - totalSafetyBps) / 10000n;
|
|
153
|
-
}
|
|
143
|
+
// ✅ 直接使用报价数量(不添加滑点保护)
|
|
144
|
+
const adjustedSellAmount = quoteResult.quotedTokenOut;
|
|
154
145
|
// ✅ 拆分买入和卖出金额
|
|
155
146
|
const buyAmountsWei = splitAmount(buyerFundsInfo.buyerFundsWei, buyCount);
|
|
156
147
|
const sellAmountsWei = splitAmount(adjustedSellAmount, sellCount);
|
|
@@ -437,8 +428,8 @@ async function buildRouteTransactions({ routeParams, buyerFundsWei, sellAmountTo
|
|
|
437
428
|
const v3RouterIface = new ethers.Interface(PANCAKE_V3_ROUTER_ABI);
|
|
438
429
|
const v3RouterBuyer = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, buyer);
|
|
439
430
|
const v3RouterSeller = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, seller);
|
|
440
|
-
// ✅ V3
|
|
441
|
-
const buyValue = useNativeToken ? buyerFundsWei + FLAT_FEE :
|
|
431
|
+
// ✅ V3 池子的处理(ERC20 模式 value = 0,因为通过代币授权支付)
|
|
432
|
+
const buyValue = useNativeToken ? buyerFundsWei + FLAT_FEE : 0n;
|
|
442
433
|
// 买入交易
|
|
443
434
|
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
444
435
|
tokenIn: v3TokenIn,
|
|
@@ -516,9 +507,9 @@ async function buildMultiRouteTransactions({ routeParams, buyAmountsWei, sellAmo
|
|
|
516
507
|
const v3RouterIface = new ethers.Interface(PANCAKE_V3_ROUTER_ABI);
|
|
517
508
|
const v3RouterBuyer = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, buyer);
|
|
518
509
|
const v3RouterSeller = new Contract(PANCAKE_V3_ROUTER_ADDRESS, PANCAKE_V3_ROUTER_ABI, seller);
|
|
519
|
-
//
|
|
510
|
+
// 构建多笔买入交易(ERC20 模式 value = 0,因为通过代币授权支付)
|
|
520
511
|
const buyUnsignedArray = await Promise.all(buyAmountsWei.map(amount => {
|
|
521
|
-
const buyValue = useNativeToken ? amount + FLAT_FEE :
|
|
512
|
+
const buyValue = useNativeToken ? amount + FLAT_FEE : 0n;
|
|
522
513
|
const buySwapData = v3RouterIface.encodeFunctionData('exactInputSingle', [{
|
|
523
514
|
tokenIn: v3TokenIn,
|
|
524
515
|
tokenOut: v3TokenOut,
|