four-flap-meme-sdk 1.4.65 → 1.4.68

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.
@@ -120,6 +120,7 @@ export async function fourBundleBuyFirstMerkle(params) {
120
120
  if (!estimatedTokenAmount || estimatedTokenAmount <= 0n) {
121
121
  throw new Error('报价失败:无法估算可买入的代币数量');
122
122
  }
123
+ // ✅ 直接使用报价的代币数量(与 Flap 一致,不做滑点调整)
123
124
  const sellAmountWei = estimatedTokenAmount;
124
125
  // 卖方余额检查
125
126
  if (!sameAddress && sellerTokenBal < sellAmountWei) {
@@ -139,7 +140,7 @@ export async function fourBundleBuyFirstMerkle(params) {
139
140
  // ✅ 构建多笔买入和卖出交易
140
141
  const buyUnsignedPromises = buyAmountsWei.map(amount => tmBuyer.buyTokenAMAP.populateTransaction(0n, tokenAddress, buyer.address, amount, 0n, { value: amount }));
141
142
  const sellUnsignedPromises = sellAmountsWei.map(amount => tmSeller.sellToken.populateTransaction(0n, tokenAddress, amount, 0n));
142
- // ✅ 规划多笔交易 nonce
143
+ // ✅ 规划多笔交易 nonce(与 Flap 一致,不含授权)
143
144
  const multiNoncePlan = await planMultiNonces({
144
145
  buyer,
145
146
  seller,
@@ -196,7 +197,7 @@ export async function fourBundleBuyFirstMerkle(params) {
196
197
  Promise.all(sellSignPromises)
197
198
  ]);
198
199
  nonceManager.clearTemp();
199
- // ✅ 组装交易列表:贿赂 → 买入(多笔) → 卖出(多笔)
200
+ // ✅ 组装交易列表:贿赂 → 买入(多笔) → 卖出(多笔)(与 Flap 一致)
200
201
  const allTransactions = [];
201
202
  if (bribeTx)
202
203
  allTransactions.push(bribeTx);
@@ -234,12 +235,13 @@ export async function fourBundleBuyFirstMerkle(params) {
234
235
  };
235
236
  }
236
237
  /**
237
- * ✅ 规划多笔交易 nonce
238
+ * ✅ 规划多笔交易 nonce(与 Flap 一致)
238
239
  * 交易顺序:贿赂 → 买入(多笔) → 卖出(多笔) → 利润
239
240
  */
240
241
  async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProfit, needBribeTx, sameAddress, nonceManager }) {
241
242
  const profitNonceCount = extractProfit ? 1 : 0;
242
243
  if (sameAddress) {
244
+ // 同一地址:贿赂(可选) + 买入(多笔) + 卖出(多笔) + 利润(可选)
243
245
  const bribeTxCount = needBribeTx ? 1 : 0;
244
246
  const totalTxCount = bribeTxCount + buyCount + sellCount + profitNonceCount;
245
247
  const nonces = await nonceManager.getNextNonceBatch(buyer, totalTxCount);
@@ -252,6 +254,9 @@ async function planMultiNonces({ buyer, seller, buyCount, sellCount, extractProf
252
254
  const profitNonce = extractProfit ? nonces[idx] : undefined;
253
255
  return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
254
256
  }
257
+ // 不同地址
258
+ // 买方:buyCount 个 nonce
259
+ // 卖方:贿赂(可选) + sellCount + 利润(可选) 个 nonce
255
260
  const bribeTxCount = needBribeTx ? 1 : 0;
256
261
  const sellerTxCount = bribeTxCount + sellCount + profitNonceCount;
257
262
  const [buyerNonces, sellerNoncesAll] = await Promise.all([
@@ -121,6 +121,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
121
121
  buyerFundsWei: buyerFundsInfo.buyerFundsWei,
122
122
  provider: context.provider
123
123
  });
124
+ // ✅ 直接使用报价的代币数量(与 Flap 一致,不做滑点调整)
124
125
  // ✅ 拆分买入和卖出金额
125
126
  const buyAmountsWei = splitAmount(buyerFundsInfo.buyerFundsWei, buyCount);
126
127
  const sellAmountsWei = splitAmount(quoteResult.quotedTokenOut, sellCount);
@@ -221,7 +222,7 @@ export async function pancakeBundleBuyFirstMerkle(params) {
221
222
  provider: context.provider,
222
223
  buyerAddress: buyer.address
223
224
  });
224
- // ✅ 组装顺序:贿赂 → 买入(多笔) → 卖出(多笔)
225
+ // ✅ 组装顺序:贿赂 → 买入(多笔) → 卖出(多笔)(与 Flap 一致)
225
226
  const allTransactions = [];
226
227
  if (bribeTx)
227
228
  allTransactions.push(bribeTx);
@@ -535,12 +536,13 @@ async function planNonces({ buyer, seller, sameAddress, extractProfit, needBribe
535
536
  return { buyerNonce, sellerNonce };
536
537
  }
537
538
  /**
538
- * ✅ 规划多笔交易 nonce
539
+ * ✅ 规划多笔交易 nonce(与 Flap 一致)
539
540
  * 交易顺序:贿赂 → 买入(多笔) → 卖出(多笔) → 利润
540
541
  */
541
542
  async function planMultiNonces({ buyer, seller, buyCount, sellCount, sameAddress, extractProfit, needBribeTx, nonceManager }) {
542
543
  const profitNonceCount = extractProfit ? 1 : 0;
543
544
  if (sameAddress) {
545
+ // 同一地址:贿赂(可选) + 买入(多笔) + 卖出(多笔) + 利润(可选)
544
546
  const bribeTxCount = needBribeTx ? 1 : 0;
545
547
  const totalTxCount = bribeTxCount + buyCount + sellCount + profitNonceCount;
546
548
  const nonces = await nonceManager.getNextNonceBatch(buyer, totalTxCount);
@@ -553,6 +555,9 @@ async function planMultiNonces({ buyer, seller, buyCount, sellCount, sameAddress
553
555
  const profitNonce = extractProfit ? nonces[idx] : undefined;
554
556
  return { buyerNonces, sellerNonces, bribeNonce, profitNonce };
555
557
  }
558
+ // 不同地址
559
+ // 买方:buyCount 个 nonce
560
+ // 卖方:贿赂(可选) + sellCount + 利润(可选) 个 nonce
556
561
  const bribeTxCount = needBribeTx ? 1 : 0;
557
562
  const sellerTxCount = bribeTxCount + sellCount + profitNonceCount;
558
563
  const [buyerNonces, sellerNoncesAll] = await Promise.all([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.4.65",
3
+ "version": "1.4.68",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",