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() { 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"

View File

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

View File

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