fix max swap amount displays

This commit is contained in:
tjs 2023-01-05 22:40:23 -05:00
parent e8d4d8e5d0
commit e8cd0b4a7b
1 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,7 @@
import MaxAmountButton from '@components/shared/MaxAmountButton'
import mangoStore from '@store/mangoStore'
import { useTranslation } from 'next-i18next'
import { formatDecimal } from 'utils/numbers'
import { useTokenMax } from './useTokenMax'
const MaxSwapAmount = ({
@ -20,20 +21,23 @@ const MaxSwapAmount = ({
if (mangoAccountLoading) return null
const maxBalanceValue = formatDecimal(tokenMax.toNumber(), decimals)
const maxBorrowValue = formatDecimal(amountWithBorrow.toNumber(), decimals)
return (
<div className="flex flex-wrap justify-end pl-6 text-xs">
<MaxAmountButton
className="mb-0.5"
label="Bal"
onClick={() => setAmountIn(tokenMax.toFixed(decimals))}
value={tokenMax.toFixed()}
onClick={() => setAmountIn(maxBalanceValue)}
value={maxBalanceValue}
/>
{useMargin ? (
<MaxAmountButton
className="mb-0.5 ml-2"
label={t('max')}
onClick={() => setAmountIn(amountWithBorrow.toFixed(decimals))}
value={amountWithBorrow.toFixed()}
onClick={() => setAmountIn(maxBorrowValue)}
value={maxBorrowValue}
/>
) : null}
</div>