four-flap-meme-sdk 1.4.41 → 1.4.43
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/utils/holders-maker.d.ts +12 -2
- package/dist/utils/holders-maker.js +93 -17
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ import { type GeneratedWallet } from './wallet.js';
|
|
|
9
9
|
/** 链类型 */
|
|
10
10
|
export type HoldersMakerChain = 'BSC' | 'MONAD';
|
|
11
11
|
/** 交易类型 */
|
|
12
|
-
export type TradeType = 'four' | 'flap';
|
|
12
|
+
export type TradeType = 'four' | 'flap' | 'v2' | 'v3';
|
|
13
13
|
/** 基础代币类型 */
|
|
14
14
|
export type BaseTokenType = 'native' | 'usdt' | 'usdc';
|
|
15
15
|
/** 刷持有人配置 */
|
|
@@ -20,7 +20,7 @@ export type HoldersMakerConfig = {
|
|
|
20
20
|
chain?: HoldersMakerChain;
|
|
21
21
|
/** 链 ID(可选,不传则自动获取) */
|
|
22
22
|
chainId?: number;
|
|
23
|
-
/** 交易类型(four
|
|
23
|
+
/** 交易类型(four/flap=内盘, v2/v3=外盘) */
|
|
24
24
|
tradeType?: TradeType;
|
|
25
25
|
/** Gas Limit */
|
|
26
26
|
gasLimit?: number;
|
|
@@ -36,6 +36,16 @@ export type HoldersMakerConfig = {
|
|
|
36
36
|
fourApiUrl?: string;
|
|
37
37
|
/** ✅ 多跳数量(0=不多跳,1-10=经过N个中转钱包) */
|
|
38
38
|
hopCount?: number;
|
|
39
|
+
/** V2 路由路径(如 [WBNB, TOKEN]) */
|
|
40
|
+
v2Path?: string[];
|
|
41
|
+
/** V3 单跳输入代币 */
|
|
42
|
+
v3TokenIn?: string;
|
|
43
|
+
/** V3 单跳手续费(100=0.01%, 500=0.05%, 2500=0.25%, 10000=1%) */
|
|
44
|
+
v3Fee?: number;
|
|
45
|
+
/** V3 多跳 LP 地址列表 */
|
|
46
|
+
v3LpAddresses?: string[];
|
|
47
|
+
/** V3 多跳代币路径 */
|
|
48
|
+
v3Tokens?: string[];
|
|
39
49
|
};
|
|
40
50
|
/** 刷持有人参数 */
|
|
41
51
|
export type HoldersMakerParams = {
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
import { JsonRpcProvider } from 'ethers';
|
|
9
9
|
import { generateWallets } from './wallet.js';
|
|
10
10
|
import { disperseWithBundleMerkle } from '../contracts/tm-bundle-merkle/utils.js';
|
|
11
|
-
import { batchBuyWithBundleMerkle } from '../contracts/tm-bundle-merkle/core.js';
|
|
11
|
+
import { batchBuyWithBundleMerkle as fourBatchBuy } from '../contracts/tm-bundle-merkle/core.js';
|
|
12
|
+
import { batchBuyWithBundleMerkle as flapBatchBuy } from '../flap/portal-bundle-merkle/core.js';
|
|
13
|
+
import { pancakeProxyBatchBuyMerkle } from '../flap/portal-bundle-merkle/pancake-proxy.js';
|
|
12
14
|
import { approveTokenBatch } from './erc20.js';
|
|
13
15
|
// ============================================================================
|
|
14
16
|
// 常量
|
|
@@ -47,8 +49,9 @@ function chunkArray(arr, size) {
|
|
|
47
49
|
*/
|
|
48
50
|
export async function holdersMaker(params) {
|
|
49
51
|
const { payerPrivateKey, holdersCount, buyAmountPerHolder, tokenAddress, baseToken = 'native', baseTokenAddress, baseTokenDecimals = 18, config } = params;
|
|
50
|
-
const { rpcUrl, chain = 'BSC', chainId: configChainId, tradeType = 'four', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, bribeAmount = 0.000001, txType = 0, maxWalletsPerBatch = DEFAULT_MAX_WALLETS_PER_BATCH, fourApiUrl, hopCount = 0 // ✅ 多跳数量,默认不多跳
|
|
51
|
-
|
|
52
|
+
const { rpcUrl, chain = 'BSC', chainId: configChainId, tradeType = 'four', gasLimit = DEFAULT_GAS_LIMIT, gasPriceGwei = DEFAULT_GAS_PRICE_GWEI, bribeAmount = 0.000001, txType = 0, maxWalletsPerBatch = DEFAULT_MAX_WALLETS_PER_BATCH, fourApiUrl, hopCount = 0, // ✅ 多跳数量,默认不多跳
|
|
53
|
+
// ✅ V2/V3 外盘路由参数
|
|
54
|
+
v2Path, v3TokenIn, v3Fee, v3LpAddresses, v3Tokens } = config;
|
|
52
55
|
const result = {
|
|
53
56
|
success: false,
|
|
54
57
|
newWallets: [],
|
|
@@ -204,11 +207,15 @@ export async function holdersMaker(params) {
|
|
|
204
207
|
// ✅ 阶段3:并行生成授权签名(每批内也是并行)
|
|
205
208
|
// ============================================================
|
|
206
209
|
console.log(`[HoldersMaker] 阶段3: 并行生成 ${walletBatches.length} 批授权签名...`);
|
|
210
|
+
// ✅ 转换 tradeType 为 approveTokenBatch 支持的 platform 格式
|
|
211
|
+
const approvePlatform = tradeType === 'v2' ? 'pancake-v2'
|
|
212
|
+
: tradeType === 'v3' ? 'pancake-v3'
|
|
213
|
+
: tradeType;
|
|
207
214
|
const approvePromises = walletBatches.map(async (batch, batchIdx) => {
|
|
208
215
|
try {
|
|
209
216
|
const approveResult = await approveTokenBatch({
|
|
210
217
|
chain: chain,
|
|
211
|
-
platform:
|
|
218
|
+
platform: approvePlatform,
|
|
212
219
|
rpcUrl,
|
|
213
220
|
privateKeys: batch.map(w => w.privateKey),
|
|
214
221
|
tokenAddress: baseTokenAddress,
|
|
@@ -257,19 +264,88 @@ export async function holdersMaker(params) {
|
|
|
257
264
|
console.log(`[HoldersMaker] 阶段4: 并行生成 ${walletBatches.length} 批买入签名...`);
|
|
258
265
|
const buyPromises = walletBatches.map(async (batch, batchIdx) => {
|
|
259
266
|
try {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
let buyResult;
|
|
268
|
+
if (tradeType === 'flap') {
|
|
269
|
+
// ✅ Flap 内盘:支持原生代币和 ERC20
|
|
270
|
+
buyResult = await flapBatchBuy({
|
|
271
|
+
chain: chain,
|
|
272
|
+
privateKeys: batch.map(w => w.privateKey),
|
|
273
|
+
buyAmounts: batch.map(() => buyAmountPerHolder),
|
|
274
|
+
tokenAddress,
|
|
275
|
+
quoteToken: isNativeBase ? undefined : baseTokenAddress,
|
|
276
|
+
quoteTokenDecimals: isNativeBase ? undefined : baseTokenDecimals,
|
|
277
|
+
config: {
|
|
278
|
+
rpcUrl,
|
|
279
|
+
gasLimit,
|
|
280
|
+
minGasPriceGwei: gasPriceGwei,
|
|
281
|
+
txType,
|
|
282
|
+
bribeAmount
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
else if (tradeType === 'v2') {
|
|
287
|
+
// ✅ PancakeSwap V2 外盘
|
|
288
|
+
buyResult = await pancakeProxyBatchBuyMerkle({
|
|
289
|
+
chain: chain,
|
|
290
|
+
privateKeys: batch.map(w => w.privateKey),
|
|
291
|
+
buyAmounts: batch.map(() => buyAmountPerHolder),
|
|
292
|
+
tokenAddress,
|
|
293
|
+
routeType: 'v2',
|
|
294
|
+
v2Path: v2Path,
|
|
295
|
+
quoteToken: isNativeBase ? undefined : baseTokenAddress,
|
|
296
|
+
quoteTokenDecimals: isNativeBase ? undefined : baseTokenDecimals,
|
|
297
|
+
config: {
|
|
298
|
+
rpcUrl,
|
|
299
|
+
gasLimit,
|
|
300
|
+
minGasPriceGwei: gasPriceGwei,
|
|
301
|
+
txType,
|
|
302
|
+
bribeAmount
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
else if (tradeType === 'v3') {
|
|
307
|
+
// ✅ PancakeSwap V3 外盘
|
|
308
|
+
const hasMultiHop = v3LpAddresses && v3LpAddresses.length > 0;
|
|
309
|
+
buyResult = await pancakeProxyBatchBuyMerkle({
|
|
310
|
+
chain: chain,
|
|
311
|
+
privateKeys: batch.map(w => w.privateKey),
|
|
312
|
+
buyAmounts: batch.map(() => buyAmountPerHolder),
|
|
313
|
+
tokenAddress,
|
|
314
|
+
routeType: hasMultiHop ? 'v3-multi' : 'v3-single',
|
|
315
|
+
v3TokenIn: v3TokenIn,
|
|
316
|
+
v3Fee: v3Fee,
|
|
317
|
+
v3LpAddresses: v3LpAddresses,
|
|
318
|
+
v3Tokens: v3Tokens,
|
|
319
|
+
quoteToken: isNativeBase ? undefined : baseTokenAddress,
|
|
320
|
+
quoteTokenDecimals: isNativeBase ? undefined : baseTokenDecimals,
|
|
321
|
+
config: {
|
|
322
|
+
rpcUrl,
|
|
323
|
+
gasLimit,
|
|
324
|
+
minGasPriceGwei: gasPriceGwei,
|
|
325
|
+
txType,
|
|
326
|
+
bribeAmount
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
// ✅ Four 内盘:仅支持原生代币(BNB)
|
|
332
|
+
if (!isNativeBase) {
|
|
333
|
+
throw new Error('Four 内盘仅支持原生代币(BNB)购买,不支持 USDT/USDC');
|
|
271
334
|
}
|
|
272
|
-
|
|
335
|
+
buyResult = await fourBatchBuy({
|
|
336
|
+
privateKeys: batch.map(w => w.privateKey),
|
|
337
|
+
buyAmounts: batch.map(() => buyAmountPerHolder),
|
|
338
|
+
tokenAddress,
|
|
339
|
+
config: {
|
|
340
|
+
rpcUrl,
|
|
341
|
+
gasLimit,
|
|
342
|
+
minGasPriceGwei: gasPriceGwei,
|
|
343
|
+
txType,
|
|
344
|
+
bribeAmount,
|
|
345
|
+
fourApiUrl
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
273
349
|
return {
|
|
274
350
|
batchIndex: batchIdx,
|
|
275
351
|
success: true,
|
|
@@ -326,7 +402,7 @@ export function estimateHoldersMakerCost(params) {
|
|
|
326
402
|
// ✅ 多跳需要额外的 Gas 费用(每跳一次需要一笔转账)
|
|
327
403
|
// 原生代币多跳:每跳 21000 gas
|
|
328
404
|
// ERC20 多跳:每跳 65000 gas
|
|
329
|
-
const hopGasPerTransfer = isNativeBase ?
|
|
405
|
+
const hopGasPerTransfer = isNativeBase ? 21055 : 65000;
|
|
330
406
|
const hopGasCost = (hopGasPerTransfer * gasPriceGwei * hopCount) / 1e9;
|
|
331
407
|
// 每个钱包的原生代币成本(包含多跳 Gas)
|
|
332
408
|
const nativePerWallet = isNativeBase
|