This commit is contained in:
Adrian Brzeziński 2023-01-13 18:07:13 +01:00
parent 3077f57c2f
commit c459c09451
1 changed files with 12 additions and 10 deletions

View File

@ -837,14 +837,17 @@ 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 withdrawIx = await this.tokenWithdrawNativeIx( const nativeAmount = token.balance(bank).data;
group, if (!nativeAmount.isZero()) {
mangoAccount, const withdrawIx = await this.tokenWithdrawNativeIx(
bank.mint, group,
new BN(token.balance(bank).toNumber()), mangoAccount,
false, bank.mint,
); nativeAmount,
instructions.push(...withdrawIx); false,
);
instructions.push(...withdrawIx);
}
} }
for (const serum3Account of mangoAccount.serum3Active()) { for (const serum3Account of mangoAccount.serum3Active()) {
@ -1049,7 +1052,7 @@ export class MangoClient {
[bank], [bank],
[], [],
); );
console.log(healthRemainingAccounts, '@@@');
const ix = await this.program.methods const ix = await this.program.methods
.tokenWithdraw(new BN(nativeAmount), allowBorrow) .tokenWithdraw(new BN(nativeAmount), allowBorrow)
.accounts({ .accounts({
@ -2707,7 +2710,6 @@ export class MangoClient {
} }
} }
} }
console.log(tokenPositionIndices);
const mintInfos = tokenPositionIndices const mintInfos = tokenPositionIndices
.filter((tokenIndex) => tokenIndex !== TokenPosition.TokenIndexUnset) .filter((tokenIndex) => tokenIndex !== TokenPosition.TokenIndexUnset)
.map((tokenIndex) => group.mintInfosMapByTokenIndex.get(tokenIndex)!); .map((tokenIndex) => group.mintInfosMapByTokenIndex.get(tokenIndex)!);