ts: Fix ix gate enum, add code for creating a disable-tx gov ix
This commit is contained in:
parent
8f86b0998e
commit
f98dfafe24
|
@ -13,7 +13,11 @@ import fs from 'fs';
|
||||||
import { TokenIndex } from '../src/accounts/bank';
|
import { TokenIndex } from '../src/accounts/bank';
|
||||||
import { Builder } from '../src/builder';
|
import { Builder } from '../src/builder';
|
||||||
import { MangoClient } from '../src/client';
|
import { MangoClient } from '../src/client';
|
||||||
import { NullTokenEditParams } from '../src/clientIxParamBuilder';
|
import {
|
||||||
|
buildIxGate,
|
||||||
|
NullTokenEditParams,
|
||||||
|
TrueIxGateParams,
|
||||||
|
} from '../src/clientIxParamBuilder';
|
||||||
import { MANGO_V4_ID, OPENBOOK_PROGRAM_ID } from '../src/constants';
|
import { MANGO_V4_ID, OPENBOOK_PROGRAM_ID } from '../src/constants';
|
||||||
import { bpsToDecimal, percentageToDecimal, toNative } from '../src/utils';
|
import { bpsToDecimal, percentageToDecimal, toNative } from '../src/utils';
|
||||||
|
|
||||||
|
@ -294,12 +298,35 @@ async function perpCreate(): Promise<void> {
|
||||||
console.log(serializeInstructionToBase64(ix));
|
console.log(serializeInstructionToBase64(ix));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function ixDisable(): Promise<void> {
|
||||||
|
const result = await buildAdminClient();
|
||||||
|
const client = result[0];
|
||||||
|
const admin = result[1];
|
||||||
|
|
||||||
|
const group = await client.getGroup(
|
||||||
|
new PublicKey('78b8f4cGCwmZ9ysPFMWLaLTkkaYnUjwMJYStWe5RTSSX'),
|
||||||
|
);
|
||||||
|
|
||||||
|
const ixGateParams = TrueIxGateParams;
|
||||||
|
ixGateParams.HealthRegion = false;
|
||||||
|
const ix = await client.program.methods
|
||||||
|
.ixGateSet(buildIxGate(ixGateParams))
|
||||||
|
.accounts({
|
||||||
|
group: group.publicKey,
|
||||||
|
admin: group.securityAdmin,
|
||||||
|
})
|
||||||
|
.instruction();
|
||||||
|
|
||||||
|
console.log(await serializeInstructionToBase64(ix));
|
||||||
|
}
|
||||||
|
|
||||||
async function main(): Promise<void> {
|
async function main(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
// await tokenRegister();
|
// await tokenRegister();
|
||||||
// await tokenEdit();
|
// await tokenEdit();
|
||||||
// await perpCreate();
|
// await perpCreate();
|
||||||
await serum3Register();
|
// await serum3Register();
|
||||||
|
await ixDisable();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,6 +171,7 @@ export interface IxGateParams {
|
||||||
TokenRegisterTrustless: boolean;
|
TokenRegisterTrustless: boolean;
|
||||||
TokenUpdateIndexAndRate: boolean;
|
TokenUpdateIndexAndRate: boolean;
|
||||||
TokenWithdraw: boolean;
|
TokenWithdraw: boolean;
|
||||||
|
AccountBuybackFeesWithMngo: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default with all ixs enabled, use with buildIxGate
|
// Default with all ixs enabled, use with buildIxGate
|
||||||
|
@ -226,6 +227,7 @@ export const TrueIxGateParams: IxGateParams = {
|
||||||
TokenRegisterTrustless: true,
|
TokenRegisterTrustless: true,
|
||||||
TokenUpdateIndexAndRate: true,
|
TokenUpdateIndexAndRate: true,
|
||||||
TokenWithdraw: true,
|
TokenWithdraw: true,
|
||||||
|
AccountBuybackFeesWithMngo: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// build ix gate e.g. buildIxGate(Builder(TrueIxGateParams).TokenDeposit(false).build()).toNumber(),
|
// build ix gate e.g. buildIxGate(Builder(TrueIxGateParams).TokenDeposit(false).build()).toNumber(),
|
||||||
|
@ -291,7 +293,7 @@ export function buildIxGate(p: IxGateParams): BN {
|
||||||
toggleIx(ixGate, p, 'TokenRegisterTrustless', 45);
|
toggleIx(ixGate, p, 'TokenRegisterTrustless', 45);
|
||||||
toggleIx(ixGate, p, 'TokenUpdateIndexAndRate', 46);
|
toggleIx(ixGate, p, 'TokenUpdateIndexAndRate', 46);
|
||||||
toggleIx(ixGate, p, 'TokenWithdraw', 47);
|
toggleIx(ixGate, p, 'TokenWithdraw', 47);
|
||||||
toggleIx(ixGate, p, 'AccountSettleFeesWithMngo', 48);
|
toggleIx(ixGate, p, 'AccountBuybackFeesWithMngo', 48);
|
||||||
|
|
||||||
return ixGate;
|
return ixGate;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue