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,15 +837,18 @@ 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;
if (!nativeAmount.isZero()) {
const withdrawIx = await this.tokenWithdrawNativeIx( const withdrawIx = await this.tokenWithdrawNativeIx(
group, group,
mangoAccount, mangoAccount,
bank.mint, bank.mint,
new BN(token.balance(bank).toNumber()), nativeAmount,
false, false,
); );
instructions.push(...withdrawIx); instructions.push(...withdrawIx);
} }
}
for (const serum3Account of mangoAccount.serum3Active()) { for (const serum3Account of mangoAccount.serum3Active()) {
const serum3Market = group.serum3MarketsMapByMarketIndex.get( const serum3Market = group.serum3MarketsMapByMarketIndex.get(
@ -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)!);