add est liq ratio
This commit is contained in:
parent
0491b79daf
commit
94b364df3a
|
@ -12,6 +12,7 @@ import SheenLoader from './shared/SheenLoader'
|
||||||
import useStakeAccounts from 'hooks/useStakeAccounts'
|
import useStakeAccounts from 'hooks/useStakeAccounts'
|
||||||
import FormatNumericValue from './shared/FormatNumericValue'
|
import FormatNumericValue from './shared/FormatNumericValue'
|
||||||
import {
|
import {
|
||||||
|
Bank,
|
||||||
Group,
|
Group,
|
||||||
MangoAccount,
|
MangoAccount,
|
||||||
toUiDecimalsForQuote,
|
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 = ({
|
const Positions = ({
|
||||||
setActiveTab,
|
setActiveTab,
|
||||||
}: {
|
}: {
|
||||||
|
@ -171,18 +184,25 @@ const Positions = ({
|
||||||
x
|
x
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
{/* <div>
|
||||||
<p className="mb-1 text-th-fgd-4">Earned</p>
|
<p className="mb-1 text-th-fgd-4">Earned</p>
|
||||||
<span className="text-xl font-bold text-th-fgd-1">
|
<span className="text-xl font-bold text-th-fgd-1">
|
||||||
{stakeBalance
|
{stakeBalance
|
||||||
? `X.XX ${formatTokenSymbol(bank.name)}`
|
? `X.XX ${formatTokenSymbol(bank.name)}`
|
||||||
: `0 ${formatTokenSymbol(bank.name)}`}
|
: `0 ${formatTokenSymbol(bank.name)}`}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div> */}
|
||||||
<div>
|
<div>
|
||||||
<p className="mb-1 text-th-fgd-4">Liquidation Price</p>
|
<p className="mb-1 text-th-fgd-4">Est. Liquidation Ratio</p>
|
||||||
<span className="whitespace-nowrap text-xl font-bold text-th-fgd-1">
|
<span className="whitespace-nowrap text-xl font-bold text-th-fgd-1">
|
||||||
{borrowBalance ? 'X.XX' : '0.00'}{' '}
|
{borrowBalance && borrowBank
|
||||||
|
? getLiquidationRatio(
|
||||||
|
borrowBalance,
|
||||||
|
stakeBalance,
|
||||||
|
bank,
|
||||||
|
borrowBank,
|
||||||
|
)
|
||||||
|
: '0.00'}{' '}
|
||||||
{`${formatTokenSymbol(bank.name)}/${BORROW_TOKEN}`}
|
{`${formatTokenSymbol(bank.name)}/${BORROW_TOKEN}`}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue