four-flap-meme-sdk 1.4.76 → 1.4.78
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.
|
@@ -26,8 +26,8 @@ const BRIBE_TX_COUNT = 1;
|
|
|
26
26
|
const PROFIT_TX_COUNT = PROFIT_HOP_COUNT + 2; // 2 + 2 = 4
|
|
27
27
|
/** 最大买卖交易数 */
|
|
28
28
|
const MAX_SWAP_TX_COUNT = MAX_BUNDLE_SIGNATURES - BRIBE_TX_COUNT - PROFIT_TX_COUNT; // 50 - 1 - 4 = 45
|
|
29
|
-
/** 每笔交易利润比例(基点):
|
|
30
|
-
const PROFIT_RATE_PER_TX_BPS =
|
|
29
|
+
/** 每笔交易利润比例(基点):6 bps = 0.06% = 万分之六 */
|
|
30
|
+
const PROFIT_RATE_PER_TX_BPS = 6;
|
|
31
31
|
/**
|
|
32
32
|
* 验证买卖笔数
|
|
33
33
|
*/
|
|
@@ -139,7 +139,7 @@ export async function fourBundleBuyFirstMerkle(params) {
|
|
|
139
139
|
if (!estimatedTokenAmount || estimatedTokenAmount <= 0n) {
|
|
140
140
|
throw new Error('报价失败:无法估算可买入的代币数量');
|
|
141
141
|
}
|
|
142
|
-
// ✅
|
|
142
|
+
// ✅ 卖出数量直接使用估算的代币数量(无滑点保护)
|
|
143
143
|
const sellAmountWei = estimatedTokenAmount;
|
|
144
144
|
// 卖方余额检查
|
|
145
145
|
if (!sameAddress && sellerTokenBal < sellAmountWei) {
|
|
@@ -66,8 +66,8 @@ const BRIBE_TX_COUNT = 1;
|
|
|
66
66
|
const PROFIT_TX_COUNT = PROFIT_HOP_COUNT + 2; // 2 + 2 = 4
|
|
67
67
|
/** 最大买卖交易数 */
|
|
68
68
|
const MAX_SWAP_TX_COUNT = MAX_BUNDLE_SIGNATURES - BRIBE_TX_COUNT - PROFIT_TX_COUNT; // 50 - 1 - 4 = 45
|
|
69
|
-
/** 每笔交易利润比例(基点):
|
|
70
|
-
const PROFIT_RATE_PER_TX_BPS =
|
|
69
|
+
/** 每笔交易利润比例(基点):6 bps = 0.06% = 万分之六 */
|
|
70
|
+
const PROFIT_RATE_PER_TX_BPS = 6;
|
|
71
71
|
/**
|
|
72
72
|
* 验证买卖笔数
|
|
73
73
|
*/
|
|
@@ -160,16 +160,12 @@ export async function flapBundleBuyFirstMerkle(params) {
|
|
|
160
160
|
// ✅ 拆分买入和卖出金额
|
|
161
161
|
const buyAmountsWei = splitAmount(buyerFundsWei, buyCount);
|
|
162
162
|
const sellAmountsWei = splitAmount(sellAmountWei, sellCount);
|
|
163
|
-
// ✅ 多笔买入时,minOutputAmount 设置为 0 以避免滑点导致交易失败
|
|
164
|
-
// 原因:每笔买入会改变池子价格,后续买入获得的代币会变少
|
|
165
|
-
// 单笔买入时使用正常的 minOutputAmount 作为保护
|
|
166
|
-
const minOutputPerBuy = buyCount === 1 ? sellAmountWei : 0n;
|
|
167
163
|
// ✅ 第三批并行 - 构建多笔买入和卖出交易、estimatedSellFunds
|
|
168
164
|
const buyUnsignedPromises = buyAmountsWei.map(amount => portalBuyer.swapExactInput.populateTransaction({
|
|
169
165
|
inputToken,
|
|
170
166
|
outputToken: tokenAddress,
|
|
171
167
|
inputAmount: amount,
|
|
172
|
-
minOutputAmount:
|
|
168
|
+
minOutputAmount: 0n,
|
|
173
169
|
permitData: '0x'
|
|
174
170
|
}, useNativeToken ? { value: amount } : {}));
|
|
175
171
|
const sellUnsignedPromises = sellAmountsWei.map(amount => portalSeller.swapExactInput.populateTransaction({
|
|
@@ -43,7 +43,6 @@ const PANCAKE_V2_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV2Router;
|
|
|
43
43
|
const PANCAKE_V3_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV3Router;
|
|
44
44
|
// 常量
|
|
45
45
|
const FLAT_FEE = 0n;
|
|
46
|
-
const WBNB_ADDRESS = ADDRESSES.BSC.WBNB;
|
|
47
46
|
// ==================== 多笔买卖常量 ====================
|
|
48
47
|
/** 最大 Bundle 签名数 */
|
|
49
48
|
const MAX_BUNDLE_SIGNATURES = 50;
|
|
@@ -53,8 +52,8 @@ const BRIBE_TX_COUNT = 1;
|
|
|
53
52
|
const PROFIT_TX_COUNT = PROFIT_HOP_COUNT + 2; // 2 + 2 = 4
|
|
54
53
|
/** 最大买卖交易数 */
|
|
55
54
|
const MAX_SWAP_TX_COUNT = MAX_BUNDLE_SIGNATURES - BRIBE_TX_COUNT - PROFIT_TX_COUNT; // 50 - 1 - 4 = 45
|
|
56
|
-
/** 每笔交易利润比例(基点):
|
|
57
|
-
const PROFIT_RATE_PER_TX_BPS =
|
|
55
|
+
/** 每笔交易利润比例(基点):6 bps = 0.06% = 万分之六 */
|
|
56
|
+
const PROFIT_RATE_PER_TX_BPS = 6;
|
|
58
57
|
/**
|
|
59
58
|
* 验证买卖笔数
|
|
60
59
|
*/
|
|
@@ -140,11 +139,9 @@ export async function pancakeBundleBuyFirstMerkle(params) {
|
|
|
140
139
|
buyerFundsWei: buyerFundsInfo.buyerFundsWei,
|
|
141
140
|
provider: context.provider
|
|
142
141
|
});
|
|
143
|
-
// ✅ 直接使用报价数量(不添加滑点保护)
|
|
144
|
-
const adjustedSellAmount = quoteResult.quotedTokenOut;
|
|
145
142
|
// ✅ 拆分买入和卖出金额
|
|
146
143
|
const buyAmountsWei = splitAmount(buyerFundsInfo.buyerFundsWei, buyCount);
|
|
147
|
-
const sellAmountsWei = splitAmount(
|
|
144
|
+
const sellAmountsWei = splitAmount(quoteResult.quotedTokenOut, sellCount);
|
|
148
145
|
// ✅ 构建多笔买入和卖出交易
|
|
149
146
|
const swapUnsignedArray = await buildMultiRouteTransactions({
|
|
150
147
|
routeParams,
|