four-flap-meme-sdk 1.6.72 → 1.6.74
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,10 +7,10 @@ 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
|
-
// ✅ 余额检查 buffer
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
const PREFUND_BUFFER_PERCENT = 200n; //
|
|
10
|
+
// ✅ 余额检查 buffer:预充值时使用 350%,这里检查只要求 200%
|
|
11
|
+
// 这样即使有1-2次交易失败消耗了部分 prefund,剩余余额仍然足够通过检查
|
|
12
|
+
// hop-wallet-manager.ts 预充值使用 DEFAULT_BUFFER_PERCENT = 350n (3.5x)
|
|
13
|
+
const PREFUND_BUFFER_PERCENT = 200n; // 执行检查阈值 (200 = 2.0x)
|
|
14
14
|
import { AAAccountManager, encodeExecute, encodeExecuteBatch, encodeExecuteViaMulticall3 } from './aa-account.js';
|
|
15
15
|
import { encodeApproveCall, lpFeeProfileToV3Fee, } from './portal-ops.js';
|
|
16
16
|
import { DexQuery, encodeSwapExactETHForTokensSupportingFee, encodeSwapExactTokensForETHSupportingFee, encodeSwapExactETHForTokensV3, encodeSwapExactTokensForETHV3, encodeSwapExactTokensForTokensSupportingFee, } from './dex.js';
|
|
@@ -14,8 +14,9 @@ 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
|
-
// ✅ 增加预充值 buffer
|
|
18
|
-
|
|
17
|
+
// ✅ 增加预充值 buffer 到 350%,确保即使有1-2次交易失败消耗 gas 后仍有足够余额重试
|
|
18
|
+
// 失败的交易会消耗 prefund(验证阶段的 gas),增加 buffer 可以应对这种情况
|
|
19
|
+
const DEFAULT_BUFFER_PERCENT = 350n; // 3.5x
|
|
19
20
|
export class HopWalletManager {
|
|
20
21
|
constructor(config = {}) {
|
|
21
22
|
this.config = config;
|
|
@@ -7,10 +7,10 @@ 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
|
-
// ✅ 余额检查 buffer
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
const PREFUND_BUFFER_PERCENT = 200n; //
|
|
10
|
+
// ✅ 余额检查 buffer:预充值时使用 350%,这里检查只要求 200%
|
|
11
|
+
// 这样即使有1-2次交易失败消耗了部分 prefund,剩余余额仍然足够通过检查
|
|
12
|
+
// hop-wallet-manager.ts 预充值使用 DEFAULT_BUFFER_PERCENT = 350n (3.5x)
|
|
13
|
+
const PREFUND_BUFFER_PERCENT = 200n; // 执行检查阈值 (200 = 2.0x)
|
|
14
14
|
import { AAAccountManager, encodeExecute, encodeExecuteBatch, encodeExecuteViaMulticall3 } from './aa-account.js';
|
|
15
15
|
import { encodeBuyCall, encodeSellCall, encodeBuyCallWithQuote, encodeSellCallWithQuote, encodeApproveCall, PortalQuery, parseOkb, } from './portal-ops.js';
|
|
16
16
|
import { BundleExecutor } from './bundle.js';
|
package/dist/xlayer/wash-ops.js
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
import { ethers } from 'ethers';
|
|
16
16
|
import { createAAAccountManager, encodeExecute, createWallet } from './aa-account.js';
|
|
17
17
|
import { encodeBuyCall, encodeSellCall, PortalQuery, lpFeeProfileToV3Fee } from './portal-ops.js';
|
|
18
|
-
import { encodeSwapExactETHForTokensSupportingFee, encodeSwapExactTokensForETHSupportingFee, encodeSwapExactETHForTokensV3, DexQuery, } from './dex.js';
|
|
19
|
-
import { FLAP_PORTAL, WOKB, XLAYER_CHAIN_ID, DEFAULT_RPC_URL, ENTRYPOINT_V06, SIMPLE_ACCOUNT_FACTORY, PARTICLE_BUNDLER_URL, POTATOSWAP_V2_ROUTER, POTATOSWAP_V3_ROUTER, POTATOSWAP_V3_FACTORY,
|
|
18
|
+
import { encodeSwapExactETHForTokensSupportingFee, encodeSwapExactTokensForETHSupportingFee, encodeSwapExactETHForTokensV3, encodeSwapExactTokensForETHV3, DexQuery, } from './dex.js';
|
|
19
|
+
import { FLAP_PORTAL, WOKB, XLAYER_CHAIN_ID, DEFAULT_RPC_URL, ENTRYPOINT_V06, SIMPLE_ACCOUNT_FACTORY, PARTICLE_BUNDLER_URL, POTATOSWAP_V2_ROUTER, POTATOSWAP_V3_ROUTER, POTATOSWAP_V3_FACTORY, } from './constants.js';
|
|
20
20
|
import { PROFIT_CONFIG, ZERO_ADDRESS } from '../utils/constants.js';
|
|
21
21
|
import { mapWithConcurrency } from '../utils/concurrency.js';
|
|
22
22
|
// ============================================================================
|
|
@@ -339,11 +339,20 @@ export async function buildWashOps(params) {
|
|
|
339
339
|
sqrtPriceLimitX96: 0n,
|
|
340
340
|
});
|
|
341
341
|
buyCallData = encodeExecute(routerAddress, buyWei, buySwapData);
|
|
342
|
-
// ✅ V3 卖出:使用
|
|
343
|
-
// SwapRouter02 是聚合 Router,可以路由到 V2/V3 池子
|
|
342
|
+
// ✅ V3 卖出:使用 V3 Router(和正常 V3 卖出一样)
|
|
344
343
|
const expectedTokenAmount = expectedTokenAmounts[i] || 0n;
|
|
345
|
-
const sellSwapData =
|
|
346
|
-
|
|
344
|
+
const sellSwapData = encodeSwapExactTokensForETHV3({
|
|
345
|
+
tokenIn: params.tokenAddress,
|
|
346
|
+
tokenOut: wokb,
|
|
347
|
+
fee: v3Fee,
|
|
348
|
+
recipient: sender,
|
|
349
|
+
unwrapRecipient: sender,
|
|
350
|
+
deadline,
|
|
351
|
+
amountIn: expectedTokenAmount,
|
|
352
|
+
amountOutMinimum: 0n,
|
|
353
|
+
sqrtPriceLimitX96: 0n,
|
|
354
|
+
});
|
|
355
|
+
sellCallData = encodeExecute(routerAddress, 0n, sellSwapData);
|
|
347
356
|
}
|
|
348
357
|
else {
|
|
349
358
|
// V2
|