four-flap-meme-sdk 1.9.44 → 1.9.46

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.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ENI BatchRouter — 发币+首买 (FairLaunch + BatchBuy)
3
+ *
4
+ * 原子化操作:在同一笔交易中完成 launchToken + V2/V3 batchBuy
5
+ */
6
+ import { type FairLaunchParamsForRouter } from './utils.js';
7
+ import type { BatchRouterConfig } from './types.js';
8
+ export interface FairLaunchAndBatchBuyParams extends BatchRouterConfig {
9
+ launcher?: string;
10
+ launchParams: FairLaunchParamsForRouter;
11
+ /** msg.value for launchToken (initialQuote when using native quote) */
12
+ launchValue: bigint;
13
+ router?: string;
14
+ token: string;
15
+ buyers: string[];
16
+ buyAmounts: bigint[];
17
+ }
18
+ export interface FairLaunchAndBatchBuyResult {
19
+ signedTx: string;
20
+ from: string;
21
+ nonce: number;
22
+ totalValue: bigint;
23
+ estimatedGas: bigint;
24
+ }
25
+ /**
26
+ * 公平发射 + V2 批量买入(原子化)
27
+ */
28
+ export declare function fairLaunchAndBatchBuyV2(params: FairLaunchAndBatchBuyParams & {
29
+ path?: string[];
30
+ }): Promise<FairLaunchAndBatchBuyResult>;
31
+ /**
32
+ * 公平发射 + V3 批量买入(原子化)
33
+ */
34
+ export declare function fairLaunchAndBatchBuyV3(params: FairLaunchAndBatchBuyParams & {
35
+ fee: number;
36
+ }): Promise<FairLaunchAndBatchBuyResult>;
37
+ export interface CreateAndBatchBuyParams extends BatchRouterConfig {
38
+ portal: string;
39
+ name: string;
40
+ symbol: string;
41
+ salt: string;
42
+ createValue: bigint;
43
+ token: string;
44
+ buyers: string[];
45
+ buyAmounts: bigint[];
46
+ }
47
+ /**
48
+ * DAOaaS 内盘发币 + 批量买入(原子化)
49
+ */
50
+ export declare function createAndBatchBuy(params: CreateAndBatchBuyParams): Promise<FairLaunchAndBatchBuyResult>;
@@ -0,0 +1,72 @@
1
+ /**
2
+ * ENI BatchRouter — 发币+首买 (FairLaunch + BatchBuy)
3
+ *
4
+ * 原子化操作:在同一笔交易中完成 launchToken + V2/V3 batchBuy
5
+ */
6
+ import { DSWAP_V2_ROUTER } from '../constants.js';
7
+ import { LP_FAIR_LAUNCHER_ADDRESS } from '../platforms/fair-launch/constants.js';
8
+ import { estimateGas } from './constants.js';
9
+ import { encodeFairLaunchAndBatchBuyV2, encodeFairLaunchAndBatchBuyV3, encodeCreateAndBatchBuy, buildBatchRouterTx, } from './utils.js';
10
+ const LAUNCH_EXTRA_GAS = 3000000n;
11
+ /**
12
+ * 公平发射 + V2 批量买入(原子化)
13
+ */
14
+ export async function fairLaunchAndBatchBuyV2(params) {
15
+ const { launcher = LP_FAIR_LAUNCHER_ADDRESS, launchParams, launchValue, router = DSWAP_V2_ROUTER, token, buyers, buyAmounts, } = params;
16
+ const totalBuyAmount = buyAmounts.reduce((a, b) => a + b, 0n);
17
+ const totalValue = launchValue + totalBuyAmount;
18
+ const calldata = encodeFairLaunchAndBatchBuyV2(launcher, launchParams, launchValue, router, token, buyers, buyAmounts);
19
+ const gasLimit = LAUNCH_EXTRA_GAS + estimateGas(buyers.length, 'v2');
20
+ const result = await buildBatchRouterTx({
21
+ rpcUrl: params.rpcUrl,
22
+ mainPrivateKey: params.mainPrivateKey,
23
+ batchRouterAddress: params.batchRouterAddress,
24
+ calldata,
25
+ value: totalValue,
26
+ gasLimit,
27
+ gasPrice: params.gasPrice,
28
+ });
29
+ return { ...result, totalValue, estimatedGas: gasLimit };
30
+ }
31
+ /**
32
+ * 公平发射 + V3 批量买入(原子化)
33
+ */
34
+ export async function fairLaunchAndBatchBuyV3(params) {
35
+ const { launcher = LP_FAIR_LAUNCHER_ADDRESS, launchParams, launchValue, router, token, fee, buyers, buyAmounts, } = params;
36
+ if (!router)
37
+ throw new Error('fairLaunchAndBatchBuyV3 requires router address');
38
+ const totalBuyAmount = buyAmounts.reduce((a, b) => a + b, 0n);
39
+ const totalValue = launchValue + totalBuyAmount;
40
+ const calldata = encodeFairLaunchAndBatchBuyV3(launcher, launchParams, launchValue, router, token, fee, buyers, buyAmounts);
41
+ const gasLimit = LAUNCH_EXTRA_GAS + estimateGas(buyers.length, 'v3');
42
+ const result = await buildBatchRouterTx({
43
+ rpcUrl: params.rpcUrl,
44
+ mainPrivateKey: params.mainPrivateKey,
45
+ batchRouterAddress: params.batchRouterAddress,
46
+ calldata,
47
+ value: totalValue,
48
+ gasLimit,
49
+ gasPrice: params.gasPrice,
50
+ });
51
+ return { ...result, totalValue, estimatedGas: gasLimit };
52
+ }
53
+ /**
54
+ * DAOaaS 内盘发币 + 批量买入(原子化)
55
+ */
56
+ export async function createAndBatchBuy(params) {
57
+ const { portal, name, symbol, salt, createValue, token, buyers, buyAmounts, } = params;
58
+ const totalBuyAmount = buyAmounts.reduce((a, b) => a + b, 0n);
59
+ const totalValue = createValue + totalBuyAmount;
60
+ const calldata = encodeCreateAndBatchBuy(portal, name, symbol, salt, createValue, token, buyers, buyAmounts);
61
+ const gasLimit = LAUNCH_EXTRA_GAS + estimateGas(buyers.length, 'portal');
62
+ const result = await buildBatchRouterTx({
63
+ rpcUrl: params.rpcUrl,
64
+ mainPrivateKey: params.mainPrivateKey,
65
+ batchRouterAddress: params.batchRouterAddress,
66
+ calldata,
67
+ value: totalValue,
68
+ gasLimit,
69
+ gasPrice: params.gasPrice,
70
+ });
71
+ return { ...result, totalValue, estimatedGas: gasLimit };
72
+ }
@@ -11,4 +11,5 @@ export { batchSellPortal, batchSellV2, batchSellV3 } from './bundle-sell.js';
11
11
  export { atomicSwapPortal, batchSwapPortal, atomicSwapV2, batchSwapV2, atomicSwapV3, batchSwapV3, type V3SwapParams, } from './bundle-swap.js';
