four-flap-meme-sdk 4.0.0 → 4.0.2
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/bundle/four-meme/utils-sweep/context.d.ts +3 -0
- package/dist/bundle/four-meme/utils-sweep/erc20-no-hop.js +1 -1
- package/dist/bundle/four-meme/utils-sweep/main.js +5 -1
- package/dist/bundle/four-meme/utils-sweep/native-no-hop.js +2 -1
- package/dist/bundle/four-meme/utils-sweep/with-hops.js +1 -1
- package/dist/domains/flap/vault/constants.js +10 -2
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { JsonRpcProvider, Wallet } from 'ethers';
|
|
5
5
|
import type { SweepSignParams } from '../types/index.js';
|
|
6
6
|
import type { GeneratedWallet } from '../../../utils/wallet.js';
|
|
7
|
+
import type { NonceManager } from '../../../core/nonce/nonce-manager.js';
|
|
7
8
|
/** 归集比例收窄(0-100 整数) */
|
|
8
9
|
export declare function clampRatio(n?: number): number | undefined;
|
|
9
10
|
/** 归集各分支共用的只读上下文 */
|
|
@@ -29,6 +30,8 @@ export interface SweepBranchContext {
|
|
|
29
30
|
nativeGasLimit: bigint;
|
|
30
31
|
/** clampRatio(ratioPct) 的结果 */
|
|
31
32
|
ratio: number | undefined;
|
|
33
|
+
/** 共享 NonceManager(用于统一协调 贿赂/利润提取 等 targetWallet 交易的 nonce,避免 nonce 冲突) */
|
|
34
|
+
nonceManager: NonceManager;
|
|
32
35
|
}
|
|
33
36
|
/** 归集分支返回值(由主流程合并) */
|
|
34
37
|
export interface SweepBranchResult {
|
|
@@ -15,7 +15,7 @@ export async function sweepErc20NoHop(ctx) {
|
|
|
15
15
|
let profitHopWallets;
|
|
16
16
|
const wallets = actualKeys.map((pk) => new Wallet(pk, provider));
|
|
17
17
|
const addresses = wallets.map((w) => w.address);
|
|
18
|
-
const nonceManager = new NonceManager(provider);
|
|
18
|
+
const nonceManager = ctx.nonceManager ?? new NonceManager(provider);
|
|
19
19
|
// ✅ ERC20:并行获取 gasPrice、decimals、余额(传入 chainIdNum 避免 NETWORK_ERROR)
|
|
20
20
|
const [gasPrice, decimals, balances, bnbBalances] = await Promise.all([
|
|
21
21
|
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
@@ -10,6 +10,7 @@ import { CHAINS, isBscChain } from '../../../core/constants/index.js';
|
|
|
10
10
|
import { getTxType, getGasPriceConfig, shouldExtractProfit, getProfitRecipient, getBribeAmount } from '../../config-helpers.js';
|
|
11
11
|
import { generateHopWallets as _generateHopWallets, calculateGasLimit as _calculateGasLimit, isNativeTokenAddress as _isNativeTokenAddress, } from '../../internal.js';
|
|
12
12
|
import { createSignProvider, resolveHopCountInput, resolveProvidedHops, signBribeTransaction } from '../../../core/sign-context-helpers.js';
|
|
13
|
+
import { NonceManager } from '../../../core/nonce/nonce-manager.js';
|
|
13
14
|
import { clampRatio } from './context.js';
|
|
14
15
|
import { sweepNativeNoHop } from './native-no-hop.js';
|
|
15
16
|
import { sweepErc20NoHop } from './erc20-no-hop.js';
|
|
@@ -55,11 +56,13 @@ export async function sweepWithBundleMerkle(params) {
|
|
|
55
56
|
const bribeAmount = isBscChain(chainIdNum) ? getBribeAmount(config) : 0n;
|
|
56
57
|
const needBribeTx = bribeAmount > 0n && targetWallet !== null;
|
|
57
58
|
const bribeSignedTx = [];
|
|
59
|
+
// ✅ 共享 NonceManager:统一协调 贿赂/利润提取 等 targetWallet 交易的 nonce,避免同一钱包 nonce 冲突
|
|
60
|
+
const nonceManager = new NonceManager(provider);
|
|
58
61
|
// ✅ 贿赂交易放在最前面(由 targetWallet 签名)
|
|
59
62
|
if (needBribeTx && targetWallet) {
|
|
60
63
|
const [bribeGasPrice, bribeNonce] = await Promise.all([
|
|
61
64
|
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
62
|
-
|
|
65
|
+
nonceManager.getNextNonceBatch(targetWallet, 1).then((ns) => ns[0]), // 预留 nonce 0
|
|
63
66
|
]);
|
|
64
67
|
bribeSignedTx.push(await signBribeTransaction(targetWallet, bribeAmount, bribeNonce, bribeGasPrice, chainIdNum, txType));
|
|
65
68
|
}
|
|
@@ -84,6 +87,7 @@ export async function sweepWithBundleMerkle(params) {
|
|
|
84
87
|
finalGasLimit,
|
|
85
88
|
nativeGasLimit,
|
|
86
89
|
ratio,
|
|
90
|
+
nonceManager,
|
|
87
91
|
};
|
|
88
92
|
const branch = !preparedHops
|
|
89
93
|
? isNative
|
|
@@ -15,7 +15,8 @@ export async function sweepNativeNoHop(ctx) {
|
|
|
15
15
|
let profitHopWallets;
|
|
16
16
|
const wallets = actualKeys.map((pk) => new Wallet(pk, provider));
|
|
17
17
|
const addresses = wallets.map((w) => w.address);
|
|
18
|
-
|
|
18
|
+
// ✅ 复用主流程共享的 NonceManager(贿赂交易已用它预留 targetWallet 的 nonce,避免利润提取与之冲突)
|
|
19
|
+
const nonceManager = ctx.nonceManager ?? new NonceManager(provider);
|
|
19
20
|
// ✅ 优化:并行获取 gasPrice 和余额
|
|
20
21
|
const [gasPrice, balances] = await Promise.all([
|
|
21
22
|
getOptimizedGasPrice(provider, getGasPriceConfig(config)),
|
|
@@ -46,7 +46,7 @@ export async function sweepWithHops(ctx, preparedHops) {
|
|
|
46
46
|
// ✅ ERC20 多跳时,中转钱包需要执行 2 笔交易(转 gas + 转 ERC20)
|
|
47
47
|
const erc20HopGasFee = erc20TransferGasLimit * gasPrice;
|
|
48
48
|
const nativeHopGasFeeForErc20 = nativeTransferGasLimit * gasPrice;
|
|
49
|
-
const nonceManager = new NonceManager(provider);
|
|
49
|
+
const nonceManager = ctx.nonceManager ?? new NonceManager(provider);
|
|
50
50
|
// ✅ 用于记录每个钱包的归集金额
|
|
51
51
|
const sweepAmounts = new Array(sourceWallets.length).fill(0n);
|
|
52
52
|
// ✅ 辅助函数:获取比例和金额
|
|
@@ -29,6 +29,7 @@ export const VAULT_TYPE_CATEGORIES = {
|
|
|
29
29
|
export const VAULT_PORTAL_ADDRESSES = {
|
|
30
30
|
BSC: '0x90497450f2a706f1951b5bdda52B4E5d16f34C06',
|
|
31
31
|
BASE: '0x027e3704fC5C16522e9393d04C60A3ac5c0d775f',
|
|
32
|
+
MORPH: '0xe9F7AB7DE8FB8756acbB6a1cd13316A43308197B',
|
|
32
33
|
};
|
|
33
34
|
/**
|
|
34
35
|
* VaultFactory 合约地址(每种金库类型 + 每条链)
|
|
@@ -38,18 +39,25 @@ export const VAULT_PORTAL_ADDRESSES = {
|
|
|
38
39
|
*/
|
|
39
40
|
export const VAULT_FACTORY_ADDRESSES = {
|
|
40
41
|
BSC: {
|
|
41
|
-
gift: '
|
|
42
|
+
gift: '0xFb7ccc4Fd09Da5b7016A18d51e227Af4ABE53f44',
|
|
42
43
|
split: '0xfab75Dc774cB9B38b91749B8833360B46a52345F',
|
|
43
44
|
// bnbshare: '0x53AD93F2454cFA532656f80E30571159d7E726A7', // 已禁用 (enabled: false)
|
|
44
45
|
buyback_burn: '0xB64655dab7156c29B63C70fb3ED7f071e2658D19',
|
|
45
46
|
burnToEarn: '0x47A216040Dc9e0AfE2e6fc5dcC44f7bBD1B60d25',
|
|
47
|
+
scheduled_buyback: '0x4ac94f87863012C4F133ef748b7cC5b75CAFE801',
|
|
48
|
+
relay: '0xB8dfFd67204105fB32d51d9cAa7c17A7bf880d9E',
|
|
49
|
+
lp_staking: '0x59F3b82Ea3aA3BCE6156CA61c0A6613C0A632452',
|
|
50
|
+
rank_burn: '0x9F5bF8EB9c4cA7179E60d0B529F4910B9A7eE0Ee',
|
|
46
51
|
buildYourVault: ZeroAddress, // 用户自定义地址
|
|
47
52
|
},
|
|
48
53
|
BASE: {
|
|
49
|
-
gift: '
|
|
54
|
+
gift: '0x2eDD880AB36b07bD030BDa28A13c3E9148C11622',
|
|
50
55
|
split: '0x1ae091F75D593eb7dC6539600a185C8A6076A424',
|
|
51
56
|
buyback_burn: '0x6F97fA674a6FE5EC37e309B63aB54E33c9e64d2E',
|
|
52
57
|
burnToEarn: '0x47A216040Dc9e0AfE2e6fc5dcC44f7bBD1B60d25',
|
|
58
|
+
scheduled_buyback: '0xdc40982a586e4692e1E4D0b05416B1FB5155075a',
|
|
59
|
+
lp_staking: '0xbFfAb600105C83Ea5009A9ccbf7a0f2D007Ad198',
|
|
60
|
+
rank_burn: '0x971ec9df7CEA81d612d48c1f6021ADeF6C6682B4',
|
|
53
61
|
buildYourVault: ZeroAddress,
|
|
54
62
|
},
|
|
55
63
|
};
|