four-flap-meme-sdk 1.5.1 → 1.5.2
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.
|
@@ -106,6 +106,26 @@ const PANCAKE_V3_ROUTER_ABI = [
|
|
|
106
106
|
// USD1/USDT 使用 100 bps (0.01%),其他使用 2500 bps (0.25%)
|
|
107
107
|
const USD1_V3_FEE = 100;
|
|
108
108
|
const DEFAULT_V3_FEE = 2500;
|
|
109
|
+
const HIGH_V3_FEE = 10000;
|
|
110
|
+
/**
|
|
111
|
+
* 根据 lpFeeProfile 获取对应的 V3 费率
|
|
112
|
+
* 参考 Flap 文档: https://docs.flap.sh/flap/developers/launch-a-token
|
|
113
|
+
*
|
|
114
|
+
* @param lpFeeProfile V3LPFeeProfile 枚举值
|
|
115
|
+
* - 0 (STANDARD) = 0.25% on PancakeSwap
|
|
116
|
+
* - 1 (LOW) = 0.01% on PancakeSwap
|
|
117
|
+
* - 2 (HIGH) = 1%
|
|
118
|
+
*/
|
|
119
|
+
function lpFeeProfileToV3Fee(lpFeeProfile) {
|
|
120
|
+
if (lpFeeProfile === undefined)
|
|
121
|
+
return undefined;
|
|
122
|
+
switch (lpFeeProfile) {
|
|
123
|
+
case 0: return DEFAULT_V3_FEE; // STANDARD: 0.25%
|
|
124
|
+
case 1: return USD1_V3_FEE; // LOW: 0.01%
|
|
125
|
+
case 2: return HIGH_V3_FEE; // HIGH: 1%
|
|
126
|
+
default: return undefined;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
109
129
|
// ==================== 工具函数 ====================
|
|
110
130
|
/** 构建 ERC20 approve 交易 */
|
|
111
131
|
async function buildApproveTransaction(wallet, tokenAddress, spenderAddress, amount, nonce, gasPrice, txType, chainId = 56 // ✅ 添加 chainId 参数
|
|
@@ -437,12 +457,15 @@ export async function flapBundleCreateToDex(params) {
|
|
|
437
457
|
// ✅ 使用动态 Router 地址
|
|
438
458
|
const smartRouter = dexPoolType === 'v3' ? chainConfig.v3Router : chainConfig.v2Router;
|
|
439
459
|
const wrappedNative = chainConfig.wrappedNative;
|
|
440
|
-
// ✅ 根据 quoteToken
|
|
441
|
-
//
|
|
442
|
-
//
|
|
443
|
-
//
|
|
444
|
-
//
|
|
445
|
-
|
|
460
|
+
// ✅ 根据 lpFeeProfile 或 quoteToken 选择 V3 费率
|
|
461
|
+
// 优先级:
|
|
462
|
+
// 1. 如果传入了 lpFeeProfile,使用对应的费率(与 newTokenV4 创建的池子匹配)
|
|
463
|
+
// 2. 如果没传,根据 quoteToken 使用默认费率(参考 Flap 官方脚本)
|
|
464
|
+
// - BNB (原生代币) → 0.25% (2500)
|
|
465
|
+
// - USD1 等稳定币 → 0.01% (100)
|
|
466
|
+
const lpFeeBasedV3Fee = lpFeeProfileToV3Fee(params.lpFeeProfile);
|
|
467
|
+
const defaultV3Fee = useNativeToken ? DEFAULT_V3_FEE : USD1_V3_FEE;
|
|
468
|
+
const actualV3Fee = lpFeeBasedV3Fee ?? v3Fee ?? defaultV3Fee;
|
|
446
469
|
// ✅ ERC20: 先构建 approve 交易
|
|
447
470
|
if (!useNativeToken) {
|
|
448
471
|
const approveNonce = noncesMap.get(addr);
|