fix negative swap max

This commit is contained in:
saml33 2023-02-10 10:26:28 +11:00
parent efdd8a8934
commit 73162e5544
1 changed files with 9 additions and 7 deletions

View File

@ -53,15 +53,17 @@ export const getTokenInMax = (
? inputTokenBalance
: new Decimal(0)
const maxUiAmountWithBorrow = floorToDecimal(
mangoAccount.getMaxSourceUiForTokenSwap(
group,
inputBank.mint,
outputBank.mint
),
inputBank.mintDecimals
const rawMaxUiAmountWithBorrow = mangoAccount.getMaxSourceUiForTokenSwap(
group,
inputBank.mint,
outputBank.mint
)
const maxUiAmountWithBorrow =
rawMaxUiAmountWithBorrow > 0
? floorToDecimal(rawMaxUiAmountWithBorrow, inputBank.mintDecimals)
: new Decimal(0)
const inputBankVaultBalance = floorToDecimal(
group
.getTokenVaultBalanceByMintUi(inputBank.mint)