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.
- package/dist/xlayer/bundle.js +15 -13
- package/package.json +1 -1
package/dist/xlayer/bundle.js
CHANGED
|
@@ -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,
|
|
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
|
-
// ✅
|
|
1474
|
-
|
|
1475
|
-
|
|
1472
|
+
// ✅ 外盘买入:使用 Portal 的 swapExactInput 进行自动路由
|
|
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:
|
|
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
|
-
|
|
1638
|
-
console.log
|
|
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
|
-
|
|
1644
|
-
|
|
1645
|
-
const
|
|
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:
|
|
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 ??
|
|
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;
|