four-flap-meme-sdk 1.7.68 → 1.7.70

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.
@@ -853,7 +853,10 @@ export async function directV3BatchBuy(params) {
853
853
  const refundData = routerIface.encodeFunctionData('refundETH', []);
854
854
  return { txData: routerIface.encodeFunctionData('multicall(uint256,bytes[])', [deadline, [swapData, refundData]]), txValue: amountWei };
855
855
  }
856
- return { txData: routerIface.encodeFunctionData('exactInputSingle', [swapParams]), txValue: 0n };
856
+ // 修复:ERC20 买入也需要使用 multicall 包装以传递 deadline
857
+ // SwapRouter02 的 exactInputSingle 不包含 deadline 参数,必须通过 multicall 传递
858
+ const swapData = routerIface.encodeFunctionData('exactInputSingle', [swapParams]);
859
+ return { txData: routerIface.encodeFunctionData('multicall(uint256,bytes[])', [deadline, [swapData]]), txValue: 0n };
857
860
  }
858
861
  };
859
862
  const maxFlowIndex = findMaxFlowIndex(flowAmounts);
@@ -981,14 +984,16 @@ export async function directV3BatchSell(params) {
981
984
  if (useNativeOutput) {
982
985
  return routerIface.encodeFunctionData('multicall(bytes[])', [[routerIface.encodeFunctionData('exactInputSingle', [swapParams]), routerIface.encodeFunctionData('unwrapWETH9', [0n, wallet.address])]]);
983
986
  }
984
- return routerIface.encodeFunctionData('exactInputSingle', [swapParams]);
987
+ // 修复:ERC20 输出也需要使用 multicall 包装以传递 deadline
988
+ return routerIface.encodeFunctionData('multicall(bytes[])', [[routerIface.encodeFunctionData('exactInputSingle', [swapParams])]]);
985
989
  }
986
990
  else {
987
991
  const swapParams = { tokenIn: tokenAddress, tokenOut: outputToken, fee, recipient: useNativeOutput ? routerAddress : wallet.address, amountIn: sellAmount, amountOutMinimum: 0n, sqrtPriceLimitX96: 0n };
988
992
  if (useNativeOutput) {
989
993
  return routerIface.encodeFunctionData('multicall(uint256,bytes[])', [deadline, [routerIface.encodeFunctionData('exactInputSingle', [swapParams]), routerIface.encodeFunctionData('unwrapWETH9', [0n, wallet.address])]]);
990
994
  }
991
- return routerIface.encodeFunctionData('exactInputSingle', [swapParams]);
995
+ // 修复:ERC20 输出也需要使用 multicall 包装以传递 deadline
996
+ return routerIface.encodeFunctionData('multicall(uint256,bytes[])', [deadline, [routerIface.encodeFunctionData('exactInputSingle', [swapParams])]]);
992
997
  }
993
998
  };
994
999
  const maxOutputIndex = findMaxFlowIndex(sellAmountsWei);
@@ -771,11 +771,12 @@ export async function pairwiseTransfer(params) {
771
771
  // 直接转账:sender → receiver
772
772
  // ========================================
773
773
  if (isNative) {
774
+ // ✅ 使用 transferAmount 转移指定金额(而不是 transferTo 全额)
774
775
  calls.push({
775
776
  target: senderWallet.address,
776
777
  allowFailure: false,
777
778
  value: shouldPassValue ? amtWei : 0n,
778
- callData: delegateInterface.encodeFunctionData('transferTo', [receiver]),
779
+ callData: delegateInterface.encodeFunctionData('transferAmount', [receiver, amtWei]),
779
780
  });
780
781
  }
781
782
  else {
@@ -810,14 +811,14 @@ export async function pairwiseTransfer(params) {
810
811
  const lastHop = hopWallets[hopWallets.length - 1];
811
812
  if (isNative) {
812
813
  // 原生 OKB 多跳
813
- // sender → 第一个中间钱包
814
+ // sender → 第一个中间钱包(使用 transferAmount 转移指定金额)
814
815
  calls.push({
815
816
  target: senderWallet.address,
816
817
  allowFailure: false,
817
818
  value: shouldPassValue ? amtWei : 0n,
818
- callData: delegateInterface.encodeFunctionData('transferTo', [firstHop.address]),
819
+ callData: delegateInterface.encodeFunctionData('transferAmount', [firstHop.address, amtWei]),
819
820
  });
820
- // 中间钱包之间转账
821
+ // 中间钱包之间转账(使用 transferTo,因为中间钱包只有这笔钱)
821
822
  for (let j = 0; j < hopWallets.length - 1; j++) {
822
823
  calls.push({
823
824
  target: hopWallets[j].address,
@@ -826,7 +827,7 @@ export async function pairwiseTransfer(params) {
826
827
  callData: delegateInterface.encodeFunctionData('transferTo', [hopWallets[j + 1].address]),
827
828
  });
828
829
  }
829
- // 最后一个中间钱包 → receiver
830
+ // 最后一个中间钱包 → receiver(使用 transferTo 转移全部)
830
831
  calls.push({
831
832
  target: lastHop.address,
832
833
  allowFailure: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.7.68",
3
+ "version": "1.7.70",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",