four-flap-meme-sdk 1.6.42 → 1.6.44

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.
@@ -7,7 +7,9 @@ import { POTATOSWAP_V2_ROUTER, POTATOSWAP_V3_ROUTER, POTATOSWAP_V3_FACTORY, WOKB
7
7
  // 多跳 prefund 估算用的 gas 常量(可配置)
8
8
  const HOP_CALL_GAS_LIMIT = 150000n; // hop 转账操作
9
9
  const DEX_BUY_CALL_GAS_LIMIT = 650000n; // DEX V3 买入操作
10
- const PREFUND_BUFFER_PERCENT = 120n; // prefund buffer 百分比 (120 = 1.2x)
10
+ // 增加余额检查 buffer 120% 180%,确保 gasPrice 波动时也有足够余额
11
+ // 预充值使用 200% buffer,这里使用 180% 作为安全阈值
12
+ const PREFUND_BUFFER_PERCENT = 180n; // prefund buffer 百分比 (180 = 1.8x)
11
13
  import { AAAccountManager, encodeExecute, encodeExecuteBatch, encodeExecuteViaMulticall3 } from './aa-account.js';
12
14
  import { encodeApproveCall, lpFeeProfileToV3Fee, } from './portal-ops.js';
13
15
  import { DexQuery, encodeSwapExactETHForTokensSupportingFee, encodeSwapExactTokensForETHSupportingFee, encodeSwapExactETHForTokensV3, encodeSwapExactTokensForETHV3, encodeSwapExactTokensForTokensSupportingFee, } from './dex.js';
@@ -832,14 +834,21 @@ export class AADexSwapExecutor {
832
834
  const transferData = erc20Iface.encodeFunctionData('transfer', [nextHop.sender, buyAmount]);
833
835
  callData = encodeExecute(quoteToken, 0n, transferData);
834
836
  }
835
- const signedHop = await this.aaManager.buildUserOpWithState({
837
+ // 关键修复:使用 buildUserOpWithFixedGas,确保 callGasLimit 与预充值时一致
838
+ // 预充值时使用 HOP_CALL_GAS_LIMIT (150,000),这里也必须使用相同的值
839
+ // 否则 buildUserOpWithState 会动态估算,可能得到 500,000,导致 prefund 不足
840
+ const { userOp: hopUserOp } = await this.aaManager.buildUserOpWithFixedGas({
836
841
  ownerWallet: currentHop.wallet,
837
842
  sender: currentHop.sender,
838
843
  nonce: nonceMap.next(currentHop.sender),
839
844
  initCode: currentHop.initCode,
840
845
  callData,
841
- signOnly: true,
846
+ deployed: currentHop.deployed,
847
+ fixedGas: {
848
+ callGasLimit: HOP_CALL_GAS_LIMIT,
849
+ },
842
850
  });
851
+ const signedHop = await this.aaManager.signUserOp(hopUserOp, currentHop.wallet);
843
852
  outOps.push(signedHop.userOp);
844
853
  }
845
854
  // 3) lastHop → buyer
@@ -853,14 +862,19 @@ export class AADexSwapExecutor {
853
862
  const transferData = erc20Iface.encodeFunctionData('transfer', [buyerSender, buyAmount]);
854
863
  callDataLast = encodeExecute(quoteToken, 0n, transferData);
855
864
  }
856
- const signedLastHop = await this.aaManager.buildUserOpWithState({
865
+ // 关键修复:同样使用 buildUserOpWithFixedGas
866
+ const { userOp: lastHopUserOp } = await this.aaManager.buildUserOpWithFixedGas({
857
867
  ownerWallet: lastHop.wallet,
858
868
  sender: lastHop.sender,
859
869
  nonce: nonceMap.next(lastHop.sender),
860
870
  initCode: lastHop.initCode,
861
871
  callData: callDataLast,
862
- signOnly: true,
872
+ deployed: lastHop.deployed,
873
+ fixedGas: {
874
+ callGasLimit: HOP_CALL_GAS_LIMIT,
875
+ },
863
876
  });
877
+ const signedLastHop = await this.aaManager.signUserOp(lastHopUserOp, lastHop.wallet);
864
878
  outOps.push(signedLastHop.userOp);
865
879
  }
866
880
  // ✅ 保存所有动态生成的多跳钱包信息,用于后续导出
@@ -14,7 +14,8 @@ import { VERIFICATION_GAS_LIMIT_DEPLOY, VERIFICATION_GAS_LIMIT_NORMAL, PRE_VERIF
14
14
  // HopWalletManager
15
15
  // ============================================================================
16
16
  const DEFAULT_HOP_CALL_GAS_LIMIT = 150000n;
17
- const DEFAULT_BUFFER_PERCENT = 150n; // 1.5x
17
+ // 增加预充值 buffer 150% 到 200%,确保 gasPrice 波动时也有足够余额
18
+ const DEFAULT_BUFFER_PERCENT = 200n; // 2.0x
18
19
  export class HopWalletManager {
19
20
  constructor(config = {}) {
20
21
  this.config = config;
@@ -7,7 +7,9 @@ import { FLAP_PORTAL, ZERO_ADDRESS, MULTICALL3, VERIFICATION_GAS_LIMIT_DEPLOY, V
7
7
  // 多跳 prefund 估算用的 gas 常量(可配置)
8
8
  const HOP_CALL_GAS_LIMIT = 150000n; // hop 转账操作
9
9
  const PORTAL_BUY_CALL_GAS_LIMIT = 450000n; // Portal 买入操作
10
- const PREFUND_BUFFER_PERCENT = 120n; // prefund buffer 百分比 (120 = 1.2x)
10
+ // 增加余额检查 buffer 120% 180%,确保 gasPrice 波动时也有足够余额
11
+ // 预充值使用 200% buffer,这里使用 180% 作为安全阈值
12
+ const PREFUND_BUFFER_PERCENT = 180n; // prefund buffer 百分比 (180 = 1.8x)
11
13
  import { AAAccountManager, encodeExecute, encodeExecuteBatch, encodeExecuteViaMulticall3 } from './aa-account.js';
12
14
  import { encodeBuyCall, encodeSellCall, encodeBuyCallWithQuote, encodeSellCallWithQuote, encodeApproveCall, PortalQuery, parseOkb, } from './portal-ops.js';
13
15
  import { BundleExecutor } from './bundle.js';
@@ -643,14 +645,21 @@ export class AAPortalSwapExecutor {
643
645
  const transferData = erc20Iface.encodeFunctionData('transfer', [nextHop.sender, buyAmount]);
644
646
  callData = encodeExecute(quoteToken, 0n, transferData);
645
647
  }
646
- const signedHop = await this.aaManager.buildUserOpWithState({
648
+ // 关键修复:使用 buildUserOpWithFixedGas,确保 callGasLimit 与预充值时一致
649
+ // 预充值时使用 HOP_CALL_GAS_LIMIT (150,000),这里也必须使用相同的值
650
+ // 否则 buildUserOpWithState 会动态估算,可能得到 500,000,导致 prefund 不足
651
+ const { userOp: hopUserOp } = await this.aaManager.buildUserOpWithFixedGas({
647
652
  ownerWallet: currentHop.wallet,
648
653
  sender: currentHop.sender,
649
654
  nonce: nonceMap.next(currentHop.sender),
650
655
  initCode: currentHop.initCode,
651
656
  callData,
652
- signOnly: true,
657
+ deployed: currentHop.deployed,
658
+ fixedGas: {
659
+ callGasLimit: HOP_CALL_GAS_LIMIT,
660
+ },
653
661
  });
662
+ const signedHop = await this.aaManager.signUserOp(hopUserOp, currentHop.wallet);
654
663
  outOps.push(signedHop.userOp);
655
664
  }
656
665
  // 3) lastHop → buyer
@@ -664,14 +673,19 @@ export class AAPortalSwapExecutor {
664
673
  const transferData = erc20Iface.encodeFunctionData('transfer', [buyerSender, buyAmount]);
665
674
  callDataLast = encodeExecute(quoteToken, 0n, transferData);
666
675
  }
667
- const signedLastHop = await this.aaManager.buildUserOpWithState({
676
+ // 关键修复:同样使用 buildUserOpWithFixedGas
677
+ const { userOp: lastHopUserOp } = await this.aaManager.buildUserOpWithFixedGas({
668
678
  ownerWallet: lastHop.wallet,
669
679
  sender: lastHop.sender,
670
680
  nonce: nonceMap.next(lastHop.sender),
671
681
  initCode: lastHop.initCode,
672
682
  callData: callDataLast,
673
- signOnly: true,
683
+ deployed: lastHop.deployed,
684
+ fixedGas: {
685
+ callGasLimit: HOP_CALL_GAS_LIMIT,
686
+ },
674
687
  });
688
+ const signedLastHop = await this.aaManager.signUserOp(lastHopUserOp, lastHop.wallet);
675
689
  outOps.push(signedLastHop.userOp);
676
690
  }
677
691
  // ✅ 保存所有动态生成的多跳钱包信息,用于后续导出
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.6.42",
3
+ "version": "1.6.44",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",