use maxWithBorrows amount if maxWithoutBorrows is greater
This commit is contained in:
parent
1bbdc2a12e
commit
1e45e2cc03
|
@ -66,7 +66,8 @@ const handleSettlePnl = async (
|
||||||
export function SettlePnlTooltip() {
|
export function SettlePnlTooltip() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
Settling will update your USDC balance to reflect the PnL amount.{' '}
|
Settling will update your USDC balance to reflect the unsettled PnL
|
||||||
|
amount.{' '}
|
||||||
<a
|
<a
|
||||||
href="https://docs.mango.markets/mango-v3/overview#settle-pnl"
|
href="https://docs.mango.markets/mango-v3/overview#settle-pnl"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
|
|
|
@ -4,14 +4,21 @@ import 'tippy.js/animations/scale.css'
|
||||||
|
|
||||||
type TooltipProps = {
|
type TooltipProps = {
|
||||||
content: ReactNode
|
content: ReactNode
|
||||||
|
placement?: any
|
||||||
className?: string
|
className?: string
|
||||||
children?: ReactNode
|
children?: ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
const Tooltip = ({ children, content, className }: TooltipProps) => {
|
const Tooltip = ({
|
||||||
|
children,
|
||||||
|
content,
|
||||||
|
className,
|
||||||
|
placement = 'top',
|
||||||
|
}: TooltipProps) => {
|
||||||
return (
|
return (
|
||||||
<Tippy
|
<Tippy
|
||||||
animation="scale"
|
animation="scale"
|
||||||
|
placement={placement}
|
||||||
appendTo={() => document.body}
|
appendTo={() => document.body}
|
||||||
maxWidth="20rem"
|
maxWidth="20rem"
|
||||||
interactive
|
interactive
|
||||||
|
|
|
@ -84,14 +84,19 @@ const WithdrawModal: FunctionComponent<WithdrawModalProps> = ({
|
||||||
tokenIndex
|
tokenIndex
|
||||||
)
|
)
|
||||||
|
|
||||||
// get max withdraw amount
|
const maxWithoutBorrows = getDepositsForSelectedAsset()
|
||||||
const maxWithdraw = includeBorrow
|
const maxWithBorrows = mangoAccount.getMaxWithBorrowForToken(
|
||||||
? mangoAccount.getMaxWithBorrowForToken(
|
|
||||||
mangoGroup,
|
mangoGroup,
|
||||||
mangoCache,
|
mangoCache,
|
||||||
tokenIndex
|
tokenIndex
|
||||||
)
|
)
|
||||||
: getDepositsForSelectedAsset()
|
|
||||||
|
// get max withdraw amount
|
||||||
|
const maxWithdraw = includeBorrow
|
||||||
|
? maxWithBorrows
|
||||||
|
: maxWithoutBorrows.gt(maxWithBorrows)
|
||||||
|
? maxWithBorrows
|
||||||
|
: maxWithoutBorrows
|
||||||
|
|
||||||
if (maxWithdraw.gt(I80F48.fromNumber(0))) {
|
if (maxWithdraw.gt(I80F48.fromNumber(0))) {
|
||||||
setMaxAmount(
|
setMaxAmount(
|
||||||
|
@ -415,7 +420,11 @@ const WithdrawModal: FunctionComponent<WithdrawModalProps> = ({
|
||||||
suffix={withdrawTokenSymbol}
|
suffix={withdrawTokenSymbol}
|
||||||
/>
|
/>
|
||||||
{simulation ? (
|
{simulation ? (
|
||||||
<Tooltip content="Projected Leverage" className="py-1">
|
<Tooltip
|
||||||
|
placement="right"
|
||||||
|
content="Projected Leverage"
|
||||||
|
className="py-1"
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
className={`${getAccountStatusColor(
|
className={`${getAccountStatusColor(
|
||||||
simulation.initHealthRatio
|
simulation.initHealthRatio
|
||||||
|
|
Loading…
Reference in New Issue