소스 검색

fix: adapt to Jupiter v3 API response format (usdPrice field)

zhangchunrui 1 개월 전
부모
커밋
524888289a
1개의 변경된 파일5개의 추가작업 그리고 3개의 파일을 삭제
  1. 5 3
      src/solana/jupiter.ts

+ 5 - 3
src/solana/jupiter.ts

@@ -114,9 +114,11 @@ export class JupiterSwapper {
 				headers: this.getHeaders(),
 			})
 			if (response.ok) {
-				const data = (await response.json()) as { data?: Record<string, { price?: number; symbol?: string }> }
-				if (data.data) {
-					Object.assign(result, data.data)
+				const data = (await response.json()) as Record<string, { usdPrice?: number }>
+				for (const [mint, info] of Object.entries(data)) {
+					if (info.usdPrice) {
+						result[mint] = { price: info.usdPrice }
+					}
 				}
 			}
 		} catch (error) {