diff --git a/components/Positions.tsx b/components/Positions.tsx index e77343f..b378736 100644 --- a/components/Positions.tsx +++ b/components/Positions.tsx @@ -12,6 +12,7 @@ import SheenLoader from './shared/SheenLoader' import useStakeAccounts from 'hooks/useStakeAccounts' import FormatNumericValue from './shared/FormatNumericValue' import { + Bank, Group, MangoAccount, toUiDecimalsForQuote, @@ -38,6 +39,18 @@ const getLeverage = (group: Group, mangoAccount: MangoAccount): number => { } } +const getLiquidationRatio = ( + borrowBalance: number, + stakeBalance: number, + stakeBank: Bank, + borrowBank: Bank, +) => { + return ( + (Math.abs(borrowBalance) * borrowBank.maintLiabWeight.toNumber()) / + (stakeBalance * stakeBank.maintAssetWeight.toNumber()) + ).toFixed(3) +} + const Positions = ({ setActiveTab, }: { @@ -171,18 +184,25 @@ const Positions = ({ x -
+ {/*

Earned

{stakeBalance ? `X.XX ${formatTokenSymbol(bank.name)}` : `0 ${formatTokenSymbol(bank.name)}`} -
+
*/}
-

Liquidation Price

+

Est. Liquidation Ratio

- {borrowBalance ? 'X.XX' : '0.00'}{' '} + {borrowBalance && borrowBank + ? getLiquidationRatio( + borrowBalance, + stakeBalance, + bank, + borrowBank, + ) + : '0.00'}{' '} {`${formatTokenSymbol(bank.name)}/${BORROW_TOKEN}`}