allow leverage sliding while not connected

This commit is contained in:
tjs 2022-08-19 17:25:31 -04:00
parent 1257c73662
commit e36a88ddbd
2 changed files with 13 additions and 5 deletions

View File

@ -73,15 +73,20 @@ export const SwapLeverageSlider = ({
amount: number
onChange: (x: string) => void
}) => {
const mangoAccountNotLoaded = mangoStore((s) => s.mangoAccount.initialLoad)
const { amountWithBorrow } = useTokenMax()
return (
<>
<LeverageSlider
amount={amount}
leverageMax={amountWithBorrow}
onChange={onChange}
/>
{mangoAccountNotLoaded ? (
<LeverageSlider amount={amount} leverageMax={100} onChange={onChange} />
) : (
<LeverageSlider
amount={amount}
leverageMax={amountWithBorrow}
onChange={onChange}
/>
)}
</>
)
}

View File

@ -382,6 +382,7 @@ const MaxSwapAmount = ({
setAmountIn: (x: any) => void
useMargin: boolean
}) => {
const mangoAccountLoading = mangoStore((s) => s.mangoAccount.initialLoad)
const { t } = useTranslation('common')
const { amount: tokenMax, amountWithBorrow } = useTokenMax()
@ -390,6 +391,8 @@ const MaxSwapAmount = ({
setAmountIn(amountIn)
}
if (mangoAccountLoading) return null
return (
<LinkButton className="no-underline" onClick={setMaxInputAmount}>
<span className="font-normal text-th-fgd-4">{t('max')}:</span>