four-flap-meme-sdk 2.2.3 → 2.2.5

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.
@@ -9,7 +9,21 @@ import { MULTICALL3_ABI } from '../../abis/common.js';
9
9
  import { FLAP_PORTAL_ADDRESSES, FLAP_ORIGINAL_PORTAL_ADDRESSES } from '../constants.js';
10
10
  import { normalizeTaxLaunchConfig, populateCreateTokenTransaction, } from '../portal-create-token.js';
11
11
  import { CHAIN_ID_MAP, PORTAL_ABI, getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, } from './config.js';
12
+ import { MigratorType } from '../portal.js';
12
13
  import { MULTICALL3_ADDRESS, getGasLimit, getTokenToNativeQuote } from './core-helpers.js';
14
+ function resolveCreateTokenLaunchFlags(params) {
15
+ const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
16
+ const isTaxLaunch = !!normalizedTax || (params.taxRate ?? 0) > 0;
17
+ const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
18
+ const useV4Portal = !isTaxLaunch &&
19
+ !hasVault &&
20
+ (params.lpFeeProfile !== undefined || params.dexId !== undefined);
21
+ const useClInfinityLaunch = !isTaxLaunch &&
22
+ !hasVault &&
23
+ !useV4Portal &&
24
+ params.migratorType === MigratorType.PCS_INFINITY_CL_MIGRATOR;
25
+ return { normalizedTax, isTaxLaunch, hasVault, useV4Portal, useClInfinityLaunch };
26
+ }
13
27
  export async function createTokenWithBundleBuyMerkle(params) {
14
28
  const { chain, privateKeys, buyAmounts, tokenInfo, tokenAddress, config } = params;
15
29
  if (privateKeys.length === 0) {
@@ -25,12 +39,7 @@ export async function createTokenWithBundleBuyMerkle(params) {
25
39
  const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
26
40
  const originalPortalAddr = FLAP_ORIGINAL_PORTAL_ADDRESSES[chain];
27
41
  const portal = new ethers.Contract(originalPortalAddr, PORTAL_ABI, devWallet);
28
- const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
29
- const isTaxLaunch = !!normalizedTax || (params.taxRate ?? 0) > 0;
30
- const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
31
- const useV3Standard = !isTaxLaunch &&
32
- !hasVault &&
33
- (params.lpFeeProfile !== undefined || params.dexId !== undefined);
42
+ const { normalizedTax, useV4Portal, useClInfinityLaunch } = resolveCreateTokenLaunchFlags(params);
34
43
  const createTxPromise = populateCreateTokenTransaction({
35
44
  chain,
36
45
  devWallet,
@@ -46,7 +55,8 @@ export async function createTokenWithBundleBuyMerkle(params) {
46
55
  lpFeeProfile: params.lpFeeProfile,
47
56
  extensionID: params.extensionID,
48
57
  extensionData: params.extensionData,
49
- useV3Standard,
58
+ useV4Portal,
59
+ useClInfinityLaunch,
50
60
  taxConfig: normalizedTax,
51
61
  });
52
62
  const [gasPrice, createTxUnsigned, devNonce] = await Promise.all([
@@ -66,7 +76,9 @@ export async function createTokenWithBundleBuyMerkle(params) {
66
76
  const signedCreateTx = await devWallet.signTransaction(createTxRequest);
67
77
  signedTxs.push(signedCreateTx);
68
78
  const buyers = createWallets(privateKeys.slice(1), provider);
69
- const extractProfit = shouldExtractProfit();
79
+ // 发币+捆绑买:默认刮利润(与 emitservice isAddressRevenue 末笔校验、BSC 白名单 slice(-3) 对齐)
80
+ // 仅当显式 extractProfitOnLaunch: false 时关闭(需后端同步放宽校验)
81
+ const extractProfit = config.extractProfitOnLaunch === false ? false : shouldExtractProfit(config);
70
82
  const { fundsList, originalAmounts, totalBuyAmount, totalProfit } = analyzeBuyFunds(buyAmounts, config, extractProfit);
71
83
  const maxFundsIndex = findMaxIndex(originalAmounts);
72
84
  const gasLimits = buildGasLimitList(buyers.length, config);
@@ -11,6 +11,7 @@ import { ethers, Contract, Wallet } from 'ethers';
11
11
  import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
12
12
  import { FLAP_PORTAL_ADDRESSES, FLAP_ORIGINAL_PORTAL_ADDRESSES } from '../constants.js';
13
13
  import { normalizeTaxLaunchConfig, populateCreateTokenTransaction, } from '../portal-create-token.js';
14
+ import { MigratorType } from '../portal.js';
14
15
  import { ZERO_ADDRESS } from '../../../shared/constants/index.js';
15
16
  import { GAS_LIMITS } from '../../constants/index.js';
16
17
  import { getGasPriceConfig, getTxType, getProfitRecipient, getProfitRateBps, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI, } from './config.js';
@@ -308,9 +309,13 @@ export async function flapBundleCreateToDex(params) {
308
309
  const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
309
310
  const isTaxLaunch = !!normalizedTax || (params.taxRate ?? 0) > 0;
310
311
  const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
311
- const useV3Standard = !isTaxLaunch &&
312
+ const useV4Portal = !isTaxLaunch &&
312
313
  !hasVault &&
313
314
  (params.lpFeeProfile !== undefined || params.dexId !== undefined);
315
+ const useClInfinityLaunch = !isTaxLaunch &&
316
+ !hasVault &&
317
+ !useV4Portal &&
318
+ params.migratorType === MigratorType.PCS_INFINITY_CL_MIGRATOR;
314
319
  const createUnsigned = await populateCreateTokenTransaction({
315
320
  chain,
316
321
  devWallet,
@@ -326,7 +331,8 @@ export async function flapBundleCreateToDex(params) {
326
331
  lpFeeProfile: params.lpFeeProfile,
327
332
  extensionID: params.extensionID,
328
333
  extensionData: params.extensionData,
329
- useV3Standard,
334
+ useV4Portal,
335
+ useClInfinityLaunch,
330
336
  taxConfig: normalizedTax,
331
337
  });
332
338
  const createTx = {
@@ -55,6 +55,11 @@ export type FlapSignConfig = {
55
55
  gasPrice?: bigint;
56
56
  bribeAmount?: number;
57
57
  profitMode?: FlapProfitMode;
58
+ /**
59
+ * 发币+捆绑买是否刮利润(默认 true,与 emitservice 提交校验对齐)。
60
+ * 设为 false 时不追加利润多跳,需后端允许末笔为 Portal 买入。
61
+ */
62
+ extractProfitOnLaunch?: boolean;
58
63
  };
59
64
  export type FlapBundleMerkleConfig = {
60
65
  apiKey: string;
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * 对齐 Flap 官方文档:
5
5
  * - newTokenV6:TOKEN_V2_PERMIT / TOKEN_TAXED_V3
6
- * - newTokenV7:TOKEN_V3_PERMITCL 迁移)
6
+ * - newTokenV4:标准 V3Pancake V3 费率 / dexId,与 CREATE2 vanity 一致)
7
+ * - newTokenV7:TOKEN_V3_PERMIT(PCS Infinity CL,需显式 migratorType=3)
7
8
  * - VaultPortal.newTaxTokenWithVault:带金库的税币(legacy 参数结构)
8
9
  */
9
10
  import { Contract, type Wallet } from 'ethers';
@@ -44,8 +45,10 @@ export type PopulateCreateTokenParams = {
44
45
  lpFeeProfile?: number;
45
46
  extensionID?: string;
46
47
  extensionData?: string;
47
- /** 标准 V3 代币(newTokenV7 + TOKEN_V3_PERMIT) */
48
- useV3Standard?: boolean;
48
+ /** 标准 V3 Pancake(newTokenV4 + lpFeeProfile/dexId,对齐 Portal 文档与 vanity) */
49
+ useV4Portal?: boolean;
50
+ /** PCS Infinity CL(newTokenV7,仅 migratorType=PCS_INFINITY_CL_MIGRATOR 时启用) */
51
+ useClInfinityLaunch?: boolean;
49
52
  /** 高级税币 / 税币 V3 配置 */
50
53
  taxConfig?: NormalizedTaxLaunchConfig;
51
54
  };
@@ -3,7 +3,8 @@
3
3
  *
4
4
  * 对齐 Flap 官方文档:
5
5
  * - newTokenV6:TOKEN_V2_PERMIT / TOKEN_TAXED_V3
6
- * - newTokenV7:TOKEN_V3_PERMITCL 迁移)
6
+ * - newTokenV4:标准 V3Pancake V3 费率 / dexId,与 CREATE2 vanity 一致)
7
+ * - newTokenV7:TOKEN_V3_PERMIT(PCS Infinity CL,需显式 migratorType=3)
7
8
  * - VaultPortal.newTaxTokenWithVault:带金库的税币(legacy 参数结构)
8
9
  */
9
10
  import { Contract, ZeroAddress } from 'ethers';
@@ -151,8 +152,28 @@ export async function populateCreateTokenTransaction(params) {
151
152
  sellTaxRate,
152
153
  }, { mktBps: 10000, deflationBps: 0, dividendBps: 0, lpBps: 0 }));
153
154
  }
154
- // 3) 标准 V3(newTokenV7 + TOKEN_V3_PERMIT)
155
- if (params.useV3Standard) {
155
+ // 3) 标准 V3 PancakenewTokenV4 与 memeweb 2.2.2 / CREATE2 vanity 一致)
156
+ if (params.useV4Portal) {
157
+ return params.originalPortal.newTokenV4.populateTransaction({
158
+ name: params.tokenInfo.name,
159
+ symbol: params.tokenInfo.symbol,
160
+ meta: params.tokenInfo.meta,
161
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
162
+ salt: params.salt ?? zeroBytes32(),
163
+ taxRate: (params.taxRate ?? 0) & 0xffff,
164
+ migratorType: (params.migratorType ?? MigratorType.V3_MIGRATOR) & 0xff,
165
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
166
+ quoteAmt: 0n,
167
+ beneficiary: params.beneficiary,
168
+ permitData: '0x',
169
+ extensionID: params.extensionID ?? zeroBytes32(),
170
+ extensionData: params.extensionData ?? '0x',
171
+ dexId: (params.dexId ?? 0) & 0xff,
172
+ lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff,
173
+ });
174
+ }
175
+ // 4) PCS Infinity CL(newTokenV7,仅显式 CL 迁移时)
176
+ if (params.useClInfinityLaunch) {
156
177
  const emptyFeeConfig = {
157
178
  feeType: FeeType.NONE,
158
179
  bps: 0,
@@ -182,7 +203,29 @@ export async function populateCreateTokenTransaction(params) {
182
203
  feeConfigs: [emptyFeeConfig, emptyFeeConfig, emptyFeeConfig, emptyFeeConfig],
183
204
  });
184
205
  }
185
- // 4) 标准 V2newTokenV6 + TOKEN_V2_PERMIT
206
+ // 5) extensionnewTokenV3
207
+ const hasExtension = !!params.extensionID &&
208
+ params.extensionID !== zeroBytes32() &&
209
+ params.lpFeeProfile === undefined &&
210
+ params.dexId === undefined;
211
+ if (hasExtension) {
212
+ return params.originalPortal.newTokenV3.populateTransaction({
213
+ name: params.tokenInfo.name,
214
+ symbol: params.tokenInfo.symbol,
215
+ meta: params.tokenInfo.meta,
216
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
217
+ salt: params.salt ?? zeroBytes32(),
218
+ taxRate: (params.taxRate ?? 0) & 0xffff,
219
+ migratorType: (params.migratorType ?? MigratorType.V3_MIGRATOR) & 0xff,
220
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
221
+ quoteAmt: 0n,
222
+ beneficiary: params.beneficiary,
223
+ permitData: '0x',
224
+ extensionID: params.extensionID,
225
+ extensionData: params.extensionData ?? '0x',
226
+ });
227
+ }
228
+ // 6) 标准 V2(newTokenV6 + TOKEN_V2_PERMIT)
186
229
  return params.originalPortal.newTokenV6.populateTransaction({
187
230
  name: params.tokenInfo.name,
188
231
  symbol: params.tokenInfo.symbol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",