round leverage max to fix slider

This commit is contained in:
saml33 2023-09-26 11:47:58 +10:00
parent 2b7da4b6a9
commit 1d334a571b
1 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,6 @@
import { useMemo } from 'react'
import useMangoGroup from './useMangoGroup'
import { floorToDecimal } from 'utils/numbers'
export default function useLeverageMax(selectedToken: string) {
const { group } = useMangoGroup()
@ -25,7 +26,7 @@ export default function useLeverageMax(selectedToken: string) {
const x = stakeInitAssetWeight.div(borrowInitLiabWeight).toNumber()
const conversionRate = borrowBank.uiPrice / stakeBank.uiPrice
const y = 1 - conversionRate * stakeInitAssetWeight.toNumber()
return 1 + x / y
return floorToDecimal(1 + x / y, 1).toNumber()
}, [stakeBank, borrowBank])
return leverageMax