use uiToNative

This commit is contained in:
Tyler Shipe 2021-04-29 16:36:54 -04:00
parent fe5172803a
commit 567e38cbcc
1 changed files with 3 additions and 6 deletions

View File

@ -389,12 +389,9 @@ export async function borrowAndWithdraw(
const tokenBalance = marginAccount.getUiDeposit(mangoGroup, tokenIndex)
const borrowQuantity = withdrawQuantity - tokenBalance
// uiToNative() uses Math.round causing
// errors so we use Math.floor here instead
const nativeBorrowQuantity = new BN(
Math.floor(
borrowQuantity * Math.pow(10, mangoGroup.mintDecimals[tokenIndex])
)
const nativeBorrowQuantity = uiToNative(
borrowQuantity,
mangoGroup.mintDecimals[tokenIndex]
)
const borrowInstruction = makeBorrowInstruction(