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 tokenBalance = marginAccount.getUiDeposit(mangoGroup, tokenIndex)
const borrowQuantity = withdrawQuantity - tokenBalance const borrowQuantity = withdrawQuantity - tokenBalance
// uiToNative() uses Math.round causing const nativeBorrowQuantity = uiToNative(
// errors so we use Math.floor here instead borrowQuantity,
const nativeBorrowQuantity = new BN( mangoGroup.mintDecimals[tokenIndex]
Math.floor(
borrowQuantity * Math.pow(10, mangoGroup.mintDecimals[tokenIndex])
)
) )
const borrowInstruction = makeBorrowInstruction( const borrowInstruction = makeBorrowInstruction(