Kaynağa Gözat

feat(my-lp): 添加上级 fee、上级 fee/tvl、1U ROI、1U/Day 回报额和当前 ROI 列

- 修改上级金额计算方式为 totalDeposit - totalWithdraw,小于 0 时显示 0.01
- 添加上级 fee 列,计算方式为 parentPositionInfo.totalClaimedFeeAndReward + totalUnClaimedFeeAndReward
- 添加上级 fee/tvl 列,计算方式为 (上级 fee / 上级金额) * 100%
- 添加 1U ROI 列,计算方式为 (上级 fee * 0.05) / 总复制金额
- 添加 1U/Day 回报额列,计算方式为 (上级 fee * 0.05 / 开仓时间天数) / 总复制金额
- 添加当前 ROI 列,计算方式为 (上级 fee * 0.05 / 开仓时间天数) * 复制金额 / 总复制金额
- 所有新增列均保留 4 位小数并添加 Tooltip 说明
lushdog@outlook.com 3 hafta önce
ebeveyn
işleme
67af55cf8e
1 değiştirilmiş dosya ile 150 ekleme ve 5 silme
  1. 150 5
      src/app/my-lp/page.tsx

+ 150 - 5
src/app/my-lp/page.tsx

@@ -51,6 +51,7 @@ interface RecordInfo {
 	pnlUsdPercent: string
 	PriceRange: string
 	totalDeposit: string
+	totalWithdraw: string
 	earnedUsd: string
 	earnedUsdPercent: string
 	allCopyAmount: string
@@ -72,6 +73,12 @@ interface RecordInfo {
 		fromCreatorPositionStatus: number
 		fromCreatorPosition: string
 	}
+	parentPositionInfo?: {
+		totalClaimedFeeAndReward: string
+		totalUnClaimedFeeAndReward: string
+		totalDeposit: string
+		totalWithdraw: string
+	}
 }
 
 function MyLPPageContent() {
@@ -118,6 +125,7 @@ function MyLPPageContent() {
 					let isParentPositionClosed = false
 					let parentLiquidityUsd = 0
 					let childPositionList: RecordInfo[] = []
+					let parentPositionInfo: RecordInfo | null = null
 
 					if (bonusInfo?.fromCreatorPosition) {
 						const copyInfo = await Promise.all([
@@ -144,6 +152,7 @@ function MyLPPageContent() {
 						}
 						isParentPositionClosed = detailData.result.data.status === 1
 						parentLiquidityUsd = detailData.result.data.totalDeposit
+						parentPositionInfo = detailData.result.data
 					}
 					const newData = {
 						...data.result.data,
@@ -152,6 +161,7 @@ function MyLPPageContent() {
 						parentLiquidityUsd,
 						allCopyAmount,
 						allCopys,
+						parentPositionInfo,
 					}
 					return {
 						positionAddress: position.positionAddress,
@@ -612,6 +622,95 @@ function MyLPPageContent() {
 				</span>
 			),
 		},
+		{
+			title: (
+				<span>
+					1U ROI{' '}
+					<Tooltip title="当前状态下,假设一开始复制金额为 1U 可获得的奖励">
+						<span style={{ cursor: 'help' }}>❓</span>
+					</Tooltip>
+				</span>
+			),
+			key: 'oneURoi',
+			render: (_text: string, record: RecordInfo) => {
+				const claimed =
+					Number(record.parentPositionInfo?.totalClaimedFeeAndReward) || 0
+				const unclaimed =
+					Number(record.parentPositionInfo?.totalUnClaimedFeeAndReward) || 0
+				const parentFee = claimed + unclaimed
+				const totalCopyAmount = Number(record.allCopyAmount) || 0
+				const oneURoi =
+					totalCopyAmount > 0 ? (parentFee * 0.05) / totalCopyAmount : 0
+				return (
+					<span className="font-mono text-base font-bold">
+						{oneURoi.toFixed(4)}
+					</span>
+				)
+			},
+		},
+		{
+			title: (
+				<span>
+					1U/Day 回报额{' '}
+					<Tooltip title="复制金额为 1U 时,每天可获得的奖励">
+						<span style={{ cursor: 'help' }}>❓</span>
+					</Tooltip>
+				</span>
+			),
+			key: 'oneUPerDayRoi',
+			render: (_text: string, record: RecordInfo) => {
+				const claimed =
+					Number(record.parentPositionInfo?.totalClaimedFeeAndReward) || 0
+				const unclaimed =
+					Number(record.parentPositionInfo?.totalUnClaimedFeeAndReward) || 0
+				const parentFee = claimed + unclaimed
+				const totalCopyAmount = Number(record.allCopyAmount) || 0
+				const openTime = record.openTime || 0
+				const now = Date.now()
+				const days = (now - openTime) / (24 * 60 * 60 * 1000) || 1
+				const oneUPerDayRoi =
+					days > 0 && totalCopyAmount > 0
+						? (parentFee * 0.05) / days / totalCopyAmount
+						: 0
+				return (
+					<span className="font-mono text-base font-bold">
+						{oneUPerDayRoi.toFixed(4)}
+					</span>
+				)
+			},
+		},
+		{
+			title: (
+				<span>
+					当前日ROI{' '}
+					<Tooltip title="当前每天的 ROI 回报">
+						<span style={{ cursor: 'help' }}>❓</span>
+					</Tooltip>
+				</span>
+			),
+			key: 'currentRoi',
+			render: (_text: string, record: RecordInfo) => {
+				const claimed =
+					Number(record.parentPositionInfo?.totalClaimedFeeAndReward) || 0
+				const unclaimed =
+					Number(record.parentPositionInfo?.totalUnClaimedFeeAndReward) || 0
+				const parentFee = claimed + unclaimed
+				const liquidityUsd = Number(record.liquidityUsd) || 0
+				const totalCopyAmount = Number(record.allCopyAmount) || 0
+				const openTime = record.openTime || 0
+				const now = Date.now()
+				const days = (now - openTime) / (24 * 60 * 60 * 1000) || 1
+				const currentRoi =
+					days > 0 && totalCopyAmount > 0
+						? (((parentFee * 0.05) / days) * liquidityUsd) / totalCopyAmount
+						: 0
+				return (
+					<span className="font-mono text-base font-bold">
+						{currentRoi.toFixed(4)}
+					</span>
+				)
+			},
+		},
 		{
 			title: '总复制金额/复制数',
 			dataIndex: 'allCopyAmount',
@@ -627,11 +726,57 @@ function MyLPPageContent() {
 			title: '上级金额',
 			dataIndex: 'parentLiquidityUsd',
 			key: 'parentLiquidityUsd',
-			render: (text: string) => (
-				<span className="font-mono text-sm text-purple-500">
-					${Number(text).toFixed(2)}
-				</span>
-			),
+			render: (_text: string, record: RecordInfo) => {
+				const parentDeposit =
+					Number(record.parentPositionInfo?.totalDeposit) || 0
+				const parentWithdraw =
+					Number(record.parentPositionInfo?.totalWithdraw) || 0
+				const parentAmount = parentDeposit - parentWithdraw
+				const displayAmount = parentAmount < 0 ? 0.01 : parentAmount
+				return (
+					<span className="font-mono text-sm text-purple-500">
+						${displayAmount.toFixed(2)}
+					</span>
+				)
+			},
+		},
+		{
+			title: '上级 fee',
+			key: 'parentFee',
+			render: (_text: string, record: RecordInfo) => {
+				const claimed =
+					Number(record.parentPositionInfo?.totalClaimedFeeAndReward) || 0
+				const unclaimed =
+					Number(record.parentPositionInfo?.totalUnClaimedFeeAndReward) || 0
+				const parentFee = claimed + unclaimed
+				return (
+					<span className="font-mono text-sm text-orange-500">
+						${parentFee.toFixed(2)}
+					</span>
+				)
+			},
+		},
+		{
+			title: '上级 fee/tvl',
+			key: 'parentFeeRatio',
+			render: (_text: string, record: RecordInfo) => {
+				const claimed =
+					Number(record.parentPositionInfo?.totalClaimedFeeAndReward) || 0
+				const unclaimed =
+					Number(record.parentPositionInfo?.totalUnClaimedFeeAndReward) || 0
+				const parentFee = claimed + unclaimed
+				const parentDeposit =
+					Number(record.parentPositionInfo?.totalDeposit) || 0
+				const parentWithdraw =
+					Number(record.parentPositionInfo?.totalWithdraw) || 0
+				const parentAmount = parentDeposit - parentWithdraw
+				const ratio = parentAmount > 0 ? (parentFee / parentAmount) * 100 : 0
+				return (
+					<span className="font-mono text-sm text-blue-500">
+						{ratio.toFixed(2)}%
+					</span>
+				)
+			},
 		},
 		{
 			title: '上级地址',