four-flap-meme-sdk 1.5.4 → 1.5.5
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.
|
@@ -463,12 +463,13 @@ export async function flapBundleCreateToDex(params) {
|
|
|
463
463
|
buyAmount, approveNonce, gasPrice, txType, chainId);
|
|
464
464
|
signedTxs.push(approveTx);
|
|
465
465
|
}
|
|
466
|
-
// 构建 PancakeSwap exactInputSingle
|
|
466
|
+
// 构建 PancakeSwap exactInputSingle 交易(使用 multicall 方式,与官方一致)
|
|
467
467
|
const buyNonce = noncesMap.get(addr);
|
|
468
468
|
noncesMap.set(addr, buyNonce + 1);
|
|
469
|
-
const router = new Contract(smartRouterAddress, PANCAKE_ROUTER_ABI, wallet);
|
|
470
469
|
// 对于 BNB,使用 WBNB 作为 tokenIn(Router 会自动 wrap)
|
|
471
470
|
const tokenIn = useNativeToken ? wbnbAddress : quoteToken;
|
|
471
|
+
// ✅ 使用官方方式:先编码 exactInputSingle,再用 multicall 包装
|
|
472
|
+
const routerInterface = new ethers.Interface(PANCAKE_ROUTER_ABI);
|
|
472
473
|
const exactInputSingleParams = {
|
|
473
474
|
tokenIn,
|
|
474
475
|
tokenOut: tokenAddress,
|
|
@@ -478,9 +479,13 @@ export async function flapBundleCreateToDex(params) {
|
|
|
478
479
|
amountOutMinimum: 0n, // 不设置滑点保护(Bundle 中可以接受)
|
|
479
480
|
sqrtPriceLimitX96: 0n
|
|
480
481
|
};
|
|
481
|
-
|
|
482
|
+
// 编码 exactInputSingle 调用
|
|
483
|
+
const exactInputSingleData = routerInterface.encodeFunctionData('exactInputSingle', [exactInputSingleParams]);
|
|
484
|
+
// 用 multicall 包装(官方要求的调用方式)
|
|
485
|
+
const multicallData = routerInterface.encodeFunctionData('multicall', [[exactInputSingleData]]);
|
|
482
486
|
const tx = {
|
|
483
|
-
|
|
487
|
+
to: smartRouterAddress,
|
|
488
|
+
data: multicallData,
|
|
484
489
|
nonce: buyNonce,
|
|
485
490
|
gasLimit: BigInt(500000),
|
|
486
491
|
chainId,
|