four-flap-meme-sdk 1.4.7 → 1.4.8
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/dex/direct-router.js +19 -8
- package/package.json +1 -1
|
@@ -657,6 +657,7 @@ async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chain,
|
|
|
657
657
|
// V3 策略 1:直接路径 代币 → WBNB
|
|
658
658
|
// 如果指定了 fee,只用指定的 fee;否则尝试所有费率
|
|
659
659
|
const feesToTry = fee ? [fee] : V3_FEE_TIERS;
|
|
660
|
+
console.log(`[getTokenToNativeQuote] 开始 V3 报价: token=${tokenAddress.slice(0, 10)}..., amount=${tokenAmount}, feesToTry=${feesToTry}`);
|
|
660
661
|
for (const tryFee of feesToTry) {
|
|
661
662
|
try {
|
|
662
663
|
const amountOut = await quoter.quoteExactInputSingle.staticCall(tokenAddress, config.wrappedNative, tryFee, tokenAmount, 0n);
|
|
@@ -665,7 +666,8 @@ async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chain,
|
|
|
665
666
|
return amountOut;
|
|
666
667
|
}
|
|
667
668
|
}
|
|
668
|
-
catch {
|
|
669
|
+
catch (err) {
|
|
670
|
+
console.log(`[getTokenToNativeQuote] V3 直接路径失败 (fee=${tryFee}): ${String(err).slice(0, 100)}`);
|
|
669
671
|
continue;
|
|
670
672
|
}
|
|
671
673
|
}
|
|
@@ -679,15 +681,24 @@ async function getTokenToNativeQuote(provider, tokenAddress, tokenAmount, chain,
|
|
|
679
681
|
const midAmount = await quoter.quoteExactInputSingle.staticCall(tokenAddress, stableCoin, fee1, tokenAmount, 0n);
|
|
680
682
|
if (midAmount <= 0n)
|
|
681
683
|
continue;
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
684
|
+
console.log(`[getTokenToNativeQuote] V3 第一跳成功: 代币 → ${stableCoin.slice(0, 10)}... = ${midAmount}`);
|
|
685
|
+
// 第二跳:稳定币 → WBNB(尝试多个费率)
|
|
686
|
+
const stableFees = [100, 500, 2500]; // 0.01%, 0.05%, 0.25%
|
|
687
|
+
for (const fee2 of stableFees) {
|
|
688
|
+
try {
|
|
689
|
+
const amountOut = await quoter.quoteExactInputSingle.staticCall(stableCoin, config.wrappedNative, fee2, midAmount, 0n);
|
|
690
|
+
if (amountOut > 0n) {
|
|
691
|
+
console.log(`[getTokenToNativeQuote] V3 多跳路径成功 (${fee1}→${fee2}): ${ethers.formatEther(amountOut)} BNB`);
|
|
692
|
+
return amountOut;
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
catch {
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
688
698
|
}
|
|
689
699
|
}
|
|
690
|
-
catch {
|
|
700
|
+
catch (err) {
|
|
701
|
+
console.log(`[getTokenToNativeQuote] V3 第一跳失败 (fee=${fee1}): ${err}`);
|
|
691
702
|
continue;
|
|
692
703
|
}
|
|
693
704
|
}
|