diff --git a/ts/client/src/accounts/bank.ts b/ts/client/src/accounts/bank.ts index db197f2be..de15c6b63 100644 --- a/ts/client/src/accounts/bank.ts +++ b/ts/client/src/accounts/bank.ts @@ -34,6 +34,7 @@ export class Bank { public initLiabWeight: I80F48; public maintLiabWeight: I80F48; public liquidationFee: I80F48; + public dust: I80F48; static from( publicKey: PublicKey, @@ -175,6 +176,7 @@ export class Bank { this.maintLiabWeight = I80F48.from(maintLiabWeight); this.initLiabWeight = I80F48.from(initLiabWeight); this.liquidationFee = I80F48.from(liquidationFee); + this.dust = I80F48.from(dust); this.price = undefined; } diff --git a/ts/client/src/debug-scripts/mb-debug-banks.ts b/ts/client/src/debug-scripts/mb-debug-banks.ts index db58f2c7a..ddaa6b7f5 100644 --- a/ts/client/src/debug-scripts/mb-debug-banks.ts +++ b/ts/client/src/debug-scripts/mb-debug-banks.ts @@ -73,6 +73,7 @@ async function main() { res = res + `\n ${'collectedFeesNative'.padEnd(40)} ${bank.collectedFeesNative}` + + `\n ${'dust'.padEnd(40)} ${bank.dust}` + `\n ${'deposits'.padEnd(40)} ${bank.indexedDeposits.mul( bank.depositIndex, )}` + diff --git a/ts/client/src/scripts/mb-example1-admin.ts b/ts/client/src/scripts/mb-example1-admin.ts index 2a6b95542..9982f787b 100644 --- a/ts/client/src/scripts/mb-example1-admin.ts +++ b/ts/client/src/scripts/mb-example1-admin.ts @@ -259,14 +259,12 @@ async function registerTokens() { } } -async function createUser() { +async function createUser(userKeypair: string) { const options = AnchorProvider.defaultOptions(); const connection = new Connection(process.env.MB_CLUSTER_URL!, options); const user = Keypair.fromSecretKey( - Buffer.from( - JSON.parse(fs.readFileSync(process.env.MB_PAYER_KEYPAIR!, 'utf-8')), - ), + Buffer.from(JSON.parse(fs.readFileSync(userKeypair, 'utf-8'))), ); const userWallet = new Wallet(user); const userProvider = new AnchorProvider(connection, userWallet, options); @@ -316,7 +314,8 @@ async function main() { console.log(error); } try { - await createUser(); + await createUser(process.env.MB_USER_KEYPAIR!); + // await createUser(process.env.MB_USER2_KEYPAIR!); } catch (error) { console.log(error); } diff --git a/ts/client/src/scripts/mb-example1-close-account.ts b/ts/client/src/scripts/mb-example1-close-account.ts index 98f557d4f..28cd9fae5 100644 --- a/ts/client/src/scripts/mb-example1-close-account.ts +++ b/ts/client/src/scripts/mb-example1-close-account.ts @@ -8,15 +8,13 @@ import { MANGO_V4_ID } from '../constants'; // // (untested?) script which closes a mango account cleanly, first closes all positions, withdraws all tokens and then closes it // -async function main() { +async function closeUserAccount(userKeypairFile: string) { const options = AnchorProvider.defaultOptions(); const connection = new Connection(process.env.MB_CLUSTER_URL!, options); // user const user = Keypair.fromSecretKey( - Buffer.from( - JSON.parse(fs.readFileSync(process.env.USER_KEYPAIR!, 'utf-8')), - ), + Buffer.from(JSON.parse(fs.readFileSync(userKeypairFile, 'utf-8'))), ); const userWallet = new Wallet(user); const userProvider = new AnchorProvider(connection, userWallet, options); @@ -115,4 +113,9 @@ async function main() { process.exit(); } +async function main() { + // await closeUserAccount(process.env.MB_USER_KEYPAIR!); + await closeUserAccount(process.env.MB_USER2_KEYPAIR!); +} + main();