From b4c362a9edbfbdef64e076944e83aac96ba16457 Mon Sep 17 00:00:00 2001
From: saml33
Date: Sun, 25 Feb 2024 22:57:39 +1100
Subject: [PATCH] simplify position cards
---
components/Positions.tsx | 78 +++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 42 deletions(-)
diff --git a/components/Positions.tsx b/components/Positions.tsx
index 4116089..f50efde 100644
--- a/components/Positions.tsx
+++ b/components/Positions.tsx
@@ -1,6 +1,6 @@
import useMangoGroup from 'hooks/useMangoGroup'
import { useMemo } from 'react'
-import { BORROW_TOKEN, SHOW_INACTIVE_POSITIONS_KEY } from 'utils/constants'
+import { SHOW_INACTIVE_POSITIONS_KEY } from 'utils/constants'
import TokenLogo from './shared/TokenLogo'
import Button from './shared/Button'
import { formatTokenSymbol } from 'utils/tokens'
@@ -15,7 +15,6 @@ import {
} from '@blockworks-foundation/mango-v4'
import useBankRates from 'hooks/useBankRates'
import usePositions from 'hooks/usePositions'
-import Tooltip from './shared/Tooltip'
const set = mangoStore.getState().set
@@ -36,7 +35,7 @@ const getLiquidationRatio = (
return (
(Math.abs(borrowBalance) * borrowBank.maintLiabWeight.toNumber()) /
(stakeBalance * stakeBank.maintAssetWeight.toNumber())
- ).toFixed(3)
+ ).toFixed(2)
}
const Positions = ({
@@ -137,6 +136,8 @@ const PositionItem = ({
return [liqRatio, liqPriceChangePercentage.toFixed(2)]
}, [bank, borrowBalance, borrowBank, stakeBalance])
+ console.log('liq price change percentage', liqPriceChangePercentage)
+
const { estimatedNetAPY, stakeBankDepositRate } = useBankRates(
bank.name,
leverage,
@@ -154,13 +155,7 @@ const PositionItem = ({
{formatTokenSymbol(bank.name)}
- {/*
- {stakeBalance ? 'Opened 2 weeks ago' : 'No Position'}
- */}
+
${bank.uiPrice.toFixed(2)}
+ ) : null}
Est. APY
@@ -205,9 +191,25 @@ const PositionItem = ({
%
- {position.bank.name == 'USDC' ? (
- <>>
- ) : (
+
+
Total Earned
+
= 0
+ ? 'text-th-success'
+ : 'text-th-error'
+ }`}
+ >
+ {stakeBalance || pnl ? (
+
+ ) : (
+ '–'
+ )}
+
+
+ {position.bank.name == 'USDC' ? null : (
<>
Leverage
@@ -215,28 +217,20 @@ const PositionItem = ({
{leverage ? leverage.toFixed(2) : 0.0}x
- {/*
-
Earned
-
- {stakeBalance
- ? `X.XX ${formatTokenSymbol(bank.name)}`
- : `0 ${formatTokenSymbol(bank.name)}`}
-
-
*/}
Est. Liquidation Price
- {liqRatio} {`${formatTokenSymbol(bank.name)}/${BORROW_TOKEN}`}
+ ${liqRatio}
- {liqPriceChangePercentage ? (
-
-
- {liqPriceChangePercentage}%
-
-
- ) : null}
+ {/* {liqPriceChangePercentage ? (
+
+
+ {liqPriceChangePercentage}%
+
+
+ ) : null} */}
>
)}