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() {
|
||||
return (
|
||||
<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
|
||||
href="https://docs.mango.markets/mango-v3/overview#settle-pnl"
|
||||
target="_blank"
|
||||
|
|
|
@ -4,14 +4,21 @@ import 'tippy.js/animations/scale.css'
|
|||
|
||||
type TooltipProps = {
|
||||
content: ReactNode
|
||||
placement?: any
|
||||
className?: string
|
||||
children?: ReactNode
|
||||
}
|
||||
|
||||
const Tooltip = ({ children, content, className }: TooltipProps) => {
|
||||
const Tooltip = ({
|
||||
children,
|
||||
content,
|
||||
className,
|
||||
placement = 'top',
|
||||
}: TooltipProps) => {
|
||||
return (
|
||||
<Tippy
|
||||
animation="scale"
|
||||
placement={placement}
|
||||
appendTo={() => document.body}
|
||||
maxWidth="20rem"
|
||||
interactive
|
||||
|
|
|
@ -84,14 +84,19 @@ const WithdrawModal: FunctionComponent<WithdrawModalProps> = ({
|
|||
tokenIndex
|
||||
)
|
||||
|
||||
// get max withdraw amount
|
||||
const maxWithdraw = includeBorrow
|
||||
? mangoAccount.getMaxWithBorrowForToken(
|
||||
const maxWithoutBorrows = getDepositsForSelectedAsset()
|
||||
const maxWithBorrows = mangoAccount.getMaxWithBorrowForToken(
|
||||
mangoGroup,
|
||||
mangoCache,
|
||||
tokenIndex
|
||||
)
|
||||
: getDepositsForSelectedAsset()
|
||||
|
||||
// get max withdraw amount
|
||||
const maxWithdraw = includeBorrow
|
||||
? maxWithBorrows
|
||||
: maxWithoutBorrows.gt(maxWithBorrows)
|
||||
? maxWithBorrows
|
||||
: maxWithoutBorrows
|
||||
|
||||
if (maxWithdraw.gt(I80F48.fromNumber(0))) {
|
||||
setMaxAmount(
|
||||
|
@ -415,7 +420,11 @@ const WithdrawModal: FunctionComponent<WithdrawModalProps> = ({
|
|||
suffix={withdrawTokenSymbol}
|
||||
/>
|
||||
{simulation ? (
|
||||
<Tooltip content="Projected Leverage" className="py-1">
|
||||
<Tooltip
|
||||
placement="right"
|
||||
content="Projected Leverage"
|
||||
className="py-1"
|
||||
>
|
||||
<span
|
||||
className={`${getAccountStatusColor(
|
||||
simulation.initHealthRatio
|
||||
|
|
Loading…
Reference in New Issue