four-flap-meme-sdk 1.8.2 → 1.8.3
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/chains/bsc/four/core.js +4 -0
- package/dist/chains/bsc/four/types.d.ts +9 -0
- package/dist/contracts/tm-bundle-merkle/core.js +4 -0
- package/dist/contracts/tm-bundle-merkle/types.d.ts +9 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -0
- package/dist/shared/abis/TaxToken.json +105 -0
- package/dist/shared/abis/index.d.ts +2 -1
- package/dist/shared/abis/index.js +2 -1
- package/dist/shared/clients/four.d.ts +33 -0
- package/dist/shared/four/index.d.ts +7 -0
- package/dist/shared/four/index.js +22 -0
- package/dist/shared/four/tax-token.d.ts +176 -0
- package/dist/shared/four/tax-token.js +302 -0
- package/dist/shared/index.d.ts +3 -3
- package/dist/shared/index.js +3 -3
- package/package.json +1 -1
|
@@ -70,6 +70,10 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
70
70
|
telegramUrl: tokenInfo.telegramUrl,
|
|
71
71
|
preSale: effectivePreSaleStr || '0',
|
|
72
72
|
onlyMPC: false,
|
|
73
|
+
// ✅ AntiSniperFeeMode(开盘高税模式)
|
|
74
|
+
...(tokenInfo.feePlan ? { feePlan: true } : {}),
|
|
75
|
+
// ✅ 税币配置(Tax Token, creatorType=5)
|
|
76
|
+
...(tokenInfo.tokenTaxInfo ? { tokenTaxInfo: tokenInfo.tokenTaxInfo } : {}),
|
|
73
77
|
lpTradingFee: 0.0025,
|
|
74
78
|
symbol: 'BNB',
|
|
75
79
|
totalSupply: 1000000000,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GeneratedWallet } from '../../../utils/wallet.js';
|
|
2
|
+
import type { FourTokenTaxInfo } from '../../../shared/clients/four.js';
|
|
2
3
|
export type FourSignConfig = {
|
|
3
4
|
rpcUrl: string;
|
|
4
5
|
fourApiUrl?: string;
|
|
@@ -94,6 +95,10 @@ export type FourCreateWithBundleBuyMerkleParams = {
|
|
|
94
95
|
webUrl?: string;
|
|
95
96
|
twitterUrl?: string;
|
|
96
97
|
telegramUrl?: string;
|
|
98
|
+
/** ✅ AntiSniperFeeMode(开盘高税模式) */
|
|
99
|
+
feePlan?: boolean;
|
|
100
|
+
/** ✅ 税币配置(Tax Token, creatorType=5) */
|
|
101
|
+
tokenTaxInfo?: FourTokenTaxInfo;
|
|
97
102
|
};
|
|
98
103
|
config: FourBundleMerkleConfig;
|
|
99
104
|
};
|
|
@@ -113,6 +118,10 @@ export type FourCreateWithBundleBuySignParams = {
|
|
|
113
118
|
webUrl?: string;
|
|
114
119
|
twitterUrl?: string;
|
|
115
120
|
telegramUrl?: string;
|
|
121
|
+
/** ✅ AntiSniperFeeMode(开盘高税模式) */
|
|
122
|
+
feePlan?: boolean;
|
|
123
|
+
/** ✅ 税币配置(Tax Token, creatorType=5) */
|
|
124
|
+
tokenTaxInfo?: FourTokenTaxInfo;
|
|
116
125
|
};
|
|
117
126
|
config: FourSignConfig;
|
|
118
127
|
};
|
|
@@ -69,6 +69,10 @@ export async function createTokenWithBundleBuyMerkle(params) {
|
|
|
69
69
|
telegramUrl: tokenInfo.telegramUrl,
|
|
70
70
|
preSale: effectivePreSaleStr || '0',
|
|
71
71
|
onlyMPC: false,
|
|
72
|
+
// ✅ AntiSniperFeeMode(开盘高税模式)
|
|
73
|
+
...(tokenInfo.feePlan ? { feePlan: true } : {}),
|
|
74
|
+
// ✅ 税币配置(Tax Token, creatorType=5)
|
|
75
|
+
...(tokenInfo.tokenTaxInfo ? { tokenTaxInfo: tokenInfo.tokenTaxInfo } : {}),
|
|
72
76
|
lpTradingFee: 0.0025,
|
|
73
77
|
symbol: 'BNB',
|
|
74
78
|
totalSupply: 1000000000,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GeneratedWallet } from '../../utils/wallet.js';
|
|
2
|
+
import type { FourTokenTaxInfo } from '../../shared/clients/four.js';
|
|
2
3
|
export type FourSignConfig = {
|
|
3
4
|
rpcUrl: string;
|
|
4
5
|
fourApiUrl?: string;
|
|
@@ -94,6 +95,10 @@ export type FourCreateWithBundleBuyMerkleParams = {
|
|
|
94
95
|
webUrl?: string;
|
|
95
96
|
twitterUrl?: string;
|
|
96
97
|
telegramUrl?: string;
|
|
98
|
+
/** ✅ AntiSniperFeeMode(开盘高税模式) */
|
|
99
|
+
feePlan?: boolean;
|
|
100
|
+
/** ✅ 税币配置(Tax Token, creatorType=5) */
|
|
101
|
+
tokenTaxInfo?: FourTokenTaxInfo;
|
|
97
102
|
};
|
|
98
103
|
config: FourBundleMerkleConfig;
|
|
99
104
|
};
|
|
@@ -113,6 +118,10 @@ export type FourCreateWithBundleBuySignParams = {
|
|
|
113
118
|
webUrl?: string;
|
|
114
119
|
twitterUrl?: string;
|
|
115
120
|
telegramUrl?: string;
|
|
121
|
+
/** ✅ AntiSniperFeeMode(开盘高税模式) */
|
|
122
|
+
feePlan?: boolean;
|
|
123
|
+
/** ✅ 税币配置(Tax Token, creatorType=5) */
|
|
124
|
+
tokenTaxInfo?: FourTokenTaxInfo;
|
|
116
125
|
};
|
|
117
126
|
config: FourSignConfig;
|
|
118
127
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { isExclusiveOnChain, isExclusiveOffChain } from './utils/mpcExclusive.js
|
|
|
7
7
|
export { ensureSellApprovalV1, checkSellApprovalV1, ensureSellApprovalV2, checkSellApprovalV2, ensureSellApproval, checkSellApproval, ensureFlapSellApproval, checkFlapSellApproval, ensureFlapSellApprovalBatch, checkFlapSellApprovalBatch, checkAllowance, approveToken, checkAllowanceBatch, approveTokenBatch, checkAllowanceRaw, approveTokenRaw, checkAllowanceBatchRaw, approveTokenBatchRaw, type EnsureAllowanceBatchItemResult, type ApproveTokenBatchParams, type ApproveTokenBatchRawParams, type ApproveTokenBatchResult, type ApproveTokenBatchSignResult } from './utils/erc20.js';
|
|
8
8
|
export { parseFourError, type FourErrorCode } from './utils/errors.js';
|
|
9
9
|
export { getTokenManagerV1, getTokenManagerV2, getTokenManagerHelper3, getTokenManagerV1Writer, getTokenManagerV2Writer, getTokenManagerHelper3Writer, getTokenManagerAddress, type ChainName } from './utils/contract-factory.js';
|
|
10
|
-
export { FourClient, buildLoginMessage, type FourConfig, type GenerateNonceReq, type LoginReq, type CreateTokenReq, type CreateTokenResp } from './shared/clients/four.js';
|
|
10
|
+
export { FourClient, buildLoginMessage, type FourConfig, type GenerateNonceReq, type LoginReq, type CreateTokenReq, type CreateTokenResp, type FourTokenTaxInfo } from './shared/clients/four.js';
|
|
11
11
|
export { createTokenOnChain, tryBuy, trySell, buyTokenWithFunds, sellToken, tradeBuy, tradeSell, type CreateOnChainParams, type TryBuyResult, type TrySellResult } from './contracts/tm.js';
|
|
12
12
|
export { TM1, type FourChainV1 } from './contracts/tm1.js';
|
|
13
13
|
export { TM2, type FourChainV2 } from './contracts/tm2.js';
|
|
@@ -31,6 +31,7 @@ export { fourPrivateBuy, fourPrivateSell, fourBatchPrivateBuy, fourBatchPrivateS
|
|
|
31
31
|
export { flapPrivateBuy, flapPrivateSell, flapBatchPrivateBuy, flapBatchPrivateSell, type FlapPrivateBuyParams, type FlapPrivateSellParams, type FlapBatchPrivateBuyParams, type FlapBatchPrivateSellParams, type FlapBatchPrivateSellResult } from './shared/flap/portal-bundle.js';
|
|
32
32
|
export { createTokenWithBundleBuyMerkle as flapCreateTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle as flapBatchBuyWithBundleMerkle, batchSellWithBundleMerkle as flapBatchSellWithBundleMerkle, flapPrivateBuyMerkle, flapPrivateSellMerkle, flapBatchPrivateBuyMerkle, flapBatchPrivateSellMerkle, pancakeProxyBatchBuyMerkle, pancakeProxyBatchSellMerkle, approvePancakeProxy, approvePancakeProxyBatch, flapDisperseWithBundleMerkle, flapSweepWithBundleMerkle, type FlapBundleMerkleConfig, type FlapSignConfig, type FlapProfitMode, type FlapChainForMerkleBundle, type FlapCreateWithBundleBuySignParams, type FlapCreateWithBundleBuyMerkleParams, type FlapCreateWithBundleBuyMerkleResult, type FlapBatchBuySignParams, type FlapBatchBuyMerkleParams, type FlapBatchBuyMerkleResult, type FlapBatchSellSignParams, type FlapBatchSellMerkleParams, type FlapBatchSellMerkleResult, type MerkleTransactionStatus, type MerkleBundleStatus, type FlapPrivateBuyMerkleParams, type FlapPrivateSellMerkleParams, type FlapBatchPrivateBuyMerkleParams, type FlapBatchPrivateSellMerkleParams, type FlapBatchPrivateMerkleResult, type FlapPrivateTransactionResult, type PancakeProxyBatchBuyParams, type PancakeProxyBatchBuyResult, type PancakeProxyBatchSellParams, type PancakeProxyBatchSellResult, type PancakeProxyApprovalParams, type PancakeProxyApprovalBatchParams, type PancakeProxyApprovalBatchResult, type FlapDisperseSignParams, type FlapDisperseMerkleResult, type FlapSweepSignParams, type FlapSweepMerkleResult } from './shared/flap/portal-bundle-merkle/index.js';
|
|
33
33
|
export { createTokenWithBundleBuyMerkle as fourCreateTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle as fourBatchBuyWithBundleMerkle, batchSellWithBundleMerkle as fourBatchSellWithBundleMerkle, fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle, disperseWithBundleMerkle, sweepWithBundleMerkle, pairwiseTransferWithBundleMerkle, fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, approveFourTokenManagerBatch, submitBundleToMerkle, submitMultipleBundles, submitMultipleBundlesParallel, submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel, type MerkleSubmitConfig, type SubmitBundleResult, type BlockRazorSubmitConfig, type BlockRazorSubmitResult, type FourBundleMerkleConfig, type FourSignConfig, type FourCreateWithBundleBuySignParams, type FourBatchBuySignParams, type FourBatchSellSignParams, type FourPrivateBuySignParams, type FourPrivateSellSignParams, type FourBatchPrivateBuySignParams, type FourBatchPrivateSellSignParams, type FourPancakeProxyBatchBuySignParams, type FourPancakeProxyBatchSellSignParams, type DisperseSignParams as FourDisperseSignParams, type SweepSignParams as FourSweepSignParams, type FourCreateWithBundleBuyMerkleParams, type FourCreateWithBundleBuyMerkleResult, type FourBatchBuyMerkleParams, type FourBatchBuyMerkleResult, type FourBatchSellMerkleParams, type FourBatchSellMerkleResult, type FourPrivateBuyMerkleParams, type FourPrivateSellMerkleParams, type FourBatchPrivateBuyMerkleParams, type FourBatchPrivateSellMerkleParams, type FourBatchPrivateMerkleResult, type FourPrivateTransactionResult, type DisperseMerkleParams, type DisperseMerkleResult, type SweepMerkleParams, type SweepMerkleResult, type FourPancakeProxyBatchBuyParams, type FourPancakeProxyBatchBuyResult, type FourPancakeProxyBatchSellParams, type FourPancakeProxyBatchSellResult, type FourPancakeProxyApprovalParams, type FourPancakeProxyApprovalBatchParams, type FourPancakeProxyApprovalBatchResult, type ApproveFourTokenManagerBatchParams, type ApproveFourTokenManagerBatchResult } from './chains/bsc/four/index.js';
|
|
34
|
+
export { isTaxToken as fourIsTaxToken, isAntiSniperFeeMode as fourIsAntiSniperFeeMode, getCreatorType as fourGetCreatorType, getTaxTokenInfo as fourGetTaxTokenInfo, getClaimableFee as fourGetClaimableFee, getClaimedFee as fourGetClaimedFee, getUserRewardInfo as fourGetUserRewardInfo, buildClaimFeeTx as fourBuildClaimFeeTx, buildBatchClaimFeeTxs as fourBuildBatchClaimFeeTxs, validateFourTokenTaxInfo, TAX_TOKEN_ABI, TransferMode as FourTransferMode, type TaxTokenConfig as FourTaxTokenConfig, type TaxTokenRewardStats as FourTaxTokenRewardStats, type TaxTokenUserInfo as FourTaxTokenUserInfo, type TaxTokenInfo as FourTaxTokenInfo, } from './shared/four/index.js';
|
|
34
35
|
export { PinataClient, type PinataConfig } from './shared/flap/pinata.js';
|
|
35
36
|
export { pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob, type PinataPinResp } from './shared/flap/pinata.js';
|
|
36
37
|
export { generateWallets, type GeneratedWallet } from './utils/wallet.js';
|
package/dist/index.js
CHANGED
|
@@ -64,6 +64,8 @@ export { fourPrivateBuy, fourPrivateSell, fourBatchPrivateBuy, fourBatchPrivateS
|
|
|
64
64
|
export { flapPrivateBuy, flapPrivateSell, flapBatchPrivateBuy, flapBatchPrivateSell } from './shared/flap/portal-bundle.js';
|
|
65
65
|
export { createTokenWithBundleBuyMerkle as flapCreateTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle as flapBatchBuyWithBundleMerkle, batchSellWithBundleMerkle as flapBatchSellWithBundleMerkle, flapPrivateBuyMerkle, flapPrivateSellMerkle, flapBatchPrivateBuyMerkle, flapBatchPrivateSellMerkle, pancakeProxyBatchBuyMerkle, pancakeProxyBatchSellMerkle, approvePancakeProxy, approvePancakeProxyBatch, flapDisperseWithBundleMerkle, flapSweepWithBundleMerkle } from './shared/flap/portal-bundle-merkle/index.js';
|
|
66
66
|
export { createTokenWithBundleBuyMerkle as fourCreateTokenWithBundleBuyMerkle, batchBuyWithBundleMerkle as fourBatchBuyWithBundleMerkle, batchSellWithBundleMerkle as fourBatchSellWithBundleMerkle, fourPrivateBuyMerkle, fourPrivateSellMerkle, fourBatchPrivateBuyMerkle, fourBatchPrivateSellMerkle, disperseWithBundleMerkle, sweepWithBundleMerkle, pairwiseTransferWithBundleMerkle, fourPancakeProxyBatchBuyMerkle, fourPancakeProxyBatchSellMerkle, approveFourPancakeProxy, approveFourPancakeProxyBatch, approveFourTokenManagerBatch, submitBundleToMerkle, submitMultipleBundles, submitMultipleBundlesParallel, submitBundleToBlockRazor, submitMultipleBundlesToBlockRazor, submitMultipleBundlesToBlockRazorParallel } from './chains/bsc/four/index.js';
|
|
67
|
+
// ✅ Four.meme TaxToken 工具(税币识别/查询/领取奖励)
|
|
68
|
+
export { isTaxToken as fourIsTaxToken, isAntiSniperFeeMode as fourIsAntiSniperFeeMode, getCreatorType as fourGetCreatorType, getTaxTokenInfo as fourGetTaxTokenInfo, getClaimableFee as fourGetClaimableFee, getClaimedFee as fourGetClaimedFee, getUserRewardInfo as fourGetUserRewardInfo, buildClaimFeeTx as fourBuildClaimFeeTx, buildBatchClaimFeeTxs as fourBuildBatchClaimFeeTxs, validateFourTokenTaxInfo, TAX_TOKEN_ABI, TransferMode as FourTransferMode, } from './shared/four/index.js';
|
|
67
69
|
export { PinataClient } from './shared/flap/pinata.js';
|
|
68
70
|
export { pinFileToIPFSWithJWT, pinImageByPath, pinFileToIPFSWithJWTWeb, pinDataURLWithJWTWeb, dataURLToBlob } from './shared/flap/pinata.js';
|
|
69
71
|
export { generateWallets } from './utils/wallet.js';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"anonymous": false,
|
|
4
|
+
"inputs": [
|
|
5
|
+
{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" },
|
|
6
|
+
{ "indexed": true, "internalType": "address", "name": "spender", "type": "address" },
|
|
7
|
+
{ "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" }
|
|
8
|
+
],
|
|
9
|
+
"name": "Approval",
|
|
10
|
+
"type": "event"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"anonymous": false,
|
|
14
|
+
"inputs": [
|
|
15
|
+
{ "indexed": false, "internalType": "address", "name": "account", "type": "address" },
|
|
16
|
+
{ "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }
|
|
17
|
+
],
|
|
18
|
+
"name": "FeeClaimed",
|
|
19
|
+
"type": "event"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"anonymous": false,
|
|
23
|
+
"inputs": [
|
|
24
|
+
{ "indexed": false, "internalType": "uint256", "name": "amountFounder", "type": "uint256" },
|
|
25
|
+
{ "indexed": false, "internalType": "uint256", "name": "amountHolder", "type": "uint256" },
|
|
26
|
+
{ "indexed": false, "internalType": "uint256", "name": "amountBurn", "type": "uint256" },
|
|
27
|
+
{ "indexed": false, "internalType": "uint256", "name": "amountLiquidity", "type": "uint256" },
|
|
28
|
+
{ "indexed": false, "internalType": "uint256", "name": "quoteFounder", "type": "uint256" },
|
|
29
|
+
{ "indexed": false, "internalType": "uint256", "name": "quoteHolder", "type": "uint256" }
|
|
30
|
+
],
|
|
31
|
+
"name": "FeeDispatched",
|
|
32
|
+
"type": "event"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"anonymous": false,
|
|
36
|
+
"inputs": [
|
|
37
|
+
{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" },
|
|
38
|
+
{ "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }
|
|
39
|
+
],
|
|
40
|
+
"name": "OwnershipTransferred",
|
|
41
|
+
"type": "event"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"anonymous": false,
|
|
45
|
+
"inputs": [
|
|
46
|
+
{ "indexed": true, "internalType": "address", "name": "from", "type": "address" },
|
|
47
|
+
{ "indexed": true, "internalType": "address", "name": "to", "type": "address" },
|
|
48
|
+
{ "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" }
|
|
49
|
+
],
|
|
50
|
+
"name": "Transfer",
|
|
51
|
+
"type": "event"
|
|
52
|
+
},
|
|
53
|
+
{ "inputs": [], "name": "DEAD", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
54
|
+
{ "inputs": [], "name": "MODE_NORMAL", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
55
|
+
{ "inputs": [], "name": "MODE_TRANSFER_CONTROLLED", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
56
|
+
{ "inputs": [], "name": "MODE_TRANSFER_RESTRICTED", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
57
|
+
{ "inputs": [], "name": "PANCAKE_FACTORY", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
58
|
+
{ "inputs": [], "name": "PANCAKE_ROUTER", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
59
|
+
{ "inputs": [], "name": "SHARE_HOLDER_MANAGER", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
60
|
+
{ "inputs": [], "name": "TOKEN_HELPER_5", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
61
|
+
{ "inputs": [], "name": "TOKEN_MANAGER_2", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
62
|
+
{ "inputs": [], "name": "WETH", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
63
|
+
{ "inputs": [], "name": "_mode", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
64
|
+
{ "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "spender", "type": "address" }], "name": "allowance", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
65
|
+
{ "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "approve", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" },
|
|
66
|
+
{ "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "balanceOf", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
67
|
+
{ "inputs": [], "name": "claimFee", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
68
|
+
{ "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "claimableFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
69
|
+
{ "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "claimedFee", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
70
|
+
{ "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" },
|
|
71
|
+
{ "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" }], "name": "decreaseAllowance", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" },
|
|
72
|
+
{ "inputs": [], "name": "feeAccumulated", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
73
|
+
{ "inputs": [], "name": "feeBurn", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
74
|
+
{ "inputs": [], "name": "feeDispatched", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
75
|
+
{ "inputs": [], "name": "feeFounder", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
76
|
+
{ "inputs": [], "name": "feeHolder", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
77
|
+
{ "inputs": [], "name": "feeLiquidity", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
78
|
+
{ "inputs": [], "name": "feePerShare", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
79
|
+
{ "inputs": [], "name": "feeRate", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
80
|
+
{ "inputs": [], "name": "founder", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
81
|
+
{ "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "addedValue", "type": "uint256" }], "name": "increaseAllowance", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" },
|
|
82
|
+
{ "inputs": [{ "components": [{ "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "string", "name": "name", "type": "string" }, { "internalType": "string", "name": "symbol", "type": "string" }, { "internalType": "uint256", "name": "totalSupply", "type": "uint256" }, { "internalType": "address", "name": "founder", "type": "address" }, { "internalType": "uint256", "name": "feeRate", "type": "uint256" }, { "internalType": "uint256", "name": "rateFounder", "type": "uint256" }, { "internalType": "uint256", "name": "rateHolder", "type": "uint256" }, { "internalType": "uint256", "name": "rateBurn", "type": "uint256" }, { "internalType": "uint256", "name": "rateLiquidity", "type": "uint256" }, { "internalType": "uint256", "name": "minDispatch", "type": "uint256" }, { "internalType": "uint256", "name": "minShare", "type": "uint256" }], "internalType": "struct ITokenCreator5.InitParams", "name": "a", "type": "tuple" }], "name": "init", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
83
|
+
{ "inputs": [], "name": "minDispatch", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
84
|
+
{ "inputs": [], "name": "minShare", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
85
|
+
{ "inputs": [], "name": "name", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" },
|
|
86
|
+
{ "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
87
|
+
{ "inputs": [], "name": "pair", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
88
|
+
{ "inputs": [], "name": "quote", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" },
|
|
89
|
+
{ "inputs": [], "name": "quoteClaimed", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
90
|
+
{ "inputs": [], "name": "quoteFounder", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
91
|
+
{ "inputs": [], "name": "quoteHolder", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
92
|
+
{ "inputs": [], "name": "rateBurn", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
93
|
+
{ "inputs": [], "name": "rateFounder", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
94
|
+
{ "inputs": [], "name": "rateHolder", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
95
|
+
{ "inputs": [], "name": "rateLiquidity", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
96
|
+
{ "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
97
|
+
{ "inputs": [{ "internalType": "uint256", "name": "v", "type": "uint256" }], "name": "setMode", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
98
|
+
{ "inputs": [], "name": "symbol", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" },
|
|
99
|
+
{ "inputs": [], "name": "totalShares", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
100
|
+
{ "inputs": [], "name": "totalSupply", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" },
|
|
101
|
+
{ "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "transfer", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" },
|
|
102
|
+
{ "inputs": [{ "internalType": "address", "name": "from", "type": "address" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "transferFrom", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "nonpayable", "type": "function" },
|
|
103
|
+
{ "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" },
|
|
104
|
+
{ "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "userInfo", "outputs": [{ "internalType": "uint256", "name": "share", "type": "uint256" }, { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }, { "internalType": "uint256", "name": "claimable", "type": "uint256" }, { "internalType": "uint256", "name": "claimed", "type": "uint256" }], "stateMutability": "view", "type": "function" }
|
|
105
|
+
]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import TokenManager from './TokenManager.json';
|
|
2
2
|
import TokenManager2 from './TokenManager2.json';
|
|
3
3
|
import TokenManagerHelper3 from './TokenManagerHelper3.json';
|
|
4
|
-
|
|
4
|
+
import TaxToken from './TaxToken.json';
|
|
5
|
+
export { TokenManager, TokenManager2, TokenManagerHelper3, TaxToken };
|
|
5
6
|
export * from './common.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import TokenManager from './TokenManager.json' with { type: 'json' };
|
|
2
2
|
import TokenManager2 from './TokenManager2.json' with { type: 'json' };
|
|
3
3
|
import TokenManagerHelper3 from './TokenManagerHelper3.json' with { type: 'json' };
|
|
4
|
-
|
|
4
|
+
import TaxToken from './TaxToken.json' with { type: 'json' };
|
|
5
|
+
export { TokenManager, TokenManager2, TokenManagerHelper3, TaxToken };
|
|
5
6
|
// ✅ 公共 ABI 导出
|
|
6
7
|
export * from './common.js';
|
|
@@ -26,6 +26,27 @@ export type LoginReq = {
|
|
|
26
26
|
};
|
|
27
27
|
walletName: 'MetaMask' | string;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Four.meme 税币配置参数
|
|
31
|
+
* - feeRate: 交易费率(固定选项:1, 3, 5, 10,代表 1%, 3%, 5%, 10%)
|
|
32
|
+
* - burnRate: 销毁比例(百分比,如 20 = 20%)
|
|
33
|
+
* - divideRate: 分红比例(百分比,如 30 = 30%)
|
|
34
|
+
* - liquidityRate: 流动性池比例(百分比,如 40 = 40%)
|
|
35
|
+
* - recipientRate: 创始人/接收者比例(百分比,如 10 = 10%)
|
|
36
|
+
* - recipientAddress: 接收者地址(不使用时传空字符串 "")
|
|
37
|
+
* - minSharing: 最低持仓分红门槛(ether 单位,须满足 d × 10^n, n≥5, 1≤d≤9)
|
|
38
|
+
*
|
|
39
|
+
* 约束:burnRate + divideRate + liquidityRate + recipientRate = 100
|
|
40
|
+
*/
|
|
41
|
+
export type FourTokenTaxInfo = {
|
|
42
|
+
feeRate: 1 | 3 | 5 | 10;
|
|
43
|
+
burnRate: number;
|
|
44
|
+
divideRate: number;
|
|
45
|
+
liquidityRate: number;
|
|
46
|
+
recipientRate: number;
|
|
47
|
+
recipientAddress: string;
|
|
48
|
+
minSharing: number;
|
|
49
|
+
};
|
|
29
50
|
export type CreateTokenReq = {
|
|
30
51
|
name: string;
|
|
31
52
|
shortName: string;
|
|
@@ -38,6 +59,18 @@ export type CreateTokenReq = {
|
|
|
38
59
|
telegramUrl?: string;
|
|
39
60
|
preSale: string;
|
|
40
61
|
onlyMPC?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* AntiSniperFeeMode(开盘高税模式)
|
|
64
|
+
* - true: 启用动态手续费系统(开盘时高税,逐区块自动降低)
|
|
65
|
+
* - false: 不启用(默认)
|
|
66
|
+
*/
|
|
67
|
+
feePlan?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* 税币配置(Tax Token)
|
|
70
|
+
* - 提供此字段时创建税币(creatorType = 5)
|
|
71
|
+
* - 不提供或为 undefined 时创建普通代币
|
|
72
|
+
*/
|
|
73
|
+
tokenTaxInfo?: FourTokenTaxInfo;
|
|
41
74
|
lpTradingFee: 0.0025;
|
|
42
75
|
symbol: 'BNB';
|
|
43
76
|
totalSupply: 1000000000;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Four.meme 工具模块
|
|
3
|
+
*
|
|
4
|
+
* 提供 Four.meme 平台相关的工具函数:
|
|
5
|
+
* - TaxToken:税币识别、状态查询、奖励领取
|
|
6
|
+
*/
|
|
7
|
+
export { isTaxToken, isAntiSniperFeeMode, getCreatorType, getTaxTokenInfo, getClaimableFee, getClaimedFee, getUserRewardInfo, buildClaimFeeTx, buildBatchClaimFeeTxs, validateFourTokenTaxInfo, TAX_TOKEN_ABI, TransferMode, type TaxTokenConfig, type TaxTokenRewardStats, type TaxTokenUserInfo, type TaxTokenInfo, } from './tax-token.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Four.meme 工具模块
|
|
3
|
+
*
|
|
4
|
+
* 提供 Four.meme 平台相关的工具函数:
|
|
5
|
+
* - TaxToken:税币识别、状态查询、奖励领取
|
|
6
|
+
*/
|
|
7
|
+
// TaxToken 工具
|
|
8
|
+
export {
|
|
9
|
+
// 识别方法
|
|
10
|
+
isTaxToken, isAntiSniperFeeMode, getCreatorType,
|
|
11
|
+
// 状态查询
|
|
12
|
+
getTaxTokenInfo,
|
|
13
|
+
// 用户奖励
|
|
14
|
+
getClaimableFee, getClaimedFee, getUserRewardInfo,
|
|
15
|
+
// 奖励领取
|
|
16
|
+
buildClaimFeeTx, buildBatchClaimFeeTxs,
|
|
17
|
+
// 校验工具
|
|
18
|
+
validateFourTokenTaxInfo,
|
|
19
|
+
// ABI
|
|
20
|
+
TAX_TOKEN_ABI,
|
|
21
|
+
// 类型
|
|
22
|
+
TransferMode, } from './tax-token.js';
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import TaxTokenAbi from '../abis/TaxToken.json';
|
|
2
|
+
/** TaxToken 转账模式 */
|
|
3
|
+
export declare enum TransferMode {
|
|
4
|
+
/** 正常转账模式 - 允许所有转账 */
|
|
5
|
+
NORMAL = 0,
|
|
6
|
+
/** 限制转账模式 - 禁止所有转账 */
|
|
7
|
+
RESTRICTED = 1,
|
|
8
|
+
/** 受控转账模式 - 只允许与 owner 相关的转账 */
|
|
9
|
+
CONTROLLED = 2
|
|
10
|
+
}
|
|
11
|
+
/** TaxToken 税收配置状态 */
|
|
12
|
+
export type TaxTokenConfig = {
|
|
13
|
+
/** 交易费率(基点,10000 = 100%) */
|
|
14
|
+
feeRate: bigint;
|
|
15
|
+
/** 创始人分配比例(百分比,100 = 100%) */
|
|
16
|
+
rateFounder: bigint;
|
|
17
|
+
/** 持有者分配比例 */
|
|
18
|
+
rateHolder: bigint;
|
|
19
|
+
/** 销毁比例 */
|
|
20
|
+
rateBurn: bigint;
|
|
21
|
+
/** 流动性比例 */
|
|
22
|
+
rateLiquidity: bigint;
|
|
23
|
+
/** 创始人地址 */
|
|
24
|
+
founder: string;
|
|
25
|
+
/** 报价代币地址 */
|
|
26
|
+
quote: string;
|
|
27
|
+
/** PancakeSwap 配对地址 */
|
|
28
|
+
pair: string;
|
|
29
|
+
/** 当前转账模式 */
|
|
30
|
+
mode: TransferMode;
|
|
31
|
+
/** 最低分发阈值 */
|
|
32
|
+
minDispatch: bigint;
|
|
33
|
+
/** 最低持仓参与分红门槛 */
|
|
34
|
+
minShare: bigint;
|
|
35
|
+
};
|
|
36
|
+
/** TaxToken 奖励统计数据 */
|
|
37
|
+
export type TaxTokenRewardStats = {
|
|
38
|
+
/** 总持仓份额 */
|
|
39
|
+
totalShares: bigint;
|
|
40
|
+
/** 每份额累计奖励 */
|
|
41
|
+
feePerShare: bigint;
|
|
42
|
+
/** 累积待分发手续费 */
|
|
43
|
+
feeAccumulated: bigint;
|
|
44
|
+
/** 已分发手续费总额 */
|
|
45
|
+
feeDispatched: bigint;
|
|
46
|
+
/** 分配给创始人的代币总额 */
|
|
47
|
+
feeFounder: bigint;
|
|
48
|
+
/** 分配给持有者的代币总额 */
|
|
49
|
+
feeHolder: bigint;
|
|
50
|
+
/** 销毁的代币总额 */
|
|
51
|
+
feeBurn: bigint;
|
|
52
|
+
/** 注入流动性的代币总额 */
|
|
53
|
+
feeLiquidity: bigint;
|
|
54
|
+
/** 创始人获得的报价代币总额 */
|
|
55
|
+
quoteFounder: bigint;
|
|
56
|
+
/** 持有者获得的报价代币总额 */
|
|
57
|
+
quoteHolder: bigint;
|
|
58
|
+
/** 已领取的报价代币总额 */
|
|
59
|
+
quoteClaimed: bigint;
|
|
60
|
+
};
|
|
61
|
+
/** 用户在 TaxToken 中的奖励信息 */
|
|
62
|
+
export type TaxTokenUserInfo = {
|
|
63
|
+
/** 用户持仓份额 */
|
|
64
|
+
share: bigint;
|
|
65
|
+
/** 已计入的奖励债务 */
|
|
66
|
+
rewardDebt: bigint;
|
|
67
|
+
/** 可领取的奖励金额(报价代币) */
|
|
68
|
+
claimable: bigint;
|
|
69
|
+
/** 已领取的奖励金额(报价代币) */
|
|
70
|
+
claimed: bigint;
|
|
71
|
+
};
|
|
72
|
+
/** TaxToken 完整信息 */
|
|
73
|
+
export type TaxTokenInfo = {
|
|
74
|
+
config: TaxTokenConfig;
|
|
75
|
+
rewardStats: TaxTokenRewardStats;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* 链上判断代币是否是 TaxToken
|
|
79
|
+
*
|
|
80
|
+
* 原理:读取 TokenManager2._tokenInfos[token].template,
|
|
81
|
+
* 提取 creatorType = (template >> 10) & 0x3F,判断是否等于 5
|
|
82
|
+
*
|
|
83
|
+
* @param tokenAddress - 代币合约地址
|
|
84
|
+
* @param rpcUrl - BSC RPC URL
|
|
85
|
+
* @returns 是否为 TaxToken
|
|
86
|
+
*/
|
|
87
|
+
export declare function isTaxToken(tokenAddress: string, rpcUrl: string): Promise<boolean>;
|
|
88
|
+
/**
|
|
89
|
+
* 链上判断代币是否启用了 AntiSniperFeeMode
|
|
90
|
+
*
|
|
91
|
+
* 原理:读取 TokenManager2._tokenInfoEx1s[token].feeSetting > 0
|
|
92
|
+
*
|
|
93
|
+
* @param tokenAddress - 代币合约地址
|
|
94
|
+
* @param rpcUrl - BSC RPC URL
|
|
95
|
+
* @returns 是否启用 AntiSniperFeeMode
|
|
96
|
+
*/
|
|
97
|
+
export declare function isAntiSniperFeeMode(tokenAddress: string, rpcUrl: string): Promise<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* 获取代币的 creatorType
|
|
100
|
+
*
|
|
101
|
+
* @param tokenAddress - 代币合约地址
|
|
102
|
+
* @param rpcUrl - BSC RPC URL
|
|
103
|
+
* @returns creatorType 数值
|
|
104
|
+
*/
|
|
105
|
+
export declare function getCreatorType(tokenAddress: string, rpcUrl: string): Promise<number>;
|
|
106
|
+
/**
|
|
107
|
+
* 获取 TaxToken 的完整配置信息
|
|
108
|
+
*
|
|
109
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
110
|
+
* @param rpcUrl - BSC RPC URL
|
|
111
|
+
* @returns 税收配置 + 奖励统计
|
|
112
|
+
*/
|
|
113
|
+
export declare function getTaxTokenInfo(tokenAddress: string, rpcUrl: string): Promise<TaxTokenInfo>;
|
|
114
|
+
/**
|
|
115
|
+
* 查询用户在 TaxToken 中的可领取奖励
|
|
116
|
+
*
|
|
117
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
118
|
+
* @param account - 用户钱包地址
|
|
119
|
+
* @param rpcUrl - BSC RPC URL
|
|
120
|
+
* @returns 可领取的报价代币数量(wei)
|
|
121
|
+
*/
|
|
122
|
+
export declare function getClaimableFee(tokenAddress: string, account: string, rpcUrl: string): Promise<bigint>;
|
|
123
|
+
/**
|
|
124
|
+
* 查询用户在 TaxToken 中的已领取奖励
|
|
125
|
+
*
|
|
126
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
127
|
+
* @param account - 用户钱包地址
|
|
128
|
+
* @param rpcUrl - BSC RPC URL
|
|
129
|
+
* @returns 已领取的报价代币数量(wei)
|
|
130
|
+
*/
|
|
131
|
+
export declare function getClaimedFee(tokenAddress: string, account: string, rpcUrl: string): Promise<bigint>;
|
|
132
|
+
/**
|
|
133
|
+
* 查询用户在 TaxToken 中的完整奖励信息
|
|
134
|
+
*
|
|
135
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
136
|
+
* @param account - 用户钱包地址
|
|
137
|
+
* @param rpcUrl - BSC RPC URL
|
|
138
|
+
* @returns 用户奖励信息(份额、债务、可领取、已领取)
|
|
139
|
+
*/
|
|
140
|
+
export declare function getUserRewardInfo(tokenAddress: string, account: string, rpcUrl: string): Promise<TaxTokenUserInfo>;
|
|
141
|
+
/**
|
|
142
|
+
* 构建 TaxToken 奖励领取的签名交易(不发送)
|
|
143
|
+
*
|
|
144
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
145
|
+
* @param privateKey - 用户私钥
|
|
146
|
+
* @param rpcUrl - BSC RPC URL
|
|
147
|
+
* @returns 签名后的交易 hex
|
|
148
|
+
*/
|
|
149
|
+
export declare function buildClaimFeeTx(tokenAddress: string, privateKey: string, rpcUrl: string): Promise<string>;
|
|
150
|
+
/**
|
|
151
|
+
* 批量构建 TaxToken 奖励领取交易(多个钱包)
|
|
152
|
+
*
|
|
153
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
154
|
+
* @param privateKeys - 用户私钥数组
|
|
155
|
+
* @param rpcUrl - BSC RPC URL
|
|
156
|
+
* @returns 签名后的交易 hex 数组
|
|
157
|
+
*/
|
|
158
|
+
export declare function buildBatchClaimFeeTxs(tokenAddress: string, privateKeys: string[], rpcUrl: string): Promise<string[]>;
|
|
159
|
+
/**
|
|
160
|
+
* 验证 FourTokenTaxInfo 参数合法性
|
|
161
|
+
*
|
|
162
|
+
* @param info - 税币配置
|
|
163
|
+
* @returns 验证结果,valid=true 表示合法
|
|
164
|
+
*/
|
|
165
|
+
export declare function validateFourTokenTaxInfo(info: {
|
|
166
|
+
feeRate: number;
|
|
167
|
+
burnRate: number;
|
|
168
|
+
divideRate: number;
|
|
169
|
+
liquidityRate: number;
|
|
170
|
+
recipientRate: number;
|
|
171
|
+
minSharing: number;
|
|
172
|
+
}): {
|
|
173
|
+
valid: boolean;
|
|
174
|
+
error?: string;
|
|
175
|
+
};
|
|
176
|
+
export { TaxTokenAbi as TAX_TOKEN_ABI };
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Four.meme TaxToken 工具模块
|
|
3
|
+
*
|
|
4
|
+
* 提供 TaxToken 的识别、状态查询、奖励领取等功能。
|
|
5
|
+
* 基于 Four.meme 官方文档: API-Contract-TaxToken.md
|
|
6
|
+
*/
|
|
7
|
+
import { ethers, Contract, Wallet, JsonRpcProvider } from 'ethers';
|
|
8
|
+
import TaxTokenAbi from '../abis/TaxToken.json' with { type: 'json' };
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// 常量
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/** Four.meme TokenManager2 合约地址(BSC) */
|
|
13
|
+
const TOKEN_MANAGER_2_ADDRESS = '0x5c952063c7fc8610FFDB798152D69F0B9550762b';
|
|
14
|
+
/** TaxToken 的 creatorType 值 */
|
|
15
|
+
const TOKEN_TYPE_TAX = 5;
|
|
16
|
+
/** TokenManager2 最小 ABI(用于查询 _tokenInfos 和 _tokenInfoEx1s) */
|
|
17
|
+
const TOKEN_MANAGER_QUERY_ABI = [
|
|
18
|
+
'function _tokenInfos(address) view returns (uint256 template)',
|
|
19
|
+
'function _tokenInfoEx1s(address) view returns (uint256 launchFee, uint256 pcFee, uint256 feeSetting, uint256 blockNumber, uint256 extraFee)',
|
|
20
|
+
];
|
|
21
|
+
/** TaxToken 读取 ABI(ethers human-readable 格式,比 JSON 更轻) */
|
|
22
|
+
const TAX_TOKEN_READ_ABI = [
|
|
23
|
+
'function feeRate() view returns (uint256)',
|
|
24
|
+
'function rateFounder() view returns (uint256)',
|
|
25
|
+
'function rateHolder() view returns (uint256)',
|
|
26
|
+
'function rateBurn() view returns (uint256)',
|
|
27
|
+
'function rateLiquidity() view returns (uint256)',
|
|
28
|
+
'function founder() view returns (address)',
|
|
29
|
+
'function quote() view returns (address)',
|
|
30
|
+
'function pair() view returns (address)',
|
|
31
|
+
'function _mode() view returns (uint256)',
|
|
32
|
+
'function minDispatch() view returns (uint256)',
|
|
33
|
+
'function minShare() view returns (uint256)',
|
|
34
|
+
'function totalShares() view returns (uint256)',
|
|
35
|
+
'function feePerShare() view returns (uint256)',
|
|
36
|
+
'function feeAccumulated() view returns (uint256)',
|
|
37
|
+
'function feeDispatched() view returns (uint256)',
|
|
38
|
+
'function feeFounder() view returns (uint256)',
|
|
39
|
+
'function feeHolder() view returns (uint256)',
|
|
40
|
+
'function feeBurn() view returns (uint256)',
|
|
41
|
+
'function feeLiquidity() view returns (uint256)',
|
|
42
|
+
'function quoteFounder() view returns (uint256)',
|
|
43
|
+
'function quoteHolder() view returns (uint256)',
|
|
44
|
+
'function quoteClaimed() view returns (uint256)',
|
|
45
|
+
'function claimableFee(address) view returns (uint256)',
|
|
46
|
+
'function claimedFee(address) view returns (uint256)',
|
|
47
|
+
'function userInfo(address) view returns (uint256 share, uint256 rewardDebt, uint256 claimable, uint256 claimed)',
|
|
48
|
+
'function claimFee()',
|
|
49
|
+
];
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// 类型
|
|
52
|
+
// ============================================================================
|
|
53
|
+
/** TaxToken 转账模式 */
|
|
54
|
+
export var TransferMode;
|
|
55
|
+
(function (TransferMode) {
|
|
56
|
+
/** 正常转账模式 - 允许所有转账 */
|
|
57
|
+
TransferMode[TransferMode["NORMAL"] = 0] = "NORMAL";
|
|
58
|
+
/** 限制转账模式 - 禁止所有转账 */
|
|
59
|
+
TransferMode[TransferMode["RESTRICTED"] = 1] = "RESTRICTED";
|
|
60
|
+
/** 受控转账模式 - 只允许与 owner 相关的转账 */
|
|
61
|
+
TransferMode[TransferMode["CONTROLLED"] = 2] = "CONTROLLED";
|
|
62
|
+
})(TransferMode || (TransferMode = {}));
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// 识别方法
|
|
65
|
+
// ============================================================================
|
|
66
|
+
/**
|
|
67
|
+
* 链上判断代币是否是 TaxToken
|
|
68
|
+
*
|
|
69
|
+
* 原理:读取 TokenManager2._tokenInfos[token].template,
|
|
70
|
+
* 提取 creatorType = (template >> 10) & 0x3F,判断是否等于 5
|
|
71
|
+
*
|
|
72
|
+
* @param tokenAddress - 代币合约地址
|
|
73
|
+
* @param rpcUrl - BSC RPC URL
|
|
74
|
+
* @returns 是否为 TaxToken
|
|
75
|
+
*/
|
|
76
|
+
export async function isTaxToken(tokenAddress, rpcUrl) {
|
|
77
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
78
|
+
const tm2 = new Contract(TOKEN_MANAGER_2_ADDRESS, TOKEN_MANAGER_QUERY_ABI, provider);
|
|
79
|
+
const template = await tm2._tokenInfos(tokenAddress);
|
|
80
|
+
const creatorType = Number((template >> 10n) & 0x3fn);
|
|
81
|
+
return creatorType === TOKEN_TYPE_TAX;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 链上判断代币是否启用了 AntiSniperFeeMode
|
|
85
|
+
*
|
|
86
|
+
* 原理:读取 TokenManager2._tokenInfoEx1s[token].feeSetting > 0
|
|
87
|
+
*
|
|
88
|
+
* @param tokenAddress - 代币合约地址
|
|
89
|
+
* @param rpcUrl - BSC RPC URL
|
|
90
|
+
* @returns 是否启用 AntiSniperFeeMode
|
|
91
|
+
*/
|
|
92
|
+
export async function isAntiSniperFeeMode(tokenAddress, rpcUrl) {
|
|
93
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
94
|
+
const tm2 = new Contract(TOKEN_MANAGER_2_ADDRESS, TOKEN_MANAGER_QUERY_ABI, provider);
|
|
95
|
+
const info = await tm2._tokenInfoEx1s(tokenAddress);
|
|
96
|
+
return BigInt(info.feeSetting) > 0n;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 获取代币的 creatorType
|
|
100
|
+
*
|
|
101
|
+
* @param tokenAddress - 代币合约地址
|
|
102
|
+
* @param rpcUrl - BSC RPC URL
|
|
103
|
+
* @returns creatorType 数值
|
|
104
|
+
*/
|
|
105
|
+
export async function getCreatorType(tokenAddress, rpcUrl) {
|
|
106
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
107
|
+
const tm2 = new Contract(TOKEN_MANAGER_2_ADDRESS, TOKEN_MANAGER_QUERY_ABI, provider);
|
|
108
|
+
const template = await tm2._tokenInfos(tokenAddress);
|
|
109
|
+
return Number((template >> 10n) & 0x3fn);
|
|
110
|
+
}
|
|
111
|
+
// ============================================================================
|
|
112
|
+
// TaxToken 状态查询
|
|
113
|
+
// ============================================================================
|
|
114
|
+
/**
|
|
115
|
+
* 获取 TaxToken 的完整配置信息
|
|
116
|
+
*
|
|
117
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
118
|
+
* @param rpcUrl - BSC RPC URL
|
|
119
|
+
* @returns 税收配置 + 奖励统计
|
|
120
|
+
*/
|
|
121
|
+
export async function getTaxTokenInfo(tokenAddress, rpcUrl) {
|
|
122
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
123
|
+
const token = new Contract(tokenAddress, TAX_TOKEN_READ_ABI, provider);
|
|
124
|
+
// 批量查询所有状态(利用 Promise.all 减少 RPC 调用轮次)
|
|
125
|
+
const [feeRate, rateFounder, rateHolder, rateBurn, rateLiquidity, founder, quote, pair, mode, minDispatch, minShare, totalShares, feePerShare, feeAccumulated, feeDispatched, feeFounderVal, feeHolderVal, feeBurnVal, feeLiquidityVal, quoteFounderVal, quoteHolderVal, quoteClaimed,] = await Promise.all([
|
|
126
|
+
token.feeRate(), token.rateFounder(), token.rateHolder(), token.rateBurn(), token.rateLiquidity(),
|
|
127
|
+
token.founder(), token.quote(), token.pair(), token._mode(), token.minDispatch(), token.minShare(),
|
|
128
|
+
token.totalShares(), token.feePerShare(), token.feeAccumulated(), token.feeDispatched(),
|
|
129
|
+
token.feeFounder(), token.feeHolder(), token.feeBurn(), token.feeLiquidity(),
|
|
130
|
+
token.quoteFounder(), token.quoteHolder(), token.quoteClaimed(),
|
|
131
|
+
]);
|
|
132
|
+
return {
|
|
133
|
+
config: {
|
|
134
|
+
feeRate: BigInt(feeRate),
|
|
135
|
+
rateFounder: BigInt(rateFounder),
|
|
136
|
+
rateHolder: BigInt(rateHolder),
|
|
137
|
+
rateBurn: BigInt(rateBurn),
|
|
138
|
+
rateLiquidity: BigInt(rateLiquidity),
|
|
139
|
+
founder: String(founder),
|
|
140
|
+
quote: String(quote),
|
|
141
|
+
pair: String(pair),
|
|
142
|
+
mode: Number(mode),
|
|
143
|
+
minDispatch: BigInt(minDispatch),
|
|
144
|
+
minShare: BigInt(minShare),
|
|
145
|
+
},
|
|
146
|
+
rewardStats: {
|
|
147
|
+
totalShares: BigInt(totalShares),
|
|
148
|
+
feePerShare: BigInt(feePerShare),
|
|
149
|
+
feeAccumulated: BigInt(feeAccumulated),
|
|
150
|
+
feeDispatched: BigInt(feeDispatched),
|
|
151
|
+
feeFounder: BigInt(feeFounderVal),
|
|
152
|
+
feeHolder: BigInt(feeHolderVal),
|
|
153
|
+
feeBurn: BigInt(feeBurnVal),
|
|
154
|
+
feeLiquidity: BigInt(feeLiquidityVal),
|
|
155
|
+
quoteFounder: BigInt(quoteFounderVal),
|
|
156
|
+
quoteHolder: BigInt(quoteHolderVal),
|
|
157
|
+
quoteClaimed: BigInt(quoteClaimed),
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// ============================================================================
|
|
162
|
+
// 用户奖励查询
|
|
163
|
+
// ============================================================================
|
|
164
|
+
/**
|
|
165
|
+
* 查询用户在 TaxToken 中的可领取奖励
|
|
166
|
+
*
|
|
167
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
168
|
+
* @param account - 用户钱包地址
|
|
169
|
+
* @param rpcUrl - BSC RPC URL
|
|
170
|
+
* @returns 可领取的报价代币数量(wei)
|
|
171
|
+
*/
|
|
172
|
+
export async function getClaimableFee(tokenAddress, account, rpcUrl) {
|
|
173
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
174
|
+
const token = new Contract(tokenAddress, TAX_TOKEN_READ_ABI, provider);
|
|
175
|
+
return BigInt(await token.claimableFee(account));
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* 查询用户在 TaxToken 中的已领取奖励
|
|
179
|
+
*
|
|
180
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
181
|
+
* @param account - 用户钱包地址
|
|
182
|
+
* @param rpcUrl - BSC RPC URL
|
|
183
|
+
* @returns 已领取的报价代币数量(wei)
|
|
184
|
+
*/
|
|
185
|
+
export async function getClaimedFee(tokenAddress, account, rpcUrl) {
|
|
186
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
187
|
+
const token = new Contract(tokenAddress, TAX_TOKEN_READ_ABI, provider);
|
|
188
|
+
return BigInt(await token.claimedFee(account));
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 查询用户在 TaxToken 中的完整奖励信息
|
|
192
|
+
*
|
|
193
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
194
|
+
* @param account - 用户钱包地址
|
|
195
|
+
* @param rpcUrl - BSC RPC URL
|
|
196
|
+
* @returns 用户奖励信息(份额、债务、可领取、已领取)
|
|
197
|
+
*/
|
|
198
|
+
export async function getUserRewardInfo(tokenAddress, account, rpcUrl) {
|
|
199
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
200
|
+
const token = new Contract(tokenAddress, TAX_TOKEN_READ_ABI, provider);
|
|
201
|
+
const info = await token.userInfo(account);
|
|
202
|
+
return {
|
|
203
|
+
share: BigInt(info.share),
|
|
204
|
+
rewardDebt: BigInt(info.rewardDebt),
|
|
205
|
+
claimable: BigInt(info.claimable),
|
|
206
|
+
claimed: BigInt(info.claimed),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// ============================================================================
|
|
210
|
+
// 奖励领取
|
|
211
|
+
// ============================================================================
|
|
212
|
+
/**
|
|
213
|
+
* 构建 TaxToken 奖励领取的签名交易(不发送)
|
|
214
|
+
*
|
|
215
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
216
|
+
* @param privateKey - 用户私钥
|
|
217
|
+
* @param rpcUrl - BSC RPC URL
|
|
218
|
+
* @returns 签名后的交易 hex
|
|
219
|
+
*/
|
|
220
|
+
export async function buildClaimFeeTx(tokenAddress, privateKey, rpcUrl) {
|
|
221
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
222
|
+
const wallet = new Wallet(privateKey, provider);
|
|
223
|
+
const token = new Contract(tokenAddress, TAX_TOKEN_READ_ABI, wallet);
|
|
224
|
+
const tx = await token.claimFee.populateTransaction();
|
|
225
|
+
const nonce = await provider.getTransactionCount(wallet.address, 'latest');
|
|
226
|
+
const feeData = await provider.getFeeData();
|
|
227
|
+
const signedTx = await wallet.signTransaction({
|
|
228
|
+
to: tokenAddress,
|
|
229
|
+
data: tx.data,
|
|
230
|
+
nonce,
|
|
231
|
+
gasLimit: 200000n,
|
|
232
|
+
gasPrice: feeData.gasPrice ?? ethers.parseUnits('3', 'gwei'),
|
|
233
|
+
chainId: 56,
|
|
234
|
+
type: 0,
|
|
235
|
+
});
|
|
236
|
+
return signedTx;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 批量构建 TaxToken 奖励领取交易(多个钱包)
|
|
240
|
+
*
|
|
241
|
+
* @param tokenAddress - TaxToken 合约地址
|
|
242
|
+
* @param privateKeys - 用户私钥数组
|
|
243
|
+
* @param rpcUrl - BSC RPC URL
|
|
244
|
+
* @returns 签名后的交易 hex 数组
|
|
245
|
+
*/
|
|
246
|
+
export async function buildBatchClaimFeeTxs(tokenAddress, privateKeys, rpcUrl) {
|
|
247
|
+
const provider = new JsonRpcProvider(rpcUrl);
|
|
248
|
+
const iface = new ethers.Interface(TAX_TOKEN_READ_ABI);
|
|
249
|
+
const claimData = iface.encodeFunctionData('claimFee', []);
|
|
250
|
+
const feeData = await provider.getFeeData();
|
|
251
|
+
const gasPrice = feeData.gasPrice ?? ethers.parseUnits('3', 'gwei');
|
|
252
|
+
const signedTxs = await Promise.all(privateKeys.map(async (pk) => {
|
|
253
|
+
const wallet = new Wallet(pk, provider);
|
|
254
|
+
const nonce = await provider.getTransactionCount(wallet.address, 'latest');
|
|
255
|
+
return wallet.signTransaction({
|
|
256
|
+
to: tokenAddress,
|
|
257
|
+
data: claimData,
|
|
258
|
+
nonce,
|
|
259
|
+
gasLimit: 200000n,
|
|
260
|
+
gasPrice,
|
|
261
|
+
chainId: 56,
|
|
262
|
+
type: 0,
|
|
263
|
+
});
|
|
264
|
+
}));
|
|
265
|
+
return signedTxs;
|
|
266
|
+
}
|
|
267
|
+
// ============================================================================
|
|
268
|
+
// 校验工具
|
|
269
|
+
// ============================================================================
|
|
270
|
+
/**
|
|
271
|
+
* 验证 FourTokenTaxInfo 参数合法性
|
|
272
|
+
*
|
|
273
|
+
* @param info - 税币配置
|
|
274
|
+
* @returns 验证结果,valid=true 表示合法
|
|
275
|
+
*/
|
|
276
|
+
export function validateFourTokenTaxInfo(info) {
|
|
277
|
+
// feeRate 必须是 1, 3, 5, 10 之一
|
|
278
|
+
if (![1, 3, 5, 10].includes(info.feeRate)) {
|
|
279
|
+
return { valid: false, error: `feeRate 必须为 1, 3, 5 或 10,当前: ${info.feeRate}` };
|
|
280
|
+
}
|
|
281
|
+
// 四项比例之和必须为 100
|
|
282
|
+
const rateSum = info.burnRate + info.divideRate + info.liquidityRate + info.recipientRate;
|
|
283
|
+
if (rateSum !== 100) {
|
|
284
|
+
return { valid: false, error: `burnRate + divideRate + liquidityRate + recipientRate 必须等于 100,当前: ${rateSum}` };
|
|
285
|
+
}
|
|
286
|
+
// 每项比例 >= 0
|
|
287
|
+
if (info.burnRate < 0 || info.divideRate < 0 || info.liquidityRate < 0 || info.recipientRate < 0) {
|
|
288
|
+
return { valid: false, error: '所有比例值不能为负数' };
|
|
289
|
+
}
|
|
290
|
+
// minSharing 验证: d × 10^n, n >= 5, 1 <= d <= 9
|
|
291
|
+
if (info.minSharing > 0) {
|
|
292
|
+
const str = String(info.minSharing);
|
|
293
|
+
// 必须形如 d000...0(d 为 1-9 的数字,后面至少 5 个 0)
|
|
294
|
+
const match = str.match(/^([1-9])(0+)$/);
|
|
295
|
+
if (!match || match[2].length < 5) {
|
|
296
|
+
return { valid: false, error: `minSharing 必须满足 d × 10^n (n≥5, 1≤d≤9),当前: ${info.minSharing}` };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return { valid: true };
|
|
300
|
+
}
|
|
301
|
+
// 导出 ABI 供外部使用
|
|
302
|
+
export { TaxTokenAbi as TAX_TOKEN_ABI };
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 包含所有跨链共享的功能:
|
|
5
5
|
* - constants: 常量定义
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* - (未来) types: 通用类型
|
|
6
|
+
* - clients: API 客户端
|
|
7
|
+
* - four: Four.meme 工具(TaxToken 等)
|
|
9
8
|
*/
|
|
10
9
|
export * from './constants/index.js';
|
|
10
|
+
export * as FourUtils from './four/index.js';
|
package/dist/shared/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 包含所有跨链共享的功能:
|
|
5
5
|
* - constants: 常量定义
|
|
6
|
-
* -
|
|
7
|
-
* -
|
|
8
|
-
* - (未来) types: 通用类型
|
|
6
|
+
* - clients: API 客户端
|
|
7
|
+
* - four: Four.meme 工具(TaxToken 等)
|
|
9
8
|
*/
|
|
10
9
|
export * from './constants/index.js';
|
|
10
|
+
export * as FourUtils from './four/index.js';
|