fix max withdraw value for dust amounts
This commit is contained in:
parent
9e82eec2f4
commit
c8ea057f68
|
@ -13,11 +13,14 @@ export const getMaxWithdrawForBank = (
|
|||
mangoAccount: MangoAccount,
|
||||
allowBorrow = false,
|
||||
): Decimal => {
|
||||
const accountBalance = mangoAccount.getTokenBalanceUi(bank)
|
||||
const accountBalance = floorToDecimal(
|
||||
mangoAccount.getTokenBalanceUi(bank),
|
||||
bank.mintDecimals,
|
||||
)
|
||||
const vaultBalance = group.getTokenVaultBalanceByMintUi(bank.mint)
|
||||
const maxBorrow = mangoAccount.getMaxWithdrawWithBorrowForTokenUi(
|
||||
group,
|
||||
bank.mint,
|
||||
const maxBorrow = floorToDecimal(
|
||||
mangoAccount.getMaxWithdrawWithBorrowForTokenUi(group, bank.mint),
|
||||
bank.mintDecimals,
|
||||
)
|
||||
const maxWithdraw = allowBorrow
|
||||
? Decimal.min(vaultBalance, maxBorrow)
|
||||
|
|
Loading…
Reference in New Issue