From f5cb67fb3b4914c7bf7e5adc18164b039a8dc102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Thu, 12 Jan 2023 22:34:48 +0100 Subject: [PATCH] start of close --- ts/client/src/client.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 4d8d067ca..6752ff1d6 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -829,6 +829,28 @@ export class MangoClient { ); } + //withdraw all assets, close oo, deactivating perp positions, close account + public async totalCloseMangoAccount( + group: Group, + mangoAccount: MangoAccount, + forceClose = false, + ): Promise { + const ix = await this.program.methods + .accountClose(forceClose) + .accounts({ + group: group.publicKey, + account: mangoAccount.publicKey, + owner: (this.program.provider as AnchorProvider).wallet.publicKey, + solDestination: mangoAccount.owner, + }) + .instruction(); + + return await this.sendAndConfirmTransaction( + [ix], + group.addressLookupTablesList, + ); + } + public async tokenDeposit( group: Group, mangoAccount: MangoAccount,