diff --git a/ts/client/src/client.ts b/ts/client/src/client.ts index 5357e3fb7..6b5c9d68b 100644 --- a/ts/client/src/client.ts +++ b/ts/client/src/client.ts @@ -4,11 +4,7 @@ import { initializeAccount, WRAPPED_SOL_MINT, } from '@project-serum/serum/lib/token-instructions'; -import { - ASSOCIATED_TOKEN_PROGRAM_ID, - createAssociatedTokenAccountInstruction, - TOKEN_PROGRAM_ID, -} from '@solana/spl-token'; +import { TOKEN_PROGRAM_ID } from '@solana/spl-token'; import { AccountMeta, Cluster, @@ -19,7 +15,6 @@ import { SystemProgram, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY, - Transaction, TransactionInstruction, TransactionSignature, } from '@solana/web3.js'; @@ -365,22 +360,18 @@ export class MangoClient { const ai = await this.program.provider.connection.getAccountInfo( dustVaultPk, ); + const preInstructions: TransactionInstruction[] = []; if (!ai) { - const tx = new Transaction(); - tx.add( - createAssociatedTokenAccountInstruction( - ASSOCIATED_TOKEN_PROGRAM_ID, - TOKEN_PROGRAM_ID, + preInstructions.push( + await createAssociatedTokenAccountIdempotentInstruction( + adminPk, + adminPk, bank.mint, - dustVaultPk, - adminPk, - adminPk, ), ); - await (this.program.provider as AnchorProvider).sendAndConfirm(tx); } - return await this.program.methods + const ix = await this.program.methods .tokenDeregister() .accounts({ group: group.publicKey, @@ -397,7 +388,19 @@ export class MangoClient { ({ pubkey: pk, isWritable: true, isSigner: false } as AccountMeta), ), ) - .rpc(); + .instruction(); + + return await sendTransaction( + this.program.provider as AnchorProvider, + [ + ...preInstructions, + ix, + ], + group.addressLookupTablesList, + { + postSendTxCallback: this.postSendTxCallback, + }, + ); } public async getBanksForGroup(group: Group): Promise { diff --git a/ts/client/src/scripts/mb-admin-close.ts b/ts/client/src/scripts/mb-admin-close.ts index 6b8acfb21..f57b0d4ac 100644 --- a/ts/client/src/scripts/mb-admin-close.ts +++ b/ts/client/src/scripts/mb-admin-close.ts @@ -46,14 +46,6 @@ async function main() { let sig; - // close all banks - for (const banks of group.banksMapByMint.values()) { - sig = await client.tokenDeregister(group, banks[0].mint); - console.log( - `Removed token ${banks[0].name}, sig https://explorer.solana.com/tx/${sig}`, - ); - } - // deregister all serum markets for (const market of group.serum3MarketsMapByExternal.values()) { sig = await client.serum3deregisterMarket( @@ -73,6 +65,15 @@ async function main() { ); } + // close all banks + for (const banks of group.banksMapByMint.values()) { + console.log(banks[0].toString()); + sig = await client.tokenDeregister(group, banks[0].mint); + console.log( + `Removed token ${banks[0].name}, sig https://explorer.solana.com/tx/${sig}`, + ); + } + // close stub oracles const stubOracles = await client.getStubOracle(group); for (const stubOracle of stubOracles) {