four-flap-meme-sdk 1.8.8 → 1.9.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/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/shared/flap/index.d.ts +1 -1
- package/dist/shared/flap/index.js +7 -5
- package/dist/shared/flap/portal-bundle-merkle/core.js +64 -29
- package/dist/shared/flap/portal-bundle-merkle/create-to-dex.js +65 -30
- package/dist/shared/flap/vault.d.ts +364 -150
- package/dist/shared/flap/vault.js +385 -208
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export { flapBundleBuyFirstMerkle, type FlapBuyFirstSignConfig, type FlapBuyFirs
|
|
|
50
50
|
export { pancakeBundleBuyFirstMerkle, type PancakeBuyFirstSignConfig, type PancakeBuyFirstConfig, type PancakeBundleBuyFirstSignParams, type PancakeBundleBuyFirstParams, type PancakeBuyFirstResult } from './chains/bsc/pancake/bundle-buy-first.js';
|
|
51
51
|
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';
|
|
52
52
|
export { flapBundleCreateToDex, type CreateToDexChain, type CreateToDexSignConfig, type CreateTokenInfo, type FlapCreateToDexParams, type FlapCreateToDexResult } from './shared/flap/portal-bundle-merkle/create-to-dex.js';
|
|
53
|
-
export {
|
|
53
|
+
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, getVaultFactoryAddress, getVaultPortalAddress, queryVaultDataSchema, queryVaultUISchema, queryVaultDescription, validateVaultFactory, getVaultInfo, isValidContract, } from './shared/flap/vault.js';
|
|
54
54
|
export { PROFIT_CONFIG } from './shared/constants/index.js';
|
|
55
55
|
export { quoteV2, quoteV3, quote, getTokenToNativeQuote, getNativeToTokenQuote, getWrappedNativeAddress, // ✅ 来自 quote-helpers,与 shared/constants 同名但实现可能不同
|
|
56
56
|
getStableCoins, V3_FEE_TIERS, // ✅ 来自 quote-helpers
|
package/dist/index.js
CHANGED
|
@@ -95,8 +95,8 @@ export { pancakeBundleBuyFirstMerkle } from './chains/bsc/pancake/bundle-buy-fir
|
|
|
95
95
|
export { flapBundleCurveToDex } from './shared/flap/portal-bundle-merkle/curve-to-dex.js';
|
|
96
96
|
// ✅ 发币 + 一键买到外盘(Create → Curve → DEX)- 新代币
|
|
97
97
|
export { flapBundleCreateToDex } from './shared/flap/portal-bundle-merkle/create-to-dex.js';
|
|
98
|
-
// ✅ Tax Vault
|
|
99
|
-
export {
|
|
98
|
+
// ✅ Tax Vault 金库模块(基于 VaultPortal + VaultFactory 规范)
|
|
99
|
+
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, getVaultFactoryAddress, getVaultPortalAddress, queryVaultDataSchema, queryVaultUISchema, queryVaultDescription, validateVaultFactory, getVaultInfo, isValidContract, } from './shared/flap/vault.js';
|
|
100
100
|
// ✅ 硬编码利润配置(统一管理)- 从 shared/constants 导出
|
|
101
101
|
export { PROFIT_CONFIG } from './shared/constants/index.js';
|
|
102
102
|
// ✅ V2/V3 报价工具(统一管理)
|
|
@@ -19,4 +19,4 @@ export { FLAP_DEFAULT_FEE_RATES, FLAP_IPFS_API_URL, FLAP_VANITY_SUFFIX, FLAP_DEX
|
|
|
19
19
|
export * from './abi.js';
|
|
20
20
|
export { createTokenWithBundleBuy, batchBuyWithBundle, batchSellWithBundle, type FlapBundleConfig, type FlapChainForBundle, type FlapCreateWithBundleBuyParams, type FlapCreateWithBundleBuyResult, type FlapBatchBuyParams, type FlapBatchBuyResult, type FlapBatchSellParams, type FlapBatchSellResult, flapPrivateBuy, flapPrivateSell, flapBatchPrivateBuy, flapBatchPrivateSell, type FlapPrivateBuyParams, type FlapPrivateSellParams, type FlapBatchPrivateBuyParams, type FlapBatchPrivateSellParams, type FlapBatchPrivateSellResult, } from './portal-bundle.js';
|
|
21
21
|
export * from './portal-bundle-merkle/index.js';
|
|
22
|
-
export {
|
|
22
|
+
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, getVaultFactoryAddress, getVaultPortalAddress, queryVaultDataSchema, queryVaultUISchema, queryVaultDescription, validateVaultFactory, getVaultInfo, isValidContract, } from './vault.js';
|
|
@@ -21,11 +21,13 @@ export * from './abi.js';
|
|
|
21
21
|
export { createTokenWithBundleBuy, batchBuyWithBundle, batchSellWithBundle, flapPrivateBuy, flapPrivateSell, flapBatchPrivateBuy, flapBatchPrivateSell, } from './portal-bundle.js';
|
|
22
22
|
// portal-bundle-merkle 子模块
|
|
23
23
|
export * from './portal-bundle-merkle/index.js';
|
|
24
|
-
// ✅ Tax Vault
|
|
24
|
+
// ✅ Tax Vault 金库模块(基于 VaultPortal + VaultFactory 规范)
|
|
25
25
|
export {
|
|
26
26
|
// 常量
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
|
|
27
|
+
NONE_EXTENSION_ID, VAULT_TYPE_LABELS, VAULT_TYPE_CATEGORIES, VAULT_FACTORY_ADDRESSES, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI, VAULT_EXTRA_CONFIG, FLAP_GUARDIAN_ADDRESSES,
|
|
28
|
+
// ABI
|
|
29
|
+
VAULT_FACTORY_ABI, VAULT_FACTORY_V2_ABI, VAULT_BASE_ABI, VAULT_BASE_V2_ABI,
|
|
30
|
+
// 工具函数
|
|
31
|
+
encodeVaultData, buildVaultParams, buildVaultExtensionParams, getVaultFactoryAddress, getVaultPortalAddress,
|
|
30
32
|
// 链上查询
|
|
31
|
-
|
|
33
|
+
queryVaultDataSchema, queryVaultUISchema, queryVaultDescription, validateVaultFactory, getVaultInfo, isValidContract, } from './vault.js';
|
|
@@ -4,7 +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 {
|
|
7
|
+
import { buildVaultParams, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI } from '../vault.js';
|
|
8
8
|
import { CHAIN_ID_MAP, PORTAL_ABI, getErrorMessage, getTxType, getGasPriceConfig, shouldExtractProfit, calculateProfit, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA } from './config.js';
|
|
9
9
|
// ✅ 常量
|
|
10
10
|
const MULTICALL3_ADDRESS = ADDRESSES.BSC.Multicall3;
|
|
@@ -120,34 +120,69 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
120
120
|
if (total !== 10000) {
|
|
121
121
|
throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
|
|
122
122
|
}
|
|
123
|
-
// ✅
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
123
|
+
// ✅ 判断是否使用金库模式(VaultPortal.newTaxTokenWithVault)
|
|
124
|
+
const hasVault = tv2.vaultConfig && tv2.vaultConfig.vaultType !== 'none';
|
|
125
|
+
if (hasVault) {
|
|
126
|
+
// ✅ 金库模式:通过 VaultPortal.newTaxTokenWithVault 创建代币
|
|
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 { vaultFactory, vaultData } = buildVaultParams(tv2.vaultConfig, chain);
|
|
133
|
+
createTxPromise = vaultPortal.newTaxTokenWithVault.populateTransaction({
|
|
134
|
+
name: tokenInfo.name,
|
|
135
|
+
symbol: tokenInfo.symbol,
|
|
136
|
+
meta: tokenInfo.meta,
|
|
137
|
+
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
138
|
+
salt: params.salt ?? '0x' + '00'.repeat(32),
|
|
139
|
+
taxRate: (params.taxRate ?? 0) & 0xffff,
|
|
140
|
+
migratorType: (params.migratorType ?? 0) & 0xff,
|
|
141
|
+
quoteToken: params.quoteToken || ZERO_ADDRESS,
|
|
142
|
+
quoteAmt: 0n,
|
|
143
|
+
permitData: '0x',
|
|
144
|
+
extensionID: '0x' + '00'.repeat(32),
|
|
145
|
+
extensionData: '0x',
|
|
146
|
+
dexId: (params.dexId ?? 0) & 0xff,
|
|
147
|
+
lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff,
|
|
148
|
+
taxDuration: BigInt(tv2.taxDuration),
|
|
149
|
+
antiFarmerDuration: BigInt(tv2.antiFarmerDuration),
|
|
150
|
+
mktBps: dist.mktBps,
|
|
151
|
+
deflationBps: dist.deflationBps,
|
|
152
|
+
dividendBps: dist.dividendBps,
|
|
153
|
+
lpBps: dist.lpBps,
|
|
154
|
+
minimumShareBalance: BigInt(dist.minimumShareBalance ?? 10000) * (10n ** 18n),
|
|
155
|
+
vaultFactory,
|
|
156
|
+
vaultData,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
// 标准 V5: Portal.newTokenV5(无金库)
|
|
161
|
+
createTxPromise = portal.newTokenV5.populateTransaction({
|
|
162
|
+
name: tokenInfo.name,
|
|
163
|
+
symbol: tokenInfo.symbol,
|
|
164
|
+
meta: tokenInfo.meta,
|
|
165
|
+
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
166
|
+
salt: params.salt ?? '0x' + '00'.repeat(32),
|
|
167
|
+
taxRate: (params.taxRate ?? 0) & 0xffff,
|
|
168
|
+
migratorType: (params.migratorType ?? 0) & 0xff,
|
|
169
|
+
quoteToken: params.quoteToken || ZERO_ADDRESS,
|
|
170
|
+
quoteAmt: 0n,
|
|
171
|
+
beneficiary: devWallet.address,
|
|
172
|
+
permitData: '0x',
|
|
173
|
+
extensionID: params.extensionID ?? '0x' + '00'.repeat(32),
|
|
174
|
+
extensionData: params.extensionData ?? '0x',
|
|
175
|
+
dexId: (params.dexId ?? 0) & 0xff,
|
|
176
|
+
lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff,
|
|
177
|
+
taxDuration: BigInt(tv2.taxDuration),
|
|
178
|
+
antiFarmerDuration: BigInt(tv2.antiFarmerDuration),
|
|
179
|
+
mktBps: dist.mktBps,
|
|
180
|
+
deflationBps: dist.deflationBps,
|
|
181
|
+
dividendBps: dist.dividendBps,
|
|
182
|
+
lpBps: dist.lpBps,
|
|
183
|
+
minimumShareBalance: BigInt(dist.minimumShareBalance ?? 10000) * (10n ** 18n),
|
|
184
|
+
});
|
|
185
|
+
}
|
|
151
186
|
}
|
|
152
187
|
else if (useV4) {
|
|
153
188
|
// V4: 支持 DEX ID 和 LP 费率配置
|
|
@@ -10,7 +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 {
|
|
13
|
+
import { buildVaultParams, VAULT_PORTAL_ADDRESSES, VAULT_PORTAL_ABI } from '../vault.js';
|
|
14
14
|
import { PROFIT_CONFIG, ZERO_ADDRESS } from '../../../utils/constants.js';
|
|
15
15
|
import { GAS_LIMITS } from '../../constants/index.js';
|
|
16
16
|
import { getGasPriceConfig, getTxType, getProfitRecipient, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI } from './config.js';
|
|
@@ -334,35 +334,70 @@ export async function flapBundleCreateToDex(params) {
|
|
|
334
334
|
if (total !== 10000) {
|
|
335
335
|
throw new Error(`Tax distribution must sum to 10000 (100%), got ${total}`);
|
|
336
336
|
}
|
|
337
|
-
// ✅
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
337
|
+
// ✅ 判断是否使用金库模式(VaultPortal.newTaxTokenWithVault)
|
|
338
|
+
const hasVault = tv2.vaultConfig && tv2.vaultConfig.vaultType !== 'none';
|
|
339
|
+
if (hasVault) {
|
|
340
|
+
// ✅ 金库模式:通过 VaultPortal.newTaxTokenWithVault 创建代币
|
|
341
|
+
const chainKey = chain.toUpperCase();
|
|
342
|
+
const vaultPortalAddr = VAULT_PORTAL_ADDRESSES[chainKey];
|
|
343
|
+
if (!vaultPortalAddr) {
|
|
344
|
+
throw new Error(`链 "${chain}" 不支持 Tax Vault 金库功能`);
|
|
345
|
+
}
|
|
346
|
+
const vaultPortal = new Contract(vaultPortalAddr, VAULT_PORTAL_ABI, devWallet);
|
|
347
|
+
const { vaultFactory, vaultData } = buildVaultParams(tv2.vaultConfig, chainKey);
|
|
348
|
+
createUnsigned = await vaultPortal.newTaxTokenWithVault.populateTransaction({
|
|
349
|
+
name: tokenInfo.name,
|
|
350
|
+
symbol: tokenInfo.symbol,
|
|
351
|
+
meta: tokenInfo.meta,
|
|
352
|
+
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
353
|
+
salt: params.salt ?? '0x' + '00'.repeat(32),
|
|
354
|
+
taxRate: (params.taxRate ?? 0) & 0xffff,
|
|
355
|
+
migratorType: (params.migratorType ?? 0) & 0xff,
|
|
356
|
+
quoteToken: inputToken,
|
|
357
|
+
quoteAmt: 0n,
|
|
358
|
+
permitData: '0x',
|
|
359
|
+
extensionID: '0x' + '00'.repeat(32),
|
|
360
|
+
extensionData: '0x',
|
|
361
|
+
dexId: (params.dexId ?? 0) & 0xff,
|
|
362
|
+
lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff,
|
|
363
|
+
taxDuration: BigInt(tv2.taxDuration),
|
|
364
|
+
antiFarmerDuration: BigInt(tv2.antiFarmerDuration),
|
|
365
|
+
mktBps: tv2.mktBps & 0xffff,
|
|
366
|
+
deflationBps: tv2.deflationBps & 0xffff,
|
|
367
|
+
dividendBps: tv2.dividendBps & 0xffff,
|
|
368
|
+
lpBps: tv2.lpBps & 0xffff,
|
|
369
|
+
minimumShareBalance: BigInt(tv2.minimumShareBalance ?? 10000) * (10n ** 18n),
|
|
370
|
+
vaultFactory,
|
|
371
|
+
vaultData,
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
// 标准 V5: Portal.newTokenV5(无金库)
|
|
376
|
+
createUnsigned = await originalPortal.newTokenV5.populateTransaction({
|
|
377
|
+
name: tokenInfo.name,
|
|
378
|
+
symbol: tokenInfo.symbol,
|
|
379
|
+
meta: tokenInfo.meta,
|
|
380
|
+
dexThresh: (params.dexThresh ?? 1) & 0xff,
|
|
381
|
+
salt: params.salt ?? '0x' + '00'.repeat(32),
|
|
382
|
+
taxRate: (params.taxRate ?? 0) & 0xffff,
|
|
383
|
+
migratorType: (params.migratorType ?? 0) & 0xff,
|
|
384
|
+
quoteToken: inputToken,
|
|
385
|
+
quoteAmt: 0n,
|
|
386
|
+
beneficiary: devWallet.address,
|
|
387
|
+
permitData: '0x',
|
|
388
|
+
extensionID: params.extensionID ?? '0x' + '00'.repeat(32),
|
|
389
|
+
extensionData: params.extensionData ?? '0x',
|
|
390
|
+
dexId: (params.dexId ?? 0) & 0xff,
|
|
391
|
+
lpFeeProfile: (params.lpFeeProfile ?? 0) & 0xff,
|
|
392
|
+
taxDuration: BigInt(tv2.taxDuration),
|
|
393
|
+
antiFarmerDuration: BigInt(tv2.antiFarmerDuration),
|
|
394
|
+
mktBps: tv2.mktBps & 0xffff,
|
|
395
|
+
deflationBps: tv2.deflationBps & 0xffff,
|
|
396
|
+
dividendBps: tv2.dividendBps & 0xffff,
|
|
397
|
+
lpBps: tv2.lpBps & 0xffff,
|
|
398
|
+
minimumShareBalance: BigInt(tv2.minimumShareBalance ?? 10000) * (10n ** 18n),
|
|
399
|
+
});
|
|
400
|
+
}
|
|
366
401
|
}
|
|
367
402
|
else if (useV4) {
|
|
368
403
|
// V4: 支持 DEX ID 和 LP 费率配置(用于选择池子费率)
|