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(() => { const leverage = useMemo(() => {
if (!mangoAccount) return 0 if (!mangoAccount) return 0
const liabsValue = mangoAccount.getLiabsValue(HealthType.init)!.toNumber() const liabsValue = mangoAccount.getLiabsValue(HealthType.init)!.toNumber()
const totalCollateral = mangoAccount const accountValue = mangoAccount.getEquity()!.toNumber()
.getAssetsValue(HealthType.init)! return liabsValue / accountValue
.toNumber()
return liabsValue / totalCollateral
}, [mangoAccount]) }, [mangoAccount])
useEffect(() => { 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 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> <div>
<Tooltip <Tooltip
content="Total position size divided by total collateral." content="Total position size divided by account value."
maxWidth="20rem" maxWidth="20rem"
placement="bottom" placement="bottom"
delay={250} delay={250}

View File

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

View File

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