four-flap-meme-sdk 4.0.7 → 4.0.9
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/abis/flap/portal.js +2 -0
- package/dist/bundle/four-meme/swap/batch.js +4 -3
- package/dist/bundle/four-meme/swap/bundle.js +5 -3
- package/dist/bundle/four-meme/swap/quick-batch.js +3 -3
- package/dist/bundle/four-meme/swap-buy-first/helpers.d.ts +1 -1
- package/dist/bundle/four-meme/swap-buy-first/helpers.js +2 -5
- package/dist/bundle/four-meme/swap-buy-first/multi-wallet.js +3 -6
- package/dist/bundle/four-meme/swap-buy-first/single.js +5 -6
- package/dist/bundle/four-meme/swap-sign-helpers.d.ts +1 -1
- package/dist/bundle/four-meme/swap-sign-helpers.js +2 -6
- package/dist/chains/bsc/pancake/bundle-buy-first-multi-wallet.js +10 -14
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.d.ts +1 -1
- package/dist/chains/bsc/pancake/bundle-buy-first-plan.js +2 -5
- package/dist/chains/bsc/pancake/bundle-buy-first.js +10 -15
- package/dist/chains/bsc/pancake/quote.d.ts +2 -2
- package/dist/chains/bsc/pancake/quote.js +5 -12
- package/dist/chains/bsc/platforms/iro/token.d.ts +1 -1
- package/dist/chains/bsc/platforms/iro/token.js +3 -5
- package/dist/chains/eni/platforms/daoaas/portal-direct-submit.js +4 -4
- package/dist/chains/xlayer/eip7702/bundle-swap-multi.js +4 -4
- package/dist/chains/xlayer/eip7702/profit.d.ts +6 -12
- package/dist/chains/xlayer/eip7702/profit.js +13 -22
- package/dist/chains/xlayer/eip7702/volume-bundle.js +5 -5
- package/dist/chains/xlayer/eip7702/volume-wash.js +4 -4
- package/dist/chains/xlayer/eoa/quote.d.ts +2 -2
- package/dist/chains/xlayer/eoa/quote.js +5 -10
- package/dist/core/constants/index.d.ts +2 -2
- package/dist/core/constants/index.js +2 -2
- package/dist/core/constants/profit.d.ts +7 -2
- package/dist/core/constants/profit.js +16 -6
- package/dist/core/constants/profit.test.d.ts +1 -0
- package/dist/core/constants/profit.test.js +18 -0
- package/dist/core/constants/quote.d.ts +2 -0
- package/dist/core/constants/quote.js +13 -0
- package/dist/core/quote/quote-helpers.d.ts +11 -0
- package/dist/core/quote/quote-helpers.js +42 -1
- package/dist/domains/flap/index.d.ts +1 -1
- package/dist/domains/flap/module.d.ts +1 -1
- package/dist/domains/flap/portal-bundle-merkle/core-helpers.js +3 -35
- package/dist/domains/flap/portal-bundle-merkle/core.js +3 -3
- package/dist/domains/flap/portal-bundle-merkle/swap-batch.js +9 -6
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-multi-wallet.js +10 -12
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.d.ts +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-plan.js +2 -5
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first-quote.js +3 -24
- package/dist/domains/flap/portal-bundle-merkle/swap-buy-first.js +10 -14
- package/dist/domains/flap/portal-bundle-merkle/swap-helpers.js +3 -23
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.d.ts +1 -1
- package/dist/domains/flap/portal-bundle-merkle/swap-planning.js +3 -14
- package/dist/domains/flap/portal-bundle-merkle/swap-quick-batch.js +4 -4
- package/dist/domains/flap/portal-bundle-merkle/swap-single.js +9 -8
- package/dist/domains/flap/portal.d.ts +1 -1
- package/dist/domains/flap/reader.d.ts +8 -1
- package/dist/domains/flap/reader.js +48 -1
- package/dist/domains/flap/types.d.ts +14 -0
- package/dist/domains/holders/holders-maker.js +3 -7
- package/dist/domains/lp-inspect/inspect.js +33 -9
- package/dist/exports/root-foundations.d.ts +2 -2
- package/dist/exports/root-foundations.js +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/package.json +1 -1
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 功能:钱包A卖出代币 → 钱包B买入相同数量 → 原子执行
|
|
5
5
|
*/
|
|
6
|
-
import { ethers,
|
|
6
|
+
import { ethers, Wallet } from 'ethers';
|
|
7
7
|
import { ADDRESSES } from '../../../core/constants/index.js';
|
|
8
8
|
import { V2_ROUTER_QUOTE_ABI, ERC20_BALANCE_ABI, ERC20_ABI } from '../../../core/shared-abis/common.js';
|
|
9
9
|
import { generateWallets } from '../../../utils/wallet.js';
|
|
10
10
|
import { GAS_LIMITS, CHAINS } from '../../../core/constants/index.js';
|
|
11
|
+
import { getTokenToNativeQuoteByChainId } from '../../../core/quote/quote-helpers.js';
|
|
11
12
|
// ==================== 多跳转账常量(使用统一常量) ====================
|
|
12
13
|
export const NATIVE_TRANSFER_GAS_LIMIT = GAS_LIMITS.NATIVE_TRANSFER;
|
|
13
14
|
export const ERC20_TRANSFER_GAS_LIMIT_HOP = GAS_LIMITS.ERC20_TRANSFER;
|
|
@@ -197,28 +198,7 @@ export const MONAD_WMON = ADDRESSES.MONAD.WMON;
|
|
|
197
198
|
* @returns 等值的原生代币数量(wei),失败返回 0n
|
|
198
199
|
*/
|
|
199
200
|
export async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chainId) {
|
|
200
|
-
|
|
201
|
-
return 0n;
|
|
202
|
-
try {
|
|
203
|
-
if (chainId === CHAINS.BSC.chainId) {
|
|
204
|
-
// BSC: 使用 PancakeSwap V2 Router
|
|
205
|
-
const router = new Contract(BSC_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
206
|
-
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, BSC_WBNB]);
|
|
207
|
-
return amounts[1];
|
|
208
|
-
}
|
|
209
|
-
if (chainId === CHAINS.MONAD.chainId) {
|
|
210
|
-
// ✅ Monad: 使用 PancakeSwap V2 Router
|
|
211
|
-
const router = new Contract(MONAD_PANCAKE_V2_ROUTER, ROUTER_ABI, provider);
|
|
212
|
-
const amounts = await router.getAmountsOut(tokenAmount, [tokenAddress, MONAD_WMON]);
|
|
213
|
-
return amounts[1];
|
|
214
|
-
}
|
|
215
|
-
// ✅ Base (8453) / XLayer (196) 等链暂不支持 V2 报价,返回 0
|
|
216
|
-
return 0n;
|
|
217
|
-
}
|
|
218
|
-
catch {
|
|
219
|
-
// 报价失败返回 0(可能是流动性不足或路径不存在)
|
|
220
|
-
return 0n;
|
|
221
|
-
}
|
|
201
|
+
return getTokenToNativeQuoteByChainId(provider, tokenAddress, tokenAmount, chainId);
|
|
222
202
|
}
|
|
223
203
|
/**
|
|
224
204
|
* 获取链ID
|
|
@@ -66,5 +66,5 @@ interface ProfitTxResult {
|
|
|
66
66
|
hopWallets: GeneratedWallet[];
|
|
67
67
|
}
|
|
68
68
|
export declare function buildProfitTransaction({ provider, seller, profitAmount, profitNonce, gasPrice, chainId, txType, }: ProfitTxArgs): Promise<ProfitTxResult | null>;
|
|
69
|
-
export declare function calculateProfitAmount(quotedNative: bigint,
|
|
69
|
+
export declare function calculateProfitAmount(quotedNative: bigint, _userType?: UserType): bigint;
|
|
70
70
|
export {};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { ethers, Contract } from 'ethers';
|
|
2
2
|
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT, } from '../../../utils/bundle-helpers.js';
|
|
3
3
|
import { FLAP_PORTAL_ADDRESSES } from '../constants.js';
|
|
4
|
-
import { ZERO_ADDRESS } from '../../../core/constants/index.js';
|
|
4
|
+
import { ZERO_ADDRESS, calculateBundleSwapRoundTripProfit } from '../../../core/constants/index.js';
|
|
5
5
|
import { ERC20_ALLOWANCE_ABI } from '../../../core/shared-abis/common.js';
|
|
6
6
|
import { getGasPriceConfig, getTxType, getProfitRecipient, PORTAL_ABI } from './config.js';
|
|
7
|
-
import { getProfitRateBps as getSharedProfitRateBps } from '../../../core/constants/index.js';
|
|
8
7
|
import { getErrorMessageFromUnknown } from '../../../core/index.js';
|
|
9
8
|
import { createSignProvider } from '../../../bundle/sign-context-helpers.js';
|
|
10
9
|
import { APPROVE_INTERFACE, ERC20_BALANCE_OF_ABI, getChainId, getNativeTokenName, } from './swap-helpers.js';
|
|
@@ -161,21 +160,11 @@ export async function buildProfitTransaction({ provider, seller, profitAmount, p
|
|
|
161
160
|
hopWallets: profitHopResult.hopWallets,
|
|
162
161
|
};
|
|
163
162
|
}
|
|
164
|
-
function
|
|
165
|
-
if (userType === 'v0') {
|
|
166
|
-
return getSharedProfitRateBps('v0Single');
|
|
167
|
-
}
|
|
168
|
-
else if (userType === 'v1') {
|
|
169
|
-
return getSharedProfitRateBps('v1Single');
|
|
170
|
-
}
|
|
171
|
-
return getSharedProfitRateBps('v0Single');
|
|
172
|
-
}
|
|
173
|
-
export function calculateProfitAmount(quotedNative, userType) {
|
|
163
|
+
export function calculateProfitAmount(quotedNative, _userType) {
|
|
174
164
|
if (quotedNative <= 0n) {
|
|
175
165
|
return 0n;
|
|
176
166
|
}
|
|
177
|
-
|
|
178
|
-
return (quotedNative * BigInt(rateBps)) / 10000n;
|
|
167
|
+
return calculateBundleSwapRoundTripProfit(quotedNative, quotedNative);
|
|
179
168
|
}
|
|
180
169
|
function countTruthy(values) {
|
|
181
170
|
return values.filter(Boolean).length;
|
|
@@ -6,11 +6,12 @@ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
|
|
|
6
6
|
import { calculateSellAmount } from '../../../utils/swap-helpers.js';
|
|
7
7
|
import { NonceManager, getOptimizedGasPrice, PROFIT_HOP_COUNT } from '../../../utils/bundle-helpers.js';
|
|
8
8
|
import { ZERO_ADDRESS } from '../../../core/constants/index.js';
|
|
9
|
+
import { quoteRoundTripProfitToNativeByChainId } from '../../../core/quote/quote-helpers.js';
|
|
9
10
|
import { ERC20_ABI } from '../../../core/shared-abis/common.js';
|
|
10
11
|
import { getGasPriceConfig, getTxType, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI, } from './config.js';
|
|
11
12
|
import { buildTransactionRequest } from '../../../core/tx/build-request.js';
|
|
12
13
|
import { GAS_LIMITS } from '../../../core/constants/index.js';
|
|
13
|
-
import { BRIBE_GAS_LIMIT, NATIVE_TRANSFER_GAS_LIMIT, buildBNBHopChainForERC20, buildERC20HopChain, buildNativeHopChain, generateDisperseHopPaths,
|
|
14
|
+
import { BRIBE_GAS_LIMIT, NATIVE_TRANSFER_GAS_LIMIT, buildBNBHopChainForERC20, buildERC20HopChain, buildNativeHopChain, generateDisperseHopPaths, } from './swap-helpers.js';
|
|
14
15
|
import { buildProfitTransaction, calculateProfitAmount, createChainContext, quoteSellOutput, } from './swap-planning.js';
|
|
15
16
|
/**
|
|
16
17
|
* Flap 内盘快捷批量换手(资金利用率模式)
|
|
@@ -91,9 +92,8 @@ export async function flapQuickBatchSwapMerkle(params) {
|
|
|
91
92
|
// ✅ 计算利润(根据 userType 动态调整)
|
|
92
93
|
const tokenProfitAmount = calculateProfitAmount(estimatedOutput, config.userType);
|
|
93
94
|
let nativeProfitAmount = tokenProfitAmount;
|
|
94
|
-
if (!useNativeToken &&
|
|
95
|
-
|
|
96
|
-
nativeProfitAmount = await getTokenToNativeQuote(chainContext.provider, quoteToken, tokenProfitAmount, chainContext.chainId);
|
|
95
|
+
if (!useNativeToken && estimatedOutput > 0n && quoteToken) {
|
|
96
|
+
nativeProfitAmount = await quoteRoundTripProfitToNativeByChainId(chainContext.provider, quoteToken, estimatedOutput, estimatedOutput, chainContext.chainId);
|
|
97
97
|
}
|
|
98
98
|
const distributableAmount = useNativeToken ? estimatedOutput - tokenProfitAmount : estimatedOutput; // ERC20 模式利润从原生代币扣
|
|
99
99
|
// ✅ 计算每个买方分到的金额
|
|
@@ -6,9 +6,10 @@ import { getGasLimit } from '../../../core/gas/bundle-gas.js';
|
|
|
6
6
|
import { calculateSellAmount } from '../../../utils/swap-helpers.js';
|
|
7
7
|
import { NonceManager, getOptimizedGasPrice } from '../../../utils/bundle-helpers.js';
|
|
8
8
|
import { ZERO_ADDRESS } from '../../../core/constants/index.js';
|
|
9
|
+
import { quoteRoundTripProfitToNativeByChainId } from '../../../core/quote/quote-helpers.js';
|
|
9
10
|
import { getGasPriceConfig, getTxType, getBribeAmount, BLOCKRAZOR_BUILDER_EOA, PORTAL_ABI, } from './config.js';
|
|
10
11
|
import { buildTransactionRequest } from '../../../core/tx/build-request.js';
|
|
11
|
-
import { BRIBE_GAS_LIMIT,
|
|
12
|
+
import { BRIBE_GAS_LIMIT, } from './swap-helpers.js';
|
|
12
13
|
import { buildApprovalTransaction, buildNoncePlan, buildProfitTransaction, calculateBuyerNeed, calculateProfitAmount, createChainContext, planNonces, quoteSellOutput, validateBalances, } from './swap-planning.js';
|
|
13
14
|
export async function flapBundleSwapMerkle(params) {
|
|
14
15
|
const { chain, sellerPrivateKey, sellAmount, sellPercentage, buyerPrivateKey, tokenAddress, config, quoteToken, quoteTokenDecimals, startNonces, // ✅ 可选:前端预获取的 nonces
|
|
@@ -62,13 +63,13 @@ export async function flapBundleSwapMerkle(params) {
|
|
|
62
63
|
quoteTokenDecimals,
|
|
63
64
|
provider: chainContext.provider,
|
|
64
65
|
});
|
|
65
|
-
// ✅
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
nativeProfitAmount = await
|
|
66
|
+
// ✅ 计算利润。ERC-20 先把卖出合计折成原生币再计提万六,避免 ANTFUN 微额报价为 0
|
|
67
|
+
let nativeProfitAmount = 0n;
|
|
68
|
+
if (useNativeToken) {
|
|
69
|
+
nativeProfitAmount = calculateProfitAmount(quote.quotedNative, config.userType);
|
|
70
|
+
}
|
|
71
|
+
else if (quote.quotedNative > 0n && quoteToken) {
|
|
72
|
+
nativeProfitAmount = await quoteRoundTripProfitToNativeByChainId(chainContext.provider, quoteToken, quote.quotedNative, quote.quotedNative, chainContext.chainId);
|
|
72
73
|
}
|
|
73
74
|
// ✅ 获取贿赂金额
|
|
74
75
|
const bribeAmount = getBribeAmount(config);
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
* 对外 export 符号与路径保持不变。
|
|
10
10
|
*/
|
|
11
11
|
export { TokenStatus, TokenVersion, FeeType, DexThreshType, MigratorType, V3LPFeeProfile, DEXId, lpFeeProfileToV3Fee, validateTaxDistribution, } from './types.js';
|
|
12
|
-
export type { FlapChain, PortalConfig, TokenStateV2, TokenStateV3, TokenStateV4, TokenStateV5, TokenStateV7, QuoteExactInputParams, ExactInputParams, ExactInputV3Params, NewTokenV3Params, NewTokenV4Params, NewTokenV5Params, TaxDistributionConfig, } from './types.js';
|
|
12
|
+
export type { FlapChain, PortalConfig, TokenStateV2, TokenStateV3, TokenStateV4, TokenStateV5, TokenStateV7, TokenStateV8, QuoteExactInputParams, ExactInputParams, ExactInputV3Params, NewTokenV3Params, NewTokenV4Params, NewTokenV5Params, TaxDistributionConfig, } from './types.js';
|
|
13
13
|
export { FlapPortal } from './reader.js';
|
|
14
14
|
export { FlapPortalWriter } from './writer.js';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Flap Portal — 只读查询(reader)
|
|
3
3
|
*/
|
|
4
4
|
import { Contract } from 'ethers';
|
|
5
|
-
import type { PortalConfig, QuoteExactInputParams, TokenStateV2, TokenStateV3, TokenStateV4, TokenStateV5, TokenStateV7 } from './types.js';
|
|
5
|
+
import type { PortalConfig, QuoteExactInputParams, TokenStateV2, TokenStateV3, TokenStateV4, TokenStateV5, TokenStateV7, TokenStateV8 } from './types.js';
|
|
6
6
|
export declare const PORTAL_ABI: string[];
|
|
7
7
|
export declare class FlapPortal {
|
|
8
8
|
private rpcUrl;
|
|
@@ -20,6 +20,13 @@ export declare class FlapPortal {
|
|
|
20
20
|
* 注意:仅部分链支持 V7(如 XLayer v5.7+),不支持的链会 revert
|
|
21
21
|
*/
|
|
22
22
|
getTokenV7(token: string): Promise<TokenStateV7>;
|
|
23
|
+
mapTokenStateV8(raw: unknown[]): TokenStateV8;
|
|
24
|
+
/**
|
|
25
|
+
* BSC TOKEN_TAXED_V3:买卖税在 buyTaxRate / sellTaxRate。
|
|
26
|
+
* 用 V7 读会把残留 taxRate(常见 100 bps)当成当前税。
|
|
27
|
+
*/
|
|
28
|
+
getTokenV8(token: string): Promise<TokenStateV8>;
|
|
29
|
+
getTokenV8Safe(token: string): Promise<TokenStateV8>;
|
|
23
30
|
/**
|
|
24
31
|
* 计算距离毕业还需多少 OKB/ETH(含手续费)
|
|
25
32
|
* @param state TokenStateV5 或 TokenStateV7
|
|
@@ -11,8 +11,11 @@ export const PORTAL_ABI = [
|
|
|
11
11
|
'function getTokenV3(address token) external view returns (uint8,uint256,uint256,uint256,uint8,uint256,uint256,address,bool)',
|
|
12
12
|
'function getTokenV4(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,address,bool,bytes32))',
|
|
13
13
|
'function getTokenV5(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32))',
|
|
14
|
-
// V7:
|
|
14
|
+
// V7: taxRate, pool, progress, lpFeeProfile(非 BSC / 旧 Portal)
|
|
15
15
|
'function getTokenV7(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32,uint256,address,uint256,uint8))',
|
|
16
|
+
// V8: taxRate 拆成 buyTaxRate, sellTaxRate,末尾带 dexId(BSC TOKEN_TAXED_V3)
|
|
17
|
+
'function getTokenV8(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32,uint256,uint256,address,uint256,uint8,uint8))',
|
|
18
|
+
'function getTokenV8Safe(address token) external view returns ((uint8,uint256,uint256,uint256,uint8,uint256,uint256,uint256,uint256,address,bool,bytes32,uint256,uint256,address,uint256,uint8,uint8))',
|
|
16
19
|
// 报价方法
|
|
17
20
|
'function previewBuy(address token, uint256 ethAmount) external view returns (uint256)',
|
|
18
21
|
'function previewSell(address token, uint256 tokenAmount) external view returns (uint256)',
|
|
@@ -143,6 +146,50 @@ export class FlapPortal {
|
|
|
143
146
|
lpFeeProfile: Number(raw[15]),
|
|
144
147
|
};
|
|
145
148
|
}
|
|
149
|
+
mapTokenStateV8(raw) {
|
|
150
|
+
const buyTaxRate = raw[12];
|
|
151
|
+
const sellTaxRate = raw[13];
|
|
152
|
+
const buy = Number(buyTaxRate ?? 0n);
|
|
153
|
+
const sell = Number(sellTaxRate ?? 0n);
|
|
154
|
+
return {
|
|
155
|
+
status: raw[0],
|
|
156
|
+
reserve: raw[1],
|
|
157
|
+
circulatingSupply: raw[2],
|
|
158
|
+
price: raw[3],
|
|
159
|
+
tokenVersion: raw[4],
|
|
160
|
+
r: raw[5],
|
|
161
|
+
h: raw[6],
|
|
162
|
+
k: raw[7],
|
|
163
|
+
dexSupplyThresh: raw[8],
|
|
164
|
+
quoteTokenAddress: raw[9],
|
|
165
|
+
nativeToQuoteSwapEnabled: raw[10],
|
|
166
|
+
extensionID: raw[11],
|
|
167
|
+
buyTaxRate,
|
|
168
|
+
sellTaxRate,
|
|
169
|
+
taxRate: BigInt(Math.max(buy, sell)),
|
|
170
|
+
pool: raw[14],
|
|
171
|
+
progress: raw[15],
|
|
172
|
+
lpFeeProfile: Number(raw[16]),
|
|
173
|
+
dexId: Number(raw[17] ?? 0),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* BSC TOKEN_TAXED_V3:买卖税在 buyTaxRate / sellTaxRate。
|
|
178
|
+
* 用 V7 读会把残留 taxRate(常见 100 bps)当成当前税。
|
|
179
|
+
*/
|
|
180
|
+
async getTokenV8(token) {
|
|
181
|
+
const raw = await this.contract.getTokenV8(token);
|
|
182
|
+
return this.mapTokenStateV8(raw);
|
|
183
|
+
}
|
|
184
|
+
async getTokenV8Safe(token) {
|
|
185
|
+
try {
|
|
186
|
+
const raw = await this.contract.getTokenV8Safe(token);
|
|
187
|
+
return this.mapTokenStateV8(raw);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return this.getTokenV8(token);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
146
193
|
/**
|
|
147
194
|
* 计算距离毕业还需多少 OKB/ETH(含手续费)
|
|
148
195
|
* @param state TokenStateV5 或 TokenStateV7
|
|
@@ -123,6 +123,20 @@ export type TokenStateV7 = TokenStateV5 & {
|
|
|
123
123
|
progress: bigint;
|
|
124
124
|
lpFeeProfile: number;
|
|
125
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* TokenStateV8 - BSC TOKEN_TAXED_V3:taxRate 拆成 buyTaxRate / sellTaxRate
|
|
128
|
+
* 其它链仍用 V7;V8 仅 BSC Portal。
|
|
129
|
+
*/
|
|
130
|
+
export type TokenStateV8 = TokenStateV5 & {
|
|
131
|
+
buyTaxRate: bigint;
|
|
132
|
+
sellTaxRate: bigint;
|
|
133
|
+
/** 兼容读侧:max(buy, sell) */
|
|
134
|
+
taxRate: bigint;
|
|
135
|
+
pool: string;
|
|
136
|
+
progress: bigint;
|
|
137
|
+
lpFeeProfile: number;
|
|
138
|
+
dexId: number;
|
|
139
|
+
};
|
|
126
140
|
/**
|
|
127
141
|
* 将 lpFeeProfile 转换为 V3 fee 值
|
|
128
142
|
*/
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { ethers, JsonRpcProvider, Wallet } from 'ethers';
|
|
5
5
|
import { generateWallets } from '../../utils/wallet.js';
|
|
6
6
|
import { NonceManager, getOptimizedGasPrice, buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../../utils/bundle-helpers.js';
|
|
7
|
-
import { BLOCKRAZOR_BUILDER_EOA, getProfitRecipient,
|
|
7
|
+
import { BLOCKRAZOR_BUILDER_EOA, getProfitRecipient, getTransferFeePerAddress, } from '../../core/constants/index.js';
|
|
8
8
|
import { getErrorMessageFromUnknown } from '../../core/index.js';
|
|
9
9
|
import { DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE_GWEI, DEFAULT_MAX_WALLETS_PER_BATCH_ERC20, DEFAULT_MAX_WALLETS_PER_BATCH_NATIVE, GAS_BUFFER_MULTIPLIER, NATIVE_TRANSFER_GAS_LIMIT, buildDaoaasBuyTx, buildDisperseHopChainERC20, buildDisperseHopChainNative, buildERC20ApproveTx, buildFlapBuyTx, buildFourBuyTx, buildNativeTransferTx, buildV2BuyTx, buildV2BuyTxWithERC20, buildV3BuyTx, buildV3BuyTxWithERC20, calculateMaxWalletsPerBatch, chunkArray, generateDisperseHopPaths, getBaseTokenAddress, getRouterAddress, } from './holders-maker-helpers.js';
|
|
10
10
|
function formatUnitsFixed(value, decimals, precision = 6) {
|
|
@@ -88,12 +88,8 @@ export async function holdersMaker(params) {
|
|
|
88
88
|
// 4. 分批处理
|
|
89
89
|
const walletBatches = chunkArray(newWallets, maxWalletsPerBatch);
|
|
90
90
|
result.totalBatchCount = walletBatches.length;
|
|
91
|
-
// 5.
|
|
92
|
-
const
|
|
93
|
-
? ethers.parseEther(buyAmountPerHolder) * BigInt(holdersCount) // 按等值 BNB 计算
|
|
94
|
-
: buyAmountWei * BigInt(holdersCount);
|
|
95
|
-
const profitRateBps = getSharedProfitRateBps('normal');
|
|
96
|
-
const totalProfit = (totalBuyAmountForProfit * BigInt(profitRateBps)) / 10000n;
|
|
91
|
+
// 5. 按地址收取转账费(与钱包分发一致)
|
|
92
|
+
const totalProfit = getTransferFeePerAddress(chainId) * BigInt(holdersCount);
|
|
97
93
|
let profitPerBatch = totalProfit / BigInt(walletBatches.length);
|
|
98
94
|
if (profitPerBatch > 0n && chain === 'ENI') {
|
|
99
95
|
profitPerBatch += NATIVE_TRANSFER_GAS_LIMIT * gasPrice;
|
|
@@ -67,13 +67,25 @@ export async function inspectTokenLP(token, opts) {
|
|
|
67
67
|
// ✅ 优先尝试 getTokenV7(包含 taxRate),失败则 fallback 到 getTokenV5
|
|
68
68
|
let st = null;
|
|
69
69
|
let taxRate;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
if (opts.flapChain === 'BSC') {
|
|
71
|
+
try {
|
|
72
|
+
const stV8 = await flap.getTokenV8Safe(token);
|
|
73
|
+
st = stV8;
|
|
74
|
+
taxRate = Math.max(Number(stV8.buyTaxRate ?? 0n), Number(stV8.sellTaxRate ?? 0n));
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// V8 不可用时走 V7
|
|
78
|
+
}
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
|
|
80
|
+
if (!st) {
|
|
81
|
+
try {
|
|
82
|
+
const stV7 = await flap.getTokenV7(token);
|
|
83
|
+
st = stV7;
|
|
84
|
+
taxRate = Number(stV7.taxRate ?? 0n);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
st = await flap.getTokenV5(token);
|
|
88
|
+
}
|
|
77
89
|
}
|
|
78
90
|
if (st && st.status !== undefined && Number(st.status) !== 4) {
|
|
79
91
|
result.platform = 'FLAP';
|
|
@@ -317,9 +329,21 @@ export async function inspectTokenLP(token, opts) {
|
|
|
317
329
|
if (opts.flapChain && !result.flap && result.platform !== 'UNKNOWN') {
|
|
318
330
|
try {
|
|
319
331
|
const flap = new FlapPortal({ chain: opts.flapChain, rpcUrl: opts.rpcUrl });
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
332
|
+
let taxRate = 0;
|
|
333
|
+
if (opts.flapChain === 'BSC') {
|
|
334
|
+
try {
|
|
335
|
+
const stV8 = await flap.getTokenV8Safe(token);
|
|
336
|
+
taxRate = Math.max(Number(stV8.buyTaxRate ?? 0n), Number(stV8.sellTaxRate ?? 0n));
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
const stV7 = await flap.getTokenV7(token);
|
|
340
|
+
taxRate = Number(stV7.taxRate ?? 0n);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
const stV7 = await flap.getTokenV7(token);
|
|
345
|
+
taxRate = Number(stV7.taxRate ?? 0n);
|
|
346
|
+
}
|
|
323
347
|
if (taxRate > 0) {
|
|
324
348
|
result.taxRate = taxRate;
|
|
325
349
|
}
|
|
@@ -8,7 +8,7 @@ export * as chains from '../chains/index.js';
|
|
|
8
8
|
export * as Abis from '../abis/index.js';
|
|
9
9
|
export { getErrorMessageFromUnknown, normalizeUnknownError, noopSdkLogger, consoleSdkLogger, buildTransactionRequest, type NormalizedErrorShape, type SdkLogger, type Aggregate3CallResult, type EnsureAllowanceResult, type EnsureAllowanceBatchItemResult, type BuildTxRequestParams, type HoldersMakerChain, type HoldersMakerTradeType, type BaseTokenType, type HoldersMakerConfig, type HoldersMakerParams, type TransactionLayer, type BatchResult, type BatchResult as HoldersMakerBatchResult, type HoldersMakerResult, type DexConfig, type ChainDexConfig, type PoolPairInfo, type V3PoolInfo, type DexPoolInfo, type BestPoolInfo, type LPPlatform, type LPInfo, type InspectOptions, type BundleSubmitResult, type SignedTransactionsResult, type DisperseParams, type AirdropDisperseSignParams, type SweepParams, type AirdropSweepSignParams, type PrivateSaleSignConfig, type PrivateSaleTransferParams, type BatchPrivateSaleParams, type PrivateSaleResult, type ApproveTokenBatchParams, type ApproveTokenBatchRawParams, type ApproveTokenBatchResult, type ApproveTokenBatchSignResult, type SupportedChain, type QuoteParams, type QuoteResult, } from '../core/index.js';
|
|
10
10
|
export { ERC20_ABI, ERC20_BALANCE_ABI, ERC20_ALLOWANCE_ABI, MULTICALL3_ABI, V2_ROUTER_ABI, V2_ROUTER_QUOTE_ABI, V3_ROUTER02_ABI, V3_ROUTER_LEGACY_ABI, V3_QUOTER_ABI, V2_FACTORY_ABI, V2_PAIR_ABI, V3_FACTORY_ABI, V3_POOL_ABI, FLAP_PORTAL_ABI, TM2_ABI, HELPER3_ABI, } from '../abis/common.js';
|
|
11
|
-
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ADDRESSES, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, ENI_SPENDERS, getEniSpenders, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateProfitHopGasCost, getTransferFeePerAddress, TRANSFER_FEE_PER_ADDRESS, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
|
11
|
+
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ADDRESSES, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, ENI_SPENDERS, getEniSpenders, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateBundleSwapRoundTripProfit, calculateProfitHopGasCost, getTransferFeePerAddress, TRANSFER_FEE_PER_ADDRESS, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
|
12
12
|
export { buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../utils/bundle-helpers.js';
|
|
13
13
|
export { isExclusiveOnChain, isExclusiveOffChain } from '../utils/mpcExclusive.js';
|
|
14
14
|
export { ensureSellApprovalV1, checkSellApprovalV1, ensureSellApprovalV2, checkSellApprovalV2, ensureSellApproval, checkSellApproval, ensureFlapSellApproval, checkFlapSellApproval, ensureFlapSellApprovalBatch, checkFlapSellApprovalBatch, checkAllowance, approveToken, checkAllowanceBatch, approveTokenBatch, checkAllowanceRaw, approveTokenRaw, checkAllowanceBatchRaw, approveTokenBatchRaw, } from '../core/erc20/index.js';
|
|
@@ -22,7 +22,7 @@ export { TM1, type FourChainV1 } from '../domains/four/contracts/tm1.js';
|
|
|
22
22
|
export { TM2, type FourChainV2 } from '../domains/four/contracts/tm2.js';
|
|
23
23
|
export { Helper3, Helper3Writer } from '../domains/four/contracts/helper3.js';
|
|
24
24
|
export { CDPV2 } from '../domains/flap/curve.js';
|
|
25
|
-
export { FlapPortal, FlapPortalWriter, type FlapChain, type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type TokenStateV5, type TokenStateV7, type QuoteExactInputParams, type ExactInputParams, type ExactInputV3Params, type NewTokenV3Params, type NewTokenV4Params, type NewTokenV5Params, type TaxDistributionConfig, validateTaxDistribution, TokenStatus, TokenVersion, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId, } from '../domains/flap/portal.js';
|
|
25
|
+
export { FlapPortal, FlapPortalWriter, type FlapChain, type PortalConfig, type TokenStateV2, type TokenStateV3, type TokenStateV4, type TokenStateV5, type TokenStateV7, type TokenStateV8, type QuoteExactInputParams, type ExactInputParams, type ExactInputV3Params, type NewTokenV3Params, type NewTokenV4Params, type NewTokenV5Params, type TaxDistributionConfig, validateTaxDistribution, TokenStatus, TokenVersion, DexThreshType, MigratorType, V3LPFeeProfile, lpFeeProfileToV3Fee, DEXId, } from '../domains/flap/portal.js';
|
|
26
26
|
export { uploadTokenMeta, type TokenMetaInput } from '../domains/flap/ipfs.js';
|
|
27
27
|
export { buildPermitPiggybackAuto } from '../domains/flap/permit.js';
|
|
28
28
|
export { predictVanityTokenAddressByChain, findSaltEndingByChain } from '../domains/flap/vanity.js';
|
|
@@ -29,7 +29,7 @@ GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit,
|
|
|
29
29
|
// 合约地址
|
|
30
30
|
ADDRESSES, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, ENI_SPENDERS, getEniSpenders,
|
|
31
31
|
// 利润配置
|
|
32
|
-
getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateProfitHopGasCost, getTransferFeePerAddress, TRANSFER_FEE_PER_ADDRESS,
|
|
32
|
+
getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateBundleSwapRoundTripProfit, calculateProfitHopGasCost, getTransferFeePerAddress, TRANSFER_FEE_PER_ADDRESS,
|
|
33
33
|
// DEX 报价配置
|
|
34
34
|
QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
|
35
35
|
export { buildProfitHopTransactions, PROFIT_HOP_COUNT } from '../utils/bundle-helpers.js';
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* v2:不再导出 `CHAIN` / `DEFAULT_DEADLINE_MINUTES` / `PROFIT_CONFIG` / 报价 `V3_FEE_TIERS`。
|
|
8
8
|
*/
|
|
9
|
-
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ZERO_ADDRESS, BLOCKRAZOR_BUILDER_EOA, ADDRESSES, getAddress, getWrappedNativeAddress, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateProfitHopGasCost, TRANSFER_FEE_PER_ADDRESS, getTransferFeePerAddress, calculateTransferFee, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
|
9
|
+
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ZERO_ADDRESS, BLOCKRAZOR_BUILDER_EOA, ADDRESSES, getAddress, getWrappedNativeAddress, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateBundleSwapRoundTripProfit, calculateProfitHopGasCost, TRANSFER_FEE_PER_ADDRESS, getTransferFeePerAddress, calculateTransferFee, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
package/dist/utils/constants.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*
|
|
7
7
|
* v2:不再导出 `CHAIN` / `DEFAULT_DEADLINE_MINUTES` / `PROFIT_CONFIG` / 报价 `V3_FEE_TIERS`。
|
|
8
8
|
*/
|
|
9
|
-
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ZERO_ADDRESS, BLOCKRAZOR_BUILDER_EOA, ADDRESSES, getAddress, getWrappedNativeAddress, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateProfitHopGasCost, TRANSFER_FEE_PER_ADDRESS, getTransferFeePerAddress, calculateTransferFee, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|
|
9
|
+
export { CHAINS, CHAIN_ID_MAP, getChainById, getChainName, getDefaultRpcUrl, isKnownChain, isBscChain, isXLayerChain, isMonadChain, isEniChain, getConfirmationTimeout, GAS_LIMITS, GAS_CONFIG, calculateGasLimit, getTransferGasLimit, ZERO_ADDRESS, BLOCKRAZOR_BUILDER_EOA, ADDRESSES, getAddress, getWrappedNativeAddress, getMulticall3Address, getFlapPortalAddress, isZeroAddress, isNativeToken, getProfitRecipient, getAllProfitRecipients, getProfitRateBps, calculateProfitAmount, calculateBundleSwapRoundTripProfit, calculateProfitHopGasCost, TRANSFER_FEE_PER_ADDRESS, getTransferFeePerAddress, calculateTransferFee, QUOTE_CONFIG, QUOTE_V3_FEE_TIERS, } from '../core/constants/index.js';
|