12
12
  export { batchApprove } from './bundle-approve.js';
13
13
  export { washVolume, washVolumeV2, washVolumeV3, type WashVolumeParams, type WashVolumeResult, } from './volume.js';
14
+ export { fairLaunchAndBatchBuyV2, fairLaunchAndBatchBuyV3, createAndBatchBuy, type FairLaunchAndBatchBuyParams, type FairLaunchAndBatchBuyResult, type CreateAndBatchBuyParams, } from './bundle-launch.js';
14
15
  export { batchTransferEgas, batchTransferToken, batchSweepToken, batchSweepEgas, eniDisperseForSubmit, eniSweepForSubmit, type BatchTransferTokenParams, type BatchSweepTokenParams, type BatchSweepTokenResult, type BatchSweepEgasParams, type EniDisperseParams, type EniDisperseResult, type EniSweepParams, type EniSweepResult, } from './transfer.js';
@@ -41,4 +41,5 @@ export { batchSellPortal, batchSellV2, batchSellV3 } from './bundle-sell.js';
41
41
  export { atomicSwapPortal, batchSwapPortal, atomicSwapV2, batchSwapV2, atomicSwapV3, batchSwapV3, } from './bundle-swap.js';
42
42
  export { batchApprove } from './bundle-approve.js';
43
43
  export { washVolume, washVolumeV2, washVolumeV3, } from './volume.js';
