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 initLiabWeight: I80F48;
|
||||||
public maintLiabWeight: I80F48;
|
public maintLiabWeight: I80F48;
|
||||||
public liquidationFee: I80F48;
|
public liquidationFee: I80F48;
|
||||||
|
public dust: I80F48;
|
||||||
|
|
||||||
static from(
|
static from(
|
||||||
publicKey: PublicKey,
|
publicKey: PublicKey,
|
||||||
|
@ -175,6 +176,7 @@ export class Bank {
|
||||||
this.maintLiabWeight = I80F48.from(maintLiabWeight);
|
this.maintLiabWeight = I80F48.from(maintLiabWeight);
|
||||||
this.initLiabWeight = I80F48.from(initLiabWeight);
|
this.initLiabWeight = I80F48.from(initLiabWeight);
|
||||||
this.liquidationFee = I80F48.from(liquidationFee);
|
this.liquidationFee = I80F48.from(liquidationFee);
|
||||||
|
this.dust = I80F48.from(dust);
|
||||||
this.price = undefined;
|
this.price = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ async function main() {
|
||||||
res =
|
res =
|
||||||
res +
|
res +
|
||||||
`\n ${'collectedFeesNative'.padEnd(40)} ${bank.collectedFeesNative}` +
|
`\n ${'collectedFeesNative'.padEnd(40)} ${bank.collectedFeesNative}` +
|
||||||
|
`\n ${'dust'.padEnd(40)} ${bank.dust}` +
|
||||||
`\n ${'deposits'.padEnd(40)} ${bank.indexedDeposits.mul(
|
`\n ${'deposits'.padEnd(40)} ${bank.indexedDeposits.mul(
|
||||||
bank.depositIndex,
|
bank.depositIndex,
|
||||||
)}` +
|
)}` +
|
||||||
|
|
|
@ -259,14 +259,12 @@ async function registerTokens() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createUser() {
|
async function createUser(userKeypair: string) {
|
||||||
const options = AnchorProvider.defaultOptions();
|
const options = AnchorProvider.defaultOptions();
|
||||||
const connection = new Connection(process.env.MB_CLUSTER_URL!, options);
|
const connection = new Connection(process.env.MB_CLUSTER_URL!, options);
|
||||||
|
|
||||||
const user = Keypair.fromSecretKey(
|
const user = Keypair.fromSecretKey(
|
||||||
Buffer.from(
|
Buffer.from(JSON.parse(fs.readFileSync(userKeypair, 'utf-8'))),
|
||||||
JSON.parse(fs.readFileSync(process.env.MB_PAYER_KEYPAIR!, 'utf-8')),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
const userWallet = new Wallet(user);
|
const userWallet = new Wallet(user);
|
||||||
const userProvider = new AnchorProvider(connection, userWallet, options);
|
const userProvider = new AnchorProvider(connection, userWallet, options);
|
||||||
|
@ -316,7 +314,8 @@ async function main() {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await createUser();
|
await createUser(process.env.MB_USER_KEYPAIR!);
|
||||||
|
// await createUser(process.env.MB_USER2_KEYPAIR!);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(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
|
// (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 options = AnchorProvider.defaultOptions();
|
||||||
const connection = new Connection(process.env.MB_CLUSTER_URL!, options);
|
const connection = new Connection(process.env.MB_CLUSTER_URL!, options);
|
||||||
|
|
||||||
// user
|
// user
|
||||||
const user = Keypair.fromSecretKey(
|
const user = Keypair.fromSecretKey(
|
||||||
Buffer.from(
|
Buffer.from(JSON.parse(fs.readFileSync(userKeypairFile, 'utf-8'))),
|
||||||
JSON.parse(fs.readFileSync(process.env.USER_KEYPAIR!, 'utf-8')),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
const userWallet = new Wallet(user);
|
const userWallet = new Wallet(user);
|
||||||
const userProvider = new AnchorProvider(connection, userWallet, options);
|
const userProvider = new AnchorProvider(connection, userWallet, options);
|
||||||
|
@ -115,4 +113,9 @@ async function main() {
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
// await closeUserAccount(process.env.MB_USER_KEYPAIR!);
|
||||||
|
await closeUserAccount(process.env.MB_USER2_KEYPAIR!);
|
||||||
|
}
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
Loading…
Reference in New Issue