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'],
|
['SOL/USDC', '8BnEgHoWFysVcuFFX7QztDmzuH8r5ZFvyP3sYwn1XTh6'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const { MB_CLUSTER_URL, MB_PAYER_KEYPAIR, MB_USER_KEYPAIR, MB_USER4_KEYPAIR } =
|
const {
|
||||||
process.env;
|
MB_CLUSTER_URL,
|
||||||
|
MB_PAYER_KEYPAIR,
|
||||||
|
MB_PAYER3_KEYPAIR: MB_PAYER2_KEYPAIR,
|
||||||
|
} = process.env;
|
||||||
|
|
||||||
const MIN_VAULT_TO_DEPOSITS_RATIO = 0.2;
|
const MIN_VAULT_TO_DEPOSITS_RATIO = 0.2;
|
||||||
const NET_BORROWS_WINDOW_SIZE_TS = 24 * 60 * 60;
|
const NET_BORROWS_WINDOW_SIZE_TS = 24 * 60 * 60;
|
||||||
|
@ -67,7 +70,7 @@ const defaultInterestRate = {
|
||||||
|
|
||||||
async function buildAdminClient(): Promise<[MangoClient, Keypair]> {
|
async function buildAdminClient(): Promise<[MangoClient, Keypair]> {
|
||||||
const admin = Keypair.fromSecretKey(
|
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();
|
const options = AnchorProvider.defaultOptions();
|
||||||
|
@ -76,17 +79,17 @@ async function buildAdminClient(): Promise<[MangoClient, Keypair]> {
|
||||||
const adminWallet = new Wallet(admin);
|
const adminWallet = new Wallet(admin);
|
||||||
console.log(`Admin ${adminWallet.publicKey.toBase58()}`);
|
console.log(`Admin ${adminWallet.publicKey.toBase58()}`);
|
||||||
const adminProvider = new AnchorProvider(connection, adminWallet, options);
|
const adminProvider = new AnchorProvider(connection, adminWallet, options);
|
||||||
return [
|
|
||||||
await MangoClient.connect(
|
const client = await MangoClient.connect(
|
||||||
adminProvider,
|
adminProvider,
|
||||||
'mainnet-beta',
|
'mainnet-beta',
|
||||||
MANGO_V4_ID['mainnet-beta'],
|
MANGO_V4_ID['mainnet-beta'],
|
||||||
{
|
{
|
||||||
idsSource: 'get-program-accounts',
|
idsSource: 'get-program-accounts',
|
||||||
},
|
},
|
||||||
),
|
);
|
||||||
admin,
|
|
||||||
];
|
return [client, admin];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildUserClient(
|
async function buildUserClient(
|
||||||
|
@ -107,11 +110,11 @@ async function buildUserClient(
|
||||||
MANGO_V4_ID['mainnet-beta'],
|
MANGO_V4_ID['mainnet-beta'],
|
||||||
);
|
);
|
||||||
|
|
||||||
const admin = Keypair.fromSecretKey(
|
const creator = Keypair.fromSecretKey(
|
||||||
Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR!, 'utf-8'))),
|
Buffer.from(JSON.parse(fs.readFileSync(MB_PAYER_KEYPAIR!, 'utf-8'))),
|
||||||
);
|
);
|
||||||
console.log(`Admin ${admin.publicKey.toBase58()}`);
|
console.log(`Creator ${creator.publicKey.toBase58()}`);
|
||||||
const group = await client.getGroupForCreator(admin.publicKey, GROUP_NUM);
|
const group = await client.getGroupForCreator(creator.publicKey, GROUP_NUM);
|
||||||
return [client, group, user];
|
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() {
|
async function createAndPopulateAlt() {
|
||||||
const result = await buildAdminClient();
|
const result = await buildAdminClient();
|
||||||
const client = result[0];
|
const client = result[0];
|
||||||
const admin = result[1];
|
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;
|
const connection = client.program.provider.connection;
|
||||||
|
|
||||||
|
@ -594,12 +557,58 @@ async function createAndPopulateAlt() {
|
||||||
await extendTable(bankAddresses);
|
await extendTable(bankAddresses);
|
||||||
await extendTable(serum3MarketAddresses);
|
await extendTable(serum3MarketAddresses);
|
||||||
await extendTable(serum3ExternalMarketAddresses);
|
await extendTable(serum3ExternalMarketAddresses);
|
||||||
await extendTable(perpMarketAddresses);
|
// TODO: dont extend for perps atm
|
||||||
|
// await extendTable(perpMarketAddresses);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(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) {
|
async function expandMangoAccount(userKeypair: string) {
|
||||||
const result = await buildUserClient(userKeypair);
|
const result = await buildUserClient(userKeypair);
|
||||||
const client = result[0];
|
const client = result[0];
|
||||||
|
|
Loading…
Reference in New Issue