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,
|
mangoAccount: MangoAccount,
|
||||||
allowBorrow = false,
|
allowBorrow = false,
|
||||||
): Decimal => {
|
): Decimal => {
|
||||||
const accountBalance = mangoAccount.getTokenBalanceUi(bank)
|
const accountBalance = floorToDecimal(
|
||||||
|
mangoAccount.getTokenBalanceUi(bank),
|
||||||
|
bank.mintDecimals,
|
||||||
|
)
|
||||||
const vaultBalance = group.getTokenVaultBalanceByMintUi(bank.mint)
|
const vaultBalance = group.getTokenVaultBalanceByMintUi(bank.mint)
|
||||||
const maxBorrow = mangoAccount.getMaxWithdrawWithBorrowForTokenUi(
|
const maxBorrow = floorToDecimal(
|
||||||
group,
|
mangoAccount.getMaxWithdrawWithBorrowForTokenUi(group, bank.mint),
|
||||||
bank.mint,
|
bank.mintDecimals,
|
||||||
)
|
)
|
||||||
const maxWithdraw = allowBorrow
|
const maxWithdraw = allowBorrow
|
||||||
? Decimal.min(vaultBalance, maxBorrow)
|
? Decimal.min(vaultBalance, maxBorrow)
|
||||||
|
|
Loading…
Reference in New Issue