four-flap-meme-sdk 2.2.10 → 2.2.11

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/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export { TM1, type FourChainV1 } from './contracts/tm1.js';
14
14
  export { TM2, type FourChainV2 } from './contracts/tm2.js';
15
15
  export { Helper3, Helper3Writer } from './contracts/helper3.js';
16
16
  export { CDPV2 } from './shared/flap/curve.js';
17
- export { FlapPortal, FlapPortalWriter, type FlapChain, type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type TokenStateV5, type TokenStateV7, type QuoteExactInputParams, type ExactInputParams, type ExactInputV3Params, type NewTokenV3Params, type NewTokenV4Params, type NewTokenV5Params, type TaxDistributionConfig, validateTaxDistribution, TokenStatus, TokenVersion, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId } from './shared/flap/portal.js';
17
+ export { FlapPortal, FlapPortalWriter, type FlapChain, type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type TokenStateV5, type TokenStateV7, type QuoteExactInputParams, type ExactInputParams, type ExactInputV3Params, type NewTokenV3Params, type NewTokenV4Params, type NewTokenV5Params, type TaxDistributionConfig, validateTaxDistribution, TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId } from './shared/flap/portal.js';
18
18
  export { uploadTokenMeta, type TokenMetaInput } from './shared/flap/ipfs.js';
19
19
  export { buildPermitPiggybackAuto } from './shared/flap/permit.js';
20
20
  export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './shared/flap/vanity.js';
@@ -53,7 +53,8 @@ export { pancakeBundleBuyFirstMerkle, type PancakeBuyFirstSignConfig, type Panca
53
53
  export { flapBundleCurveToDex, type CurveToDexChain, type DexPoolType, type CurveToDexSignConfig, type CurveBuyerConfig, type DexBuyerConfig, type FlapCurveToDexParams, type FlapCurveToDexResult } from './shared/flap/portal-bundle-merkle/curve-to-dex.js';
54
54
  export { flapBundleCreateToDex, type CreateToDexChain, type CreateToDexSignConfig, type CreateTokenInfo, type FlapCreateToDexParams, type FlapCreateToDexResult } from './shared/flap/portal-bundle-merkle/create-to-dex.js';
55
55
  export { NONE_EXTENSION_ID, VAULT_TYPE_LABELS, VAULT_TYPE_CATEGORIES, VAULT_FACTORY_ADDRESSES, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI, VAULT_EXTRA_CONFIG, FLAP_GUARDIAN_ADDRESSES, VAULT_FACTORY_ABI, VAULT_FACTORY_V2_ABI, VAULT_BASE_ABI, VAULT_BASE_V2_ABI, type VaultType, type TaxVaultConfig, type VaultInfo, type FieldDescriptor, type VaultDataSchema, type ApproveAction, type VaultMethodSchema, type VaultUISchema, encodeVaultData, buildVaultParams, buildVaultExtensionParams, buildNewTokenV6WithVaultParams, getVaultLaunchVanityOptions, TOKEN_TAXED_V3_VERSION, getVaultFactoryAddress, getVaultPortalAddress, queryVaultDataSchema, queryVaultUISchema, queryVaultDescription, validateVaultFactory, getVaultInfo, isValidContract, } from './shared/flap/vault.js';
56
- export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, } from './shared/flap/launch-v6.js';
56
+ export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, getV3PermitLaunchVanityOptions, } from './shared/flap/launch-v6.js';
57
+ export { populateCreateTokenTransaction, normalizeTaxLaunchConfig, resolveCreateTokenLaunchFlags, MAGIC_DIVIDEND_SELF, type PopulateCreateTokenParams, type NormalizedTaxLaunchConfig, } from './shared/flap/portal-create-token.js';
57
58
  export { PROFIT_CONFIG } from './shared/constants/index.js';
58
59
  export { quoteV2, quoteV3, quote, getTokenToNativeQuote, getNativeToTokenQuote, getWrappedNativeAddress, // ✅ 来自 quote-helpers,与 shared/constants 同名但实现可能不同
59
60
  getStableCoins, V3_FEE_TIERS, // ✅ 来自 quote-helpers
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ export { TM1 } from './contracts/tm1.js';
47
47
  export { TM2 } from './contracts/tm2.js';
48
48
  export { Helper3, Helper3Writer } from './contracts/helper3.js';
49
49
  export { CDPV2 } from './shared/flap/curve.js';
50
- export { FlapPortal, FlapPortalWriter, validateTaxDistribution, TokenStatus, TokenVersion, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId } from './shared/flap/portal.js';
50
+ export { FlapPortal, FlapPortalWriter, validateTaxDistribution, TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId } from './shared/flap/portal.js';
51
51
  export { uploadTokenMeta } from './shared/flap/ipfs.js';
52
52
  export { buildPermitPiggybackAuto } from './shared/flap/permit.js';
53
53
  export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './shared/flap/vanity.js';
@@ -99,7 +99,8 @@ export { flapBundleCurveToDex } from './shared/flap/portal-bundle-merkle/curve-t
99
99
  export { flapBundleCreateToDex } from './shared/flap/portal-bundle-merkle/create-to-dex.js';
100
100
  // ✅ Tax Vault 金库模块(基于 VaultPortal + VaultFactory 规范)
101
101
  export { NONE_EXTENSION_ID, VAULT_TYPE_LABELS, VAULT_TYPE_CATEGORIES, VAULT_FACTORY_ADDRESSES, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI, VAULT_EXTRA_CONFIG, FLAP_GUARDIAN_ADDRESSES, VAULT_FACTORY_ABI, VAULT_FACTORY_V2_ABI, VAULT_BASE_ABI, VAULT_BASE_V2_ABI, encodeVaultData, buildVaultParams, buildVaultExtensionParams, buildNewTokenV6WithVaultParams, getVaultLaunchVanityOptions, TOKEN_TAXED_V3_VERSION, getVaultFactoryAddress, getVaultPortalAddress, queryVaultDataSchema, queryVaultUISchema, queryVaultDescription, validateVaultFactory, getVaultInfo, isValidContract, } from './shared/flap/vault.js';
102
- export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, } from './shared/flap/launch-v6.js';
102
+ export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, getV3PermitLaunchVanityOptions, } from './shared/flap/launch-v6.js';
103
+ export { populateCreateTokenTransaction, normalizeTaxLaunchConfig, resolveCreateTokenLaunchFlags, MAGIC_DIVIDEND_SELF, } from './shared/flap/portal-create-token.js';
103
104
  // ✅ 硬编码利润配置(统一管理)- 从 shared/constants 导出
104
105
  export { PROFIT_CONFIG } from './shared/constants/index.js';
105
106
  // ✅ V2/V3 报价工具(统一管理)
