update script for alts and new admin change
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
ae615b7473
commit
b174ee13cc
|
@ -44,8 +44,11 @@ const MAINNET_SERUM3_MARKETS = new Map([
|
|||
['SOL/USDC', '8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'],
|
||||
]);
|
||||
|
||||
const { MB_CLUSTER_URL, MB_PAYER_KEYPAIR, MB_USER_KEYPAIR, MB_USER4_KEYPAIR } =
|
||||
process.env;
|
||||
const {
|
||||
MB_CLUSTER_URL,
|
||||
MB_PAYER_KEYPAIR,
|
||||
MB_PAYER3_KEYPAIR: MB_PAYER2_KEYPAIR,
|
||||
} = process.env;
|
||||
|
||||
const MIN_VAULT_TO_DEPOSITS_RATIO = 0.2;
|
||||
const NET_BORROWS_WINDOW_SIZE_TS = 24 * 60 * 60;
|
||||
|
@ -67,7 +70,7 @@ const defaultInterestRate = {
|
|||
|
||||
async function buildAdminClient(): Promise<[MangoClient, Keypair]> {
|
||||
const admin = Keypair.fromSecretKey(
|
||||
Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR!, 'utf-8'))),
|
||||
Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER2_KEYPAIR!, 'utf-8'))),
|
||||
);
|
||||
|
||||
const options = AnchorProvider.defaultOptions();
|
||||
|
@ -76,17 +79,17 @@ async function buildAdminClient(): Promise<[MangoClient, Keypair]> {
|
|||
const adminWallet = new Wallet(admin);
|
||||
console.log(`Admin ${adminWallet.publicKey.toBase58()}`);
|
||||
const adminProvider = new AnchorProvider(connection, adminWallet, options);
|
||||
return [
|
||||
await MangoClient.connect(
|
||||
adminProvider,
|
||||
'mainnet-beta',
|
||||
MANGO_V4_ID['mainnet-beta'],
|
||||
{
|
||||
idsSource: 'get-program-accounts',
|
||||
},
|
||||
),
|
||||
admin,
|
||||
];
|
||||
|
||||
const client = await MangoClient.connect(
|
||||
adminProvider,
|
||||
'mainnet-beta',
|
||||
MANGO_V4_ID['mainnet-beta'],
|
||||
{
|
||||
idsSource: 'get-program-accounts',
|
||||
},
|
||||
);
|
||||
|
||||
return [client, admin];
|
||||
}
|
||||
|
||||
async function buildUserClient(
|
||||
|
@ -107,11 +110,11 @@ async function buildUserClient(
|
|||
MANGO_V4_ID['mainnet-beta'],
|
||||
);
|
||||
|
||||
const admin = Keypair.fromSecretKey(
|
||||
const creator = Keypair.fromSecretKey(
|
||||
Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR!, 'utf-8'))),
|
||||
);
|
||||
console.log(`Admin ${admin.publicKey.toBase58()}`);
|
||||
const group = await client.getGroupForCreator(admin.publicKey, GROUP_NUM);
|
||||
console.log(`Creator ${creator.publicKey.toBase58()}`);
|
||||
const group = await client.getGroupForCreator(creator.publicKey, GROUP_NUM);
|
||||
return [client, group, user];
|
||||
}
|
||||
|
||||
|
@ -436,56 +439,16 @@ async function registerPerpMarkets() {
|
|||
);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// await createGroup();
|
||||
// await changeAdmin();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
try {
|
||||
// await registerTokens();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
try {
|
||||
// await registerSerum3Markets();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
try {
|
||||
// await registerPerpMarkets();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
try {
|
||||
// await createUser(MB_USER_KEYPAIR!);
|
||||
// depositForUser(MB_USER_KEYPAIR!);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
try {
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
try {
|
||||
main();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// UNUSED /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
async function createAndPopulateAlt() {
|
||||
const result = await buildAdminClient();
|
||||
const client = result[0];
|
||||
const admin = result[1];
|
||||
|
||||
const group = await client.getGroupForCreator(admin.publicKey, GROUP_NUM);
|
||||
const creator = Keypair.fromSecretKey(
|
||||
Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR!, 'utf-8'))),
|
||||
);
|
||||
console.log(`Creator ${creator.publicKey.toBase58()}`);
|
||||
const group = await client.getGroupForCreator(creator.publicKey, GROUP_NUM);
|
||||
|
||||
const connection = client.program.provider.connection;
|
||||
|
||||
|
@ -594,12 +557,58 @@ async function createAndPopulateAlt() {
|
|||
await extendTable(bankAddresses);
|
||||
await extendTable(serum3MarketAddresses);
|
||||
await extendTable(serum3ExternalMarketAddresses);
|
||||
await extendTable(perpMarketAddresses);
|
||||
// TODO: dont extend for perps atm
|
||||
// await extendTable(perpMarketAddresses);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
// await createGroup();
|
||||
// await changeAdmin();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
try {
|
||||
// await registerTokens();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
try {
|
||||
// await registerSerum3Markets();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
try {
|
||||
// await registerPerpMarkets();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
try {
|
||||
// await createUser(MB_USER_KEYPAIR!);
|
||||
// depositForUser(MB_USER_KEYPAIR!);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
try {
|
||||
// createAndPopulateAlt();
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
try {
|
||||
main();
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// UNUSED /////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
async function expandMangoAccount(userKeypair: string) {
|
||||
const result = await buildUserClient(userKeypair);
|
||||
const client = result[0];
|
||||
|
|
Loading…
Reference in New Issue