This commit is contained in:
Adrian Brzeziński 2023-01-13 18:54:25 +01:00
parent c459c09451
commit 448cdf7c09
1 changed files with 9 additions and 11 deletions

View File

@ -55,6 +55,7 @@ import {
createAssociatedTokenAccountIdempotentInstruction, createAssociatedTokenAccountIdempotentInstruction,
getAssociatedTokenAddress, getAssociatedTokenAddress,
toNative, toNative,
U64_MAX_BN,
} from './utils'; } from './utils';
import { sendTransaction } from './utils/rpc'; import { sendTransaction } from './utils/rpc';
@ -837,17 +838,14 @@ export class MangoClient {
const instructions: TransactionInstruction[] = []; const instructions: TransactionInstruction[] = [];
for (const token of mangoAccount.tokensActive()) { for (const token of mangoAccount.tokensActive()) {
const bank = group.getFirstBankByTokenIndex(token.tokenIndex); const bank = group.getFirstBankByTokenIndex(token.tokenIndex);
const nativeAmount = token.balance(bank).data; const withdrawIx = await this.tokenWithdrawNativeIx(
if (!nativeAmount.isZero()) { group,
const withdrawIx = await this.tokenWithdrawNativeIx( mangoAccount,
group, bank.mint,
mangoAccount, U64_MAX_BN,
bank.mint, false,
nativeAmount, );
false, instructions.push(...withdrawIx);
);
instructions.push(...withdrawIx);
}
} }
for (const serum3Account of mangoAccount.serum3Active()) { for (const serum3Account of mangoAccount.serum3Active()) {