@@ -229,6 +229,7 @@ export const FLAP_PORTAL_ABI = [
229
229
  // ✅ V5:Tax Token V2 高级税收分配
230
230
  'function newTokenV5((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint16 taxRate,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint8 lpFeeProfile,uint64 taxDuration,uint64 antiFarmerDuration,uint16 mktBps,uint16 deflationBps,uint16 dividendBps,uint16 lpBps,uint256 minimumShareBalance)) external payable returns (address)',
231
231
  'function newTokenV6((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint8 lpFeeProfile,uint16 buyTaxRate,uint16 sellTaxRate,uint64 taxDuration,uint64 antiFarmerDuration,uint16 mktBps,uint16 deflationBps,uint16 dividendBps,uint16 lpBps,uint256 minimumShareBalance,address dividendToken,address commissionReceiver,uint8 tokenVersion)) external payable returns (address)',
232
+ 'function newTokenV7((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint8 migratorType,address quoteToken,uint256 quoteAmt,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint16 buyTaxRate,uint16 sellTaxRate,uint64 taxDuration,uint64 antiFarmerDuration,address commissionReceiver,uint8 tokenVersion,(uint8 feeType,uint16 bps,address marketingAddress,address dividendToken,uint256 minimumShareBalance)[4] feeConfigs)) external payable returns (address)',
232
233
  // 交易
233
234
  'function swapExactInput((address inputToken,address outputToken,uint256 inputAmount,uint256 minOutputAmount,bytes permitData)) external payable returns (uint256)',
234
235
  // ✅ V3:支持 extensionData(注意:这里的 V3 指“扩展交易接口版本”,不是“外盘 V3 池子”)
@@ -27,6 +27,8 @@ export declare const FLAP_ORIGINAL_PORTAL_ADDRESSES: {
27
27
  */
28
28
  export declare const FLAP_TOKEN_IMPL_ADDRESSES: {
29
29
  readonly BSC_NORMAL: "0x8b4329947e34b6d56d71a3385cac122bade7d78d";
30
+ /** TOKEN_V3_PERMIT / newTokenV7(Flap Portal v5.8.6+,vanity 后缀仍为 8888) */
31
+ readonly BSC_V3_PERMIT: "0x88881b6f03090462a969eC7f48385744Eeb63333";
30
32
  readonly BSC_TAXED: "0x29e6383F0ce68507b5A72a53c2B118a118332aA8";
31
33
  readonly BSC_TAXED_V5: "0xae562c6A05b798499507c6276C6Ed796027807BA";
32
34
  readonly BSC_TAXED_V3: "0x024f18294970B5c76c0691b87f138A0317156422";
@@ -29,6 +29,8 @@ export const FLAP_ORIGINAL_PORTAL_ADDRESSES = {
29
29
  */
30
30
  export const FLAP_TOKEN_IMPL_ADDRESSES = {
31
31
  BSC_NORMAL: '0x8b4329947e34b6d56d71a3385cac122bade7d78d',
32
+ /** TOKEN_V3_PERMIT / newTokenV7(Flap Portal v5.8.6+,vanity 后缀仍为 8888) */
33
+ BSC_V3_PERMIT: '0x88881b6f03090462a969eC7f48385744Eeb63333',
32
34
  BSC_TAXED: '0x29e6383F0ce68507b5A72a53c2B118a118332aA8', // V2: 只有运营钱包的税代币
33
35
  BSC_TAXED_V5: '0xae562c6A05b798499507c6276C6Ed796027807BA', // Legacy V5 impl(已由 V3 取代)
34
36
  BSC_TAXED_V3: '0x024f18294970B5c76c0691b87f138A0317156422', // V3: VaultPortal.newTokenV6WithVault / Portal.newTokenV6 税币
@@ -7,13 +7,14 @@
7
7
  * 使用时请从具体文件导入
8
8
  */
9
9
  export { FlapPortal, FlapPortalWriter, type FlapChain, // 主要的 FlapChain 定义
10
- type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type TokenStateV5, type TokenStateV7, type QuoteExactInputParams, type ExactInputParams, type ExactInputV3Params, type NewTokenV3Params, type NewTokenV4Params, type NewTokenV5Params, type TaxDistributionConfig, validateTaxDistribution, TokenStatus, TokenVersion, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId, } from './portal.js';
10
+ type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type TokenStateV5, type TokenStateV7, type QuoteExactInputParams, type ExactInputParams, type ExactInputV3Params, type NewTokenV3Params, type NewTokenV4Params, type NewTokenV5Params, type TaxDistributionConfig, validateTaxDistribution, TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId, } from './portal.js';
11
11
  export { CDPV2 } from './curve.js';
12
12
  export { buildPermitPiggybackAuto } from './permit.js';
13
13
  export { uploadTokenMeta, type TokenMetaInput } from './ipfs.js';
14
14
  export { PinataClient, type PinataConfig, pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob, type PinataPinResp } from './pinata.js';
15
15
  export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './vanity.js';
16
- export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, } from './launch-v6.js';
16
+ export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, getV3PermitLaunchVanityOptions, } from './launch-v6.js';
17
+ export { populateCreateTokenTransaction, normalizeTaxLaunchConfig, resolveCreateTokenLaunchFlags, MAGIC_DIVIDEND_SELF, type PopulateCreateTokenParams, type NormalizedTaxLaunchConfig, } from './portal-create-token.js';
17
18
  export { getFlapMetaByAddress, getFlapMetasByAddresses } from './meta.js';
18
19
  export { parseFlapError, getFlapErrorMessage, getFlapErrorMessageEn, type FlapErrorCode } from './errors.js';
19
20
  export { FLAP_DEFAULT_FEE_RATES, FLAP_IPFS_API_URL, FLAP_VANITY_SUFFIX, FLAP_DEX_THRESHOLDS, FLAP_TOTAL_SUPPLY, ZERO_ADDRESS, CHAIN_TAX_SUPPORT, getVanitySuffix, isChainSupportTax, FLAP_PORTAL_ADDRESSES } from './constants.js';
@@ -7,13 +7,14 @@
7
7
  * 使用时请从具体文件导入
8
8
  */
9
9
  // 核心模块 - 显式导出避免冲突
10
- export { FlapPortal, FlapPortalWriter, validateTaxDistribution, TokenStatus, TokenVersion, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId, } from './portal.js';
10
+ export { FlapPortal, FlapPortalWriter, validateTaxDistribution, TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId, } from './portal.js';
11
11
  export { CDPV2 } from './curve.js';
12
12
  export { buildPermitPiggybackAuto } from './permit.js';
13
13
  export { uploadTokenMeta } from './ipfs.js';
14
14
  export { PinataClient, pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob } from './pinata.js';
15
15
  export { predictVanityTokenAddressByChain, findSaltEndingByChain } from './vanity.js';
16
- export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, } from './launch-v6.js';
16
+ export { buildNewTokenV6Params, normalizeTaxV2Fields, NEW_TOKEN_V6_ABI, getTaxV3LaunchVanityOptions, getV3PermitLaunchVanityOptions, } from './launch-v6.js';
17
+ export { populateCreateTokenTransaction, normalizeTaxLaunchConfig, resolveCreateTokenLaunchFlags, MAGIC_DIVIDEND_SELF, } from './portal-create-token.js';
17
18
  export { getFlapMetaByAddress, getFlapMetasByAddresses } from './meta.js';
18
19
  export { parseFlapError, getFlapErrorMessage, getFlapErrorMessageEn } from './errors.js';
19
20
  export { FLAP_DEFAULT_FEE_RATES, FLAP_IPFS_API_URL, FLAP_VANITY_SUFFIX, FLAP_DEX_THRESHOLDS, FLAP_TOTAL_SUPPLY, ZERO_ADDRESS, CHAIN_TAX_SUPPORT, getVanitySuffix, isChainSupportTax, FLAP_PORTAL_ADDRESSES } from './constants.js';
@@ -112,6 +112,16 @@ export declare function getTaxV3LaunchVanityOptions(chain: string): {
112
112
  taxed: boolean;
113
113
  taxedV3: boolean;
114
114
  taxedV5: boolean;
115
+ useV3Permit: boolean;
116
+ suffix: string | undefined;
117
+ chain: "BSC" | "BASE" | "XLAYER" | "MORPH" | "MONAD";
118
+ };
119
+ /** 标准 V3 池 Vanity:TOKEN_V3_PERMIT / newTokenV7 + BSC_V3_PERMIT impl */
120
+ export declare function getV3PermitLaunchVanityOptions(chain: string): {
121
+ taxed: boolean;
122
+ taxedV3: boolean;
123
+ taxedV5: boolean;
124
+ useV3Permit: boolean;
115
125
  suffix: string | undefined;
116
126
  chain: "BSC" | "BASE" | "XLAYER" | "MORPH" | "MONAD";
117
127
  };
@@ -105,6 +105,18 @@ export function getTaxV3LaunchVanityOptions(chain) {
105
105
  taxed: true,
106
106
  taxedV3: true,
107
107
  taxedV5: false,
108
+ useV3Permit: false,
109
+ suffix: undefined,
110
+ chain: chain.toUpperCase(),
111
+ };
112
+ }
113
+ /** 标准 V3 池 Vanity:TOKEN_V3_PERMIT / newTokenV7 + BSC_V3_PERMIT impl */
114
+ export function getV3PermitLaunchVanityOptions(chain) {
115
+ return {
116
+ taxed: false,
117
+ taxedV3: false,
118
+ taxedV5: false,
119
+ useV3Permit: true,
108
120
  suffix: undefined,
109
121
  chain: chain.toUpperCase(),
110
122
  };
@@ -4,8 +4,7 @@ import { ADDRESSES, ZERO_ADDRESS } from '../../../utils/constants.js';
4
4
  import { GAS_LIMITS, CHAINS } from '../../constants/index.js';
5
5
  import { MULTICALL3_ABI, V2_ROUTER_QUOTE_ABI } from '../../abis/common.js';
6
6
  import { FLAP_PORTAL_ADDRESSES, FLAP_ORIGINAL_PORTAL_ADDRESSES } from '../constants.js';
7
- import { buildNewTokenV6WithVaultParams, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI } from '../vault.js';
8
- import { buildNewTokenV6Params } from '../launch-v6.js';
7
+ import { populateCreateTokenTransaction, resolveCreateTokenLaunchFlags, } from '../portal-create-token.js';
9
8
  import { CHAIN_ID_MAP, PORTAL_ABI, getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA } from './config.js';
10
9
  // ✅ 常量
11
10
  const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
@@ -103,124 +102,28 @@ export async function createTokenWithBundleBuyMerkle(params) {
103
102
  const portalAddr = FLAP_PORTAL_ADDRESSES[chain];
104
103
  const originalPortalAddr = FLAP_ORIGINAL_PORTAL_ADDRESSES[chain];
105
104
  const portal = new ethers.Contract(originalPortalAddr, PORTAL_ABI, devWallet);
106
- // 判断使用哪个版本的 newToken
107
- // V5: 提供了 taxV2Config 且 taxRate > 0(Tax Token V2 高级税收分配)
108
- // V4: 提供了 dexId 或 lpFeeProfile(支持 DEX 选择和 LP 费率配置)
109
- // V3: 提供了 extensionID(支持扩展数据)
110
- // V2: 默认
111
- const useV5 = params.taxV2Config !== undefined && (params.taxRate ?? 0) > 0;
112
- const useV4 = !useV5 && (params.dexId !== undefined || params.lpFeeProfile !== undefined);
113
- const useV3 = !useV5 && !useV4 && !!params.extensionID;
114
- // ✅ 优化:并行获取 gasPrice、devWallet nonce 和 createTx
115
- let createTxPromise;
116
- if (useV5) {
117
- // V5: Tax Token V2 高级税收分配
118
- const tv2 = params.taxV2Config;
119
- const dist = tv2.distribution;
120
- const total = dist.mktBps + dist.deflationBps + dist.dividendBps + dist.lpBps;
121
- if (total !== 10000) {
122
- throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
123
- }
124
- // ✅ 金库:VaultPortal.newTokenV6WithVault;无金库:Portal.newTokenV6 + TOKEN_TAXED_V3
125
- const hasVault = tv2.vaultConfig && tv2.vaultConfig.vaultType !== 'none';
126
- if (hasVault) {
127
- const vaultPortalAddr = VAULT_PORTAL_ADDRESSES[chain];
128
- if (!vaultPortalAddr) {
129
- throw new Error(`链 "${chain}" 不支持 Tax Vault 金库功能`);
130
- }
131
- const vaultPortal = new ethers.Contract(vaultPortalAddr, VAULT_PORTAL_ABI, devWallet);
132
- const v6VaultParams = buildNewTokenV6WithVaultParams({
133
- tokenInfo,
134
- taxV2: tv2,
135
- chain,
136
- salt: params.salt,
137
- taxRate: params.taxRate,
138
- buyTaxRate: params.buyTaxRate,
139
- sellTaxRate: params.sellTaxRate,
140
- dexThresh: params.dexThresh,
141
- migratorType: params.migratorType,
142
- quoteToken: params.quoteToken,
143
- quoteAmt: 0n,
144
- dexId: params.dexId,
145
- lpFeeProfile: params.lpFeeProfile,
146
- });
147
- createTxPromise = vaultPortal.newTokenV6WithVault.populateTransaction(v6VaultParams);
148
- }
149
- else {
150
- const v6Params = buildNewTokenV6Params({
151
- tokenInfo,
152
- taxV2: tv2,
153
- beneficiary: devWallet.address,
154
- salt: params.salt,
155
- taxRate: params.taxRate,
156
- buyTaxRate: params.buyTaxRate,
157
- sellTaxRate: params.sellTaxRate,
158
- dexThresh: params.dexThresh,
159
- migratorType: params.migratorType,
160
- quoteToken: params.quoteToken,
161
- quoteAmt: 0n,
162
- dexId: params.dexId,
163
- lpFeeProfile: params.lpFeeProfile,
164
- extensionID: params.extensionID,
165
- extensionData: params.extensionData,
166
- });
167
- createTxPromise = portal.newTokenV6.populateTransaction(v6Params);
168
- }
169
- }
170
- else if (useV4) {
171
- // V4: 支持 DEX ID 和 LP 费率配置
172
- createTxPromise = portal.newTokenV4.populateTransaction({
173
- name: tokenInfo.name,
174
- symbol: tokenInfo.symbol,
175
- meta: tokenInfo.meta,
176
- dexThresh: (params.dexThresh ?? 1) & 0xff,
177
- salt: params.salt ?? '0x' + '00'.repeat(32),
178
- taxRate: (params.taxRate ?? 0) & 0xffff,
179
- migratorType: (params.migratorType ?? 0) & 0xff,
180
- quoteToken: params.quoteToken || ZERO_ADDRESS,
181
- quoteAmt: 0n,
182
- beneficiary: devWallet.address,
183
- permitData: '0x',
184
- extensionID: params.extensionID ?? '0x' + '00'.repeat(32),
185
- extensionData: params.extensionData ?? '0x',
186
- dexId: (params.dexId ?? 0) & 0xff,
187
- lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff
188
- });
189
- }
190
- else if (useV3) {
191
- // V3: 支持扩展数据
192
- createTxPromise = portal.newTokenV3.populateTransaction({
193
- name: tokenInfo.name,
194
- symbol: tokenInfo.symbol,
195
- meta: tokenInfo.meta,
196
- dexThresh: (params.dexThresh ?? 1) & 0xff,
197
- salt: params.salt ?? '0x' + '00'.repeat(32),
198
- taxRate: (params.taxRate ?? 0) & 0xffff,
199
- migratorType: (params.migratorType ?? 0) & 0xff,
200
- quoteToken: params.quoteToken || ZERO_ADDRESS,
201
- quoteAmt: 0n,
202
- beneficiary: devWallet.address,
203
- permitData: '0x',
204
- extensionID: params.extensionID,
205
- extensionData: params.extensionData ?? '0x'
206
- });
207
- }
208
- else {
209
- // V2: 基础版本
210
- createTxPromise = portal.newTokenV2.populateTransaction({
211
- name: tokenInfo.name,
212
- symbol: tokenInfo.symbol,
213
- meta: tokenInfo.meta,
214
- dexThresh: (params.dexThresh ?? 1) & 0xff,
215
- salt: params.salt ?? '0x' + '00'.repeat(32),
216
- taxRate: (params.taxRate ?? 0) & 0xffff,
217
- migratorType: (params.migratorType ?? 0) & 0xff,
218
- quoteToken: params.quoteToken || ZERO_ADDRESS,
219
- quoteAmt: 0n,
220
- beneficiary: devWallet.address,
221
- permitData: '0x'
222
- });
223
- }
105
+ const { normalizedTax, useV7Portal } = resolveCreateTokenLaunchFlags(params);
106
+ const createTxPromise = populateCreateTokenTransaction({
107
+ chain,
108
+ devWallet,
109
+ originalPortal: portal,
110
+ tokenInfo,
111
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
112
+ beneficiary: devWallet.address,
113
+ dexThresh: params.dexThresh,
114
+ salt: params.salt,
115
+ migratorType: params.migratorType,
116
+ taxRate: params.taxRate,
117
+ buyTaxRate: params.buyTaxRate,
118
+ sellTaxRate: params.sellTaxRate,
119
+ dexId: params.dexId,
120
+ lpFeeProfile: params.lpFeeProfile,
121
+ extensionID: params.extensionID,
122
+ extensionData: params.extensionData,
123
+ useV7Portal,
124
+ taxConfig: normalizedTax,
125
+ initialQuoteAmt: 0n,
126
+ });
224
127
  const [gasPrice, createTxUnsigned, devNonce] = await Promise.all([
225
128
  resolveGasPrice(provider, config),
226
129
  createTxPromise,
@@ -10,8 +10,7 @@
10
10
  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
- import { buildNewTokenV6WithVaultParams, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI } from '../vault.js';
14
- import { buildNewTokenV6Params } from '../launch-v6.js';
13
+ import { populateCreateTokenTransaction, resolveCreateTokenLaunchFlags, } from '../portal-create-token.js';
15
14
  import { PROFIT_CONFIG, ZERO_ADDRESS } from '../../../utils/constants.js';
16
15
  import { GAS_LIMITS } from '../../constants/index.js';
17
16
  import { getGasPriceConfig, getTxType, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI } from './config.js';
@@ -312,118 +311,28 @@ export async function flapBundleCreateToDex(params) {
312
311
  const devNonce = noncesMap.get(devAddr);
313
312
  noncesMap.set(devAddr, devNonce + 1);
314
313
  const originalPortal = new Contract(originalPortalAddress, PORTAL_ABI, devWallet);
315
- // 判断使用哪个版本的 newToken
316
- // V5: 提供了 taxV2Config(Tax Token V2 高级税收分配)
317
- // V4: 提供了 dexId 或 lpFeeProfile(支持 DEX 选择和 LP 费率配置)
318
- // V3: 提供了 extensionID(支持扩展数据)
319
- // V2: 默认
320
- const useV5 = params.taxV2Config !== undefined && (params.taxRate ?? 0) > 0;
321
- const useV4 = !useV5 && (params.dexId !== undefined || params.lpFeeProfile !== undefined);
322
- const useV3 = !useV5 && !useV4 && !!params.extensionID;
323
- let createUnsigned;
324
- if (useV5) {
325
- // V5: Tax Token V2 高级税收分配
326
- const tv2 = params.taxV2Config;
327
- const hasVault = tv2.vaultConfig && tv2.vaultConfig.vaultType !== 'none';
328
- if (hasVault) {
329
- const chainKey = chain.toUpperCase();
330
- const vaultPortalAddr = VAULT_PORTAL_ADDRESSES[chainKey];
331
- if (!vaultPortalAddr) {
332
- throw new Error(`链 "${chain}" 不支持 Tax Vault 金库功能`);
333
- }
334
- const vaultPortal = new Contract(vaultPortalAddr, VAULT_PORTAL_ABI, devWallet);
335
- const v6VaultParams = buildNewTokenV6WithVaultParams({
336
- tokenInfo,
337
- taxV2: tv2,
338
- chain: chainKey,
339
- salt: params.salt,
340
- taxRate: params.taxRate,
341
- buyTaxRate: params.buyTaxRate,
342
- sellTaxRate: params.sellTaxRate,
343
- dexThresh: params.dexThresh,
344
- migratorType: params.migratorType,
345
- quoteToken: inputToken,
346
- quoteAmt: 0n,
347
- dexId: params.dexId,
348
- lpFeeProfile: params.lpFeeProfile,
349
- });
350
- createUnsigned = await vaultPortal.newTokenV6WithVault.populateTransaction(v6VaultParams);
351
- }
352
- else {
353
- const v6Params = buildNewTokenV6Params({
354
- tokenInfo,
355
- taxV2: tv2,
356
- beneficiary: devWallet.address,
357
- salt: params.salt,
358
- taxRate: params.taxRate,
359
- buyTaxRate: params.buyTaxRate,
360
- sellTaxRate: params.sellTaxRate,
361
- dexThresh: params.dexThresh,
362
- migratorType: params.migratorType,
363
- quoteToken: inputToken,
364
- quoteAmt: 0n,
365
- dexId: params.dexId,
366
- lpFeeProfile: params.lpFeeProfile,
367
- extensionID: params.extensionID,
368
- extensionData: params.extensionData,
369
- });
370
- createUnsigned = await originalPortal.newTokenV6.populateTransaction(v6Params);
371
- }
372
- }
373
- else if (useV4) {
374
- // V4: 支持 DEX ID 和 LP 费率配置(用于选择池子费率)
375
- createUnsigned = await originalPortal.newTokenV4.populateTransaction({
376
- name: tokenInfo.name,
377
- symbol: tokenInfo.symbol,
378
- meta: tokenInfo.meta,
379
- dexThresh: (params.dexThresh ?? 1) & 0xff,
380
- salt: params.salt ?? '0x' + '00'.repeat(32),
381
- taxRate: (params.taxRate ?? 0) & 0xffff,
382
- migratorType: (params.migratorType ?? 0) & 0xff,
383
- quoteToken: inputToken,
384
- quoteAmt: 0n,
385
- beneficiary: devWallet.address,
386
- permitData: '0x',
387
- extensionID: params.extensionID ?? '0x' + '00'.repeat(32),
388
- extensionData: params.extensionData ?? '0x',
389
- dexId: (params.dexId ?? 0) & 0xff,
390
- lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff
391
- });
392
- }
393
- else if (useV3) {
394
- // V3: 支持扩展数据
395
- createUnsigned = await originalPortal.newTokenV3.populateTransaction({
396
- name: tokenInfo.name,
397
- symbol: tokenInfo.symbol,
398
- meta: tokenInfo.meta,
399
- dexThresh: (params.dexThresh ?? 1) & 0xff,
400
- salt: params.salt ?? '0x' + '00'.repeat(32),
401
- taxRate: (params.taxRate ?? 0) & 0xffff,
402
- migratorType: (params.migratorType ?? 0) & 0xff,
403
- quoteToken: inputToken,
404
- quoteAmt: 0n,
405
- beneficiary: devWallet.address,
406
- permitData: '0x',
407
- extensionID: params.extensionID,
408
- extensionData: params.extensionData ?? '0x'
409
- });
410
- }
411
- else {
412
- // V2: 基础版本
413
- createUnsigned = await originalPortal.newTokenV2.populateTransaction({
414
- name: tokenInfo.name,
415
- symbol: tokenInfo.symbol,
416
- meta: tokenInfo.meta,
417
- dexThresh: (params.dexThresh ?? 1) & 0xff,
418
- salt: params.salt ?? '0x' + '00'.repeat(32),
419
- taxRate: (params.taxRate ?? 0) & 0xffff,
420
- migratorType: (params.migratorType ?? 0) & 0xff,
421
- quoteToken: inputToken,
422
- quoteAmt: 0n,
423
- beneficiary: devWallet.address,
424
- permitData: '0x'
425
- });
426
- }
314
+ const { normalizedTax, useV7Portal } = resolveCreateTokenLaunchFlags(params);
315
+ const createUnsigned = await populateCreateTokenTransaction({
316
+ chain,
317
+ devWallet,
318
+ originalPortal,
319
+ tokenInfo,
320
+ quoteToken: inputToken,
321
+ beneficiary: devWallet.address,
322
+ dexThresh: params.dexThresh,
323
+ salt: params.salt,
324
+ migratorType: params.migratorType,
325
+ taxRate: params.taxRate,
326
+ buyTaxRate: params.buyTaxRate,
327
+ sellTaxRate: params.sellTaxRate,
328
+ dexId: params.dexId,
329
+ lpFeeProfile: params.lpFeeProfile,
330
+ extensionID: params.extensionID,
331
+ extensionData: params.extensionData,
332
+ useV7Portal,
333
+ taxConfig: normalizedTax,
334
+ initialQuoteAmt: 0n,
335
+ });
427
336
  const createTx = {
428
337
  ...createUnsigned,
429
338
  from: devWallet.address,
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Portal 发币交易构建(newTokenV6 / newTokenV7 / VaultPortal)
3
+ * @see https://docs.flap.sh/flap/developers/token-launcher-developers/launch-token-through-portal
4
+ */
5
+ import { Contract, type Wallet } from 'ethers';
6
+ import { type TaxVaultConfig } from './vault.js';
7
+ import type { TaxV2Config } from './portal-bundle-merkle/types.js';
8
+ export declare const MAGIC_DIVIDEND_SELF = "0xfEEDFEEDfeEDFEedFEEdFEEDFeEdfEEdFeEdFEEd";
9
+ export type NormalizedTaxLaunchConfig = {
10
+ taxDuration: number;
11
+ antiFarmerDuration: number;
12
+ mktBps: number;
13
+ deflationBps: number;
14
+ dividendBps: number;
15
+ lpBps: number;
16
+ minimumShareBalance?: number;
17
+ buyTaxRate: number;
18
+ sellTaxRate: number;
19
+ dividendToken?: string;
20
+ commissionReceiver?: string;
21
+ vaultConfig?: TaxVaultConfig;
22
+ };
23
+ export type PopulateCreateTokenParams = {
24
+ chain: string;
25
+ devWallet: Wallet;
26
+ originalPortal: Contract;
27
+ tokenInfo: {
28
+ name: string;
29
+ symbol: string;
30
+ meta: string;
31
+ };
32
+ quoteToken?: string;
33
+ beneficiary: string;
34
+ dexThresh?: number;
35
+ salt?: string;
36
+ migratorType?: number;
37
+ taxRate?: number;
38
+ buyTaxRate?: number;
39
+ sellTaxRate?: number;
40
+ dexId?: number;
41
+ lpFeeProfile?: number;
42
+ extensionID?: string;
43
+ extensionData?: string;
44
+ /** 标准 V3 池 → newTokenV7 + TOKEN_V3_PERMIT(与 Flap 官网一致) */
45
+ useV7Portal?: boolean;
46
+ taxConfig?: NormalizedTaxLaunchConfig;
47
+ initialQuoteAmt?: bigint;
48
+ };
49
+ /** bundle 发币路径:标准 V3(dexId/lpFeeProfile)→ newTokenV7,税币/金库 → V6 */
50
+ export declare function resolveCreateTokenLaunchFlags(params: {
51
+ taxRate?: number;
52
+ taxV2Config?: TaxV2Config;
53
+ lpFeeProfile?: number;
54
+ dexId?: number;
55
+ migratorType?: number;
56
+ extensionID?: string;
57
+ }): {
58
+ normalizedTax: NormalizedTaxLaunchConfig | undefined;
59
+ useV7Portal: boolean;
60
+ };
61
+ /** 将 TaxV2Config(含 distribution)归一化;金库发射在税率为 0 时仍返回配置 */
62
+ export declare function normalizeTaxLaunchConfig(input?: TaxV2Config, fallbackTaxRate?: number): NormalizedTaxLaunchConfig | undefined;
63
+ export declare function populateCreateTokenTransaction(params: PopulateCreateTokenParams): Promise<import("ethers").ContractTransaction>;
@@ -0,0 +1,258 @@
1
+ /**
2
+ * Portal 发币交易构建(newTokenV6 / newTokenV7 / VaultPortal)
3
+ * @see https://docs.flap.sh/flap/developers/token-launcher-developers/launch-token-through-portal
4
+ */
5
+ import { Contract, ZeroAddress } from 'ethers';
6
+ import { ZERO_ADDRESS } from '../constants/index.js';
7
+ import { buildNewTokenV6WithVaultParams, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI, } from './vault.js';
8
+ import { buildNewTokenV6Params, normalizeTaxV2Fields } from './launch-v6.js';
9
+ import { TokenVersion, MigratorType, FeeType } from './portal.js';
10
+ export const MAGIC_DIVIDEND_SELF = '0xfEEDFEEDfeEDFEedFEEdFEEDFeEdfEEdFeEdFEEd';
11
+ function zeroBytes32() {
12
+ return '0x' + '00'.repeat(32);
13
+ }
14
+ function resolveTaxRates(taxConfig, taxRate, buyTaxRate, sellTaxRate) {
15
+ const buy = taxConfig?.buyTaxRate ?? buyTaxRate ?? taxRate ?? 0;
16
+ const sell = taxConfig?.sellTaxRate ?? sellTaxRate ?? taxRate ?? 0;
17
+ return { buyTaxRate: buy & 0xffff, sellTaxRate: sell & 0xffff };
18
+ }
19
+ function validateTaxDistribution(mkt, def, div, lp) {
20
+ const total = mkt + def + div + lp;
21
+ if (total !== 10000) {
22
+ throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
23
+ }
24
+ }
25
+ function resolveCreateQuoteAmt(params) {
26
+ return params.initialQuoteAmt ?? 0n;
27
+ }
28
+ function resolveUseV7Portal(params) {
29
+ return !!params.useV7Portal;
30
+ }
31
+ /** bundle 发币路径:标准 V3(dexId/lpFeeProfile)→ newTokenV7,税币/金库 → V6 */
32
+ export function resolveCreateTokenLaunchFlags(params) {
33
+ const normalizedTax = normalizeTaxLaunchConfig(params.taxV2Config, params.taxRate);
34
+ const hasVault = !!normalizedTax?.vaultConfig && normalizedTax.vaultConfig.vaultType !== 'none';
35
+ const isTaxLaunch = !!normalizedTax || hasVault || (params.taxRate ?? 0) > 0;
36
+ const useV7Portal = !isTaxLaunch &&
37
+ !hasVault &&
38
+ (params.lpFeeProfile !== undefined ||
39
+ params.dexId !== undefined ||
40
+ params.migratorType === MigratorType.PCS_INFINITY_CL_MIGRATOR);
41
+ return { normalizedTax, useV7Portal };
42
+ }
43
+ /** 将 TaxV2Config(含 distribution)归一化;金库发射在税率为 0 时仍返回配置 */
44
+ export function normalizeTaxLaunchConfig(input, fallbackTaxRate) {
45
+ if (!input)
46
+ return undefined;
47
+ const flat = normalizeTaxV2Fields(input);
48
+ const buyTaxRate = fallbackTaxRate ?? 0;
49
+ const sellTaxRate = fallbackTaxRate ?? 0;
50
+ const hasVault = flat.vaultConfig && flat.vaultConfig.vaultType !== 'none';
51
+ if (buyTaxRate <= 0 && sellTaxRate <= 0 && !hasVault)
52
+ return undefined;
53
+ return {
54
+ taxDuration: flat.taxDuration,
55
+ antiFarmerDuration: flat.antiFarmerDuration,
56
+ mktBps: flat.mktBps,
57
+ deflationBps: flat.deflationBps,
58
+ dividendBps: flat.dividendBps,
59
+ lpBps: flat.lpBps,
60
+ minimumShareBalance: flat.minimumShareBalance,
61
+ buyTaxRate: buyTaxRate > 0 ? buyTaxRate : (hasVault ? 1 : 0),
62
+ sellTaxRate: sellTaxRate > 0 ? sellTaxRate : (hasVault ? 1 : 0),
63
+ vaultConfig: flat.vaultConfig,
64
+ };
65
+ }
66
+ function buildNewTokenV7PermitParams(params) {
67
+ const emptyFeeConfig = {
68
+ feeType: FeeType.NONE,
69
+ bps: 0,
70
+ marketingAddress: ZeroAddress,
71
+ dividendToken: ZeroAddress,
72
+ minimumShareBalance: 0n,
73
+ };
74
+ const marketingFeeConfig = {
75
+ feeType: FeeType.MARKETING_OR_VAULT,
76
+ bps: 10000,
77
+ marketingAddress: params.beneficiary,
78
+ dividendToken: ZeroAddress,
79
+ minimumShareBalance: 0n,
80
+ };
81
+ return {
82
+ name: params.tokenInfo.name,
83
+ symbol: params.tokenInfo.symbol,
84
+ meta: params.tokenInfo.meta,
85
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
86
+ salt: params.salt ?? zeroBytes32(),
87
+ migratorType: MigratorType.PCS_INFINITY_CL_MIGRATOR,
88
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
89
+ quoteAmt: resolveCreateQuoteAmt(params),
90
+ permitData: '0x',
91
+ extensionID: params.extensionID ?? zeroBytes32(),
92
+ extensionData: params.extensionData ?? '0x',
93
+ dexId: (params.dexId ?? 0) & 0xff,
94
+ buyTaxRate: 0,
95
+ sellTaxRate: 0,
96
+ taxDuration: 0n,
97
+ antiFarmerDuration: 0n,
98
+ commissionReceiver: ZeroAddress,
99
+ tokenVersion: TokenVersion.TOKEN_V3_PERMIT,
100
+ feeConfigs: [marketingFeeConfig, emptyFeeConfig, emptyFeeConfig, emptyFeeConfig],
101
+ };
102
+ }
103
+ export async function populateCreateTokenTransaction(params) {
104
+ const taxConfig = params.taxConfig;
105
+ const { buyTaxRate, sellTaxRate } = resolveTaxRates(taxConfig, params.taxRate, params.buyTaxRate, params.sellTaxRate);
106
+ const isTaxLaunch = buyTaxRate > 0 || sellTaxRate > 0;
107
+ // 1) 金库税币 → VaultPortal.newTokenV6WithVault
108
+ if (taxConfig?.vaultConfig && taxConfig.vaultConfig.vaultType !== 'none') {
109
+ validateTaxDistribution(taxConfig.mktBps, taxConfig.deflationBps, taxConfig.dividendBps, taxConfig.lpBps);
110
+ const chainKey = params.chain.toUpperCase();
111
+ const vaultPortalAddr = VAULT_PORTAL_ADDRESSES[chainKey];
112
+ if (!vaultPortalAddr) {
113
+ throw new Error(`链 "${params.chain}" 不支持 Tax Vault 金库功能`);
114
+ }
115
+ const vaultPortal = new Contract(vaultPortalAddr, VAULT_PORTAL_ABI, params.devWallet);
116
+ const tv2 = {
117
+ taxDuration: taxConfig.taxDuration,
118
+ antiFarmerDuration: taxConfig.antiFarmerDuration,
119
+ distribution: {
120
+ mktBps: taxConfig.mktBps,
121
+ deflationBps: taxConfig.deflationBps,
122
+ dividendBps: taxConfig.dividendBps,
123
+ lpBps: taxConfig.lpBps,
124
+ minimumShareBalance: taxConfig.minimumShareBalance,
125
+ },
126
+ vaultConfig: taxConfig.vaultConfig,
127
+ };
128
+ const v6VaultParams = buildNewTokenV6WithVaultParams({
129
+ tokenInfo: params.tokenInfo,
130
+ taxV2: tv2,
131
+ chain: chainKey,
132
+ salt: params.salt,
133
+ taxRate: Math.max(buyTaxRate, sellTaxRate),
134
+ buyTaxRate,
135
+ sellTaxRate,
136
+ dexThresh: params.dexThresh,
137
+ migratorType: params.migratorType,
138
+ quoteToken: params.quoteToken,
139
+ quoteAmt: resolveCreateQuoteAmt(params),
140
+ dexId: params.dexId,
141
+ lpFeeProfile: params.lpFeeProfile,
142
+ });
143
+ return vaultPortal.newTokenV6WithVault.populateTransaction(v6VaultParams);
144
+ }
145
+ // 2) 税币无金库 → newTokenV6 + TOKEN_TAXED_V3
146
+ if (isTaxLaunch && taxConfig) {
147
+ const tv2 = {
148
+ taxDuration: taxConfig.taxDuration,
149
+ antiFarmerDuration: taxConfig.antiFarmerDuration,
150
+ distribution: {
151
+ mktBps: taxConfig.mktBps,
152
+ deflationBps: taxConfig.deflationBps,
153
+ dividendBps: taxConfig.dividendBps,
154
+ lpBps: taxConfig.lpBps,
155
+ minimumShareBalance: taxConfig.minimumShareBalance,
156
+ },
157
+ vaultConfig: taxConfig.vaultConfig,
158
+ };
159
+ return params.originalPortal.newTokenV6.populateTransaction(buildNewTokenV6Params({
160
+ tokenInfo: params.tokenInfo,
161
+ taxV2: tv2,
162
+ beneficiary: params.beneficiary,
163
+ salt: params.salt,
164
+ taxRate: Math.max(buyTaxRate, sellTaxRate),
165
+ buyTaxRate,
166
+ sellTaxRate,
167
+ dexThresh: params.dexThresh,
168
+ migratorType: params.migratorType,
169
+ quoteToken: params.quoteToken,
170
+ quoteAmt: resolveCreateQuoteAmt(params),
171
+ dexId: params.dexId,
172
+ lpFeeProfile: params.lpFeeProfile,
173
+ extensionID: params.extensionID,
174
+ extensionData: params.extensionData,
175
+ }));
176
+ }
177
+ if (isTaxLaunch) {
178
+ return params.originalPortal.newTokenV6.populateTransaction(buildNewTokenV6Params({
179
+ tokenInfo: params.tokenInfo,
180
+ taxV2: {
181
+ taxDuration: 365 * 24 * 60 * 60,
182
+ antiFarmerDuration: 3 * 24 * 60 * 60,
183
+ distribution: {
184
+ mktBps: 10000,
185
+ deflationBps: 0,
186
+ dividendBps: 0,
187
+ lpBps: 0,
188
+ },
189
+ },
190
+ beneficiary: params.beneficiary,
191
+ salt: params.salt,
192
+ taxRate: Math.max(buyTaxRate, sellTaxRate),
193
+ buyTaxRate,
194
+ sellTaxRate,
195
+ dexThresh: params.dexThresh,
196
+ migratorType: params.migratorType,
197
+ quoteToken: params.quoteToken,
198
+ quoteAmt: resolveCreateQuoteAmt(params),
199
+ dexId: params.dexId,
200
+ lpFeeProfile: params.lpFeeProfile,
201
+ }));
202
+ }
203
+ // 3) 标准 V3 池 → newTokenV7(Portal v5.8.6+;V4 已 FeatureDisabled)
204
+ if (resolveUseV7Portal(params)) {
205
+ return params.originalPortal.newTokenV7.populateTransaction(buildNewTokenV7PermitParams(params));
206
+ }
207
+ // 4) extension only → newTokenV3
208
+ const hasExtension = !!params.extensionID &&
209
+ params.extensionID !== zeroBytes32() &&
210
+ params.lpFeeProfile === undefined &&
211
+ params.dexId === undefined;
212
+ if (hasExtension) {
213
+ return params.originalPortal.newTokenV3.populateTransaction({
214
+ name: params.tokenInfo.name,
215
+ symbol: params.tokenInfo.symbol,
216
+ meta: params.tokenInfo.meta,
217
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
218
+ salt: params.salt ?? zeroBytes32(),
219
+ taxRate: (params.taxRate ?? 0) & 0xffff,
220
+ migratorType: (params.migratorType ?? MigratorType.V3_MIGRATOR) & 0xff,
221
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
222
+ quoteAmt: resolveCreateQuoteAmt(params),
223
+ beneficiary: params.beneficiary,
224
+ permitData: '0x',
225
+ extensionID: params.extensionID,
226
+ extensionData: params.extensionData ?? '0x',
227
+ });
228
+ }
229
+ // 5) 标准 V2 路径 → newTokenV6 + TOKEN_V2_PERMIT
230
+ return params.originalPortal.newTokenV6.populateTransaction({
231
+ name: params.tokenInfo.name,
232
+ symbol: params.tokenInfo.symbol,
233
+ meta: params.tokenInfo.meta,
234
+ dexThresh: (params.dexThresh ?? 1) & 0xff,
235
+ salt: params.salt ?? zeroBytes32(),
236
+ migratorType: (params.migratorType ?? MigratorType.V2_MIGRATOR) & 0xff,
237
+ quoteToken: params.quoteToken || ZERO_ADDRESS,
238
+ quoteAmt: resolveCreateQuoteAmt(params),
239
+ beneficiary: params.beneficiary,
240
+ permitData: '0x',
241
+ extensionID: params.extensionID ?? zeroBytes32(),
242
+ extensionData: params.extensionData ?? '0x',
243
+ dexId: (params.dexId ?? 0) & 0xff,
244
+ lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff,
245
+ buyTaxRate: 0,
246
+ sellTaxRate: 0,
247
+ taxDuration: 0n,
248
+ antiFarmerDuration: 0n,
249
+ mktBps: 0,
250
+ deflationBps: 0,
251
+ dividendBps: 0,
252
+ lpBps: 0,
253
+ minimumShareBalance: 0n,
254
+ dividendToken: ZeroAddress,
255
+ commissionReceiver: ZeroAddress,
256
+ tokenVersion: TokenVersion.TOKEN_V2_PERMIT,
257
+ });
258
+ }
@@ -13,7 +13,17 @@ export declare enum TokenVersion {
13
13
  TOKEN_GOPLUS = 3,
14
14
  TOKEN_TAXED = 4,
15
15
  /** FlapTaxTokenV3 — 推荐税币;配合 newTokenV6 / newTokenV6WithVault */
16
- TOKEN_TAXED_V3 = 6
16
+ TOKEN_TAXED_V3 = 6,
17
+ /** 标准 V3 池(PCS Infinity CL);配合 newTokenV7 */
18
+ TOKEN_V3_PERMIT = 7
19
+ }
20
+ /** newTokenV7 feeConfigs 槽位类型 */
21
+ export declare enum FeeType {
22
+ NONE = 0,
23
+ MARKETING_OR_VAULT = 1,
24
+ DIVIDEND = 2,
25
+ DEFLATION = 3,
26
+ LP_BPS = 4
17
27
  }
18
28
  export declare enum DexThreshType {
19
29
  TWO_THIRDS = 0,
@@ -25,7 +35,9 @@ export declare enum DexThreshType {
25
35
  }
26
36
  export declare enum MigratorType {
27
37
  V3_MIGRATOR = 0,
28
- V2_MIGRATOR = 1
38
+ V2_MIGRATOR = 1,
39
+ /** PCS Infinity CL 迁移(newTokenV7 / TOKEN_V3_PERMIT) */
40
+ PCS_INFINITY_CL_MIGRATOR = 3
29
41
  }
30
42
  /**
31
43
  * V3 LP 费率档位
@@ -18,7 +18,18 @@ export var TokenVersion;
18
18
  TokenVersion[TokenVersion["TOKEN_TAXED"] = 4] = "TOKEN_TAXED";
19
19
  /** FlapTaxTokenV3 — 推荐税币;配合 newTokenV6 / newTokenV6WithVault */
20
20
  TokenVersion[TokenVersion["TOKEN_TAXED_V3"] = 6] = "TOKEN_TAXED_V3";
21
+ /** 标准 V3 池(PCS Infinity CL);配合 newTokenV7 */
22
+ TokenVersion[TokenVersion["TOKEN_V3_PERMIT"] = 7] = "TOKEN_V3_PERMIT";
21
23
  })(TokenVersion || (TokenVersion = {}));
24
+ /** newTokenV7 feeConfigs 槽位类型 */
25
+ export var FeeType;
26
+ (function (FeeType) {
27
+ FeeType[FeeType["NONE"] = 0] = "NONE";
28
+ FeeType[FeeType["MARKETING_OR_VAULT"] = 1] = "MARKETING_OR_VAULT";
29
+ FeeType[FeeType["DIVIDEND"] = 2] = "DIVIDEND";
30
+ FeeType[FeeType["DEFLATION"] = 3] = "DEFLATION";
31
+ FeeType[FeeType["LP_BPS"] = 4] = "LP_BPS";
32
+ })(FeeType || (FeeType = {}));
22
33
  export var DexThreshType;
23
34
  (function (DexThreshType) {
24
35
  DexThreshType[DexThreshType["TWO_THIRDS"] = 0] = "TWO_THIRDS";
@@ -32,6 +43,8 @@ export var MigratorType;
32
43
  (function (MigratorType) {
33
44
  MigratorType[MigratorType["V3_MIGRATOR"] = 0] = "V3_MIGRATOR";
34
45
  MigratorType[MigratorType["V2_MIGRATOR"] = 1] = "V2_MIGRATOR";
46
+ /** PCS Infinity CL 迁移(newTokenV7 / TOKEN_V3_PERMIT) */
47
+ MigratorType[MigratorType["PCS_INFINITY_CL_MIGRATOR"] = 3] = "PCS_INFINITY_CL_MIGRATOR";
35
48
  })(MigratorType || (MigratorType = {}));
36
49
  /**
37
50
  * V3 LP 费率档位
@@ -87,6 +100,8 @@ const PORTAL_ABI = [
87
100
  'function newTokenV5((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint16 taxRate,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint8 lpFeeProfile,uint64 taxDuration,uint64 antiFarmerDuration,uint16 mktBps,uint16 deflationBps,uint16 dividendBps,uint16 lpBps,uint256 minimumShareBalance)) external payable returns (address)',
88
101
  // newTokenV6: 统一发射入口(标准 TOKEN_V2_PERMIT / 税币 TOKEN_TAXED_V3)
89
102
  'function newTokenV6((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint8 migratorType,address quoteToken,uint256 quoteAmt,address beneficiary,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint8 lpFeeProfile,uint16 buyTaxRate,uint16 sellTaxRate,uint64 taxDuration,uint64 antiFarmerDuration,uint16 mktBps,uint16 deflationBps,uint16 dividendBps,uint16 lpBps,uint256 minimumShareBalance,address dividendToken,address commissionReceiver,uint8 tokenVersion)) external payable returns (address)',
103
+ // newTokenV7: TOKEN_V3_PERMIT + PCS Infinity CL 迁移(标准 V3 池,Portal v5.8.6+)
104
+ 'function newTokenV7((string name,string symbol,string meta,uint8 dexThresh,bytes32 salt,uint8 migratorType,address quoteToken,uint256 quoteAmt,bytes permitData,bytes32 extensionID,bytes extensionData,uint8 dexId,uint16 buyTaxRate,uint16 sellTaxRate,uint64 taxDuration,uint64 antiFarmerDuration,address commissionReceiver,uint8 tokenVersion,(uint8 feeType,uint16 bps,address marketingAddress,address dividendToken,uint256 minimumShareBalance)[4] feeConfigs)) external payable returns (address)',
90
105
  // 受益人领取
91
106
  'function claim(address token) external returns (uint256,uint256)',
92
107
  'function delegateClaim(address token) external returns (uint256,uint256)',
@@ -10,8 +10,9 @@ export declare function predictVanityTokenAddress(salt: string, portal: string,
10
10
  * BSC/MONAD 默认使用 NORMAL 实现(非税版)
11
11
  * @param taxedV5 - Legacy V5 税币 impl(不推荐,请用 taxedV3)
12
12
  * @param taxedV3 - TOKEN_TAXED_V3(newTokenV6 / newTokenV6WithVault)
13
+ * @param useV3Permit - TOKEN_V3_PERMIT / newTokenV7(标准 V3 池)
13
14
  */
14
- export declare function predictVanityTokenAddressByChain(chain: 'BSC' | 'BASE' | 'XLAYER' | 'MORPH' | 'MONAD', salt: string, taxed?: boolean, taxedV5?: boolean, taxedV3?: boolean): string;
15
+ export declare function predictVanityTokenAddressByChain(chain: 'BSC' | 'BASE' | 'XLAYER' | 'MORPH' | 'MONAD', salt: string, taxed?: boolean, taxedV5?: boolean, taxedV3?: boolean, useV3Permit?: boolean): string;
15
16
  /**
16
17
  * 寻找满足后缀的 salt(默认 8888)
17
18
  * 注意:该方法为同步 CPU 搜索,谨慎设置迭代限制
@@ -44,6 +45,8 @@ export declare function findSaltEndingByChain(opts: {
44
45
  taxed?: boolean;
45
46
  taxedV5?: boolean;
46
47
  taxedV3?: boolean;
48
+ /** BSC 标准币 UI「V3」/ newTokenV7 */
49
+ useV3Permit?: boolean;
47
50
  }): Promise<{
48
51
  salt: string;
49
52
  address: string;
@@ -21,8 +21,9 @@ export function predictVanityTokenAddress(salt, portal, tokenImpl) {
21
21
  * BSC/MONAD 默认使用 NORMAL 实现(非税版)
22
22
  * @param taxedV5 - Legacy V5 税币 impl(不推荐,请用 taxedV3)
23
23
  * @param taxedV3 - TOKEN_TAXED_V3(newTokenV6 / newTokenV6WithVault)
24
+ * @param useV3Permit - TOKEN_V3_PERMIT / newTokenV7(标准 V3 池)
24
25
  */
25
- export function predictVanityTokenAddressByChain(chain, salt, taxed = false, taxedV5 = false, taxedV3 = false) {
26
+ export function predictVanityTokenAddressByChain(chain, salt, taxed = false, taxedV5 = false, taxedV3 = false, useV3Permit = false) {
26
27
  // 使用 Flap 平台的原始 Portal 地址(用于 CREATE2)
27
28
  const portal = FLAP_ORIGINAL_PORTAL_ADDRESSES[chain];
28
29
  let tokenImpl;
@@ -33,6 +34,9 @@ export function predictVanityTokenAddressByChain(chain, salt, taxed = false, tax
33
34
  else if (taxedV5) {
34
35
  tokenImpl = FLAP_TOKEN_IMPL_ADDRESSES.BSC_TAXED_V5;
35
36
  }
37
+ else if (useV3Permit) {
38
+ tokenImpl = FLAP_TOKEN_IMPL_ADDRESSES.BSC_V3_PERMIT;
39
+ }
36
40
  else {
37
41
  tokenImpl = taxed ? FLAP_TOKEN_IMPL_ADDRESSES.BSC_TAXED : FLAP_TOKEN_IMPL_ADDRESSES.BSC_NORMAL;
38
42
  }
@@ -89,6 +93,9 @@ export async function findSaltEndingByChain(opts) {
89
93
  else if (opts.taxedV5) {
90
94
  tokenImpl = FLAP_TOKEN_IMPL_ADDRESSES.BSC_TAXED_V5;
91
95
  }
96
+ else if (opts.useV3Permit) {
97
+ tokenImpl = FLAP_TOKEN_IMPL_ADDRESSES.BSC_V3_PERMIT;
98
+ }
92
99
  else {
93
100
  tokenImpl = opts.taxed ? FLAP_TOKEN_IMPL_ADDRESSES.BSC_TAXED : FLAP_TOKEN_IMPL_ADDRESSES.BSC_NORMAL;
94
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "four-flap-meme-sdk",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
4
4
  "description": "SDK for Flap bonding curve and four.meme TokenManager",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",