use maxWithBorrows amount if maxWithoutBorrows is greater

This commit is contained in:
Tyler Shipe 2021-08-23 14:36:02 -04:00
parent 1bbdc2a12e
commit 1e45e2cc03
3 changed files with 26 additions and 9 deletions

View File

@ -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"

View File

@ -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

View File

@ -84,14 +84,19 @@ const WithdrawModal: FunctionComponent<WithdrawModalProps> = ({
tokenIndex
)
const maxWithoutBorrows = getDepositsForSelectedAsset()
const maxWithBorrows = mangoAccount.getMaxWithBorrowForToken(
mangoGroup,
mangoCache,
tokenIndex
)
// get max withdraw amount
const maxWithdraw = includeBorrow
? mangoAccount.getMaxWithBorrowForToken(
mangoGroup,
mangoCache,
tokenIndex
)
: getDepositsForSelectedAsset()
? 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