four-flap-meme-sdk 2.0.0 → 2.1.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 +34 -0
- package/dist/chains/index.d.ts +13 -0
- package/dist/chains/index.js +13 -0
- package/dist/chains/xlayer/eip7702/index.d.ts +2 -0
- package/dist/flap/index.d.ts +10 -0
- package/dist/flap/index.js +8 -0
- package/dist/shared/constants/index.d.ts +2 -0
- package/dist/shared/index.d.ts +2 -0
- package/package.json +66 -1
- 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,218 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 刷持有人(Holders Maker)
|
|
3
|
-
*
|
|
4
|
-
* 一键完成:生成钱包 → 分发资金 → 批量买入
|
|
5
|
-
*/
|
|
6
|
-
import { ethers, JsonRpcProvider, Wallet } from 'ethers';
|
|
7
|
-
import { generateWallets } from '../wallet.js';
|
|
8
|
-
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../bundle-helpers.js';
|
|
9
|
-
import { BLOCKRAZOR_BUILDER_EOA, PROFIT_CONFIG, getProfitRecipient } from '../constants.js';
|
|
10
|
-
import { calculateMaxWalletsPerBatch, DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE, DEFAULT_MAX_WALLETS_PER_BATCH_ERC20, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE_GWEI, GAS_BUFFER_MULTIPLIER, NATIVE_TRANSFER_GAS_LIMIT, chunkArray, generateDisperseHopPaths, buildDisperseHopChainNative, buildDisperseHopChainERC20, buildNativeTransferTx, buildERC20ApproveTx, buildFlapBuyTx, buildFourBuyTx, buildDaoaasBuyTx, buildV2BuyTx, buildV3BuyTx, buildV2BuyTxWithERC20, buildV3BuyTxWithERC20, getBaseTokenAddress, getRouterAddress, } from './helpers.js';
|
|
11
|
-
/**
|
|
12
|
-
* 刷持有人(一个 bundle 完成分发+买入)
|
|
13
|
-
*/
|
|
14
|
-
export async function holdersMaker(params) {
|
|
15
|
-
const { payerPrivateKey, holdersCount, buyAmountPerHolder, tokenAddress, baseToken = 'native', baseTokenAddress, baseTokenDecimals = 18, config } = params;
|
|
16
|
-
const { rpcUrl, chain = 'BSC', chainId: configChainId, tradeType = 'flap', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, bribeAmount = 0.000001, txType: configTxType = 0, disperseHopCount = 0 } = config;
|
|
17
|
-
const txType = chain === 'ENI' ? 2 : configTxType;
|
|
18
|
-
const result = {
|
|
19
|
-
success: false, newWallets: [], disperseHopWallets: [], profitHopWallets: [],
|
|
20
|
-
signedTransactions: [], batchResults: [], successBatchCount: 0, totalBatchCount: 0,
|
|
21
|
-
};
|
|
22
|
-
const isERC20Mode = baseToken !== 'native';
|
|
23
|
-
if (isERC20Mode && (tradeType === 'four' || tradeType === 'flap')) {
|
|
24
|
-
result.error = `ERC20 模式(${baseToken})不支持 ${tradeType} 内盘,仅支持 v2/v3 外盘`;
|
|
25
|
-
return result;
|
|
26
|
-
}
|
|
27
|
-
const supportedTradeTypes = ['four', 'flap', 'v2', 'v3', 'daoaas'];
|
|
28
|
-
if (!supportedTradeTypes.includes(tradeType)) {
|
|
29
|
-
result.error = `不支持的交易类型: ${tradeType}`;
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
const effectiveDisperseHopCount = chain === 'XLAYER' ? 0 : disperseHopCount;
|
|
33
|
-
const maxWalletsPerBatch = config.maxWalletsPerBatch || calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
|
|
34
|
-
console.log(`[HoldersMaker] chain: ${chain}, 分发多跳数: ${effectiveDisperseHopCount}, 每批最大钱包数: ${maxWalletsPerBatch}`);
|
|
35
|
-
try {
|
|
36
|
-
const provider = new JsonRpcProvider(rpcUrl);
|
|
37
|
-
const chainId = configChainId || Number((await provider.getNetwork()).chainId);
|
|
38
|
-
const payer = new Wallet(payerPrivateKey, provider);
|
|
39
|
-
const nonceManager = new NonceManager(provider);
|
|
40
|
-
const newWallets = generateWallets(holdersCount);
|
|
41
|
-
result.newWallets = newWallets;
|
|
42
|
-
const gasPriceWei = BigInt(Math.floor(gasPriceGwei * 1e9));
|
|
43
|
-
const gasPrice = await getOptimizedGasPrice(provider, { minGasPrice: gasPriceWei });
|
|
44
|
-
const bribeAmountWei = ethers.parseEther(String(bribeAmount));
|
|
45
|
-
const gasMultiplier = isERC20Mode ? 2 : 1;
|
|
46
|
-
const gasFeePerWallet = BigInt(gasLimit) * gasPrice * BigInt(gasMultiplier);
|
|
47
|
-
const gasWithBuffer = gasFeePerWallet * BigInt(GAS_BUFFER_MULTIPLIER);
|
|
48
|
-
let buyAmountWei;
|
|
49
|
-
let transferNativePerWallet;
|
|
50
|
-
let erc20TokenAddress;
|
|
51
|
-
if (isERC20Mode) {
|
|
52
|
-
buyAmountWei = ethers.parseUnits(buyAmountPerHolder, baseTokenDecimals);
|
|
53
|
-
transferNativePerWallet = gasWithBuffer;
|
|
54
|
-
erc20TokenAddress = getBaseTokenAddress(baseToken, chain, baseTokenAddress);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
buyAmountWei = ethers.parseEther(buyAmountPerHolder);
|
|
58
|
-
transferNativePerWallet = buyAmountWei + gasWithBuffer;
|
|
59
|
-
}
|
|
60
|
-
const walletBatches = chunkArray(newWallets, maxWalletsPerBatch);
|
|
61
|
-
result.totalBatchCount = walletBatches.length;
|
|
62
|
-
const totalBuyAmountForProfit = isERC20Mode
|
|
63
|
-
? ethers.parseEther(buyAmountPerHolder) * BigInt(holdersCount)
|
|
64
|
-
: buyAmountWei * BigInt(holdersCount);
|
|
65
|
-
const profitRateBps = PROFIT_CONFIG.RATE_BPS;
|
|
66
|
-
const totalProfit = (totalBuyAmountForProfit * BigInt(profitRateBps)) / 10000n;
|
|
67
|
-
let profitPerBatch = totalProfit / BigInt(walletBatches.length);
|
|
68
|
-
if (profitPerBatch > 0n && chain === 'ENI') {
|
|
69
|
-
profitPerBatch += NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
|
|
70
|
-
}
|
|
71
|
-
let allDisperseHopWallets = [];
|
|
72
|
-
const disperseHopPaths = generateDisperseHopPaths(newWallets, effectiveDisperseHopCount, provider);
|
|
73
|
-
if (effectiveDisperseHopCount > 0) {
|
|
74
|
-
for (const path of disperseHopPaths) {
|
|
75
|
-
allDisperseHopWallets.push(...path.hopWalletsInfo);
|
|
76
|
-
}
|
|
77
|
-
result.disperseHopWallets = allDisperseHopWallets;
|
|
78
|
-
}
|
|
79
|
-
const isSimpleChain = chain === 'XLAYER' || chain === 'ENI';
|
|
80
|
-
const needBribe = !isSimpleChain;
|
|
81
|
-
const needProfitHop = !isSimpleChain;
|
|
82
|
-
const batchPromises = walletBatches.map(async (batch, batchIdx) => {
|
|
83
|
-
try {
|
|
84
|
-
const signedTxs = [];
|
|
85
|
-
const bribeCount = needBribe ? 1 : 0;
|
|
86
|
-
const profitCount = needProfitHop ? PROFIT_HOP_COUNT + 1 : 1;
|
|
87
|
-
const payerNonceCount = isERC20Mode
|
|
88
|
-
? bribeCount + batch.length * 2 + profitCount
|
|
89
|
-
: bribeCount + batch.length + profitCount;
|
|
90
|
-
const payerNonces = await nonceManager.getNextNonceBatch(payer, payerNonceCount);
|
|
91
|
-
let payerNonceIdx = 0;
|
|
92
|
-
if (needBribe) {
|
|
93
|
-
const bribeTx = await buildNativeTransferTx(payer, BLOCKRAZOR_BUILDER_EOA, bribeAmountWei, payerNonces[payerNonceIdx++], gasPrice, chainId, txType);
|
|
94
|
-
signedTxs.push(bribeTx);
|
|
95
|
-
}
|
|
96
|
-
const batchStartIdx = batchIdx * maxWalletsPerBatch;
|
|
97
|
-
const batchPaths = disperseHopPaths.slice(batchStartIdx, batchStartIdx + batch.length);
|
|
98
|
-
for (let i = 0; i < batch.length; i++) {
|
|
99
|
-
const { signedTxs: hopTxs } = await buildDisperseHopChainNative(payer, batchPaths[i], transferNativePerWallet, gasPrice, chainId, txType, payerNonces[payerNonceIdx++], isERC20Mode);
|
|
100
|
-
signedTxs.push(...hopTxs);
|
|
101
|
-
}
|
|
102
|
-
if (isERC20Mode && erc20TokenAddress) {
|
|
103
|
-
for (let i = 0; i < batch.length; i++) {
|
|
104
|
-
const { signedTxs: hopTxs } = await buildDisperseHopChainERC20(payer, batchPaths[i], erc20TokenAddress, buyAmountWei, gasPrice, chainId, txType, payerNonces[payerNonceIdx++]);
|
|
105
|
-
signedTxs.push(...hopTxs);
|
|
106
|
-
}
|
|
107
|
-
const routerAddress = getRouterAddress(tradeType, chain, config.v2RouterAddress);
|
|
108
|
-
for (const newWallet of batch) {
|
|
109
|
-
const buyerWallet = new Wallet(newWallet.privateKey, provider);
|
|
110
|
-
const approveTx = await buildERC20ApproveTx(buyerWallet, erc20TokenAddress, routerAddress, ethers.MaxUint256, 0, gasPrice, chainId, txType);
|
|
111
|
-
signedTxs.push(approveTx);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
const buyNonce = isERC20Mode ? 1 : 0;
|
|
115
|
-
for (const newWallet of batch) {
|
|
116
|
-
const buyerWallet = new Wallet(newWallet.privateKey, provider);
|
|
117
|
-
let buyTx;
|
|
118
|
-
if (isERC20Mode && erc20TokenAddress) {
|
|
119
|
-
switch (tradeType) {
|
|
120
|
-
case 'v2':
|
|
121
|
-
buyTx = await buildV2BuyTxWithERC20(buyerWallet, tokenAddress, erc20TokenAddress, buyAmountWei, buyNonce, gasPrice, gasLimit, chainId, txType, config.v2RouterAddress, chain);
|
|
122
|
-
break;
|
|
123
|
-
case 'v3':
|
|
124
|
-
buyTx = await buildV3BuyTxWithERC20(buyerWallet, tokenAddress, erc20TokenAddress, buyAmountWei, buyNonce, gasPrice, gasLimit, chainId, txType, config.v3Fee);
|
|
125
|
-
break;
|
|
126
|
-
default:
|
|
127
|
-
throw new Error(`ERC20 模式不支持交易类型: ${tradeType}`);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
switch (tradeType) {
|
|
132
|
-
case 'four':
|
|
133
|
-
buyTx = await buildFourBuyTx(buyerWallet, tokenAddress, buyAmountWei, buyNonce, gasPrice, gasLimit, chainId, txType);
|
|
134
|
-
break;
|
|
135
|
-
case 'flap':
|
|
136
|
-
buyTx = await buildFlapBuyTx(buyerWallet, tokenAddress, buyAmountWei, buyNonce, gasPrice, gasLimit, chainId, txType, chain);
|
|
137
|
-
break;
|
|
138
|
-
case 'v2':
|
|
139
|
-
buyTx = await buildV2BuyTx(buyerWallet, tokenAddress, buyAmountWei, buyNonce, gasPrice, gasLimit, chainId, txType, config.v2Path, chain, config.v2RouterAddress);
|
|
140
|
-
break;
|
|
141
|
-
case 'v3':
|
|
142
|
-
buyTx = await buildV3BuyTx(buyerWallet, tokenAddress, buyAmountWei, buyNonce, gasPrice, gasLimit, chainId, txType, config.v3Fee, chain);
|
|
143
|
-
break;
|
|
144
|
-
case 'daoaas':
|
|
145
|
-
buyTx = await buildDaoaasBuyTx(buyerWallet, tokenAddress, buyAmountWei, buyNonce, gasPrice, gasLimit, chainId);
|
|
146
|
-
break;
|
|
147
|
-
default:
|
|
148
|
-
throw new Error(`不支持的交易类型: ${tradeType}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
signedTxs.push(buyTx);
|
|
152
|
-
}
|
|
153
|
-
let profitHopWallets;
|
|
154
|
-
const profitAddr = getProfitRecipient();
|
|
155
|
-
if (profitPerBatch > 0n) {
|
|
156
|
-
if (needProfitHop) {
|
|
157
|
-
const profitHopResult = await buildProfitHopTransactions({ provider, payerWallet: payer, profitAmount: profitPerBatch, profitRecipient: profitAddr, hopCount: PROFIT_HOP_COUNT, gasPrice, chainId, txType, startNonce: payerNonces[payerNonceIdx] });
|
|
158
|
-
signedTxs.push(...profitHopResult.signedTransactions);
|
|
159
|
-
profitHopWallets = profitHopResult.hopWallets;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
const profitTx = await buildNativeTransferTx(payer, profitAddr, profitPerBatch, payerNonces[payerNonceIdx], gasPrice, chainId, txType);
|
|
163
|
-
signedTxs.push(profitTx);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return { batchIndex: batchIdx, success: true, signedTransactions: signedTxs, walletCount: batch.length, profitHopWallets };
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
return { batchIndex: batchIdx, success: false, error: error.message, walletCount: batch.length };
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
const batchResults = await Promise.all(batchPromises);
|
|
173
|
-
const allProfitHopWallets = [];
|
|
174
|
-
for (const res of batchResults) {
|
|
175
|
-
if (res.success && res.signedTransactions) {
|
|
176
|
-
result.signedTransactions.push(res.signedTransactions);
|
|
177
|
-
result.successBatchCount++;
|
|
178
|
-
if (res.profitHopWallets) {
|
|
179
|
-
allProfitHopWallets.push(...res.profitHopWallets);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
result.batchResults.push({
|
|
183
|
-
batchIndex: res.batchIndex,
|
|
184
|
-
success: res.success,
|
|
185
|
-
signedTransactions: res.signedTransactions,
|
|
186
|
-
error: res.error,
|
|
187
|
-
walletCount: res.walletCount,
|
|
188
|
-
disperseHopCount: effectiveDisperseHopCount,
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
if (allProfitHopWallets.length > 0) {
|
|
192
|
-
result.profitHopWallets = allProfitHopWallets;
|
|
193
|
-
}
|
|
194
|
-
result.disperseHopCount = effectiveDisperseHopCount;
|
|
195
|
-
result.success = result.successBatchCount > 0;
|
|
196
|
-
}
|
|
197
|
-
catch (error) {
|
|
198
|
-
result.error = error.message;
|
|
199
|
-
}
|
|
200
|
-
return result;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* 获取刷持有人预估费用
|
|
204
|
-
*/
|
|
205
|
-
export function estimateHoldersMakerCost(params) {
|
|
206
|
-
const { holdersCount, buyAmountPerHolder, baseToken = 'native', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI } = params;
|
|
207
|
-
const isERC20Mode = baseToken !== 'native';
|
|
208
|
-
const gasMultiplier = isERC20Mode ? 2 : 1;
|
|
209
|
-
const gasFeePerWallet = (gasLimit * gasPriceGwei * gasMultiplier) / 1e9;
|
|
210
|
-
const gasWithBuffer = gasFeePerWallet * GAS_BUFFER_MULTIPLIER;
|
|
211
|
-
const buyAmount = parseFloat(buyAmountPerHolder);
|
|
212
|
-
const maxPerBatch = isERC20Mode ? DEFAULT_MAX_WALLETS_PER_BATCH_ERC20 : DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE;
|
|
213
|
-
const batchCount = Math.ceil(holdersCount / maxPerBatch);
|
|
214
|
-
if (isERC20Mode) {
|
|
215
|
-
return { totalNativeCost: (gasWithBuffer * holdersCount).toFixed(6), totalERC20Cost: (buyAmount * holdersCount).toFixed(6), gasEstimate: (gasWithBuffer * holdersCount).toFixed(6), batchCount };
|
|
216
|
-
}
|
|
217
|
-
return { totalNativeCost: ((buyAmount + gasWithBuffer) * holdersCount).toFixed(6), gasEstimate: (gasWithBuffer * holdersCount).toFixed(6), batchCount };
|
|
218
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 刷持有人(Holders Maker)类型定义
|
|
3
|
-
*/
|
|
4
|
-
import type { GeneratedWallet } from '../wallet.js';
|
|
5
|
-
/** 链类型 */
|
|
6
|
-
export type HoldersMakerChain = 'BSC' | 'MONAD' | 'XLAYER' | 'ENI';
|
|
7
|
-
/** 交易类型 */
|
|
8
|
-
export type TradeType = 'four' | 'flap' | 'v2' | 'v3' | 'daoaas';
|
|
9
|
-
/** 基础代币类型 */
|
|
10
|
-
export type BaseTokenType = 'native' | 'usdt' | 'usdc';
|
|
11
|
-
/** 刷持有人配置 */
|
|
12
|
-
export type HoldersMakerConfig = {
|
|
13
|
-
rpcUrl: string;
|
|
14
|
-
chain?: HoldersMakerChain;
|
|
15
|
-
chainId?: number;
|
|
16
|
-
tradeType?: TradeType;
|
|
17
|
-
gasLimit?: number;
|
|
18
|
-
gasPriceGwei?: number;
|
|
19
|
-
bribeAmount?: number;
|
|
20
|
-
txType?: 0 | 2;
|
|
21
|
-
maxWalletsPerBatch?: number;
|
|
22
|
-
fourApiUrl?: string;
|
|
23
|
-
disperseHopCount?: number;
|
|
24
|
-
v2Path?: string[];
|
|
25
|
-
v3TokenIn?: string;
|
|
26
|
-
v3Fee?: number;
|
|
27
|
-
v3LpAddresses?: string[];
|
|
28
|
-
v3Tokens?: string[];
|
|
29
|
-
v2RouterAddress?: string;
|
|
30
|
-
};
|
|
31
|
-
/** 刷持有人参数 */
|
|
32
|
-
export type HoldersMakerParams = {
|
|
33
|
-
payerPrivateKey: string;
|
|
34
|
-
holdersCount: number;
|
|
35
|
-
buyAmountPerHolder: string;
|
|
36
|
-
tokenAddress: string;
|
|
37
|
-
baseToken?: BaseTokenType;
|
|
38
|
-
baseTokenAddress?: string;
|
|
39
|
-
baseTokenDecimals?: number;
|
|
40
|
-
config: HoldersMakerConfig;
|
|
41
|
-
};
|
|
42
|
-
/** 交易层级(用于按依赖顺序广播) */
|
|
43
|
-
export type TransactionLayer = {
|
|
44
|
-
name: string;
|
|
45
|
-
startIndex: number;
|
|
46
|
-
endIndex: number;
|
|
47
|
-
count: number;
|
|
48
|
-
};
|
|
49
|
-
/** 批次结果 */
|
|
50
|
-
export type BatchResult = {
|
|
51
|
-
batchIndex: number;
|
|
52
|
-
success: boolean;
|
|
53
|
-
signedTransactions?: string[];
|
|
54
|
-
txHashes?: string[];
|
|
55
|
-
error?: string;
|
|
56
|
-
walletCount: number;
|
|
57
|
-
transactionLayers?: TransactionLayer[];
|
|
58
|
-
disperseHopCount?: number;
|
|
59
|
-
};
|
|
60
|
-
/** 刷持有人结果 */
|
|
61
|
-
export type HoldersMakerResult = {
|
|
62
|
-
success: boolean;
|
|
63
|
-
newWallets: GeneratedWallet[];
|
|
64
|
-
disperseHopWallets?: GeneratedWallet[];
|
|
65
|
-
profitHopWallets?: GeneratedWallet[];
|
|
66
|
-
signedTransactions: string[][];
|
|
67
|
-
batchResults: BatchResult[];
|
|
68
|
-
successBatchCount: number;
|
|
69
|
-
totalBatchCount: number;
|
|
70
|
-
error?: string;
|
|
71
|
-
disperseHopCount?: number;
|
|
72
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { HoldersMakerChain, HoldersMakerTradeType, BaseTokenType, HoldersMakerConfig, HoldersMakerParams, TransactionLayer, BatchResult, HoldersMakerResult, } from '../shared/foundation/types/holders-maker.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { DexConfig, ChainDexConfig, LPInfo, InspectOptions } from './types.js';
|
|
2
|
-
export type { DexConfig, ChainDexConfig, PoolPairInfo, V3PoolInfo, DexPoolInfo, BestPoolInfo, LPPlatform, LPInfo, InspectOptions } from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* 从 Router 合约获取 Factory 地址
|
|
5
|
-
* 支持 Uniswap V2 Router 和 V3 SwapRouter02
|
|
6
|
-
*/
|
|
7
|
-
export declare function getFactoryFromRouter(routerAddress: string, rpcUrl: string, routerType?: 'v2' | 'v3'): Promise<{
|
|
8
|
-
v2Factory?: string;
|
|
9
|
-
v3Factory?: string;
|
|
10
|
-
}>;
|
|
11
|
-
/**
|
|
12
|
-
* 动态注册 DYORSwap(从 Router 获取 Factory)
|
|
13
|
-
*/
|
|
14
|
-
export declare function registerDYORSwap(rpcUrl: string): Promise<boolean>;
|
|
15
|
-
/** 注册新的 DEX */
|
|
16
|
-
export declare function registerDex(chain: string, dexKey: string, config: DexConfig): void;
|
|
17
|
-
/** 注册新的稳定币 */
|
|
18
|
-
export declare function registerStableCoin(chain: string, coin: {
|
|
19
|
-
address: string;
|
|
20
|
-
symbol: string;
|
|
21
|
-
decimals: number;
|
|
22
|
-
}): void;
|
|
23
|
-
/** 获取链配置(优先运行时配置) */
|
|
24
|
-
export declare function getChainConfig(chain: string): ChainDexConfig | undefined;
|
|
25
|
-
/** 获取支持的 DEX 列表 */
|
|
26
|
-
export declare function getSupportedDexes(chain: string): Array<{
|
|
27
|
-
key: string;
|
|
28
|
-
name: string;
|
|
29
|
-
enabled: boolean;
|
|
30
|
-
}>;
|
|
31
|
-
/** 获取支持的稳定币列表 */
|
|
32
|
-
export declare function getSupportedStableCoins(chain: string): Array<{
|
|
33
|
-
address: string;
|
|
34
|
-
symbol: string;
|
|
35
|
-
decimals: number;
|
|
36
|
-
}>;
|
|
37
|
-
/** 获取所有报价代币(包装原生 + 稳定币) */
|
|
38
|
-
export declare function getQuoteTokens(chain: string): Array<{
|
|
39
|
-
address: string;
|
|
40
|
-
symbol: string;
|
|
41
|
-
decimals: number;
|
|
42
|
-
isNative: boolean;
|
|
43
|
-
}>;
|
|
44
|
-
export declare function inspectTokenLP(token: string, opts: InspectOptions): Promise<LPInfo>;
|