Skip to content

Commit

Permalink
lock mints
Browse files Browse the repository at this point in the history
  • Loading branch information
ebatsell committed Nov 13, 2024
1 parent 853ec39 commit aed3a9c
Show file tree
Hide file tree
Showing 15 changed files with 195 additions and 76 deletions.
6 changes: 5 additions & 1 deletion clients/js/jito_tip_router/errors/jitoTipRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ export const JITO_TIP_ROUTER_ERROR__CONFIG_MINTS_NOT_UPDATED = 0x2209; // 8713
export const JITO_TIP_ROUTER_ERROR__CONFIG_MINT_LIST_FULL = 0x220a; // 8714
/** TrackedMintListFull: Tracked mints are at capacity */
export const JITO_TIP_ROUTER_ERROR__TRACKED_MINT_LIST_FULL = 0x220b; // 8715
/** TrackedMintsLocked: Tracked mints are locked for the epoch */
export const JITO_TIP_ROUTER_ERROR__TRACKED_MINTS_LOCKED = 0x220c; // 8716
/** VaultIndexAlreadyInUse: Vault index already in use by a different mint */
export const JITO_TIP_ROUTER_ERROR__VAULT_INDEX_ALREADY_IN_USE = 0x220c; // 8716
export const JITO_TIP_ROUTER_ERROR__VAULT_INDEX_ALREADY_IN_USE = 0x220d; // 8717
/** FeeCapExceeded: Fee cap exceeded */
export const JITO_TIP_ROUTER_ERROR__FEE_CAP_EXCEEDED = 0x2300; // 8960
/** IncorrectNcnAdmin: Incorrect NCN Admin */
Expand Down Expand Up @@ -78,6 +80,7 @@ export type JitoTipRouterError =
| typeof JITO_TIP_ROUTER_ERROR__NO_MINTS_IN_TABLE
| typeof JITO_TIP_ROUTER_ERROR__TOO_MANY_MINTS_FOR_TABLE
| typeof JITO_TIP_ROUTER_ERROR__TRACKED_MINT_LIST_FULL
| typeof JITO_TIP_ROUTER_ERROR__TRACKED_MINTS_LOCKED
| typeof JITO_TIP_ROUTER_ERROR__VAULT_INDEX_ALREADY_IN_USE
| typeof JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_LENGTH
| typeof JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_MINT_HASH
Expand All @@ -104,6 +107,7 @@ if (process.env.NODE_ENV !== 'production') {
[JITO_TIP_ROUTER_ERROR__NO_MINTS_IN_TABLE]: `There are no mints in the table`,
[JITO_TIP_ROUTER_ERROR__TOO_MANY_MINTS_FOR_TABLE]: `Too many mints for table`,
[JITO_TIP_ROUTER_ERROR__TRACKED_MINT_LIST_FULL]: `Tracked mints are at capacity`,
[JITO_TIP_ROUTER_ERROR__TRACKED_MINTS_LOCKED]: `Tracked mints are locked for the epoch`,
[JITO_TIP_ROUTER_ERROR__VAULT_INDEX_ALREADY_IN_USE]: `Vault index already in use by a different mint`,
[JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_LENGTH]: `Weight mints do not match - length`,
[JITO_TIP_ROUTER_ERROR__WEIGHT_MINTS_DO_NOT_MATCH_MINT_HASH]: `Weight mints do not match - mint hash`,
Expand Down
28 changes: 14 additions & 14 deletions clients/js/jito_tip_router/instructions/initializeWeightTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function getInitializeWeightTableDiscriminatorBytes() {
export type InitializeWeightTableInstruction<
TProgram extends string = typeof JITO_TIP_ROUTER_PROGRAM_ADDRESS,
TAccountRestakingConfig extends string | IAccountMeta<string> = string,
TAccountNcnConfig extends string | IAccountMeta<string> = string,
TAccountTrackedMints extends string | IAccountMeta<string> = string,
TAccountNcn extends string | IAccountMeta<string> = string,
TAccountWeightTable extends string | IAccountMeta<string> = string,
TAccountPayer extends string | IAccountMeta<string> = string,
Expand All @@ -61,9 +61,9 @@ export type InitializeWeightTableInstruction<
TAccountRestakingConfig extends string
? ReadonlyAccount<TAccountRestakingConfig>
: TAccountRestakingConfig,
TAccountNcnConfig extends string
? ReadonlyAccount<TAccountNcnConfig>
: TAccountNcnConfig,
TAccountTrackedMints extends string
? ReadonlyAccount<TAccountTrackedMints>
: TAccountTrackedMints,
TAccountNcn extends string ? ReadonlyAccount<TAccountNcn> : TAccountNcn,
TAccountWeightTable extends string
? WritableAccount<TAccountWeightTable>
Expand Down Expand Up @@ -123,15 +123,15 @@ export function getInitializeWeightTableInstructionDataCodec(): Codec<

export type InitializeWeightTableInput<
TAccountRestakingConfig extends string = string,
TAccountNcnConfig extends string = string,
TAccountTrackedMints extends string = string,
TAccountNcn extends string = string,
TAccountWeightTable extends string = string,
TAccountPayer extends string = string,
TAccountRestakingProgramId extends string = string,
TAccountSystemProgram extends string = string,
> = {
restakingConfig: Address<TAccountRestakingConfig>;
ncnConfig: Address<TAccountNcnConfig>;
trackedMints: Address<TAccountTrackedMints>;
ncn: Address<TAccountNcn>;
weightTable: Address<TAccountWeightTable>;
payer: TransactionSigner<TAccountPayer>;
Expand All @@ -142,7 +142,7 @@ export type InitializeWeightTableInput<

export function getInitializeWeightTableInstruction<
TAccountRestakingConfig extends string,
TAccountNcnConfig extends string,
TAccountTrackedMints extends string,
TAccountNcn extends string,
TAccountWeightTable extends string,
TAccountPayer extends string,
Expand All @@ -152,7 +152,7 @@ export function getInitializeWeightTableInstruction<
>(
input: InitializeWeightTableInput<
TAccountRestakingConfig,
TAccountNcnConfig,
TAccountTrackedMints,
TAccountNcn,
TAccountWeightTable,
TAccountPayer,
Expand All @@ -163,7 +163,7 @@ export function getInitializeWeightTableInstruction<
): InitializeWeightTableInstruction<
TProgramAddress,
TAccountRestakingConfig,
TAccountNcnConfig,
TAccountTrackedMints,
TAccountNcn,
TAccountWeightTable,
TAccountPayer,
Expand All @@ -180,7 +180,7 @@ export function getInitializeWeightTableInstruction<
value: input.restakingConfig ?? null,
isWritable: false,
},
ncnConfig: { value: input.ncnConfig ?? null, isWritable: false },
trackedMints: { value: input.trackedMints ?? null, isWritable: false },
ncn: { value: input.ncn ?? null, isWritable: false },
weightTable: { value: input.weightTable ?? null, isWritable: true },
payer: { value: input.payer ?? null, isWritable: true },
Expand Down Expand Up @@ -208,7 +208,7 @@ export function getInitializeWeightTableInstruction<
const instruction = {
accounts: [
getAccountMeta(accounts.restakingConfig),
getAccountMeta(accounts.ncnConfig),
getAccountMeta(accounts.trackedMints),
getAccountMeta(accounts.ncn),
getAccountMeta(accounts.weightTable),
getAccountMeta(accounts.payer),
Expand All @@ -222,7 +222,7 @@ export function getInitializeWeightTableInstruction<
} as InitializeWeightTableInstruction<
TProgramAddress,
TAccountRestakingConfig,
TAccountNcnConfig,
TAccountTrackedMints,
TAccountNcn,
TAccountWeightTable,
TAccountPayer,
Expand All @@ -240,7 +240,7 @@ export type ParsedInitializeWeightTableInstruction<
programAddress: Address<TProgram>;
accounts: {
restakingConfig: TAccountMetas[0];
ncnConfig: TAccountMetas[1];
trackedMints: TAccountMetas[1];
ncn: TAccountMetas[2];
weightTable: TAccountMetas[3];
payer: TAccountMetas[4];
Expand Down Expand Up @@ -272,7 +272,7 @@ export function parseInitializeWeightTableInstruction<
programAddress: instruction.programAddress,
accounts: {
restakingConfig: getNextAccount(),
ncnConfig: getNextAccount(),
trackedMints: getNextAccount(),
ncn: getNextAccount(),
weightTable: getNextAccount(),
payer: getNextAccount(),
Expand Down
26 changes: 20 additions & 6 deletions clients/js/jito_tip_router/instructions/registerMint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type RegisterMintInstruction<
TAccountRestakingConfig extends string | IAccountMeta<string> = string,
TAccountTrackedMints extends string | IAccountMeta<string> = string,
TAccountNcn extends string | IAccountMeta<string> = string,
TAccountWeightTable extends string | IAccountMeta<string> = string,
TAccountVault extends string | IAccountMeta<string> = string,
TAccountVaultNcnTicket extends string | IAccountMeta<string> = string,
TAccountNcnVaultTicket extends string | IAccountMeta<string> = string,
Expand All @@ -55,6 +56,9 @@ export type RegisterMintInstruction<
? WritableAccount<TAccountTrackedMints>
: TAccountTrackedMints,
TAccountNcn extends string ? ReadonlyAccount<TAccountNcn> : TAccountNcn,
TAccountWeightTable extends string
? ReadonlyAccount<TAccountWeightTable>
: TAccountWeightTable,
TAccountVault extends string
? ReadonlyAccount<TAccountVault>
: TAccountVault,
Expand Down Expand Up @@ -103,6 +107,7 @@ export type RegisterMintInput<
TAccountRestakingConfig extends string = string,
TAccountTrackedMints extends string = string,
TAccountNcn extends string = string,
TAccountWeightTable extends string = string,
TAccountVault extends string = string,
TAccountVaultNcnTicket extends string = string,
TAccountNcnVaultTicket extends string = string,
Expand All @@ -112,6 +117,7 @@ export type RegisterMintInput<
restakingConfig: Address<TAccountRestakingConfig>;
trackedMints: Address<TAccountTrackedMints>;
ncn: Address<TAccountNcn>;
weightTable: Address<TAccountWeightTable>;
vault: Address<TAccountVault>;
vaultNcnTicket: Address<TAccountVaultNcnTicket>;
ncnVaultTicket: Address<TAccountNcnVaultTicket>;
Expand All @@ -123,6 +129,7 @@ export function getRegisterMintInstruction<
TAccountRestakingConfig extends string,
TAccountTrackedMints extends string,
TAccountNcn extends string,
TAccountWeightTable extends string,
TAccountVault extends string,
TAccountVaultNcnTicket extends string,
TAccountNcnVaultTicket extends string,
Expand All @@ -134,6 +141,7 @@ export function getRegisterMintInstruction<
TAccountRestakingConfig,
TAccountTrackedMints,
TAccountNcn,
TAccountWeightTable,
TAccountVault,
TAccountVaultNcnTicket,
TAccountNcnVaultTicket,
Expand All @@ -146,6 +154,7 @@ export function getRegisterMintInstruction<
TAccountRestakingConfig,
TAccountTrackedMints,
TAccountNcn,
TAccountWeightTable,
TAccountVault,
TAccountVaultNcnTicket,
TAccountNcnVaultTicket,
Expand All @@ -164,6 +173,7 @@ export function getRegisterMintInstruction<
},
trackedMints: { value: input.trackedMints ?? null, isWritable: true },
ncn: { value: input.ncn ?? null, isWritable: false },
weightTable: { value: input.weightTable ?? null, isWritable: false },
vault: { value: input.vault ?? null, isWritable: false },
vaultNcnTicket: { value: input.vaultNcnTicket ?? null, isWritable: false },
ncnVaultTicket: { value: input.ncnVaultTicket ?? null, isWritable: false },
Expand All @@ -184,6 +194,7 @@ export function getRegisterMintInstruction<
getAccountMeta(accounts.restakingConfig),
getAccountMeta(accounts.trackedMints),
getAccountMeta(accounts.ncn),
getAccountMeta(accounts.weightTable),
getAccountMeta(accounts.vault),
getAccountMeta(accounts.vaultNcnTicket),
getAccountMeta(accounts.ncnVaultTicket),
Expand All @@ -197,6 +208,7 @@ export function getRegisterMintInstruction<
TAccountRestakingConfig,
TAccountTrackedMints,
TAccountNcn,
TAccountWeightTable,
TAccountVault,
TAccountVaultNcnTicket,
TAccountNcnVaultTicket,
Expand All @@ -216,11 +228,12 @@ export type ParsedRegisterMintInstruction<
restakingConfig: TAccountMetas[0];
trackedMints: TAccountMetas[1];
ncn: TAccountMetas[2];
vault: TAccountMetas[3];
vaultNcnTicket: TAccountMetas[4];
ncnVaultTicket: TAccountMetas[5];
restakingProgramId: TAccountMetas[6];
vaultProgramId: TAccountMetas[7];
weightTable: TAccountMetas[3];
vault: TAccountMetas[4];
vaultNcnTicket: TAccountMetas[5];
ncnVaultTicket: TAccountMetas[6];
restakingProgramId: TAccountMetas[7];
vaultProgramId: TAccountMetas[8];
};
data: RegisterMintInstructionData;
};
Expand All @@ -233,7 +246,7 @@ export function parseRegisterMintInstruction<
IInstructionWithAccounts<TAccountMetas> &
IInstructionWithData<Uint8Array>
): ParsedRegisterMintInstruction<TProgram, TAccountMetas> {
if (instruction.accounts.length < 8) {
if (instruction.accounts.length < 9) {
// TODO: Coded error.
throw new Error('Not enough accounts');
}
Expand All @@ -249,6 +262,7 @@ export function parseRegisterMintInstruction<
restakingConfig: getNextAccount(),
trackedMints: getNextAccount(),
ncn: getNextAccount(),
weightTable: getNextAccount(),
vault: getNextAccount(),
vaultNcnTicket: getNextAccount(),
ncnVaultTicket: getNextAccount(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ pub enum JitoTipRouterError {
/// 8715 - Tracked mints are at capacity
#[error("Tracked mints are at capacity")]
TrackedMintListFull = 0x220B,
/// 8716 - Vault index already in use by a different mint
/// 8716 - Tracked mints are locked for the epoch
#[error("Tracked mints are locked for the epoch")]
TrackedMintsLocked = 0x220C,
/// 8717 - Vault index already in use by a different mint
#[error("Vault index already in use by a different mint")]
VaultIndexAlreadyInUse = 0x220C,
VaultIndexAlreadyInUse = 0x220D,
/// 8960 - Fee cap exceeded
#[error("Fee cap exceeded")]
FeeCapExceeded = 0x2300,
Expand Down
Loading

0 comments on commit aed3a9c

Please sign in to comment.