four-flap-meme-sdk 2.0.0 → 2.1.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/__tests__/subpath-exports.test.js +34 -0
- package/dist/chains/index.d.ts +13 -0
- package/dist/chains/index.js +13 -0
- package/dist/chains/xlayer/eip7702/index.d.ts +2 -0
- package/dist/flap/index.d.ts +10 -0
- package/dist/flap/index.js +8 -0
- package/dist/shared/constants/index.d.ts +2 -0
- package/dist/shared/index.d.ts +2 -0
- package/package.json +66 -1
- package/dist/chains/bsc/four/disperse.d.ts +0 -12
- package/dist/chains/bsc/four/disperse.js +0 -470
- package/dist/chains/bsc/four/pairwise.d.ts +0 -7
- package/dist/chains/bsc/four/pairwise.js +0 -308
- package/dist/chains/bsc/four/submit/blockrazor.d.ts +0 -18
- package/dist/chains/bsc/four/submit/blockrazor.js +0 -86
- package/dist/chains/bsc/four/submit/direct.d.ts +0 -66
- package/dist/chains/bsc/four/submit/direct.js +0 -452
- package/dist/chains/bsc/four/submit/helpers.d.ts +0 -18
- package/dist/chains/bsc/four/submit/helpers.js +0 -57
- package/dist/chains/bsc/four/submit/index.d.ts +0 -12
- package/dist/chains/bsc/four/submit/index.js +0 -11
- package/dist/chains/bsc/four/submit/merkle.d.ts +0 -18
- package/dist/chains/bsc/four/submit/merkle.js +0 -74
- package/dist/chains/bsc/four/submit/types.d.ts +0 -143
- package/dist/chains/bsc/four/swap/index.d.ts +0 -32
- package/dist/chains/bsc/four/swap/index.js +0 -829
- package/dist/chains/bsc/four/swap/types.d.ts +0 -70
- package/dist/chains/bsc/four/swap/types.js +0 -1
- package/dist/chains/bsc/four/sweep.d.ts +0 -13
- package/dist/chains/bsc/four/sweep.js +0 -788
- package/dist/chains/bsc/four/utils/index.d.ts +0 -20
- package/dist/chains/bsc/four/utils/index.js +0 -1558
- package/dist/chains/bsc/four/utils/types.d.ts +0 -1
- package/dist/chains/bsc/four/utils/types.js +0 -1
- package/dist/chains/bsc/pancake/bundle-buy-first/index.d.ts +0 -8
- package/dist/chains/bsc/pancake/bundle-buy-first/index.js +0 -907
- package/dist/chains/bsc/pancake/bundle-buy-first/types.d.ts +0 -73
- package/dist/chains/bsc/pancake/bundle-buy-first/types.js +0 -1
- package/dist/chains/bsc/pancake/bundle-swap/helpers.d.ts +0 -102
- package/dist/chains/bsc/pancake/bundle-swap/helpers.js +0 -572
- package/dist/chains/bsc/pancake/bundle-swap/index.d.ts +0 -50
- package/dist/chains/bsc/pancake/bundle-swap/index.js +0 -1066
- package/dist/chains/bsc/pancake/bundle-swap/types.d.ts +0 -202
- package/dist/chains/bsc/pancake/bundle-swap/types.js +0 -3
- package/dist/chains/xlayer/eip7702/bundle-swap/index.d.ts +0 -72
- package/dist/chains/xlayer/eip7702/bundle-swap/index.js +0 -921
- package/dist/chains/xlayer/eip7702/bundle-swap/types.d.ts +0 -65
- package/dist/chains/xlayer/eip7702/bundle-swap/types.js +0 -1
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.d.ts +0 -128
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/index.js +0 -857
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.d.ts +0 -85
- package/dist/chains/xlayer/eip7702/multi-hop-transfer/types.js +0 -1
- package/dist/chains/xlayer/eip7702/volume/index.d.ts +0 -96
- package/dist/chains/xlayer/eip7702/volume/index.js +0 -793
- package/dist/chains/xlayer/eip7702/volume/types.d.ts +0 -124
- package/dist/chains/xlayer/eip7702/volume/types.js +0 -1
- package/dist/chains/xlayer/eoa/types-core.d.ts +0 -363
- package/dist/chains/xlayer/eoa/types-core.js +0 -53
- package/dist/chains/xlayer/eoa/types-create.d.ts +0 -413
- package/dist/chains/xlayer/eoa/types-create.js +0 -9
- package/dist/chains/xlayer/eoa/types-volume.d.ts +0 -209
- package/dist/chains/xlayer/eoa/types-volume.js +0 -13
- package/dist/dex/direct-router/index.d.ts +0 -70
- package/dist/dex/direct-router/index.js +0 -1410
- package/dist/dex/direct-router/types.d.ts +0 -81
- package/dist/dex/direct-router/types.js +0 -1
- package/dist/shared/abis/TaxToken.json +0 -969
- package/dist/shared/abis/TokenManager.json +0 -836
- package/dist/shared/abis/TokenManager2.json +0 -136
- package/dist/shared/abis/TokenManagerHelper3.json +0 -993
- package/dist/shared/abis 2/TaxToken.json +0 -105
- package/dist/shared/abis 2/TokenManager.json +0 -836
- package/dist/shared/abis 2/TokenManager2.json +0 -60
- package/dist/shared/abis 2/TokenManagerHelper3.json +0 -993
- package/dist/shared/abis 2/common.d.ts +0 -85
- package/dist/shared/abis 2/common.js +0 -254
- package/dist/shared/abis 2/index.d.ts +0 -8
- package/dist/shared/abis 2/index.js +0 -8
- package/dist/shared/clients 2/blockrazor.d.ts +0 -314
- package/dist/shared/clients 2/blockrazor.js +0 -596
- package/dist/shared/clients 2/club48.d.ts +0 -154
- package/dist/shared/clients 2/club48.js +0 -331
- package/dist/shared/clients 2/emitservice.d.ts +0 -47
- package/dist/shared/clients 2/emitservice.js +0 -44
- package/dist/shared/clients 2/four.d.ts +0 -132
- package/dist/shared/clients 2/four.js +0 -281
- package/dist/shared/clients 2/merkle.d.ts +0 -210
- package/dist/shared/clients 2/merkle.js +0 -400
- package/dist/shared/flap/__tests__/curve.test.d.ts +0 -1
- package/dist/shared/flap/__tests__/curve.test.js +0 -85
- package/dist/shared/flap/portal/index.d.ts +0 -12
- package/dist/shared/flap/portal/index.js +0 -11
- package/dist/shared/flap/portal/portal.d.ts +0 -47
- package/dist/shared/flap/portal/portal.js +0 -218
- package/dist/shared/flap/portal/types.d.ts +0 -227
- package/dist/shared/flap/portal/types.js +0 -80
- package/dist/shared/flap/portal/writer.d.ts +0 -121
- package/dist/shared/flap/portal/writer.js +0 -265
- package/dist/shared/flap/portal-bundle-merkle/core/index.d.ts +0 -18
- package/dist/shared/flap/portal-bundle-merkle/core/index.js +0 -938
- package/dist/shared/flap/portal-bundle-merkle/core/types.d.ts +0 -1
- package/dist/shared/flap/portal-bundle-merkle/core/types.js +0 -1
- package/dist/shared/flap/portal-bundle-merkle/swap/index.d.ts +0 -42
- package/dist/shared/flap/portal-bundle-merkle/swap/index.js +0 -1448
- package/dist/shared/flap/portal-bundle-merkle/swap/types.d.ts +0 -84
- package/dist/shared/flap/portal-bundle-merkle/swap/types.js +0 -1
- package/dist/shared/flap/portal-bundle-merkle/utils/index.d.ts +0 -17
- package/dist/shared/flap/portal-bundle-merkle/utils/index.js +0 -1024
- package/dist/shared/flap/portal-bundle-merkle/utils/types.d.ts +0 -16
- package/dist/shared/flap/portal-bundle-merkle/utils/types.js +0 -1
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.d.ts +0 -100
- package/dist/shared/flap/portal-bundle-merkle/utils-helpers.js +0 -133
- package/dist/shared/flap 2/__tests__/curve.test.d.ts +0 -1
- package/dist/shared/flap 2/__tests__/curve.test.js +0 -85
- package/dist/shared/flap 2/abi.d.ts +0 -4
- package/dist/shared/flap 2/abi.js +0 -4
- package/dist/shared/flap 2/constants.d.ts +0 -128
- package/dist/shared/flap 2/constants.js +0 -143
- package/dist/shared/flap 2/curve.d.ts +0 -33
- package/dist/shared/flap 2/curve.js +0 -84
- package/dist/shared/flap 2/errors.d.ts +0 -37
- package/dist/shared/flap 2/errors.js +0 -114
- package/dist/shared/flap 2/index.d.ts +0 -22
- package/dist/shared/flap 2/index.js +0 -33
- package/dist/shared/flap 2/ipfs.d.ts +0 -21
- package/dist/shared/flap 2/ipfs.js +0 -38
- package/dist/shared/flap 2/meta.d.ts +0 -30
- package/dist/shared/flap 2/meta.js +0 -195
- package/dist/shared/flap 2/permit.d.ts +0 -16
- package/dist/shared/flap 2/permit.js +0 -67
- package/dist/shared/flap 2/pinata.d.ts +0 -40
- package/dist/shared/flap 2/pinata.js +0 -106
- package/dist/shared/flap 2/portal-bundle-merkle/config.d.ts +0 -79
- package/dist/shared/flap 2/portal-bundle-merkle/config.js +0 -133
- package/dist/shared/flap 2/portal-bundle-merkle/core.d.ts +0 -18
- package/dist/shared/flap 2/portal-bundle-merkle/core.js +0 -938
- package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.d.ts +0 -125
- package/dist/shared/flap 2/portal-bundle-merkle/create-to-dex.js +0 -665
- package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.d.ts +0 -88
- package/dist/shared/flap 2/portal-bundle-merkle/curve-to-dex.js +0 -446
- package/dist/shared/flap 2/portal-bundle-merkle/index.d.ts +0 -14
- package/dist/shared/flap 2/portal-bundle-merkle/index.js +0 -26
- package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.d.ts +0 -28
- package/dist/shared/flap 2/portal-bundle-merkle/pancake-proxy.js +0 -701
- package/dist/shared/flap 2/portal-bundle-merkle/private.d.ts +0 -17
- package/dist/shared/flap 2/portal-bundle-merkle/private.js +0 -549
- package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.d.ts +0 -65
- package/dist/shared/flap 2/portal-bundle-merkle/swap-buy-first.js +0 -831
- package/dist/shared/flap 2/portal-bundle-merkle/swap.d.ts +0 -201
- package/dist/shared/flap 2/portal-bundle-merkle/swap.js +0 -1359
- package/dist/shared/flap 2/portal-bundle-merkle/types.d.ts +0 -358
- package/dist/shared/flap 2/portal-bundle-merkle/types.js +0 -1
- package/dist/shared/flap 2/portal-bundle-merkle/utils.d.ts +0 -89
- package/dist/shared/flap 2/portal-bundle-merkle/utils.js +0 -963
- package/dist/shared/flap 2/portal-bundle.d.ts +0 -119
- package/dist/shared/flap 2/portal-bundle.js +0 -584
- package/dist/shared/flap 2/portal.d.ts +0 -392
- package/dist/shared/flap 2/portal.js +0 -559
- package/dist/shared/flap 2/vanity.d.ts +0 -48
- package/dist/shared/flap 2/vanity.js +0 -110
- package/dist/shared/flap 2/vault.d.ts +0 -240
- package/dist/shared/flap 2/vault.js +0 -366
- package/dist/shared/four 2/index.d.ts +0 -7
- package/dist/shared/four 2/index.js +0 -22
- package/dist/shared/four 2/tax-token.d.ts +0 -176
- package/dist/shared/four 2/tax-token.js +0 -302
- package/dist/shared/index 2.js +0 -10
- package/dist/shared/index.d 2.ts +0 -10
- package/dist/types/distribute.d.ts +0 -72
- package/dist/types/distribute.js +0 -1
- package/dist/types 2/errors.d.ts +0 -27
- package/dist/types 2/errors.js +0 -34
- package/dist/utils/__tests__/errors.test.d.ts +0 -1
- package/dist/utils/__tests__/errors.test.js +0 -76
- package/dist/utils/airdrop-sweep-types.d.ts +0 -1
- package/dist/utils/airdrop-sweep-types.js +0 -1
- package/dist/utils/erc20/index.d.ts +0 -242
- package/dist/utils/erc20/index.js +0 -645
- package/dist/utils/erc20/types.d.ts +0 -77
- package/dist/utils/erc20/types.js +0 -1
- package/dist/utils/erc20-types.d.ts +0 -1
- package/dist/utils/erc20-types.js +0 -1
- package/dist/utils/holders-maker/helpers.d.ts +0 -43
- package/dist/utils/holders-maker/helpers.js +0 -371
- package/dist/utils/holders-maker/index.d.ts +0 -26
- package/dist/utils/holders-maker/index.js +0 -218
- package/dist/utils/holders-maker/types.d.ts +0 -72
- package/dist/utils/holders-maker/types.js +0 -4
- package/dist/utils/holders-maker-types.d.ts +0 -1
- package/dist/utils/holders-maker-types.js +0 -1
- package/dist/utils/lp-inspect/index.d.ts +0 -44
- package/dist/utils/lp-inspect/index.js +0 -937
- package/dist/utils/lp-inspect/types.d.ts +0 -100
- package/dist/utils/lp-inspect/types.js +0 -1
- package/dist/utils/lp-inspect-types.d.ts +0 -1
- package/dist/utils/lp-inspect-types.js +0 -1
- package/dist/utils/private-sale-types.d.ts +0 -1
- package/dist/utils/private-sale-types.js +0 -1
- package/dist/utils/quote-helpers/index.d.ts +0 -107
- package/dist/utils/quote-helpers/index.js +0 -346
- package/dist/utils/quote-helpers/types.d.ts +0 -16
- package/dist/utils/quote-helpers/types.js +0 -1
- package/dist/utils/quote-helpers-types.d.ts +0 -1
- package/dist/utils/quote-helpers-types.js +0 -1
- /package/dist/{chains/bsc/four/submit/types.js → __tests__/subpath-exports.test.d.ts} +0 -0
|
@@ -1,559 +0,0 @@
|
|
|
1
|
-
import { Contract, Wallet, JsonRpcProvider, formatEther, FixedNumber } from 'ethers';
|
|
2
|
-
import { CDPV2 } from './curve.js';
|
|
3
|
-
import { FLAP_PORTAL_ADDRESSES, FLAP_DEFAULT_FEE_RATES } from './constants.js';
|
|
4
|
-
export var TokenStatus;
|
|
5
|
-
(function (TokenStatus) {
|
|
6
|
-
TokenStatus[TokenStatus["Invalid"] = 0] = "Invalid";
|
|
7
|
-
TokenStatus[TokenStatus["Tradable"] = 1] = "Tradable";
|
|
8
|
-
TokenStatus[TokenStatus["InDuel"] = 2] = "InDuel";
|
|
9
|
-
TokenStatus[TokenStatus["Killed"] = 3] = "Killed";
|
|
10
|
-
TokenStatus[TokenStatus["DEX"] = 4] = "DEX";
|
|
11
|
-
})(TokenStatus || (TokenStatus = {}));
|
|
12
|
-
export var TokenVersion;
|
|
13
|
-
(function (TokenVersion) {
|
|
14
|
-
TokenVersion[TokenVersion["TOKEN_LEGACY_MINT_NO_PERMIT"] = 0] = "TOKEN_LEGACY_MINT_NO_PERMIT";
|
|
15
|
-
TokenVersion[TokenVersion["TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE"] = 1] = "TOKEN_LEGACY_MINT_NO_PERMIT_DUPLICATE";
|
|
16
|
-
TokenVersion[TokenVersion["TOKEN_V2_PERMIT"] = 2] = "TOKEN_V2_PERMIT";
|
|
17
|
-
TokenVersion[TokenVersion["TOKEN_GOPLUS"] = 3] = "TOKEN_GOPLUS";
|
|
18
|
-
TokenVersion[TokenVersion["TOKEN_TAXED"] = 4] = "TOKEN_TAXED";
|
|
19
|
-
})(TokenVersion || (TokenVersion = {}));
|
|
20
|
-
export var DexThreshType;
|
|
21
|
-
(function (DexThreshType) {
|
|
22
|
-
DexThreshType[DexThreshType["TWO_THIRDS"] = 0] = "TWO_THIRDS";
|
|
23
|
-
DexThreshType[DexThreshType["FOUR_FIFTHS"] = 1] = "FOUR_FIFTHS";
|
|
24
|
-
DexThreshType[DexThreshType["HALF"] = 2] = "HALF";
|
|
25
|
-
DexThreshType[DexThreshType["_95_PERCENT"] = 3] = "_95_PERCENT";
|
|
26
|
-
DexThreshType[DexThreshType["_81_PERCENT"] = 4] = "_81_PERCENT";
|
|
27
|
-
DexThreshType[DexThreshType["_1_PERCENT"] = 5] = "_1_PERCENT";
|
|
28
|
-
})(DexThreshType || (DexThreshType = {}));
|
|
29
|
-
export var MigratorType;
|
|
30
|
-
(function (MigratorType) {
|
|
31
|
-
MigratorType[MigratorType["V3_MIGRATOR"] = 0] = "V3_MIGRATOR";
|
|
32
|
-
MigratorType[MigratorType["V2_MIGRATOR"] = 1] = "V2_MIGRATOR";
|
|
33
|
-
})(MigratorType || (MigratorType = {}));
|
|
34
|
-
/**
|
|
35
|
-
* V3 LP 费率档位
|
|
36
|
-
* 决定代币迁移到 Uniswap V3 或 PancakeSwap V3 时使用的费率
|
|
37
|
-
*/
|
|
38
|
-
export var V3LPFeeProfile;
|
|
39
|
-
(function (V3LPFeeProfile) {
|
|
40
|
-
/** 标准费率: PancakeSwap 0.25%, Uniswap 0.3% */
|
|
41
|
-
V3LPFeeProfile[V3LPFeeProfile["LP_FEE_PROFILE_STANDARD"] = 0] = "LP_FEE_PROFILE_STANDARD";
|
|
42
|
-
/** 低费率: PancakeSwap 0.01%, Uniswap 0.05% (BNB 链需要白名单) */
|
|
43
|
-
V3LPFeeProfile[V3LPFeeProfile["LP_FEE_PROFILE_LOW"] = 1] = "LP_FEE_PROFILE_LOW";
|
|
44
|
-
/** 高费率: 1% (适用于特殊交易对) */
|
|
45
|
-
V3LPFeeProfile[V3LPFeeProfile["LP_FEE_PROFILE_HIGH"] = 2] = "LP_FEE_PROFILE_HIGH";
|
|
46
|
-
})(V3LPFeeProfile || (V3LPFeeProfile = {}));
|
|
47
|
-
/**
|
|
48
|
-
* DEX ID
|
|
49
|
-
* 决定代币迁移到哪个 DEX
|
|
50
|
-
* - BSC: DEX0 = PancakeSwap
|
|
51
|
-
* - xLayer: DEX0 = PotatoSwap
|
|
52
|
-
* - Monad: DEX0 = Uniswap, DEX1 = PancakeSwap, DEX2 = Monday
|
|
53
|
-
*/
|
|
54
|
-
export var DEXId;
|
|
55
|
-
(function (DEXId) {
|
|
56
|
-
DEXId[DEXId["DEX0"] = 0] = "DEX0";
|
|
57
|
-
DEXId[DEXId["DEX1"] = 1] = "DEX1";
|
|
58
|
-
DEXId[DEXId["DEX2"] = 2] = "DEX2";
|
|
59
|
-
})(DEXId || (DEXId = {}));
|
|
60
|
-
import { PORTAL_ABI } from '../../abis/flap/portal.js';
|
|
61
|
-
/**
|
|
62
|
-
* 将 lpFeeProfile 转换为 V3 fee 值
|
|
63
|
-
*/
|
|
64
|
-
export function lpFeeProfileToV3Fee(profile) {
|
|
65
|
-
switch (profile) {
|
|
66
|
-
case V3LPFeeProfile.LP_FEE_PROFILE_STANDARD: return 2500;
|
|
67
|
-
case V3LPFeeProfile.LP_FEE_PROFILE_LOW: return 100;
|
|
68
|
-
case V3LPFeeProfile.LP_FEE_PROFILE_HIGH: return 10000;
|
|
69
|
-
default: return 2500; // 默认 STANDARD
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* 验证税收分配是否有效
|
|
74
|
-
*/
|
|
75
|
-
export function validateTaxDistribution(config) {
|
|
76
|
-
const total = config.mktBps + config.deflationBps + config.dividendBps + config.lpBps;
|
|
77
|
-
if (total !== 10000) {
|
|
78
|
-
return { valid: false, error: `税收分配总计必须为 100%,当前为 ${total / 100}%` };
|
|
79
|
-
}
|
|
80
|
-
if (config.dividendBps > 0 && (!config.minimumShareBalance || config.minimumShareBalance < 10000n * 10n ** 18n)) {
|
|
81
|
-
return { valid: false, error: '启用分红时,最低持仓门槛必须至少为 10,000 个代币' };
|
|
82
|
-
}
|
|
83
|
-
return { valid: true };
|
|
84
|
-
}
|
|
85
|
-
export class FlapPortal {
|
|
86
|
-
constructor(cfg) {
|
|
87
|
-
this.rpcUrl = cfg.rpcUrl;
|
|
88
|
-
this.portal = cfg.addressOverride ?? FLAP_PORTAL_ADDRESSES[cfg.chain];
|
|
89
|
-
// 使用链对应的默认费率,如果用户指定了费率则覆盖
|
|
90
|
-
const defaultFees = FLAP_DEFAULT_FEE_RATES[cfg.chain];
|
|
91
|
-
this.buyFeeRate = cfg.buyFeeRate ?? defaultFees.buy;
|
|
92
|
-
this.sellFeeRate = cfg.sellFeeRate ?? defaultFees.sell;
|
|
93
|
-
// 使用 ethers v6 创建只读合约实例
|
|
94
|
-
const provider = new JsonRpcProvider(this.rpcUrl);
|
|
95
|
-
this.contract = new Contract(this.portal, PORTAL_ABI, provider);
|
|
96
|
-
}
|
|
97
|
-
async getTokenV2(token) {
|
|
98
|
-
const r = await this.contract.getTokenV2(token);
|
|
99
|
-
return {
|
|
100
|
-
status: r[0], reserve: r[1], circulatingSupply: r[2], price: r[3], tokenVersion: r[4], r: r[5], dexSupplyThresh: r[6],
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
async getTokenV3(token) {
|
|
104
|
-
const r = await this.contract.getTokenV3(token);
|
|
105
|
-
return {
|
|
106
|
-
status: r[0], reserve: r[1], circulatingSupply: r[2], price: r[3], tokenVersion: r[4], r: r[5], dexSupplyThresh: r[6], quoteTokenAddress: r[7], nativeToQuoteSwapEnabled: r[8],
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
async getTokenV4(token) {
|
|
110
|
-
const raw = await this.contract.getTokenV4(token);
|
|
111
|
-
return {
|
|
112
|
-
status: raw[0],
|
|
113
|
-
reserve: raw[1],
|
|
114
|
-
circulatingSupply: raw[2],
|
|
115
|
-
price: raw[3],
|
|
116
|
-
tokenVersion: raw[4],
|
|
117
|
-
r: raw[5],
|
|
118
|
-
dexSupplyThresh: raw[6],
|
|
119
|
-
quoteTokenAddress: raw[7],
|
|
120
|
-
nativeToQuoteSwapEnabled: raw[8],
|
|
121
|
-
extensionID: raw[9],
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
async getTokenV5(token) {
|
|
125
|
-
const raw = await this.contract.getTokenV5(token);
|
|
126
|
-
return {
|
|
127
|
-
status: raw[0],
|
|
128
|
-
reserve: raw[1],
|
|
129
|
-
circulatingSupply: raw[2],
|
|
130
|
-
price: raw[3],
|
|
131
|
-
tokenVersion: raw[4],
|
|
132
|
-
r: raw[5],
|
|
133
|
-
h: raw[6],
|
|
134
|
-
k: raw[7],
|
|
135
|
-
dexSupplyThresh: raw[8],
|
|
136
|
-
quoteTokenAddress: raw[9],
|
|
137
|
-
nativeToQuoteSwapEnabled: raw[10],
|
|
138
|
-
extensionID: raw[11],
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* 获取代币状态 V7(包含毕业相关信息)
|
|
143
|
-
* 注意:仅部分链支持 V7(如 XLayer v5.7+),不支持的链会 revert
|
|
144
|
-
*/
|
|
145
|
-
async getTokenV7(token) {
|
|
146
|
-
const raw = await this.contract.getTokenV7(token);
|
|
147
|
-
return {
|
|
148
|
-
status: raw[0],
|
|
149
|
-
reserve: raw[1],
|
|
150
|
-
circulatingSupply: raw[2],
|
|
151
|
-
price: raw[3],
|
|
152
|
-
tokenVersion: raw[4],
|
|
153
|
-
r: raw[5],
|
|
154
|
-
h: raw[6],
|
|
155
|
-
k: raw[7],
|
|
156
|
-
dexSupplyThresh: raw[8],
|
|
157
|
-
quoteTokenAddress: raw[9],
|
|
158
|
-
nativeToQuoteSwapEnabled: raw[10],
|
|
159
|
-
extensionID: raw[11],
|
|
160
|
-
taxRate: raw[12],
|
|
161
|
-
pool: raw[13],
|
|
162
|
-
progress: raw[14],
|
|
163
|
-
lpFeeProfile: Number(raw[15]),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 计算距离毕业还需多少 OKB/ETH(含手续费)
|
|
168
|
-
* @param state TokenStateV5 或 TokenStateV7
|
|
169
|
-
* @returns 毕业相关信息
|
|
170
|
-
*/
|
|
171
|
-
computeRemainingToGraduation(state) {
|
|
172
|
-
const r = Number(formatEther(state.r));
|
|
173
|
-
const h = Number(formatEther(state.h));
|
|
174
|
-
const k = Number(formatEther(state.k));
|
|
175
|
-
const curve = new CDPV2(r, h, k);
|
|
176
|
-
const currentReserve = formatEther(state.reserve);
|
|
177
|
-
const dexSupplyThresh = formatEther(state.dexSupplyThresh);
|
|
178
|
-
const circulatingSupply = formatEther(state.circulatingSupply);
|
|
179
|
-
// 计算毕业时的储备
|
|
180
|
-
const graduationReserve = curve.estimateReserve(dexSupplyThresh);
|
|
181
|
-
const graduationReserveNum = parseFloat(graduationReserve.toString());
|
|
182
|
-
const currentReserveNum = parseFloat(currentReserve);
|
|
183
|
-
// 是否已毕业 (status == 4 表示 DEX)
|
|
184
|
-
const isGraduated = state.status === 4;
|
|
185
|
-
// 还需多少(净值)
|
|
186
|
-
const remainingNet = Math.max(0, graduationReserveNum - currentReserveNum);
|
|
187
|
-
// 含手续费(1% buy fee)
|
|
188
|
-
const remainingWithFee = remainingNet / (1 - this.buyFeeRate);
|
|
189
|
-
// 计算进度
|
|
190
|
-
const progressPercent = isGraduated
|
|
191
|
-
? '100.00'
|
|
192
|
-
: (currentReserveNum / graduationReserveNum * 100).toFixed(2);
|
|
193
|
-
return {
|
|
194
|
-
remainingOkb: remainingWithFee.toFixed(6),
|
|
195
|
-
graduationReserve: graduationReserveNum.toFixed(6),
|
|
196
|
-
currentReserve: currentReserveNum.toFixed(6),
|
|
197
|
-
isGraduated,
|
|
198
|
-
progressPercent,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
// 价格/进度
|
|
202
|
-
computePriceAndProgress(state) {
|
|
203
|
-
// 使用合约返回的实时价格,而不是重新计算
|
|
204
|
-
// 合约的 price 字段会在每次买卖后更新,是最准确的实时价格
|
|
205
|
-
const price = formatEther(state.price);
|
|
206
|
-
// 计算进度(保留4位小数,格式如 "0.5432" 或 "1.0000")
|
|
207
|
-
let progress;
|
|
208
|
-
const supply = formatEther(state.circulatingSupply);
|
|
209
|
-
const dexThresh = formatEther(state.dexSupplyThresh);
|
|
210
|
-
const supplyNum = FixedNumber.fromString(supply);
|
|
211
|
-
const dexThreshNum = FixedNumber.fromString(dexThresh);
|
|
212
|
-
if (supplyNum.gte(dexThreshNum)) {
|
|
213
|
-
// 如果已达到或超过 DEX 阈值,进度为 100%
|
|
214
|
-
progress = '1.0000';
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
// 使用曲线计算当前和预期的储备量
|
|
218
|
-
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
219
|
-
const currReserve = curve.estimateReserve(supply);
|
|
220
|
-
const expectReserve = curve.estimateReserve(dexThresh);
|
|
221
|
-
if (expectReserve.isZero() || parseFloat(expectReserve.toString()) <= 0) {
|
|
222
|
-
// 如果预期储备量为 0 或负数,进度为 0
|
|
223
|
-
progress = '0.0000';
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
// 使用 FixedNumber 进行精度计算,保留 4 位小数
|
|
227
|
-
const progressNum = currReserve.div(expectReserve);
|
|
228
|
-
progress = parseFloat(progressNum.toString()).toFixed(4);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return { price, progress };
|
|
232
|
-
}
|
|
233
|
-
// 示例报价(离线)
|
|
234
|
-
quoteBuy(state, inputEth) {
|
|
235
|
-
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
236
|
-
const supply = formatEther(state.circulatingSupply);
|
|
237
|
-
const dexThresh = formatEther(state.dexSupplyThresh);
|
|
238
|
-
const currReserve = curve.estimateReserve(supply);
|
|
239
|
-
const maxReserve = curve.estimateReserve(dexThresh);
|
|
240
|
-
// 使用 FixedNumber 进行精度计算
|
|
241
|
-
const inputAfterFee = FixedNumber.fromString(inputEth).mul(FixedNumber.fromValue(1 - this.buyFeeRate));
|
|
242
|
-
let newReserve;
|
|
243
|
-
if (curve.h === 0) {
|
|
244
|
-
newReserve = currReserve.add(inputAfterFee);
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
const availableReserve = maxReserve.sub(currReserve);
|
|
248
|
-
const actualInput = parseFloat(inputAfterFee.toString()) <= parseFloat(availableReserve.toString())
|
|
249
|
-
? inputAfterFee
|
|
250
|
-
: availableReserve;
|
|
251
|
-
newReserve = currReserve.add(actualInput);
|
|
252
|
-
}
|
|
253
|
-
const newSupply = curve.estimateSupply(newReserve.toString());
|
|
254
|
-
const outputTokens = newSupply.sub(FixedNumber.fromString(supply));
|
|
255
|
-
return outputTokens.toString();
|
|
256
|
-
}
|
|
257
|
-
quoteSell(state, inputToken) {
|
|
258
|
-
const curve = new CDPV2(Number(formatEther(state.r)), Number(formatEther(state.h)), Number(formatEther(state.k)));
|
|
259
|
-
const currSupply = FixedNumber.fromString(formatEther(state.circulatingSupply));
|
|
260
|
-
const inputAmt = FixedNumber.fromString(inputToken);
|
|
261
|
-
// 使用 FixedNumber 进行精度计算
|
|
262
|
-
const currReserve = curve.estimateReserve(currSupply.toString());
|
|
263
|
-
const newSupply = currSupply.sub(inputAmt);
|
|
264
|
-
const newReserve = curve.estimateReserve(newSupply.toString());
|
|
265
|
-
const beforeFee = currReserve.sub(newReserve);
|
|
266
|
-
const afterFee = beforeFee.mul(FixedNumber.fromValue(1 - this.sellFeeRate));
|
|
267
|
-
return afterFee.toString();
|
|
268
|
-
}
|
|
269
|
-
// 合约链上报价(买入)
|
|
270
|
-
async previewBuy(token, ethAmount) {
|
|
271
|
-
return await this.contract.previewBuy(token, ethAmount);
|
|
272
|
-
}
|
|
273
|
-
// 合约链上报价(卖出)
|
|
274
|
-
async previewSell(token, tokenAmount) {
|
|
275
|
-
return await this.contract.previewSell(token, tokenAmount);
|
|
276
|
-
}
|
|
277
|
-
// 合约 quote(使用 staticCall 模拟)
|
|
278
|
-
async quoteExactInput(params) {
|
|
279
|
-
return await this.contract.quoteExactInput.staticCall(params);
|
|
280
|
-
}
|
|
281
|
-
// 获取平台手续费率
|
|
282
|
-
async getFeeRate() {
|
|
283
|
-
const result = await this.contract.getFeeRate();
|
|
284
|
-
return { buyFeeRate: result[0], sellFeeRate: result[1] };
|
|
285
|
-
}
|
|
286
|
-
// 获取合约 nonce
|
|
287
|
-
async nonce() {
|
|
288
|
-
return await this.contract.nonce();
|
|
289
|
-
}
|
|
290
|
-
// 获取合约版本
|
|
291
|
-
async version() {
|
|
292
|
-
return await this.contract.version();
|
|
293
|
-
}
|
|
294
|
-
// 获取代币的锁仓信息
|
|
295
|
-
async getLocks(token) {
|
|
296
|
-
return await this.contract.getLocks(token);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
export class FlapPortalWriter extends FlapPortal {
|
|
300
|
-
constructor(cfg, privateKey) {
|
|
301
|
-
super(cfg);
|
|
302
|
-
// 使用 ethers v6 创建钱包
|
|
303
|
-
const provider = new JsonRpcProvider(cfg.rpcUrl);
|
|
304
|
-
this.wallet = new Wallet(privateKey, provider);
|
|
305
|
-
// 重新创建可写合约实例
|
|
306
|
-
this.contract = new Contract(this.portal, PORTAL_ABI, this.wallet);
|
|
307
|
-
}
|
|
308
|
-
// 买入代币
|
|
309
|
-
async buy(token, to, minAmount, msgValue) {
|
|
310
|
-
const tx = await this.contract.buy(token, to, minAmount, { value: msgValue });
|
|
311
|
-
return await tx.wait();
|
|
312
|
-
}
|
|
313
|
-
// 创建代币时同时买入
|
|
314
|
-
// buyOnCreation 已从合约端移除,SDK 同步移除
|
|
315
|
-
// 卖出代币
|
|
316
|
-
async sell(token, amount, minEth) {
|
|
317
|
-
const tx = await this.contract.sell(token, amount, minEth);
|
|
318
|
-
return await tx.wait();
|
|
319
|
-
}
|
|
320
|
-
// 发送 swap 交易
|
|
321
|
-
async swapExactInput(params, msgValue) {
|
|
322
|
-
const tx = await this.contract.swapExactInput({
|
|
323
|
-
inputToken: params.inputToken,
|
|
324
|
-
outputToken: params.outputToken,
|
|
325
|
-
inputAmount: params.inputAmount,
|
|
326
|
-
minOutputAmount: params.minOutputAmount,
|
|
327
|
-
permitData: params.permitData ?? '0x',
|
|
328
|
-
}, { value: msgValue });
|
|
329
|
-
return await tx.wait();
|
|
330
|
-
}
|
|
331
|
-
// 发送显式买入交易
|
|
332
|
-
async swapExactInputBuy(params, msgValue) {
|
|
333
|
-
const tx = await this.contract.swapExactInputBuy({
|
|
334
|
-
inputToken: params.inputToken,
|
|
335
|
-
outputToken: params.outputToken,
|
|
336
|
-
inputAmount: params.inputAmount,
|
|
337
|
-
minOutputAmount: params.minOutputAmount,
|
|
338
|
-
permitData: params.permitData ?? '0x',
|
|
339
|
-
}, { value: msgValue });
|
|
340
|
-
return await tx.wait();
|
|
341
|
-
}
|
|
342
|
-
// 发送显式卖出交易
|
|
343
|
-
async swapExactInputSell(params) {
|
|
344
|
-
const tx = await this.contract.swapExactInputSell({
|
|
345
|
-
inputToken: params.inputToken,
|
|
346
|
-
outputToken: params.outputToken,
|
|
347
|
-
inputAmount: params.inputAmount,
|
|
348
|
-
minOutputAmount: params.minOutputAmount,
|
|
349
|
-
permitData: params.permitData ?? '0x',
|
|
350
|
-
});
|
|
351
|
-
return await tx.wait();
|
|
352
|
-
}
|
|
353
|
-
// 发送 swap 交易(V3,支持扩展数据)
|
|
354
|
-
async swapExactInputV3(params, msgValue) {
|
|
355
|
-
const tx = await this.contract.swapExactInputV3({
|
|
356
|
-
inputToken: params.inputToken,
|
|
357
|
-
outputToken: params.outputToken,
|
|
358
|
-
inputAmount: params.inputAmount,
|
|
359
|
-
minOutputAmount: params.minOutputAmount,
|
|
360
|
-
permitData: params.permitData ?? '0x',
|
|
361
|
-
extensionData: params.extensionData ?? '0x',
|
|
362
|
-
}, { value: msgValue });
|
|
363
|
-
return await tx.wait();
|
|
364
|
-
}
|
|
365
|
-
async newTokenV2(args) {
|
|
366
|
-
const tx = await this.contract.newTokenV2({
|
|
367
|
-
name: args.name,
|
|
368
|
-
symbol: args.symbol,
|
|
369
|
-
meta: args.meta,
|
|
370
|
-
dexThresh: args.dexThresh,
|
|
371
|
-
salt: args.salt,
|
|
372
|
-
taxRate: args.taxRate,
|
|
373
|
-
migratorType: args.migratorType,
|
|
374
|
-
quoteToken: args.quoteToken,
|
|
375
|
-
quoteAmt: args.quoteAmt,
|
|
376
|
-
beneficiary: args.beneficiary,
|
|
377
|
-
permitData: args.permitData ?? '0x',
|
|
378
|
-
}, { value: args.msgValue });
|
|
379
|
-
return await tx.wait();
|
|
380
|
-
}
|
|
381
|
-
async newTokenV3(args) {
|
|
382
|
-
const tx = await this.contract.newTokenV3({
|
|
383
|
-
name: args.name,
|
|
384
|
-
symbol: args.symbol,
|
|
385
|
-
meta: args.meta,
|
|
386
|
-
dexThresh: args.dexThresh,
|
|
387
|
-
salt: args.salt,
|
|
388
|
-
taxRate: args.taxRate,
|
|
389
|
-
migratorType: args.migratorType,
|
|
390
|
-
quoteToken: args.quoteToken,
|
|
391
|
-
quoteAmt: args.quoteAmt,
|
|
392
|
-
beneficiary: args.beneficiary,
|
|
393
|
-
permitData: args.permitData ?? '0x',
|
|
394
|
-
extensionID: args.extensionID,
|
|
395
|
-
extensionData: args.extensionData ?? '0x',
|
|
396
|
-
}, { value: args.msgValue });
|
|
397
|
-
return await tx.wait();
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* 创建代币 V4 版本
|
|
401
|
-
* 相比 V3 新增了 DEX 选择和 LP 费率配置
|
|
402
|
-
*
|
|
403
|
-
* @param args 创建代币参数
|
|
404
|
-
* @param args.dexId DEX ID,选择迁移到哪个 DEX(使用 DEXId 枚举)
|
|
405
|
-
* @param args.lpFeeProfile LP 费率档位(使用 V3LPFeeProfile 枚举)
|
|
406
|
-
*
|
|
407
|
-
* @example
|
|
408
|
-
* ```typescript
|
|
409
|
-
* await portal.newTokenV4({
|
|
410
|
-
* name: 'My Token',
|
|
411
|
-
* symbol: 'MTK',
|
|
412
|
-
* meta: 'bafkreicwlkpvrcqg4bbhyp2fnhdwbqos5ghka6gdjra3tdkgxxs74hqsze',
|
|
413
|
-
* dexThresh: DexThreshType.FOUR_FIFTHS,
|
|
414
|
-
* salt: '0x...',
|
|
415
|
-
* taxRate: 0,
|
|
416
|
-
* migratorType: MigratorType.V3_MIGRATOR,
|
|
417
|
-
* quoteToken: '0x0000000000000000000000000000000000000000',
|
|
418
|
-
* quoteAmt: 0n,
|
|
419
|
-
* beneficiary: '0x...',
|
|
420
|
-
* extensionID: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
421
|
-
* dexId: DEXId.DEX0,
|
|
422
|
-
* lpFeeProfile: V3LPFeeProfile.LP_FEE_PROFILE_STANDARD,
|
|
423
|
-
* msgValue: parseEther('0.01'),
|
|
424
|
-
* });
|
|
425
|
-
* ```
|
|
426
|
-
*
|
|
427
|
-
* @note BNB 链上使用 LP_FEE_PROFILE_LOW (0.01%) 需要白名单地址
|
|
428
|
-
*/
|
|
429
|
-
async newTokenV4(args) {
|
|
430
|
-
const tx = await this.contract.newTokenV4({
|
|
431
|
-
name: args.name,
|
|
432
|
-
symbol: args.symbol,
|
|
433
|
-
meta: args.meta,
|
|
434
|
-
dexThresh: args.dexThresh,
|
|
435
|
-
salt: args.salt,
|
|
436
|
-
taxRate: args.taxRate,
|
|
437
|
-
migratorType: args.migratorType,
|
|
438
|
-
quoteToken: args.quoteToken,
|
|
439
|
-
quoteAmt: args.quoteAmt,
|
|
440
|
-
beneficiary: args.beneficiary,
|
|
441
|
-
permitData: args.permitData ?? '0x',
|
|
442
|
-
extensionID: args.extensionID,
|
|
443
|
-
extensionData: args.extensionData ?? '0x',
|
|
444
|
-
dexId: args.dexId,
|
|
445
|
-
lpFeeProfile: args.lpFeeProfile,
|
|
446
|
-
}, { value: args.msgValue });
|
|
447
|
-
return await tx.wait();
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* 创建 Token V5(支持 Tax Token V2 高级税收分配)
|
|
451
|
-
*
|
|
452
|
-
* 当 taxRate > 0 时,支持以下税收分配:
|
|
453
|
-
* - mktBps: 营销分配(发送到 beneficiary 地址)
|
|
454
|
-
* - deflationBps: 通缩销毁(直接销毁)
|
|
455
|
-
* - dividendBps: 持有者分红(发送到分红合约)
|
|
456
|
-
* - lpBps: 流动性提供(LP 发送到 dead address)
|
|
457
|
-
*
|
|
458
|
-
* 注意:mktBps + deflationBps + dividendBps + lpBps 必须等于 10000 (100%)
|
|
459
|
-
*
|
|
460
|
-
* @example
|
|
461
|
-
* ```typescript
|
|
462
|
-
* // 创建一个 3% 税率的代币,税收分配:40% 营销,30% 销毁,20% 分红,10% 流动性
|
|
463
|
-
* await portal.newTokenV5({
|
|
464
|
-
* name: 'My Tax Token',
|
|
465
|
-
* symbol: 'MTT',
|
|
466
|
-
* meta: 'bafkrei...',
|
|
467
|
-
* dexThresh: DexThreshType.FOUR_FIFTHS,
|
|
468
|
-
* salt: '0x...',
|
|
469
|
-
* taxRate: 300, // 3%
|
|
470
|
-
* migratorType: MigratorType.V2_MIGRATOR, // 税代币必须使用 V2 迁移器
|
|
471
|
-
* quoteToken: '0x0000000000000000000000000000000000000000',
|
|
472
|
-
* quoteAmt: 0n,
|
|
473
|
-
* beneficiary: '0x...',
|
|
474
|
-
* extensionID: '0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
475
|
-
* dexId: DEXId.DEX0,
|
|
476
|
-
* lpFeeProfile: V3LPFeeProfile.LP_FEE_PROFILE_STANDARD,
|
|
477
|
-
* taxDuration: 365n * 24n * 60n * 60n, // 1 年
|
|
478
|
-
* antiFarmerDuration: 60n * 60n, // 1 小时
|
|
479
|
-
* mktBps: 4000, // 40%
|
|
480
|
-
* deflationBps: 3000, // 30%
|
|
481
|
-
* dividendBps: 2000, // 20%
|
|
482
|
-
* lpBps: 1000, // 10%
|
|
483
|
-
* minimumShareBalance: 10000n * 10n ** 18n, // 10K 代币
|
|
484
|
-
* msgValue: parseEther('0.01'),
|
|
485
|
-
* });
|
|
486
|
-
* ```
|
|
487
|
-
*
|
|
488
|
-
* @note 税代币(taxRate > 0)必须使用 V2_MIGRATOR
|
|
489
|
-
*/
|
|
490
|
-
async newTokenV5(args) {
|
|
491
|
-
// 验证税收分配
|
|
492
|
-
if (args.taxRate > 0) {
|
|
493
|
-
const total = args.mktBps + args.deflationBps + args.dividendBps + args.lpBps;
|
|
494
|
-
if (total !== 10000) {
|
|
495
|
-
throw new Error(`税收分配总计必须为 10000 (100%),当前为 ${total}`);
|
|
496
|
-
}
|
|
497
|
-
if (args.dividendBps > 0 && args.minimumShareBalance < 10000n * 10n ** 18n) {
|
|
498
|
-
throw new Error('启用分红时,最低持仓门槛必须至少为 10,000 个代币');
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
const tx = await this.contract.newTokenV5({
|
|
502
|
-
name: args.name,
|
|
503
|
-
symbol: args.symbol,
|
|
504
|
-
meta: args.meta,
|
|
505
|
-
dexThresh: args.dexThresh,
|
|
506
|
-
salt: args.salt,
|
|
507
|
-
taxRate: args.taxRate,
|
|
508
|
-
migratorType: args.migratorType,
|
|
509
|
-
quoteToken: args.quoteToken,
|
|
510
|
-
quoteAmt: args.quoteAmt,
|
|
511
|
-
beneficiary: args.beneficiary,
|
|
512
|
-
permitData: args.permitData ?? '0x',
|
|
513
|
-
extensionID: args.extensionID,
|
|
514
|
-
extensionData: args.extensionData ?? '0x',
|
|
515
|
-
dexId: args.dexId,
|
|
516
|
-
lpFeeProfile: args.lpFeeProfile,
|
|
517
|
-
taxDuration: args.taxDuration,
|
|
518
|
-
antiFarmerDuration: args.antiFarmerDuration,
|
|
519
|
-
mktBps: args.mktBps,
|
|
520
|
-
deflationBps: args.deflationBps,
|
|
521
|
-
dividendBps: args.dividendBps,
|
|
522
|
-
lpBps: args.lpBps,
|
|
523
|
-
minimumShareBalance: args.minimumShareBalance,
|
|
524
|
-
}, { value: args.msgValue });
|
|
525
|
-
return await tx.wait();
|
|
526
|
-
}
|
|
527
|
-
// 受益人领取收益
|
|
528
|
-
async claim(token) {
|
|
529
|
-
const tx = await this.contract.claim(token);
|
|
530
|
-
const receipt = await tx.wait();
|
|
531
|
-
// 这里返回 hash,具体的 tokenAmount 和 ethAmount 需要从事件中解析
|
|
532
|
-
return { txHash: receipt.hash, tokenAmount: 0n, ethAmount: 0n };
|
|
533
|
-
}
|
|
534
|
-
// 受益人委托领取收益
|
|
535
|
-
async delegateClaim(token) {
|
|
536
|
-
const tx = await this.contract.delegateClaim(token);
|
|
537
|
-
const receipt = await tx.wait();
|
|
538
|
-
return { txHash: receipt.hash, tokenAmount: 0n, ethAmount: 0n };
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* 获取当前使用的 Portal 合约地址
|
|
542
|
-
* 用于事件监听等场景
|
|
543
|
-
*/
|
|
544
|
-
getContractAddress() {
|
|
545
|
-
return this.portal;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* 获取 Flap Portal 合约地址(内部使用)
|
|
550
|
-
* 注意:此方法不对外导出,用户应使用 FlapPortal 实例而非直接获取地址
|
|
551
|
-
* @internal
|
|
552
|
-
*/
|
|
553
|
-
function getFlapPortalAddress(chain) {
|
|
554
|
-
const address = FLAP_PORTAL_ADDRESSES[chain];
|
|
555
|
-
if (!address) {
|
|
556
|
-
throw new Error(`Flap Portal not deployed on ${chain}`);
|
|
557
|
-
}
|
|
558
|
-
return address;
|
|
559
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 预测 vanity 地址(CREATE2 proxy bytecode 方案)
|
|
3
|
-
* 使用 ethers v6 的 getCreate2Address
|
|
4
|
-
*/
|
|
5
|
-
export declare function predictVanityTokenAddress(salt: string, portal: string, tokenImpl: string): string;
|
|
6
|
-
/**
|
|
7
|
-
* 预测 vanity 地址(使用链枚举)
|
|
8
|
-
* SDK 自动使用该链的 Portal 和 TokenImpl 地址
|
|
9
|
-
* 注意:使用 Flap 平台的原始 Portal 地址进行 CREATE2 计算
|
|
10
|
-
* BSC/MONAD 默认使用 NORMAL 实现(非税版)
|
|
11
|
-
* @param taxedV5 - 是否使用 V5 高级税代币实现 (mkt/deflation/dividend/lp)
|
|
12
|
-
*/
|
|
13
|
-
export declare function predictVanityTokenAddressByChain(chain: 'BSC' | 'BASE' | 'XLAYER' | 'MORPH' | 'MONAD', salt: string, taxed?: boolean, taxedV5?: boolean): string;
|
|
14
|
-
/**
|
|
15
|
-
* 寻找满足后缀的 salt(默认 8888)
|
|
16
|
-
* 注意:该方法为同步 CPU 搜索,谨慎设置迭代限制
|
|
17
|
-
*/
|
|
18
|
-
export declare function findSaltEnding(opts: {
|
|
19
|
-
portal: string;
|
|
20
|
-
tokenImpl: string;
|
|
21
|
-
suffix?: string;
|
|
22
|
-
maxIterations?: number;
|
|
23
|
-
seed?: string;
|
|
24
|
-
}): Promise<{
|
|
25
|
-
salt: string;
|
|
26
|
-
address: string;
|
|
27
|
-
iterations: number;
|
|
28
|
-
}>;
|
|
29
|
-
/**
|
|
30
|
-
* 寻找满足后缀的 salt(使用链枚举)
|
|
31
|
-
* SDK 自动使用该链的 Portal 和 TokenImpl 地址
|
|
32
|
-
* 注意:使用 Flap 平台的原始 Portal 地址进行 CREATE2 计算
|
|
33
|
-
* BSC/MONAD 默认使用 NORMAL 实现(非税版)
|
|
34
|
-
* XLayer 只有标准版,后缀是 1111
|
|
35
|
-
* @param taxedV5 - 是否使用 V5 高级税代币实现 (mkt/deflation/dividend/lp)
|
|
36
|
-
*/
|
|
37
|
-
export declare function findSaltEndingByChain(opts: {
|
|
38
|
-
chain: 'BSC' | 'BASE' | 'XLAYER' | 'MORPH' | 'MONAD';
|
|
39
|
-
suffix?: string;
|
|
40
|
-
maxIterations?: number;
|
|
41
|
-
seed?: string;
|
|
42
|
-
taxed?: boolean;
|
|
43
|
-
taxedV5?: boolean;
|
|
44
|
-
}): Promise<{
|
|
45
|
-
salt: string;
|
|
46
|
-
address: string;
|
|
47
|
-
iterations: number;
|
|
48
|
-
}>;
|