44
+ export { fairLaunchAndBatchBuyV2, fairLaunchAndBatchBuyV3, createAndBatchBuy, } from './bundle-launch.js';
44
45
  export { batchTransferEgas, batchTransferToken, batchSweepToken, batchSweepEgas, eniDisperseForSubmit, eniSweepForSubmit, } from './transfer.js';
package/dist/index.d.ts CHANGED
@@ -73,7 +73,8 @@ export type { LaunchParams as EniLaunchParams, FairLaunchTokenInfo as EniFairLau
73
73
  export { FairPoolQuery as EniFairPoolQuery, claimFromPool as eniClaimFromPool, claimFromPoolForSubmit as eniClaimFromPoolForSubmit, batchClaimForSubmit as eniBatchClaimForSubmit, } from './chains/eni/index.js';
74
74
  export type { PoolOverview as EniPoolOverview, PoolClaimParams as EniPoolClaimParams, PoolClaimResult as EniPoolClaimResult, } from './chains/eni/index.js';
75
75
  export { batchBuyPortal as eniBatchBuyPortal, batchBuyV2 as eniBatchBuyV2, batchSellPortal as eniBatchSellPortal, batchSellV2 as eniBatchSellV2, atomicSwapPortal as eniAtomicSwapPortal, batchSwapPortal as eniBatchSwapPortal, atomicSwapV2 as eniAtomicSwapV2, batchSwapV2 as eniBatchSwapV2, batchApprove as eniBatchApprove, washVolume as eniWashVolume, washVolumeV2 as eniWashVolumeV2, batchTransferEgas as eniBatchTransferEgas, batchTransferToken as eniBatchTransferToken, batchSweepToken as eniBatchSweepToken, batchSweepEgas as eniBatchSweepEgas, eniDisperseForSubmit, eniSweepForSubmit, validateBatchParams as eniValidateBatchParams, encodeBatchBuy as eniEncodeBatchBuy, encodeBatchSell as eniEncodeBatchSell, encodeAtomicSwap as eniEncodeAtomicSwap, encodeBatchSwap as eniEncodeBatchSwap, encodeAtomicSwapV2 as eniEncodeAtomicSwapV2, encodeBatchSwapV2 as eniEncodeBatchSwapV2, encodeBatchTransfer as eniEncodeBatchTransfer, encodeBatchSweepToken as eniEncodeBatchSweepToken, buildBatchRouterTx as eniBuildBatchRouterTx, estimateGas as eniEstimateGas, BATCH_ROUTER_ADDRESS as ENI_BATCH_ROUTER_ADDRESS, BATCH_ROUTER_ABI as ENI_BATCH_ROUTER_ABI, MAX_BATCH_SIZE as ENI_MAX_BATCH_SIZE, } from './chains/eni/batch-router/index.js';
76
- export type { BatchRouterConfig as EniBatchRouterConfig, BatchBuyParams as EniBatchBuyParams, BatchBuyResult as EniBatchBuyResult, BatchSellParams as EniBatchSellParams, BatchSellResult as EniBatchSellResult, AtomicSwapParams as EniAtomicSwapParams, AtomicSwapResult as EniAtomicSwapResult, BatchApproveParams as EniBatchApproveParams, BatchApproveResult as EniBatchApproveResult, BatchTransferParams as EniBatchTransferParams, BatchTransferResult as EniBatchTransferResult, WashVolumeParams as EniWashVolumeParams, WashVolumeResult as EniWashVolumeResult, BatchSweepTokenParams as EniBatchSweepTokenParams, BatchSweepTokenResult as EniBatchSweepTokenResult, BatchSweepEgasParams as EniBatchSweepEgasParams, BatchTransferTokenParams as EniBatchTransferTokenParams, EniDisperseParams, EniDisperseResult, EniSweepParams, EniSweepResult, } from './chains/eni/batch-router/index.js';
76
+ export type { BatchRouterConfig as EniBatchRouterConfig, BatchBuyParams as EniBatchBuyParams, BatchBuyResult as EniBatchBuyResult, BatchSellParams as EniBatchSellParams, BatchSellResult as EniBatchSellResult, AtomicSwapParams as EniAtomicSwapParams, AtomicSwapResult as EniAtomicSwapResult, BatchApproveParams as EniBatchApproveParams, BatchApproveResult as EniBatchApproveResult, BatchTransferParams as EniBatchTransferParams, BatchTransferResult as EniBatchTransferResult, WashVolumeParams as EniWashVolumeParams, WashVolumeResult as EniWashVolumeResult, BatchSweepTokenParams as EniBatchSweepTokenParams, BatchSweepTokenResult as EniBatchSweepTokenResult, BatchSweepEgasParams as EniBatchSweepEgasParams, BatchTransferTokenParams as EniBatchTransferTokenParams, EniDisperseParams, EniDisperseResult, EniSweepParams, EniSweepResult, FairLaunchAndBatchBuyParams as EniFairLaunchAndBatchBuyParams, FairLaunchAndBatchBuyResult as EniFairLaunchAndBatchBuyResult, CreateAndBatchBuyParams as EniCreateAndBatchBuyParams, } from './chains/eni/batch-router/index.js';
77
+ export type { FairLaunchParamsForRouter, } from './chains/eni/batch-router/utils.js';
77
78
  export { getLPPairInfo as eniGetLPPairInfo, batchGetLPPairInfo as eniBatchGetLPPairInfo, getPairAddress as eniGetPairAddress, addLiquidityETHForSubmit as eniAddLiquidityETHForSubmit, removeLiquidityETHForSubmit as eniRemoveLiquidityETHForSubmit, addLiquidityForSubmit as eniAddLiquidityForSubmit, removeLiquidityForSubmit as eniRemoveLiquidityForSubmit, } from './chains/eni/index.js';
78
79
  export type { LPPairInfo as EniLPPairInfo, GetLPInfoParams as EniGetLPInfoParams, AddLiquidityETHParams as EniAddLiquidityETHParams, RemoveLiquidityETHParams as EniRemoveLiquidityETHParams, AddLiquidityParams as EniAddLiquidityParams, RemoveLiquidityParams as EniRemoveLiquidityParams, LiquidityForSubmitResult as EniLiquidityForSubmitResult, } from './chains/eni/index.js';
79
80
  export { EniIroFactoryQuery, eniIroEncodeCreateProjectCall, eniIroCreateProject, eniIroParseCreateProjectEvent, EniIroTokenQuery, eniIroSubscribe, eniIroPledge, eniIroBatchSubscribe, eniIroBatchSubscribeForSubmit, EniIroPoolQuery, eniIroPoolRemovePledge, eniIroPoolExtract, eniIroPoolTransferAwards, eniIroBatchExtract, ENI_IRO_FACTORY_ADDRESS, ENI_IRO_OWNER_ADDRESS, ENI_IRO_SELL_FEE_CONTRACT, ENI_IROSWAP_V2_ROUTER, ENI_IROSWAP_V2_FACTORY, ENI_IRO_FACTORY_ABI, ENI_IRO_TOKEN_ABI, ENI_IRO_POOL_ABI, ENI_IRO_PLATFORM_URL, setEniIroApiBase, eniIroApiCreateProject, eniIroApiUploadImage, eniIroGetTokenWhiteList, eniIroAddTokenWhiteListForSubmit, eniIroBatchAddTokenWhiteListForSubmit, eniIroRemoveTokenWhiteListForSubmit, ENI_IRO_OWNER_WHITELIST_ABI, } from './chains/eni/index.js';
@@ -48,6 +48,8 @@ export type HoldersMakerConfig = {
48
48
  v3Tokens?: string[];
49
49
  /** 自定义 V2 Router 地址(如 IROSwap),不传则使用 PancakeSwap */
50
50
  v2RouterAddress?: string;
51
+ /** ENI 链使用 BatchRouter 合约模式(跳过分发,合约代买) */
52
+ useBatchRouter?: boolean;
51
53
  };
52
54
  /** 刷持有人参数 */
53
55
  export type HoldersMakerParams = {
@@ -12,6 +12,8 @@ import { ADDRESSES, BLOCKRAZOR_BUILDER_EOA, PROFIT_CONFIG } from './constants.js
12
12
  import { GAS_LIMITS } from '../shared/constants/index.js';
13
13
  import { FLAP_PORTAL_ADDRESSES } from '../shared/flap/constants.js';
14
14
  import { V2_ROUTER_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, ERC20_ABI } from '../shared/abis/common.js';
15
+ import { batchBuyPortal, batchBuyV2 } from '../chains/eni/batch-router/bundle-buy.js';
16
+ import { BATCH_ROUTER_ADDRESS } from '../chains/eni/batch-router/constants.js';
15
17
  // Four 内盘 ABI
16
18
  const FOUR_TM2_ABI = [
17
19
  'function buyTokenAMAP(uint256 origin, address token, address to, uint256 funds, uint256 minAmount) payable'
@@ -663,8 +665,11 @@ export async function holdersMaker(params) {
663
665
  // ✅ 根据分发多跳数动态计算每批最大钱包数
664
666
  // XLayer 强制禁用分发多跳(ENI 已支持前端分层广播)
665
667
  const effectiveDisperseHopCount = chain === 'XLAYER' ? 0 : disperseHopCount;
666
- const maxWalletsPerBatch = config.maxWalletsPerBatch ||
667
- calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain);
668
+ const isEniBatchRouterMode = chain === 'ENI' && config.useBatchRouter === true
669
+ && (tradeType === 'v2' || tradeType === 'daoaas') && !isERC20Mode;
670
+ const maxWalletsPerBatch = isEniBatchRouterMode
671
+ ? (config.maxWalletsPerBatch || 35)
672
+ : (config.maxWalletsPerBatch || calculateMaxWalletsPerBatch(isERC20Mode, effectiveDisperseHopCount, chain));
668
673
  console.log(`[HoldersMaker] chain: ${chain}, 分发多跳数: ${effectiveDisperseHopCount}, 每批最大钱包数: ${maxWalletsPerBatch}`);
669
674
  try {
670
675
  // 1. 初始化
@@ -736,9 +741,41 @@ export async function holdersMaker(params) {
736
741
  const needProfitHop = !isSimpleChain;
737
742
  const effectiveProfitHopCount = needProfitHop ? PROFIT_HOP_COUNT : 0;
738
743
  // 7. 并行生成所有批次的签名
744
+ const useEniBatchRouter = chain === 'ENI' && config.useBatchRouter === true
745
+ && (tradeType === 'v2' || tradeType === 'daoaas') && !isERC20Mode;
739
746
  const batchPromises = walletBatches.map(async (batch, batchIdx) => {
740
747
  try {
741
748
  const signedTxs = [];
749
+ // ENI BatchRouter 模式:1笔 batchBuy + 1笔利润,无需分发
750
+ if (useEniBatchRouter) {
751
+ const buyerAddrs = batch.map(w => w.address);
752
+ const amounts = batch.map(() => buyAmountWei);
753
+ const batchFn = tradeType === 'daoaas' ? batchBuyPortal : batchBuyV2;
754
+ const batchParams = {
755
+ rpcUrl,
756
+ mainPrivateKey: payerPrivateKey,
757
+ batchRouterAddress: BATCH_ROUTER_ADDRESS,
758
+ target: tradeType === 'daoaas' ? ENI_DAOAAS_PORTAL_ADDRESS : (config.v2RouterAddress || ENI_V2_ROUTER_ADDRESS),
759
+ token: tokenAddress,
760
+ buyers: buyerAddrs,
761
+ amounts,
762
+ };
763
+ if (tradeType === 'v2')
764
+ batchParams.router = config.v2RouterAddress || ENI_V2_ROUTER_ADDRESS;
765
+ const buyResult = await batchFn(batchParams);
766
+ signedTxs.push(buyResult.signedTx);
767
+ // 利润交易 (nonce = batchBuy nonce + 1)
768
+ if (profitPerBatch > 0n) {
769
+ const profitTx = await buildNativeTransferTx(payer, PROFIT_CONFIG.RECIPIENT, profitPerBatch, buyResult.nonce + 1, gasPrice, chainId, txType);
770
+ signedTxs.push(profitTx);
771
+ }
772
+ return {
773
+ batchIndex: batchIdx,
774
+ success: true,
775
+ signedTransactions: signedTxs,
776
+ walletCount: batch.length,
777
+ };
778
+ }
742
779
  // 计算这批需要的 payer nonce 数量
743
780
  // XLayer: 分发 N + 买入后利润 1
744
781
  // BSC 原生模式(无多跳): 贿赂 1 + 分发 N + 利润 (PROFIT_HOP_COUNT + 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "1.9.44",
3
+ "version": "1.9.46",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",