|
|
@@ -11,6 +11,13 @@ const USDC_MINT = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
|
|
|
const USDT_MINT = 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'
|
|
|
const SOL_MINT = 'So11111111111111111111111111111111111111112'
|
|
|
|
|
|
+/** 稳定币 mint:用 USDC 换这些币时无需 swap */
|
|
|
+const STABLECOIN_MINTS = [
|
|
|
+ USDC_MINT,
|
|
|
+ USDT_MINT,
|
|
|
+ 'USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB', // USD1
|
|
|
+]
|
|
|
+
|
|
|
export interface JupiterQuote {
|
|
|
inputMint: string
|
|
|
inAmount: string
|
|
|
@@ -174,6 +181,16 @@ export async function swapIfNeeded(
|
|
|
return { success: true }
|
|
|
}
|
|
|
|
|
|
+ const mint = String(outputMint ?? '').trim()
|
|
|
+ const isStablecoin =
|
|
|
+ STABLECOIN_MINTS.includes(mint) || mint === USDC_MINT
|
|
|
+ if (isStablecoin) {
|
|
|
+ console.log(
|
|
|
+ `Skip swap: output is stablecoin (USDC/USDT), no need to swap USDC -> same`
|
|
|
+ )
|
|
|
+ return { success: true }
|
|
|
+ }
|
|
|
+
|
|
|
const inputAmountRaw = Math.floor(Number(usdValue) * 1e6)
|
|
|
if (inputAmountRaw < 1e6) {
|
|
|
console.log(`Skip swap: USD value too small (${usdValue})`)
|