fix max swap amount displays
This commit is contained in:
parent
e8d4d8e5d0
commit
e8cd0b4a7b
|
@ -1,6 +1,7 @@
|
||||||
import MaxAmountButton from '@components/shared/MaxAmountButton'
|
import MaxAmountButton from '@components/shared/MaxAmountButton'
|
||||||
import mangoStore from '@store/mangoStore'
|
import mangoStore from '@store/mangoStore'
|
||||||
import { useTranslation } from 'next-i18next'
|
import { useTranslation } from 'next-i18next'
|
||||||
|
import { formatDecimal } from 'utils/numbers'
|
||||||
import { useTokenMax } from './useTokenMax'
|
import { useTokenMax } from './useTokenMax'
|
||||||
|
|
||||||
const MaxSwapAmount = ({
|
const MaxSwapAmount = ({
|
||||||
|
@ -20,20 +21,23 @@ const MaxSwapAmount = ({
|
||||||
|
|
||||||
if (mangoAccountLoading) return null
|
if (mangoAccountLoading) return null
|
||||||
|
|
||||||
|
const maxBalanceValue = formatDecimal(tokenMax.toNumber(), decimals)
|
||||||
|
const maxBorrowValue = formatDecimal(amountWithBorrow.toNumber(), decimals)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-wrap justify-end pl-6 text-xs">
|
<div className="flex flex-wrap justify-end pl-6 text-xs">
|
||||||
<MaxAmountButton
|
<MaxAmountButton
|
||||||
className="mb-0.5"
|
className="mb-0.5"
|
||||||
label="Bal"
|
label="Bal"
|
||||||
onClick={() => setAmountIn(tokenMax.toFixed(decimals))}
|
onClick={() => setAmountIn(maxBalanceValue)}
|
||||||
value={tokenMax.toFixed()}
|
value={maxBalanceValue}
|
||||||
/>
|
/>
|
||||||
{useMargin ? (
|
{useMargin ? (
|
||||||
<MaxAmountButton
|
<MaxAmountButton
|
||||||
className="mb-0.5 ml-2"
|
className="mb-0.5 ml-2"
|
||||||
label={t('max')}
|
label={t('max')}
|
||||||
onClick={() => setAmountIn(amountWithBorrow.toFixed(decimals))}
|
onClick={() => setAmountIn(maxBorrowValue)}
|
||||||
value={amountWithBorrow.toFixed()}
|
value={maxBorrowValue}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue