four-flap-meme-sdk 2.0.0 → 2.2.0
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/__tests__/subpath-exports.test.js +64 -0
- package/dist/chains/bsc/iro.d.ts +5 -0
- package/dist/chains/bsc/iro.js +4 -0
- package/dist/chains/eni/flat-aliases.d.ts +10 -0
- package/dist/chains/eni/flat-aliases.js +8 -0
- package/dist/chains/eni/index.d.ts +1 -0
- package/dist/chains/eni/index.js +1 -0
- package/dist/chains/index.d.ts +13 -0
- package/dist/chains/index.js +13 -0
- package/dist/chains/xlayer/eip7702/flat-aliases.d.ts +13 -0
- package/dist/chains/xlayer/eip7702/flat-aliases.js +10 -0
- package/dist/chains/xlayer/eip7702/index.d.ts +1 -0
- package/dist/chains/xlayer/eip7702/index.js +1 -0
- package/dist/chains/xlayer/index.d.ts +3 -2
- package/dist/chains/xlayer/index.js +4 -7
- package/dist/flap/index.d.ts +10 -0
- package/dist/flap/index.js +8 -0
- package/dist/merkle/index.d.ts +12 -0
- package/dist/merkle/index.js +11 -0
- package/dist/shared/constants/index.d.ts +2 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/vanity/index.d.ts +5 -0
- package/dist/vanity/index.js +5 -0
- package/package.json +93 -2
- package/dist/chains/bsc/four/disperse.d.ts +0 -12
- package/dist/chains/bsc/four/disperse.js +0 -470
- package/dist/chains/bsc/four/pairwise.d.ts +0 -7
- package/dist/chains/bsc/four/pairwise.js +0 -308
- package/dist/chains/bsc/four/submit/blockrazor.d.ts +0 -18
- package/dist/chains/bsc/four/submit/blockrazor.js +0 -86
- package/dist/chains/bsc/four/submit/direct.d.ts +0 -66
- package/dist/chains/bsc/four/submit/direct.js +0 -452
- package/dist/chains/bsc/four/submit/helpers.d.ts +0 -18
- package/dist/chains/bsc/four/submit/helpers.js +0 -57
- package/dist/chains/bsc/four/submit/index.d.ts +0 -12
- package/dist/chains/bsc/four/submit/index.js +0 -11
- package/dist/chains/bsc/four/submit/merkle.d.ts +0 -18
- package/dist/chains/bsc/four/submit/merkle.js +0 -74
- package/dist/chains/bsc/four/submit/types.d.ts +0 -143
- package/dist/chains/bsc/four/swap/index.d.ts +0 -32
- package/dist/chains/bsc/four/swap/index.js +0 -829
- package/dist/chains/bsc/four/swap/types.d.ts +0 -70
- package/dist/chains/bsc/four/swap/types.js +0 -1
- package/dist/chains/bsc/four/sweep.d.ts +0 -13
- package/dist/chains/bsc/four/sweep.js +0 -788
- package/dist/chains/bsc/four/utils/index.d.ts +0 -20
- package/dist/chains/bsc/four/utils/index.js +0 -1558
- package/dist/chains/bsc/four/utils/types.d.ts +0 -1
- package/dist/chains/bsc/four/utils/types.js +0 -1
- package/dist/chains/bsc/pancake/bundle-buy-first/index.d.ts +0 -8
- package/dist/chains/bsc/pancake/bundle-buy-first/index.js +0 -907
- package/dist/chains/bsc/pancake/bundle-buy-first/types.d.ts +0 -73
- package/dist/chains/bsc/pancake/bundle-buy-first/types.js +0 -1
- package/dist/chains/bsc/pancake/bundle-swap/helpers.d.ts +0 -102
- package/dist/chains/bsc/pancake/bundle-swap/helpers.js +0 -572
- package/dist/chains/bsc/pancake/bundle-swap/index.d.ts +0 -50
- package/dist/chains/bsc/pancake/bundle-swap/index.js +0 -1066
- package/dist/chains/bsc/pancake/bundle-swap/types.d.ts +0 -202
- package/dist/chains/bsc/pancake/bundle-swap/types.js +0 -3
- package/dist/chains/xlayer/eip7702/bundle-swap/index.d.ts +0 -72
- package/dist/chains/xlayer/eip7702/bundle-swap/index.js +0 -921
- package/dist/chains/xlayer/eip7702/bundle-swap/types.d.ts +0 -65
- package/dist/chains/xlayer/eip7702/bundle-swap/types.js +0 -1
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.d.ts +0 -128
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.js +0 -857
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.d.ts +0 -85
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.js +0 -1
- package/dist/chains/xlayer/eip7702/volume/index.d.ts +0 -96
- package/dist/chains/xlayer/eip7702/volume/index.js +0 -793
- package/dist/chains/xlayer/eip7702/volume/types.d.ts +0 -124
- package/dist/chains/xlayer/eip7702/volume/types.js +0 -1
- package/dist/chains/xlayer/eoa/types-core.d.ts +0 -363
- package/dist/chains/xlayer/eoa/types-core.js +0 -53
- package/dist/chains/xlayer/eoa/types-create.d.ts +0 -413
- package/dist/chains/xlayer/eoa/types-create.js +0 -9
- package/dist/chains/xlayer/eoa/types-volume.d.ts +0 -209
- package/dist/chains/xlayer/eoa/types-volume.js +0 -13
- package/dist/dex/direct-router/index.d.ts +0 -70
- package/dist/dex/direct-router/index.js +0 -1410
- package/dist/dex/direct-router/types.d.ts +0 -81
- package/dist/dex/direct-router/types.js +0 -1
- package/dist/shared/abis/TaxToken.json +0 -969
- package/dist/shared/abis/TokenManager.json +0 -836
- package/dist/shared/abis/TokenManager2.json +0 -136
- package/dist/shared/abis/TokenManagerHelper3.json +0 -993
- package/dist/shared/abis 2/TaxToken.json +0 -105
- package/dist/shared/abis 2/TokenManager.json +0 -836
- package/dist/shared/abis 2/TokenManager2.json +0 -60
- package/dist/shared/abis 2/TokenManagerHelper3.json +0 -993
- package/dist/shared/abis 2/common.d.ts +0 -85
- package/dist/shared/abis 2/common.js +0 -254
- package/dist/shared/abis 2/index.d.ts +0 -8
- package/dist/shared/abis 2/index.js +0 -8
- package/dist/shared/clients 2/blockrazor.d.ts +0 -314
- package/dist/shared/clients 2/blockrazor.js +0 -596
- package/dist/shared/clients 2/club48.d.ts +0 -154
- package/dist/shared/clients 2/club48.js +0 -331
- package/dist/shared/clients 2/emitservice.d.ts +0 -47
- package/dist/shared/clients 2/emitservice.js +0 -44
- package/dist/shared/clients 2/four.d.ts +0 -132
- package/dist/shared/clients 2/four.js +0 -281
- package/dist/shared/clients 2/merkle.d.ts +0 -210
- package/dist/shared/clients 2/merkle.js +0 -400
- package/dist/shared/flap/__tests__/curve.test.d.ts +0 -1
- package/dist/shared/flap/__tests__/curve.test.js +0 -85
- package/dist/shared/flap/portal/index.d.ts +0 -12
- package/dist/shared/flap/portal/index.js +0 -11
- package/dist/shared/flap/portal/portal.d.ts +0 -47
- package/dist/shared/flap/portal/portal.js +0 -218
- package/dist/shared/flap/portal/types.d.ts +0 -227
- package/dist/shared/flap/portal/types.js +0 -80
- package/dist/shared/flap/portal/writer.d.ts +0 -121
- package/dist/shared/flap/portal/writer.js +0 -265
- package/dist/shared/flap/portal-bundle-merkle/core/index.d.ts +0 -18
- package/dist/shared/flap/portal-bundle-merkle/core/index.js +0 -938
- package/dist/shared/flap/portal-bundle-merkle/core/types.d.ts +0 -1
- package/dist/shared/flap/portal-bundle-merkle/core/types.js +0 -1
- package/dist/shared/flap/portal-bundle-merkle/swap/index.d.ts +0 -42
- package/dist/shared/flap/portal-bundle-merkle/swap/index.js +0 -1448
- package/dist/shared/flap/portal-bundle-merkle/swap/types.d.ts +0 -84
- package/dist/shared/flap/portal-bundle-merkle/swap/types.js +0 -1
- package/dist/shared/flap/portal-bundle-merkle/utils/index.d.ts +0 -17
- package/dist/shared/flap/portal-bundle-merkle/utils/index.js +0 -1024
- package/dist/shared/flap/portal-bundle-merkle/utils/types.d.ts +0 -16
- package/dist/shared/flap/portal-bundle-merkle/utils/types.js +0 -1
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.d.ts +0 -100
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.js +0 -133
- package/dist/shared/flap 2/__tests__/curve.test.d.ts +0 -1
- package/dist/shared/flap 2/__tests__/curve.test.js +0 -85
- package/dist/shared/flap 2/abi.d.ts +0 -4
- package/dist/shared/flap 2/abi.js +0 -4
- package/dist/shared/flap 2/constants.d.ts +0 -128
- package/dist/shared/flap 2/constants.js +0 -143
- package/dist/shared/flap 2/curve.d.ts +0 -33
- package/dist/shared/flap 2/curve.js +0 -84
- package/dist/shared/flap 2/errors.d.ts +0 -37
- package/dist/shared/flap 2/errors.js +0 -114
- package/dist/shared/flap 2/index.d.ts +0 -22
- package/dist/shared/flap 2/index.js +0 -33
- package/dist/shared/flap 2/ipfs.d.ts +0 -21
- package/dist/shared/flap 2/ipfs.js +0 -38
- package/dist/shared/flap 2/meta.d.ts +0 -30
- package/dist/shared/flap 2/meta.js +0 -195
- package/dist/shared/flap 2/permit.d.ts +0 -16
- package/dist/shared/flap 2/permit.js +0 -67
- package/dist/shared/flap 2/pinata.d.ts +0 -40
- package/dist/shared/flap 2/pinata.js +0 -106
- package/dist/shared/flap 2/portal-bundle-merkle/config.d.ts +0 -79
- package/dist/shared/flap 2/portal-bundle-merkle/config.js +0 -133
- package/dist/shared/flap 2/portal-bundle-merkle/core.d.ts +0 -18
- package/dist/shared/flap 2/portal-bundle-merkle/core.js +0 -938
- package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.d.ts +0 -125
- package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.js +0 -665
- package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.d.ts +0 -88
- package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.js +0 -446
- package/dist/shared/flap 2/portal-bundle-merkle/index.d.ts +0 -14
- package/dist/shared/flap 2/portal-bundle-merkle/index.js +0 -26
- package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.d.ts +0 -28
- package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.js +0 -701
- package/dist/shared/flap 2/portal-bundle-merkle/private.d.ts +0 -17
- package/dist/shared/flap 2/portal-bundle-merkle/private.js +0 -549
- package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.d.ts +0 -65
- package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.js +0 -831
- package/dist/shared/flap 2/portal-bundle-merkle/swap.d.ts +0 -201
- package/dist/shared/flap 2/portal-bundle-merkle/swap.js +0 -1359
- package/dist/shared/flap 2/portal-bundle-merkle/types.d.ts +0 -358
- package/dist/shared/flap 2/portal-bundle-merkle/types.js +0 -1
- package/dist/shared/flap 2/portal-bundle-merkle/utils.d.ts +0 -89
- package/dist/shared/flap 2/portal-bundle-merkle/utils.js +0 -963
- package/dist/shared/flap 2/portal-bundle.d.ts +0 -119
- package/dist/shared/flap 2/portal-bundle.js +0 -584
- package/dist/shared/flap 2/portal.d.ts +0 -392
- package/dist/shared/flap 2/portal.js +0 -559
- package/dist/shared/flap 2/vanity.d.ts +0 -48
- package/dist/shared/flap 2/vanity.js +0 -110
- package/dist/shared/flap 2/vault.d.ts +0 -240
- package/dist/shared/flap 2/vault.js +0 -366
- package/dist/shared/four 2/index.d.ts +0 -7
- package/dist/shared/four 2/index.js +0 -22
- package/dist/shared/four 2/tax-token.d.ts +0 -176
- package/dist/shared/four 2/tax-token.js +0 -302
- package/dist/shared/index 2.js +0 -10
- package/dist/shared/index.d 2.ts +0 -10
- package/dist/types/distribute.d.ts +0 -72
- package/dist/types/distribute.js +0 -1
- package/dist/types 2/errors.d.ts +0 -27
- package/dist/types 2/errors.js +0 -34
- package/dist/utils/__tests__/errors.test.d.ts +0 -1
- package/dist/utils/__tests__/errors.test.js +0 -76
- package/dist/utils/airdrop-sweep-types.d.ts +0 -1
- package/dist/utils/airdrop-sweep-types.js +0 -1
- package/dist/utils/erc20/index.d.ts +0 -242
- package/dist/utils/erc20/index.js +0 -645
- package/dist/utils/erc20/types.d.ts +0 -77
- package/dist/utils/erc20/types.js +0 -1
- package/dist/utils/erc20-types.d.ts +0 -1
- package/dist/utils/erc20-types.js +0 -1
- package/dist/utils/holders-maker/helpers.d.ts +0 -43
- package/dist/utils/holders-maker/helpers.js +0 -371
- package/dist/utils/holders-maker/index.d.ts +0 -26
- package/dist/utils/holders-maker/index.js +0 -218
- package/dist/utils/holders-maker/types.d.ts +0 -72
- package/dist/utils/holders-maker/types.js +0 -4
- package/dist/utils/holders-maker-types.d.ts +0 -1
- package/dist/utils/holders-maker-types.js +0 -1
- package/dist/utils/lp-inspect/index.d.ts +0 -44
- package/dist/utils/lp-inspect/index.js +0 -937
- package/dist/utils/lp-inspect/types.d.ts +0 -100
- package/dist/utils/lp-inspect/types.js +0 -1
- package/dist/utils/lp-inspect-types.d.ts +0 -1
- package/dist/utils/lp-inspect-types.js +0 -1
- package/dist/utils/private-sale-types.d.ts +0 -1
- package/dist/utils/private-sale-types.js +0 -1
- package/dist/utils/quote-helpers/index.d.ts +0 -107
- package/dist/utils/quote-helpers/index.js +0 -346
- package/dist/utils/quote-helpers/types.d.ts +0 -16
- package/dist/utils/quote-helpers/types.js +0 -1
- package/dist/utils/quote-helpers-types.d.ts +0 -1
- package/dist/utils/quote-helpers-types.js +0 -1
- /package/dist/{chains/bsc/four/submit/types.js → __tests__/subpath-exports.test.d.ts} +0 -0
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { NonceManager } from '../bundle-helpers.js';
|
|
2
|
-
export type EnsureAllowanceResult = {
|
|
3
|
-
alreadyApproved: boolean;
|
|
4
|
-
currentAllowance: bigint;
|
|
5
|
-
requiredAllowance: bigint;
|
|
6
|
-
txReceipt?: any;
|
|
7
|
-
};
|
|
8
|
-
export type EnsureAllowanceBatchItemResult = EnsureAllowanceResult & {
|
|
9
|
-
owner: string;
|
|
10
|
-
};
|
|
11
|
-
export type ApproveTokenBatchParams = {
|
|
12
|
-
chain: 'BSC' | 'BASE' | 'XLAYER' | 'MORPH' | 'MONAD';
|
|
13
|
-
platform: 'flap' | 'four' | 'pancake-v2' | 'pancake-v3';
|
|
14
|
-
rpcUrl: string;
|
|
15
|
-
privateKeys: string[];
|
|
16
|
-
tokenAddress: string;
|
|
17
|
-
amounts: (bigint | 'max')[];
|
|
18
|
-
/** 是否只签名不提交(默认 false,直接发送交易) */
|
|
19
|
-
signOnly?: boolean;
|
|
20
|
-
/** Gas Price(可选,单位 Gwei,signOnly=true 时生效) */
|
|
21
|
-
gasPriceGwei?: number;
|
|
22
|
-
/** Gas Limit(可选,默认 100000,signOnly=true 时生效) */
|
|
23
|
-
gasLimit?: number;
|
|
24
|
-
/** 链ID(可选,默认56=BSC,signOnly=true 时生效) */
|
|
25
|
-
chainId?: number;
|
|
26
|
-
/** 跳过合约地址验证(可选,用于某些特殊场景) */
|
|
27
|
-
skipValidation?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type ApproveTokenBatchRawParams = {
|
|
30
|
-
rpcUrl: string;
|
|
31
|
-
privateKeys: string[];
|
|
32
|
-
tokenAddress: string;
|
|
33
|
-
spenderAddress: string;
|
|
34
|
-
amounts: (bigint | 'max')[];
|
|
35
|
-
/** 是否只签名不提交(默认 false,直接发送交易) */
|
|
36
|
-
signOnly?: boolean;
|
|
37
|
-
/** Gas Price(可选,单位 Gwei,signOnly=true 时生效) */
|
|
38
|
-
gasPriceGwei?: number;
|
|
39
|
-
/** Gas Limit(可选,默认 100000,signOnly=true 时生效) */
|
|
40
|
-
gasLimit?: number;
|
|
41
|
-
/** 链ID(可选,默认56=BSC,signOnly=true 时生效) */
|
|
42
|
-
chainId?: number;
|
|
43
|
-
/** 外部 NonceManager(可选,用于同一钱包签多笔交易时共享 nonce 状态) */
|
|
44
|
-
nonceManager?: NonceManager;
|
|
45
|
-
/** 跳过合约地址验证(可选,用于某些特殊场景,如 RPC 返回异常时) */
|
|
46
|
-
skipValidation?: boolean;
|
|
47
|
-
};
|
|
48
|
-
export type ApproveTokenBatchResult = {
|
|
49
|
-
success: boolean;
|
|
50
|
-
approvedCount: number;
|
|
51
|
-
results: Array<{
|
|
52
|
-
owner: string;
|
|
53
|
-
alreadyApproved: boolean;
|
|
54
|
-
currentAllowance: bigint;
|
|
55
|
-
requiredAllowance: bigint;
|
|
56
|
-
txHash?: string;
|
|
57
|
-
error?: string;
|
|
58
|
-
}>;
|
|
59
|
-
};
|
|
60
|
-
export type ApproveTokenBatchSignResult = {
|
|
61
|
-
/** 需要授权的签名交易数组(已过滤掉已授权的钱包) */
|
|
62
|
-
signedTransactions: string[];
|
|
63
|
-
/** 详细结果 */
|
|
64
|
-
results: Array<{
|
|
65
|
-
owner: string;
|
|
66
|
-
/** 是否已授权(无需发送交易) */
|
|
67
|
-
alreadyApproved: boolean;
|
|
68
|
-
currentAllowance: bigint;
|
|
69
|
-
requiredAllowance: bigint;
|
|
70
|
-
/** 签名交易(仅当 alreadyApproved=false 时有值) */
|
|
71
|
-
signedTx?: string;
|
|
72
|
-
}>;
|
|
73
|
-
/** 需要授权的钱包数量 */
|
|
74
|
-
needApproveCount: number;
|
|
75
|
-
/** 已授权的钱包数量 */
|
|
76
|
-
alreadyApprovedCount: number;
|
|
77
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { EnsureAllowanceResult, EnsureAllowanceBatchItemResult, ApproveTokenBatchParams, ApproveTokenBatchRawParams, ApproveTokenBatchResult, ApproveTokenBatchSignResult, } from '../shared/foundation/types/erc20.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 刷持有人(Holders Maker)辅助函数
|
|
3
|
-
*/
|
|
4
|
-
import { JsonRpcProvider, Wallet } from 'ethers';
|
|
5
|
-
import { type GeneratedWallet } from '../wallet.js';
|
|
6
|
-
import type { HoldersMakerChain, TradeType, BaseTokenType } from './types.js';
|
|
7
|
-
declare const DEFAULT_GAS_LIMIT = 800000;
|
|
8
|
-
declare const DEFAULT_GAS_PRICE_GWEI = 3;
|
|
9
|
-
declare const GAS_BUFFER_MULTIPLIER = 2;
|
|
10
|
-
declare const NATIVE_TRANSFER_GAS_LIMIT: 21055n;
|
|
11
|
-
declare const ERC20_TRANSFER_GAS_LIMIT: 65000n;
|
|
12
|
-
declare const ERC20_APPROVE_GAS_LIMIT = 50000n;
|
|
13
|
-
export declare function calculateMaxWalletsPerBatch(isERC20Mode: boolean, disperseHopCount: number, chain?: HoldersMakerChain): number;
|
|
14
|
-
export declare const DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE: number;
|
|
15
|
-
export declare const DEFAULT_MAX_WALLETS_PER_BATCH_ERC20: number;
|
|
16
|
-
export declare function chunkArray<T>(arr: T[], size: number): T[][];
|
|
17
|
-
type DisperseHopPath = {
|
|
18
|
-
targetAddress: string;
|
|
19
|
-
hopWallets: Wallet[];
|
|
20
|
-
hopWalletsInfo: GeneratedWallet[];
|
|
21
|
-
};
|
|
22
|
-
export declare function generateDisperseHopPaths(targetWallets: GeneratedWallet[], hopCount: number, provider: JsonRpcProvider): DisperseHopPath[];
|
|
23
|
-
declare function buildNativeTransferTx(wallet: Wallet, to: string, amount: bigint, nonce: number, gasPrice: bigint, chainId: number, txType: 0 | 2): Promise<string>;
|
|
24
|
-
export declare function buildDisperseHopChainNative(payer: Wallet, path: DisperseHopPath, finalAmount: bigint, gasPrice: bigint, chainId: number, txType: 0 | 2, payerNonce: number, isERC20Mode?: boolean): Promise<{
|
|
25
|
-
signedTxs: string[];
|
|
26
|
-
payerNoncesUsed: number;
|
|
27
|
-
}>;
|
|
28
|
-
declare function buildERC20ApproveTx(wallet: Wallet, tokenAddress: string, spender: string, amount: bigint, nonce: number, gasPrice: bigint, chainId: number, txType: 0 | 2): Promise<string>;
|
|
29
|
-
export declare function buildDisperseHopChainERC20(payer: Wallet, path: DisperseHopPath, erc20Address: string, erc20Amount: bigint, gasPrice: bigint, chainId: number, txType: 0 | 2, payerNonce: number): Promise<{
|
|
30
|
-
signedTxs: string[];
|
|
31
|
-
payerNoncesUsed: number;
|
|
32
|
-
}>;
|
|
33
|
-
declare function getBaseTokenAddress(baseToken: BaseTokenType, chain: HoldersMakerChain, customAddress?: string): string;
|
|
34
|
-
declare function getRouterAddress(tradeType: TradeType, chain?: HoldersMakerChain, v2RouterOverride?: string): string;
|
|
35
|
-
declare function getWrappedNativeAddress(chain?: HoldersMakerChain): string;
|
|
36
|
-
export declare function buildFlapBuyTx(wallet: Wallet, tokenAddress: string, buyAmount: bigint, nonce: number, gasPrice: bigint, gasLimit: number, chainId: number, txType: 0 | 2, chain: HoldersMakerChain): Promise<string>;
|
|
37
|
-
export declare function buildFourBuyTx(wallet: Wallet, tokenAddress: string, buyAmount: bigint, nonce: number, gasPrice: bigint, gasLimit: number, chainId: number, txType: 0 | 2): Promise<string>;
|
|
38
|
-
export declare function buildDaoaasBuyTx(wallet: Wallet, tokenAddress: string, buyAmount: bigint, nonce: number, gasPrice: bigint, gasLimit: number, chainId: number): Promise<string>;
|
|
39
|
-
export declare function buildV2BuyTx(wallet: Wallet, tokenAddress: string, buyAmount: bigint, nonce: number, gasPrice: bigint, gasLimit: number, chainId: number, txType: 0 | 2, v2Path?: string[], chain?: HoldersMakerChain, v2RouterOverride?: string): Promise<string>;
|
|
40
|
-
export declare function buildV3BuyTx(wallet: Wallet, tokenAddress: string, buyAmount: bigint, nonce: number, gasPrice: bigint, gasLimit: number, chainId: number, txType: 0 | 2, v3Fee?: number, chain?: HoldersMakerChain): Promise<string>;
|
|
41
|
-
export declare function buildV2BuyTxWithERC20(wallet: Wallet, tokenAddress: string, baseTokenAddress: string, buyAmount: bigint, nonce: number, gasPrice: bigint, gasLimit: number, chainId: number, txType: 0 | 2, v2RouterOverride?: string, chain?: HoldersMakerChain): Promise<string>;
|
|
42
|
-
export declare function buildV3BuyTxWithERC20(wallet: Wallet, tokenAddress: string, baseTokenAddress: string, buyAmount: bigint, nonce: number, gasPrice: bigint, gasLimit: number, chainId: number, txType: 0 | 2, v3Fee?: number): Promise<string>;
|
|
43
|
-
export { DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE_GWEI, GAS_BUFFER_MULTIPLIER, NATIVE_TRANSFER_GAS_LIMIT, ERC20_TRANSFER_GAS_LIMIT, ERC20_APPROVE_GAS_LIMIT, getBaseTokenAddress, getRouterAddress, getWrappedNativeAddress, buildNativeTransferTx, buildERC20ApproveTx, };
|
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 刷持有人(Holders Maker)辅助函数
|
|
3
|
-
*/
|
|
4
|
-
import { ethers, Wallet, Contract } from 'ethers';
|
|
5
|
-
import { generateWallets } from '../wallet.js';
|
|
6
|
-
import { getDeadline } from '../bundle-helpers.js';
|
|
7
|
-
import { ADDRESSES } from '../constants.js';
|
|
8
|
-
import { GAS_LIMITS } from '../../shared/constants/index.js';
|
|
9
|
-
import { FLAP_PORTAL_ADDRESSES } from '../../shared/flap/constants.js';
|
|
10
|
-
import { V2_ROUTER_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, ERC20_ABI, } from '../../shared/abis/common.js';
|
|
11
|
-
// ==================== 常量 ====================
|
|
12
|
-
const DEFAULT_GAS_LIMIT = 800000;
|
|
13
|
-
const DEFAULT_GAS_PRICE_GWEI = 3;
|
|
14
|
-
const GAS_BUFFER_MULTIPLIER = 2;
|
|
15
|
-
const NATIVE_TRANSFER_GAS_LIMIT = GAS_LIMITS.NATIVE_TRANSFER;
|
|
16
|
-
const FOUR_TM2_ABI = [
|
|
17
|
-
'function buyTokenAMAP(uint256 origin, address token, address to, uint256 funds, uint256 minAmount) payable',
|
|
18
|
-
];
|
|
19
|
-
const PANCAKE_V2_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV2Router;
|
|
20
|
-
const PANCAKE_V3_ROUTER_ADDRESS = ADDRESSES.BSC.PancakeV3Router;
|
|
21
|
-
const WBNB_ADDRESS = ADDRESSES.BSC.WBNB;
|
|
22
|
-
const USDT_ADDRESS = ADDRESSES.BSC.USDT;
|
|
23
|
-
const USDC_ADDRESS = ADDRESSES.BSC.USDC;
|
|
24
|
-
const XLAYER_V2_ROUTER_ADDRESS = ADDRESSES.XLAYER.PotatoSwapV2Router;
|
|
25
|
-
const XLAYER_V3_ROUTER_ADDRESS = ADDRESSES.XLAYER.PotatoSwapV3Router;
|
|
26
|
-
const WOKB_ADDRESS = ADDRESSES.XLAYER.WOKB;
|
|
27
|
-
const ENI_V2_ROUTER_ADDRESS = ADDRESSES.ENI.DswapV2Router;
|
|
28
|
-
const ENI_DAOAAS_PORTAL_ADDRESS = ADDRESSES.ENI.DaoaasPortal;
|
|
29
|
-
const WEGAS_ADDRESS = ADDRESSES.ENI.WEGAS;
|
|
30
|
-
const ERC20_TRANSFER_GAS_LIMIT = GAS_LIMITS.ERC20_TRANSFER;
|
|
31
|
-
const ERC20_APPROVE_GAS_LIMIT = 50000n;
|
|
32
|
-
// ==================== 通用辅助 ====================
|
|
33
|
-
export function calculateMaxWalletsPerBatch(isERC20Mode, disperseHopCount, chain) {
|
|
34
|
-
const isSimpleChain = chain === 'XLAYER' || chain === 'ENI';
|
|
35
|
-
const fixedOverhead = isSimpleChain
|
|
36
|
-
? 1
|
|
37
|
-
: 1 + 3 + 1;
|
|
38
|
-
const maxTxs = 50 - fixedOverhead;
|
|
39
|
-
if (isERC20Mode) {
|
|
40
|
-
const perWalletTxs = 2 * (disperseHopCount + 1) + 2;
|
|
41
|
-
return Math.floor(maxTxs / perWalletTxs);
|
|
42
|
-
}
|
|
43
|
-
const perWalletTxs = disperseHopCount + 2;
|
|
44
|
-
return Math.floor(maxTxs / perWalletTxs);
|
|
45
|
-
}
|
|
46
|
-
export const DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE = calculateMaxWalletsPerBatch(false, 0);
|
|
47
|
-
export const DEFAULT_MAX_WALLETS_PER_BATCH_ERC20 = calculateMaxWalletsPerBatch(true, 0);
|
|
48
|
-
export function chunkArray(arr, size) {
|
|
49
|
-
const chunks = [];
|
|
50
|
-
for (let i = 0; i < arr.length; i += size) {
|
|
51
|
-
chunks.push(arr.slice(i, i + size));
|
|
52
|
-
}
|
|
53
|
-
return chunks;
|
|
54
|
-
}
|
|
55
|
-
export function generateDisperseHopPaths(targetWallets, hopCount, provider) {
|
|
56
|
-
if (hopCount <= 0) {
|
|
57
|
-
return targetWallets.map((w) => ({
|
|
58
|
-
targetAddress: w.address,
|
|
59
|
-
hopWallets: [],
|
|
60
|
-
hopWalletsInfo: [],
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
return targetWallets.map((targetWallet) => {
|
|
64
|
-
const hopWalletsInfo = generateWallets(hopCount);
|
|
65
|
-
const hopWallets = hopWalletsInfo.map((w) => new Wallet(w.privateKey, provider));
|
|
66
|
-
return { targetAddress: targetWallet.address, hopWallets, hopWalletsInfo };
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
async function buildNativeTransferTx(wallet, to, amount, nonce, gasPrice, chainId, txType) {
|
|
70
|
-
const tx = {
|
|
71
|
-
to,
|
|
72
|
-
value: amount,
|
|
73
|
-
nonce,
|
|
74
|
-
gasLimit: GAS_LIMITS.BRIBE,
|
|
75
|
-
chainId,
|
|
76
|
-
};
|
|
77
|
-
if (txType === 2) {
|
|
78
|
-
tx.maxFeePerGas = gasPrice;
|
|
79
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
80
|
-
tx.type = 2;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
tx.gasPrice = gasPrice;
|
|
84
|
-
tx.type = 0;
|
|
85
|
-
}
|
|
86
|
-
return await wallet.signTransaction(tx);
|
|
87
|
-
}
|
|
88
|
-
export async function buildDisperseHopChainNative(payer, path, finalAmount, gasPrice, chainId, txType, payerNonce, isERC20Mode = false) {
|
|
89
|
-
const signedTxs = [];
|
|
90
|
-
const hopCount = path.hopWallets.length;
|
|
91
|
-
if (hopCount === 0) {
|
|
92
|
-
const tx = await buildNativeTransferTx(payer, path.targetAddress, finalAmount, payerNonce, gasPrice, chainId, txType);
|
|
93
|
-
signedTxs.push(tx);
|
|
94
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
95
|
-
}
|
|
96
|
-
const hopGasCost = NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
|
|
97
|
-
const erc20TransferGasCost = isERC20Mode ? ERC20_TRANSFER_GAS_LIMIT * gasPrice : 0n;
|
|
98
|
-
const amountsPerHop = [];
|
|
99
|
-
for (let i = 0; i < hopCount; i++) {
|
|
100
|
-
const remainingHops = hopCount - i;
|
|
101
|
-
const amount = finalAmount +
|
|
102
|
-
hopGasCost * BigInt(remainingHops) +
|
|
103
|
-
(isERC20Mode ? erc20TransferGasCost * BigInt(remainingHops) : 0n);
|
|
104
|
-
amountsPerHop.push(amount);
|
|
105
|
-
}
|
|
106
|
-
const firstTx = await buildNativeTransferTx(payer, path.hopWallets[0].address, amountsPerHop[0], payerNonce, gasPrice, chainId, txType);
|
|
107
|
-
signedTxs.push(firstTx);
|
|
108
|
-
for (let i = 0; i < hopCount; i++) {
|
|
109
|
-
const fromWallet = path.hopWallets[i];
|
|
110
|
-
const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
|
|
111
|
-
const amount = i === hopCount - 1 ? finalAmount : amountsPerHop[i + 1];
|
|
112
|
-
const tx = await buildNativeTransferTx(fromWallet, toAddress, amount, 0, gasPrice, chainId, txType);
|
|
113
|
-
signedTxs.push(tx);
|
|
114
|
-
}
|
|
115
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
116
|
-
}
|
|
117
|
-
// ==================== ERC20 转账 ====================
|
|
118
|
-
async function buildERC20TransferTx(wallet, tokenAddress, to, amount, nonce, gasPrice, chainId, txType) {
|
|
119
|
-
const iface = new ethers.Interface(ERC20_ABI);
|
|
120
|
-
const data = iface.encodeFunctionData('transfer', [to, amount]);
|
|
121
|
-
const tx = {
|
|
122
|
-
to: tokenAddress,
|
|
123
|
-
data,
|
|
124
|
-
value: 0n,
|
|
125
|
-
nonce,
|
|
126
|
-
gasLimit: ERC20_TRANSFER_GAS_LIMIT,
|
|
127
|
-
chainId,
|
|
128
|
-
};
|
|
129
|
-
if (txType === 2) {
|
|
130
|
-
tx.maxFeePerGas = gasPrice;
|
|
131
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
132
|
-
tx.type = 2;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
tx.gasPrice = gasPrice;
|
|
136
|
-
tx.type = 0;
|
|
137
|
-
}
|
|
138
|
-
return await wallet.signTransaction(tx);
|
|
139
|
-
}
|
|
140
|
-
async function buildERC20ApproveTx(wallet, tokenAddress, spender, amount, nonce, gasPrice, chainId, txType) {
|
|
141
|
-
const iface = new ethers.Interface(ERC20_ABI);
|
|
142
|
-
const data = iface.encodeFunctionData('approve', [spender, amount]);
|
|
143
|
-
const tx = {
|
|
144
|
-
to: tokenAddress,
|
|
145
|
-
data,
|
|
146
|
-
value: 0n,
|
|
147
|
-
nonce,
|
|
148
|
-
gasLimit: ERC20_APPROVE_GAS_LIMIT,
|
|
149
|
-
chainId,
|
|
150
|
-
};
|
|
151
|
-
if (txType === 2) {
|
|
152
|
-
tx.maxFeePerGas = gasPrice;
|
|
153
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
154
|
-
tx.type = 2;
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
tx.gasPrice = gasPrice;
|
|
158
|
-
tx.type = 0;
|
|
159
|
-
}
|
|
160
|
-
return await wallet.signTransaction(tx);
|
|
161
|
-
}
|
|
162
|
-
export async function buildDisperseHopChainERC20(payer, path, erc20Address, erc20Amount, gasPrice, chainId, txType, payerNonce) {
|
|
163
|
-
const signedTxs = [];
|
|
164
|
-
const hopCount = path.hopWallets.length;
|
|
165
|
-
if (hopCount === 0) {
|
|
166
|
-
const tx = await buildERC20TransferTx(payer, erc20Address, path.targetAddress, erc20Amount, payerNonce, gasPrice, chainId, txType);
|
|
167
|
-
signedTxs.push(tx);
|
|
168
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
169
|
-
}
|
|
170
|
-
const firstTx = await buildERC20TransferTx(payer, erc20Address, path.hopWallets[0].address, erc20Amount, payerNonce, gasPrice, chainId, txType);
|
|
171
|
-
signedTxs.push(firstTx);
|
|
172
|
-
for (let i = 0; i < hopCount; i++) {
|
|
173
|
-
const fromWallet = path.hopWallets[i];
|
|
174
|
-
const toAddress = i === hopCount - 1 ? path.targetAddress : path.hopWallets[i + 1].address;
|
|
175
|
-
const tx = await buildERC20TransferTx(fromWallet, erc20Address, toAddress, erc20Amount, 1, gasPrice, chainId, txType);
|
|
176
|
-
signedTxs.push(tx);
|
|
177
|
-
}
|
|
178
|
-
return { signedTxs, payerNoncesUsed: 1 };
|
|
179
|
-
}
|
|
180
|
-
// ==================== 地址查询 ====================
|
|
181
|
-
function getBaseTokenAddress(baseToken, chain, customAddress) {
|
|
182
|
-
if (customAddress)
|
|
183
|
-
return customAddress;
|
|
184
|
-
if (chain === 'ENI') {
|
|
185
|
-
if (baseToken === 'usdt')
|
|
186
|
-
return ADDRESSES.ENI.USDT;
|
|
187
|
-
if (baseToken === 'usdc')
|
|
188
|
-
return ADDRESSES.ENI.USDC;
|
|
189
|
-
}
|
|
190
|
-
if (baseToken === 'usdt')
|
|
191
|
-
return USDT_ADDRESS;
|
|
192
|
-
if (baseToken === 'usdc')
|
|
193
|
-
return USDC_ADDRESS;
|
|
194
|
-
throw new Error(`未知的基础代币类型: ${baseToken}`);
|
|
195
|
-
}
|
|
196
|
-
function getRouterAddress(tradeType, chain, v2RouterOverride) {
|
|
197
|
-
if (chain === 'ENI') {
|
|
198
|
-
switch (tradeType) {
|
|
199
|
-
case 'v2':
|
|
200
|
-
return v2RouterOverride || ENI_V2_ROUTER_ADDRESS;
|
|
201
|
-
case 'daoaas':
|
|
202
|
-
return ENI_DAOAAS_PORTAL_ADDRESS;
|
|
203
|
-
default:
|
|
204
|
-
throw new Error(`ENI 链不支持交易类型: ${tradeType}`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const isXLayer = chain === 'XLAYER';
|
|
208
|
-
switch (tradeType) {
|
|
209
|
-
case 'v2':
|
|
210
|
-
return v2RouterOverride || (isXLayer ? XLAYER_V2_ROUTER_ADDRESS : PANCAKE_V2_ROUTER_ADDRESS);
|
|
211
|
-
case 'v3':
|
|
212
|
-
return isXLayer ? XLAYER_V3_ROUTER_ADDRESS : PANCAKE_V3_ROUTER_ADDRESS;
|
|
213
|
-
default:
|
|
214
|
-
throw new Error(`ERC20 模式不支持交易类型: ${tradeType}`);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function getWrappedNativeAddress(chain) {
|
|
218
|
-
if (chain === 'ENI')
|
|
219
|
-
return WEGAS_ADDRESS;
|
|
220
|
-
return chain === 'XLAYER' ? WOKB_ADDRESS : WBNB_ADDRESS;
|
|
221
|
-
}
|
|
222
|
-
// ==================== 买入交易构建 ====================
|
|
223
|
-
export async function buildFlapBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, chain) {
|
|
224
|
-
const portalAddress = FLAP_PORTAL_ADDRESSES[chain];
|
|
225
|
-
const iface = new ethers.Interface([
|
|
226
|
-
'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
|
|
227
|
-
]);
|
|
228
|
-
const data = iface.encodeFunctionData('swapExactInput', [
|
|
229
|
-
{ inputToken: ethers.ZeroAddress, outputToken: tokenAddress, inputAmount: buyAmount, minOutputAmount: 0n, permitData: '0x' },
|
|
230
|
-
]);
|
|
231
|
-
const tx = { to: portalAddress, data, value: buyAmount, nonce, gasLimit: BigInt(gasLimit), chainId };
|
|
232
|
-
if (txType === 2) {
|
|
233
|
-
tx.maxFeePerGas = gasPrice;
|
|
234
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
235
|
-
tx.type = 2;
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
tx.gasPrice = gasPrice;
|
|
239
|
-
tx.type = 0;
|
|
240
|
-
}
|
|
241
|
-
return await wallet.signTransaction(tx);
|
|
242
|
-
}
|
|
243
|
-
export async function buildFourBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType) {
|
|
244
|
-
const tmAddress = ADDRESSES.BSC.TokenManagerOriginal;
|
|
245
|
-
const iface = new ethers.Interface(FOUR_TM2_ABI);
|
|
246
|
-
const data = iface.encodeFunctionData('buyTokenAMAP', [0n, tokenAddress, wallet.address, buyAmount, 0n]);
|
|
247
|
-
const tx = { to: tmAddress, data, value: buyAmount, nonce, gasLimit: BigInt(gasLimit), chainId };
|
|
248
|
-
if (txType === 2) {
|
|
249
|
-
tx.maxFeePerGas = gasPrice;
|
|
250
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
251
|
-
tx.type = 2;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
tx.gasPrice = gasPrice;
|
|
255
|
-
tx.type = 0;
|
|
256
|
-
}
|
|
257
|
-
return await wallet.signTransaction(tx);
|
|
258
|
-
}
|
|
259
|
-
export async function buildDaoaasBuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId) {
|
|
260
|
-
const portalAbi = ['function purchaseToken(address token, uint256 AmountMin) payable'];
|
|
261
|
-
const iface = new ethers.Interface(portalAbi);
|
|
262
|
-
const data = iface.encodeFunctionData('purchaseToken', [tokenAddress, 0n]);
|
|
263
|
-
const tx = {
|
|
264
|
-
to: ENI_DAOAAS_PORTAL_ADDRESS, data, value: buyAmount, nonce, gasLimit: BigInt(gasLimit), chainId,
|
|
265
|
-
type: 2, maxFeePerGas: gasPrice, maxPriorityFeePerGas: gasPrice / 10n || 1n,
|
|
266
|
-
};
|
|
267
|
-
return await wallet.signTransaction(tx);
|
|
268
|
-
}
|
|
269
|
-
export async function buildV2BuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v2Path, chain, v2RouterOverride) {
|
|
270
|
-
const wrappedNative = getWrappedNativeAddress(chain);
|
|
271
|
-
const routerAddress = v2RouterOverride || getRouterAddress('v2', chain);
|
|
272
|
-
const path = v2Path ? [...v2Path].reverse() : [wrappedNative, tokenAddress];
|
|
273
|
-
const deadline = getDeadline();
|
|
274
|
-
const v2Router = new Contract(routerAddress, V2_ROUTER_ABI, wallet);
|
|
275
|
-
const unsigned = await v2Router.swapExactETHForTokensSupportingFeeOnTransferTokens.populateTransaction(0n, path, wallet.address, deadline, { value: buyAmount });
|
|
276
|
-
const tx = { ...unsigned, nonce, gasLimit: BigInt(gasLimit), chainId };
|
|
277
|
-
if (txType === 2) {
|
|
278
|
-
tx.maxFeePerGas = gasPrice;
|
|
279
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
280
|
-
tx.type = 2;
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
tx.gasPrice = gasPrice;
|
|
284
|
-
tx.type = 0;
|
|
285
|
-
}
|
|
286
|
-
return await wallet.signTransaction(tx);
|
|
287
|
-
}
|
|
288
|
-
export async function buildV3BuyTx(wallet, tokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v3Fee = 2500, chain) {
|
|
289
|
-
const deadline = getDeadline();
|
|
290
|
-
const wrappedNative = getWrappedNativeAddress(chain);
|
|
291
|
-
const routerAddress = chain === 'XLAYER' ? XLAYER_V3_ROUTER_ADDRESS : PANCAKE_V3_ROUTER_ADDRESS;
|
|
292
|
-
const useLegacyRouter = chain === 'XLAYER' || chain === 'MONAD';
|
|
293
|
-
const v3RouterIface = new ethers.Interface(useLegacyRouter ? V3_ROUTER_LEGACY_ABI : V3_ROUTER02_ABI);
|
|
294
|
-
let multicallData;
|
|
295
|
-
const swapParams = {
|
|
296
|
-
tokenIn: wrappedNative, tokenOut: tokenAddress, fee: v3Fee, recipient: wallet.address,
|
|
297
|
-
amountIn: buyAmount, amountOutMinimum: 0n, sqrtPriceLimitX96: 0n,
|
|
298
|
-
};
|
|
299
|
-
if (useLegacyRouter) {
|
|
300
|
-
swapParams;
|
|
301
|
-
const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [
|
|
302
|
-
{ ...swapParams, deadline },
|
|
303
|
-
]);
|
|
304
|
-
const refundETHData = v3RouterIface.encodeFunctionData('refundETH', []);
|
|
305
|
-
multicallData = v3RouterIface.encodeFunctionData('multicall(bytes[])', [
|
|
306
|
-
[exactInputSingleData, refundETHData],
|
|
307
|
-
]);
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
|
|
311
|
-
const refundETHData = v3RouterIface.encodeFunctionData('refundETH', []);
|
|
312
|
-
multicallData = v3RouterIface.encodeFunctionData('multicall(uint256,bytes[])', [
|
|
313
|
-
deadline,
|
|
314
|
-
[exactInputSingleData, refundETHData],
|
|
315
|
-
]);
|
|
316
|
-
}
|
|
317
|
-
const tx = { to: routerAddress, data: multicallData, value: buyAmount, nonce, gasLimit: BigInt(gasLimit), chainId };
|
|
318
|
-
if (txType === 2) {
|
|
319
|
-
tx.maxFeePerGas = gasPrice;
|
|
320
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
321
|
-
tx.type = 2;
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
tx.gasPrice = gasPrice;
|
|
325
|
-
tx.type = 0;
|
|
326
|
-
}
|
|
327
|
-
return await wallet.signTransaction(tx);
|
|
328
|
-
}
|
|
329
|
-
export async function buildV2BuyTxWithERC20(wallet, tokenAddress, baseTokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v2RouterOverride, chain) {
|
|
330
|
-
const path = [baseTokenAddress, tokenAddress];
|
|
331
|
-
const deadline = getDeadline();
|
|
332
|
-
const routerAddress = v2RouterOverride || getRouterAddress('v2', chain);
|
|
333
|
-
const v2Router = new Contract(routerAddress, V2_ROUTER_ABI, wallet);
|
|
334
|
-
const unsigned = await v2Router.swapExactTokensForTokensSupportingFeeOnTransferTokens.populateTransaction(buyAmount, 0n, path, wallet.address, deadline);
|
|
335
|
-
const tx = { ...unsigned, nonce, gasLimit: BigInt(gasLimit), chainId };
|
|
336
|
-
if (txType === 2) {
|
|
337
|
-
tx.maxFeePerGas = gasPrice;
|
|
338
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
339
|
-
tx.type = 2;
|
|
340
|
-
}
|
|
341
|
-
else {
|
|
342
|
-
tx.gasPrice = gasPrice;
|
|
343
|
-
tx.type = 0;
|
|
344
|
-
}
|
|
345
|
-
return await wallet.signTransaction(tx);
|
|
346
|
-
}
|
|
347
|
-
export async function buildV3BuyTxWithERC20(wallet, tokenAddress, baseTokenAddress, buyAmount, nonce, gasPrice, gasLimit, chainId, txType, v3Fee = 2500) {
|
|
348
|
-
const deadline = getDeadline();
|
|
349
|
-
const v3RouterIface = new ethers.Interface(V3_ROUTER02_ABI);
|
|
350
|
-
const swapParams = {
|
|
351
|
-
tokenIn: baseTokenAddress, tokenOut: tokenAddress, fee: v3Fee, recipient: wallet.address,
|
|
352
|
-
amountIn: buyAmount, amountOutMinimum: 0n, sqrtPriceLimitX96: 0n,
|
|
353
|
-
};
|
|
354
|
-
const exactInputSingleData = v3RouterIface.encodeFunctionData('exactInputSingle', [swapParams]);
|
|
355
|
-
const multicallData = v3RouterIface.encodeFunctionData('multicall(uint256,bytes[])', [
|
|
356
|
-
deadline,
|
|
357
|
-
[exactInputSingleData],
|
|
358
|
-
]);
|
|
359
|
-
const tx = { to: PANCAKE_V3_ROUTER_ADDRESS, data: multicallData, value: 0n, nonce, gasLimit: BigInt(gasLimit), chainId };
|
|
360
|
-
if (txType === 2) {
|
|
361
|
-
tx.maxFeePerGas = gasPrice;
|
|
362
|
-
tx.maxPriorityFeePerGas = gasPrice / 10n || 1n;
|
|
363
|
-
tx.type = 2;
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
tx.gasPrice = gasPrice;
|
|
367
|
-
tx.type = 0;
|
|
368
|
-
}
|
|
369
|
-
return await wallet.signTransaction(tx);
|
|
370
|
-
}
|
|
371
|
-
export { DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE_GWEI, GAS_BUFFER_MULTIPLIER, NATIVE_TRANSFER_GAS_LIMIT, ERC20_TRANSFER_GAS_LIMIT, ERC20_APPROVE_GAS_LIMIT, getBaseTokenAddress, getRouterAddress, getWrappedNativeAddress, buildNativeTransferTx, buildERC20ApproveTx, };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 刷持有人(Holders Maker)
|
|
3
|
-
*
|
|
4
|
-
* 一键完成:生成钱包 → 分发资金 → 批量买入
|
|
5
|
-
*/
|
|
6
|
-
export type { HoldersMakerChain, TradeType, BaseTokenType, HoldersMakerConfig, HoldersMakerParams, TransactionLayer, BatchResult, HoldersMakerResult, } from './types.js';
|
|
7
|
-
import type { HoldersMakerParams, HoldersMakerResult } from './types.js';
|
|
8
|
-
/**
|
|
9
|
-
* 刷持有人(一个 bundle 完成分发+买入)
|
|
10
|
-
*/
|
|
11
|
-
export declare function holdersMaker(params: HoldersMakerParams): Promise<HoldersMakerResult>;
|
|
12
|
-
/**
|
|
13
|
-
* 获取刷持有人预估费用
|
|
14
|
-
*/
|
|
15
|
-
export declare function estimateHoldersMakerCost(params: {
|
|
16
|
-
holdersCount: number;
|
|
17
|
-
buyAmountPerHolder: string;
|
|
18
|
-
baseToken?: 'native' | 'usdt' | 'usdc';
|
|
19
|
-
gasLimit?: number;
|
|
20
|
-
gasPriceGwei?: number;
|
|
21
|
-
}): {
|
|
22
|
-
totalNativeCost: string;
|
|
23
|
-
totalERC20Cost?: string;
|
|
24
|
-
gasEstimate: string;
|
|
25
|
-
batchCount: number;
|
|
26
|
-
};
|