update acct leverage to match ftx calc

This commit is contained in:
tjs 2022-10-06 21:08:08 -04:00
parent 86f5411cb3
commit 9f073e6b87
3 changed files with 6 additions and 9 deletions

View File

@ -73,10 +73,8 @@ const AccountPage = () => {
const leverage = useMemo(() => {
if (!mangoAccount) return 0
const liabsValue = mangoAccount.getLiabsValue(HealthType.init)!.toNumber()
const totalCollateral = mangoAccount
.getAssetsValue(HealthType.init)!
.toNumber()
return liabsValue / totalCollateral
const accountValue = mangoAccount.getEquity()!.toNumber()
return liabsValue / accountValue
}, [mangoAccount])
useEffect(() => {
@ -374,7 +372,7 @@ const AccountPage = () => {
<div className="col-span-5 flex border-t border-th-bkg-3 py-3 pl-6 lg:col-span-1 lg:border-l lg:border-t-0">
<div>
<Tooltip
content="Total position size divided by total collateral."
content="Total position size divided by account value."
maxWidth="20rem"
placement="bottom"
delay={250}

View File

@ -22,10 +22,8 @@ const MangoAccountSummary = () => {
const leverage = useMemo(() => {
if (!mangoAccount) return 0
const liabsValue = mangoAccount.getLiabsValue(HealthType.init)!.toNumber()
const totalCollateral = mangoAccount
.getAssetsValue(HealthType.init)!
.toNumber()
return liabsValue / totalCollateral
const accountValue = mangoAccount.getEquity()!.toNumber()
return liabsValue / accountValue
}, [mangoAccount])
return (

View File

@ -27,6 +27,7 @@ const SpotSlider = () => {
)
}
} catch (e) {
console.error('SpotSlider: ', e)
notify({
type: 'error',
title: 'Error calculating max leverage.',