From 6b31b6af481dbdbd2a3235690eb26142f89fcac1 Mon Sep 17 00:00:00 2001 From: microwavedcola1 Date: Thu, 14 Jul 2022 10:12:47 +0200 Subject: [PATCH] update Signed-off-by: microwavedcola1 --- HOW-TO-RELEASE.md | 13 ++++++- .../src/scripts/mb-example1-close-account.ts | 37 +++++++++---------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/HOW-TO-RELEASE.md b/HOW-TO-RELEASE.md index 440b7e0c0..26b217bf1 100644 --- a/HOW-TO-RELEASE.md +++ b/HOW-TO-RELEASE.md @@ -13,4 +13,15 @@ If there are no breaking changes, simply running `release-to-mainnet.sh` should - merge dev to main, and then `release-to-mainnet.sh` to deploy latest code to mainnet - setup group and banks, etc. using `ts/client/src/scripts/mb-example1-admin.ts` - update ids json `ts/client/src/scripts/mb-example1-ids-json.ts` -- create mango account and deposit some tokens `ts/client/src/scripts/mb-example1-close-account.ts` +- create mango account and deposit some tokens `ts/client/src/scripts/mb-example1-ids-json.ts` + +tldr; + +``` +yarn ts-node ts/client/src/scripts/mb-example1-close-account.ts +yarn ts-node ts/client/src/scripts/mb-example1-admin-close.ts +./release-to-mainnet.sh +yarn ts-node ts/client/src/scripts/mb-example1-admin.ts +yarn ts-node ts/client/src/scripts/mb-example1-ids-json.ts +yarn ts-node ts/client/src/scripts/mb-example1-ids-json.ts +``` diff --git a/ts/client/src/scripts/mb-example1-close-account.ts b/ts/client/src/scripts/mb-example1-close-account.ts index ec096685e..a4874960c 100644 --- a/ts/client/src/scripts/mb-example1-close-account.ts +++ b/ts/client/src/scripts/mb-example1-close-account.ts @@ -37,19 +37,18 @@ async function main() { ); console.log(`Admin ${admin.publicKey.toBase58()}`); + // fetch group + const group = await client.getGroupForAdmin(admin.publicKey); + console.log(`Found group ${group.publicKey.toBase58()}`); + + // account + const mangoAccount = ( + await client.getMangoAccountForOwner(group, user.publicKey) + )[0]; + console.log(`...found mangoAccount ${mangoAccount.publicKey}`); + console.log(mangoAccount.toString(group)); + try { - // fetch group - const group = await client.getGroupForAdmin(admin.publicKey); - console.log(`Found group ${group.publicKey.toBase58()}`); - - // account - console.log(`Creating mangoaccount...`); - const mangoAccount = ( - await client.getMangoAccountForOwner(group, user.publicKey) - )[0]; - console.log(`...created/found mangoAccount ${mangoAccount.publicKey}`); - console.log(mangoAccount.toString(group)); - // cancel serum3 accounts, closing might require cancelling orders and settling for (const serum3Account of mangoAccount.serum3Active()) { let orders = await client.getSerum3Orders( @@ -104,17 +103,17 @@ async function main() { false, ); } - - await mangoAccount.reload(client, group); - console.log(`...mangoAccount ${mangoAccount.publicKey}`); - console.log(mangoAccount.toString()); - - console.log(`Close mango account...`); - const res = await client.closeMangoAccount(group, mangoAccount); } catch (error) { console.log(error); } + await mangoAccount.reload(client, group); + console.log(`...mangoAccount ${mangoAccount.publicKey}`); + console.log(mangoAccount.toString()); + + console.log(`Close mango account...`); + const res = await client.closeMangoAccount(group, mangoAccount); + process.exit(); }