From c459c09451e99c1d285ede1fe7f8fe61d6f8f6b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Fri, 13 Jan 2023 18:07:13 +0100 Subject: [PATCH] fixes --- ts/client/src/client.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 097765062..3a3a43b5a 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -837,14 +837,17 @@ export class MangoClient { const instructions: TransactionInstruction[] = []; for (const token of mangoAccount.tokensActive()) { const bank = group.getFirstBankByTokenIndex(token.tokenIndex); - const withdrawIx = await this.tokenWithdrawNativeIx( - group, - mangoAccount, - bank.mint, - new BN(token.balance(bank).toNumber()), - false, - ); - instructions.push(...withdrawIx); + const nativeAmount = token.balance(bank).data; + if (!nativeAmount.isZero()) { + const withdrawIx = await this.tokenWithdrawNativeIx( + group, + mangoAccount, + bank.mint, + nativeAmount, + false, + ); + instructions.push(...withdrawIx); + } } for (const serum3Account of mangoAccount.serum3Active()) { @@ -1049,7 +1052,7 @@ export class MangoClient { [bank], [], ); - console.log(healthRemainingAccounts, '@@@'); + const ix = await this.program.methods .tokenWithdraw(new BN(nativeAmount), allowBorrow) .accounts({ @@ -2707,7 +2710,6 @@ export class MangoClient { } } } - console.log(tokenPositionIndices); const mintInfos = tokenPositionIndices .filter((tokenIndex) => tokenIndex !== TokenPosition.TokenIndexUnset) .map((tokenIndex) => group.mintInfosMapByTokenIndex.get(tokenIndex)!);