four-flap-meme-sdk 1.5.74 → 1.5.75

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.
@@ -8,13 +8,12 @@
8
8
  * - OKB 归集:将 sender 的 OKB 转回 owner
9
9
  */
10
10
  import { Wallet, Interface, Contract, ethers } from 'ethers';
11
- import { FLAP_PORTAL, ENTRYPOINT_ABI, PORTAL_ABI, DEFAULT_CALL_GAS_LIMIT_SELL, DEFAULT_WITHDRAW_RESERVE, WOKB, POTATOSWAP_V2_ROUTER, } from './constants.js';
11
+ import { FLAP_PORTAL, ENTRYPOINT_ABI, PORTAL_ABI, DEFAULT_CALL_GAS_LIMIT_SELL, DEFAULT_WITHDRAW_RESERVE, } from './constants.js';
12
12
  import { AAAccountManager, encodeExecute, encodeExecuteBatch, createWallet } from './aa-account.js';
13
13
  import { encodeBuyCall, encodeSellCall, encodeApproveCall, encodeTransferCall, encodeCreateCallV2, encodeCreateCallV3, encodeCreateCallV4, PortalQuery, parseOkb, formatOkb, } from './portal-ops.js';
14
14
  import { mapWithConcurrency } from '../utils/concurrency.js';
15
15
  import { PROFIT_CONFIG, ZERO_ADDRESS } from '../utils/constants.js';
16
16
  import { DexQuery } from './dex.js';
17
- import { encodeSwapExactETHForTokensSupportingFee, } from './dex.js';
18
17
  // ============================================================================
19
18
  // AA Nonce(EntryPoint nonce)本地分配器
20
19
  // ============================================================================
@@ -1470,9 +1469,11 @@ export class BundleExecutor {
1470
1469
  // ✅ 并行构建和签名所有外盘买入 UserOps
1471
1470
  const signedDexBuyOps = await mapWithConcurrency(dexBuyData, 5, async (data) => {
1472
1471
  const { wallet, info, buyWei } = data;
1473
- // ✅ 外盘买入:用 OKB 买代币,不需要 approve,直接调用 Router swap 方法
1474
- const swapData = encodeSwapExactETHForTokensSupportingFee(0n, [WOKB, tokenAddress], info.sender, deadline);
1475
- const dexBuyCallData = encodeExecute(POTATOSWAP_V2_ROUTER, buyWei, swapData);
1472
+ // ✅ 外盘买入:使用 PortalswapExactInput 进行自动路由
1473
+ // 优势:Portal 会自动识别代币的池子类型(V2/V3),无需手动指定
1474
+ // 参考 BSC 版本的逻辑(create-to-dex.ts:604-616)
1475
+ const buyData = encodeBuyCall(tokenAddress, buyWei, 0n);
1476
+ const dexBuyCallData = encodeExecute(FLAP_PORTAL, buyWei, buyData);
1476
1477
  const dexBuyOpRes = await aaManager.buildUserOpWithFixedGas({
1477
1478
  ownerWallet: wallet,
1478
1479
  sender: info.sender,
@@ -1480,7 +1481,7 @@ export class BundleExecutor {
1480
1481
  nonce: nonceMap.next(info.sender),
1481
1482
  initCode: '0x', // HandleOps1 已部署
1482
1483
  deployed: true,
1483
- fixedGas: { callGasLimit: 600000n }
1484
+ fixedGas: { callGasLimit: 800000n } // ✅ 提高到 800K,外盘买入可能需要更多 gas
1484
1485
  });
1485
1486
  const signedDexBuyOp = await aaManager.signUserOp(dexBuyOpRes.userOp, wallet);
1486
1487
  return signedDexBuyOp.userOp;
@@ -1634,23 +1635,24 @@ export class BundleExecutor {
1634
1635
  nonceMap.init(info.sender, info.nonce);
1635
1636
  return info;
1636
1637
  });
1637
- const deadline = Math.floor(Date.now() / 1000) + 3600; // ✅ 60 min (修复 DeadlineExceeded 错误)
1638
- console.log(`[DeadlineDebug] bundleGraduateBuy: current=${Math.floor(Date.now() / 1000)}, deadline=${deadline}, buffer=${3600}s`);
1638
+ // ✅ 移除 deadline:Portal swapExactInput 内部会处理 deadline
1639
+ // console.log 也不再需要
1639
1640
  const signedDexBuyOps = await mapWithConcurrency(dexBuyers, 5, async (data, i) => {
1640
1641
  const { wallet, amount } = data;
1641
1642
  const info = dexBuyerInfos[i];
1642
1643
  totalDexBuyWei += amount;
1643
- const approveData = encodeApproveCall(POTATOSWAP_V2_ROUTER);
1644
- const swapData = encodeSwapExactETHForTokensSupportingFee(0n, [WOKB, tokenAddress], info.sender, deadline);
1645
- const batchCallData = encodeExecuteBatch([tokenAddress, POTATOSWAP_V2_ROUTER], [0n, amount], [approveData, swapData]);
1644
+ // 使用 Portal 的 swapExactInput 进行自动路由(OKB -> 代币)
1645
+ // 优势:自动识别池子类型(V2/V3),无需 approve(OKB 是原生币)
1646
+ const buyData = encodeBuyCall(tokenAddress, amount, 0n);
1647
+ const dexBuyCallData = encodeExecute(FLAP_PORTAL, amount, buyData);
1646
1648
  const dexBuyOpRes = await aaManager.buildUserOpWithFixedGas({
1647
1649
  ownerWallet: wallet,
1648
1650
  sender: info.sender,
1649
- callData: batchCallData,
1651
+ callData: dexBuyCallData,
1650
1652
  nonce: nonceMap.next(info.sender),
1651
1653
  initCode: info.deployed ? '0x' : (await aaManager.generateInitCode(wallet.address)),
1652
1654
  deployed: info.deployed,
1653
- fixedGas: { callGasLimit: effConfig.fixedGas?.callGasLimit ?? 600000n }
1655
+ fixedGas: { callGasLimit: effConfig.fixedGas?.callGasLimit ?? 800000n } // ✅ 提高到 800K
1654
1656
  });
1655
1657
  const signedDexBuyOp = await aaManager.signUserOp(dexBuyOpRes.userOp, wallet);
1656
1658
  return signedDexBuyOp.userOp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.5.74",
3
+ "version": "1.5.75",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",