update scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
c9a5fb5fc1
commit
24524d7cd5
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
)}` +
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue