use uiToNative
This commit is contained in:
parent
fe5172803a
commit
567e38cbcc
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue