Quellcode durchsuchen

fix: check bonus

lushdog@outlook.com vor 3 Wochen
Ursprung
Commit
af514a7cd3
1 geänderte Dateien mit 19 neuen und 14 gelöschten Zeilen
  1. 19 14
      src/app/my-lp/page.tsx

+ 19 - 14
src/app/my-lp/page.tsx

@@ -93,24 +93,29 @@ function MyLPPageContent() {
 					const detailData = data.result.data
 					const { pool, bonusInfo } = detailData
 
-					const copyInfo = await fetch(
-						`/api/my-lp/copyInfo?parentPositionAddress=${bonusInfo.fromCreatorPosition}&poolAddress=${pool.poolAddress}`
-					)
 					let allCopyAmount = 0
-					const copyInfoData = await copyInfo.json()
-					if (copyInfoData.retCode === 0 && copyInfoData.result) {
-						allCopyAmount = copyInfoData.result.data.records
-							.filter((item: RecordInfo) => item.status === 0)
-							.reduce(
-								(acc: number, curr: RecordInfo) =>
-									acc + Number(curr.liquidityUsd),
-								0
-							)
+					let allCopys = 0
+
+					if (bonusInfo?.fromCreatorPosition) {
+						const copyInfo = await fetch(
+							`/api/my-lp/copyInfo?parentPositionAddress=${bonusInfo.fromCreatorPosition}&poolAddress=${pool.poolAddress}`
+						)
+						const copyInfoData = await copyInfo.json()
+						if (copyInfoData.retCode === 0 && copyInfoData.result) {
+							allCopys = copyInfoData.result.data.total
+							allCopyAmount = copyInfoData.result.data.records
+								.filter((item: RecordInfo) => item.status === 0)
+								.reduce(
+									(acc: number, curr: RecordInfo) =>
+										acc + Number(curr.liquidityUsd),
+									0
+								)
+						}
 					}
 					const newData = {
 						...data.result.data,
-						allCopyAmount: allCopyAmount,
-						allCopys: copyInfoData.result.data.total,
+						allCopyAmount,
+						allCopys,
 					}
 					return {
 						positionAddress: position.positionAddress,