Example scripts: accept GROUP_NUM env var
This commit is contained in:
parent
bbca1d8763
commit
33d4412ff8
|
@ -30,6 +30,8 @@ const DEVNET_ORACLES = new Map([
|
|||
['ORCA', 'A1WttWF7X3Rg6ZRpB2YQUFHCRh1kiXV8sKKLV3S9neJV'],
|
||||
]);
|
||||
|
||||
const GROUP_NUM = Number(process.env.GROUP_NUM || 0);
|
||||
|
||||
async function main() {
|
||||
const options = AnchorProvider.defaultOptions();
|
||||
const connection = new Connection(
|
||||
|
@ -55,11 +57,11 @@ async function main() {
|
|||
console.log(`Creating Group...`);
|
||||
const insuranceMint = new PublicKey(DEVNET_MINTS.get('USDC')!);
|
||||
try {
|
||||
await client.groupCreate(0, true, insuranceMint);
|
||||
await client.groupCreate(GROUP_NUM, true, insuranceMint);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
const group = await client.getGroupForAdmin(admin.publicKey);
|
||||
const group = await client.getGroupForAdmin(admin.publicKey, GROUP_NUM);
|
||||
console.log(`...registered group ${group.publicKey}`);
|
||||
|
||||
// register token 1
|
||||
|
|
|
@ -21,6 +21,8 @@ import { toUiDecimals } from '../utils';
|
|||
// This script deposits some tokens, places some serum orders, cancels them, places some perp orders
|
||||
//
|
||||
|
||||
const GROUP_NUM = Number(process.env.GROUP_NUM || 0);
|
||||
|
||||
async function main() {
|
||||
const options = AnchorProvider.defaultOptions();
|
||||
const connection = new Connection(
|
||||
|
@ -48,7 +50,7 @@ async function main() {
|
|||
JSON.parse(fs.readFileSync(process.env.ADMIN_KEYPAIR!, 'utf-8')),
|
||||
),
|
||||
);
|
||||
const group = await client.getGroupForAdmin(admin.publicKey, 0);
|
||||
const group = await client.getGroupForAdmin(admin.publicKey, GROUP_NUM);
|
||||
console.log(group.toString());
|
||||
|
||||
// create + fetch account
|
||||
|
|
|
@ -4,6 +4,8 @@ import fs from 'fs';
|
|||
import { MangoClient } from '../../client';
|
||||
import { MANGO_V4_ID } from '../../constants';
|
||||
|
||||
const GROUP_NUM = Number(process.env.GROUP_NUM || 0);
|
||||
|
||||
async function main() {
|
||||
const options = AnchorProvider.defaultOptions();
|
||||
const connection = new Connection(
|
||||
|
@ -31,7 +33,7 @@ async function main() {
|
|||
JSON.parse(fs.readFileSync(process.env.ADMIN_KEYPAIR!, 'utf-8')),
|
||||
),
|
||||
);
|
||||
const group = await user1Client.getGroupForAdmin(admin.publicKey, 0);
|
||||
const group = await user1Client.getGroupForAdmin(admin.publicKey, GROUP_NUM);
|
||||
console.log(`Found group ${group.publicKey.toBase58()}`);
|
||||
|
||||
const user1MangoAccount = await user1Client.getOrCreateMangoAccount(
|
||||
|
|
Loading…
Reference in New Issue