浏览代码

fix: symbol

lushdog@outlook.com 1 月之前
父节点
当前提交
b2bd82856d
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/app/api/lp-copy/calculate/route.ts

+ 8 - 1
src/app/api/lp-copy/calculate/route.ts

@@ -100,8 +100,10 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
 		let tokenAPriceUsd = 0
 		let tokenBPriceUsd = 0
 		let priceFromApi = false
+		let tokenASymbol: string | undefined
+		let tokenBSymbol: string | undefined
 
-		// 首先尝试从 ByReal API 获取真实 USD 价格
+		// 首先尝试从 ByReal API 获取真实 USD 价格和 symbol
 		try {
 			const detailData = await fetch(
 				`https://api2.byreal.io/byreal/api/dex/v2/position/detail?address=${positionAddress}`
@@ -113,6 +115,9 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
 				tokenBPriceUsd = parseFloat(poolData.mintB.price)
 				priceFromApi = true
 			}
+			// 提取 symbol
+			tokenASymbol = poolData?.mintA?.symbol
+			tokenBSymbol = poolData?.mintB?.symbol
 		} catch (error) {
 			console.warn('Failed to fetch prices from API:', error)
 		}
@@ -424,6 +429,7 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
 				estimatedValue: totalValue,
 				tokenA: {
 					address: poolInfo.mintA.toBase58(),
+					symbol: tokenASymbol,
 					decimals: poolInfo.mintDecimalsA,
 					amount: finalUiAmountA.toString(),
 					amountRaw: (base === 'MintA'
@@ -435,6 +441,7 @@ export async function POST(request: NextRequest): Promise<NextResponse> {
 				},
 				tokenB: {
 					address: poolInfo.mintB.toBase58(),
+					symbol: tokenBSymbol,
 					decimals: poolInfo.mintDecimalsB,
 					amount: finalUiAmountB.toString(),
 					amountRaw: (base === 'MintB'