Skip to content

Commit

Permalink
looking better
Browse files Browse the repository at this point in the history
  • Loading branch information
coachchucksol committed Nov 25, 2024
1 parent 4051ac9 commit 741362e
Show file tree
Hide file tree
Showing 43 changed files with 933 additions and 323 deletions.
14 changes: 8 additions & 6 deletions clients/js/jito_tip_router/accounts/epochSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
getArrayEncoder,
getStructDecoder,
getStructEncoder,
getU128Decoder,
getU128Encoder,
getU64Decoder,
getU64Encoder,
getU8Decoder,
Expand All @@ -39,8 +37,12 @@ import {
import {
getFeesDecoder,
getFeesEncoder,
getStakeWeightDecoder,
getStakeWeightEncoder,
type Fees,
type FeesArgs,
type StakeWeight,
type StakeWeightArgs,
} from '../types';

export type EpochSnapshot = {
Expand All @@ -55,7 +57,7 @@ export type EpochSnapshot = {
vaultCount: bigint;
operatorsRegistered: bigint;
validOperatorVaultDelegations: bigint;
stakeWeight: bigint;
stakeWeight: StakeWeight;
reserved: Array<number>;
};

Expand All @@ -71,7 +73,7 @@ export type EpochSnapshotArgs = {
vaultCount: number | bigint;
operatorsRegistered: number | bigint;
validOperatorVaultDelegations: number | bigint;
stakeWeight: number | bigint;
stakeWeight: StakeWeightArgs;
reserved: Array<number>;
};

Expand All @@ -88,7 +90,7 @@ export function getEpochSnapshotEncoder(): Encoder<EpochSnapshotArgs> {
['vaultCount', getU64Encoder()],
['operatorsRegistered', getU64Encoder()],
['validOperatorVaultDelegations', getU64Encoder()],
['stakeWeight', getU128Encoder()],
['stakeWeight', getStakeWeightEncoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })],
]);
}
Expand All @@ -106,7 +108,7 @@ export function getEpochSnapshotDecoder(): Decoder<EpochSnapshot> {
['vaultCount', getU64Decoder()],
['operatorsRegistered', getU64Decoder()],
['validOperatorVaultDelegations', getU64Decoder()],
['stakeWeight', getU128Decoder()],
['stakeWeight', getStakeWeightDecoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })],
]);
}
Expand Down
16 changes: 8 additions & 8 deletions clients/js/jito_tip_router/accounts/ncnConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ import {
type MaybeEncodedAccount,
} from '@solana/web3.js';
import {
getFeesDecoder,
getFeesEncoder,
type Fees,
type FeesArgs,
getFeeConfigDecoder,
getFeeConfigEncoder,
type FeeConfig,
type FeeConfigArgs,
} from '../types';

export type NcnConfig = {
discriminator: bigint;
ncn: Address;
tieBreakerAdmin: Address;
feeAdmin: Address;
fees: Fees;
feeConfig: FeeConfig;
bump: number;
reserved: Array<number>;
};
Expand All @@ -56,7 +56,7 @@ export type NcnConfigArgs = {
ncn: Address;
tieBreakerAdmin: Address;
feeAdmin: Address;
fees: FeesArgs;
feeConfig: FeeConfigArgs;
bump: number;
reserved: Array<number>;
};
Expand All @@ -67,7 +67,7 @@ export function getNcnConfigEncoder(): Encoder<NcnConfigArgs> {
['ncn', getAddressEncoder()],
['tieBreakerAdmin', getAddressEncoder()],
['feeAdmin', getAddressEncoder()],
['fees', getFeesEncoder()],
['feeConfig', getFeeConfigEncoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 127 })],
]);
Expand All @@ -79,7 +79,7 @@ export function getNcnConfigDecoder(): Decoder<NcnConfig> {
['ncn', getAddressDecoder()],
['tieBreakerAdmin', getAddressDecoder()],
['feeAdmin', getAddressDecoder()],
['fees', getFeesDecoder()],
['feeConfig', getFeeConfigDecoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 127 })],
]);
Expand Down
14 changes: 8 additions & 6 deletions clients/js/jito_tip_router/accounts/operatorSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import {
getBoolEncoder,
getStructDecoder,
getStructEncoder,
getU128Decoder,
getU128Encoder,
getU16Decoder,
getU16Encoder,
getU64Decoder,
Expand All @@ -41,8 +39,12 @@ import {
type MaybeEncodedAccount,
} from '@solana/web3.js';
import {
getStakeWeightDecoder,
getStakeWeightEncoder,
getVaultOperatorStakeWeightDecoder,
getVaultOperatorStakeWeightEncoder,
type StakeWeight,
type StakeWeightArgs,
type VaultOperatorStakeWeight,
type VaultOperatorStakeWeightArgs,
} from '../types';
Expand All @@ -62,7 +64,7 @@ export type OperatorSnapshot = {
vaultOperatorDelegationCount: bigint;
vaultOperatorDelegationsRegistered: bigint;
validOperatorVaultDelegations: bigint;
stakeWeight: bigint;
stakeWeight: StakeWeight;
reserved: Array<number>;
vaultOperatorStakeWeight: Array<VaultOperatorStakeWeight>;
};
Expand All @@ -82,7 +84,7 @@ export type OperatorSnapshotArgs = {
vaultOperatorDelegationCount: number | bigint;
vaultOperatorDelegationsRegistered: number | bigint;
validOperatorVaultDelegations: number | bigint;
stakeWeight: number | bigint;
stakeWeight: StakeWeightArgs;
reserved: Array<number>;
vaultOperatorStakeWeight: Array<VaultOperatorStakeWeightArgs>;
};
Expand All @@ -103,7 +105,7 @@ export function getOperatorSnapshotEncoder(): Encoder<OperatorSnapshotArgs> {
['vaultOperatorDelegationCount', getU64Encoder()],
['vaultOperatorDelegationsRegistered', getU64Encoder()],
['validOperatorVaultDelegations', getU64Encoder()],
['stakeWeight', getU128Encoder()],
['stakeWeight', getStakeWeightEncoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 256 })],
[
'vaultOperatorStakeWeight',
Expand All @@ -128,7 +130,7 @@ export function getOperatorSnapshotDecoder(): Decoder<OperatorSnapshot> {
['vaultOperatorDelegationCount', getU64Decoder()],
['vaultOperatorDelegationsRegistered', getU64Decoder()],
['validOperatorVaultDelegations', getU64Decoder()],
['stakeWeight', getU128Decoder()],
['stakeWeight', getStakeWeightDecoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 256 })],
[
'vaultOperatorStakeWeight',
Expand Down
40 changes: 24 additions & 16 deletions clients/js/jito_tip_router/errors/jitoTipRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,42 @@ export const JITO_TIP_ROUTER_ERROR__TRACKED_MINT_LIST_FULL = 0x220b; // 8715
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 = 0x220d; // 8717
/** MintEntryNotFound: Mint Entry not found */
export const JITO_TIP_ROUTER_ERROR__MINT_ENTRY_NOT_FOUND = 0x220e; // 8718
/** FeeCapExceeded: Fee cap exceeded */
export const JITO_TIP_ROUTER_ERROR__FEE_CAP_EXCEEDED = 0x220e; // 8718
export const JITO_TIP_ROUTER_ERROR__FEE_CAP_EXCEEDED = 0x220f; // 8719
/** IncorrectNcnAdmin: Incorrect NCN Admin */
export const JITO_TIP_ROUTER_ERROR__INCORRECT_NCN_ADMIN = 0x220f; // 8719
export const JITO_TIP_ROUTER_ERROR__INCORRECT_NCN_ADMIN = 0x2210; // 8720
/** IncorrectNcn: Incorrect NCN */
export const JITO_TIP_ROUTER_ERROR__INCORRECT_NCN = 0x2210; // 8720
export const JITO_TIP_ROUTER_ERROR__INCORRECT_NCN = 0x2211; // 8721
/** IncorrectFeeAdmin: Incorrect fee admin */
export const JITO_TIP_ROUTER_ERROR__INCORRECT_FEE_ADMIN = 0x2211; // 8721
export const JITO_TIP_ROUTER_ERROR__INCORRECT_FEE_ADMIN = 0x2212; // 8722
/** WeightTableNotFinalized: Weight table not finalized */
export const JITO_TIP_ROUTER_ERROR__WEIGHT_TABLE_NOT_FINALIZED = 0x2212; // 8722
export const JITO_TIP_ROUTER_ERROR__WEIGHT_TABLE_NOT_FINALIZED = 0x2213; // 8723
/** WeightNotFound: Weight not found */
export const JITO_TIP_ROUTER_ERROR__WEIGHT_NOT_FOUND = 0x2213; // 8723
export const JITO_TIP_ROUTER_ERROR__WEIGHT_NOT_FOUND = 0x2214; // 8724
/** NoOperators: No operators in ncn */
export const JITO_TIP_ROUTER_ERROR__NO_OPERATORS = 0x2214; // 8724
export const JITO_TIP_ROUTER_ERROR__NO_OPERATORS = 0x2215; // 8725
/** VaultOperatorDelegationFinalized: Vault operator delegation is already finalized - should not happen */
export const JITO_TIP_ROUTER_ERROR__VAULT_OPERATOR_DELEGATION_FINALIZED = 0x2215; // 8725
export const JITO_TIP_ROUTER_ERROR__VAULT_OPERATOR_DELEGATION_FINALIZED = 0x2216; // 8726
/** OperatorFinalized: Operator is already finalized - should not happen */
export const JITO_TIP_ROUTER_ERROR__OPERATOR_FINALIZED = 0x2216; // 8726
export const JITO_TIP_ROUTER_ERROR__OPERATOR_FINALIZED = 0x2217; // 8727
/** TooManyVaultOperatorDelegations: Too many vault operator delegations */
export const JITO_TIP_ROUTER_ERROR__TOO_MANY_VAULT_OPERATOR_DELEGATIONS = 0x2217; // 8727
export const JITO_TIP_ROUTER_ERROR__TOO_MANY_VAULT_OPERATOR_DELEGATIONS = 0x2218; // 8728
/** DuplicateVaultOperatorDelegation: Duplicate vault operator delegation */
export const JITO_TIP_ROUTER_ERROR__DUPLICATE_VAULT_OPERATOR_DELEGATION = 0x2218; // 8728
export const JITO_TIP_ROUTER_ERROR__DUPLICATE_VAULT_OPERATOR_DELEGATION = 0x2219; // 8729
/** DuplicateVoteCast: Duplicate Vote Cast */
export const JITO_TIP_ROUTER_ERROR__DUPLICATE_VOTE_CAST = 0x2219; // 8729
export const JITO_TIP_ROUTER_ERROR__DUPLICATE_VOTE_CAST = 0x221a; // 8730
/** OperatorVotesFull: Operator votes full */
export const JITO_TIP_ROUTER_ERROR__OPERATOR_VOTES_FULL = 0x221a; // 8730
export const JITO_TIP_ROUTER_ERROR__OPERATOR_VOTES_FULL = 0x221b; // 8731
/** BallotTallyFull: Merkle root tally full */
export const JITO_TIP_ROUTER_ERROR__BALLOT_TALLY_FULL = 0x221b; // 8731
export const JITO_TIP_ROUTER_ERROR__BALLOT_TALLY_FULL = 0x221c; // 8732
/** ConsensusAlreadyReached: Consensus already reached */
export const JITO_TIP_ROUTER_ERROR__CONSENSUS_ALREADY_REACHED = 0x221c; // 8732
export const JITO_TIP_ROUTER_ERROR__CONSENSUS_ALREADY_REACHED = 0x221d; // 8733
/** ConsensusNotReached: Consensus not reached */
export const JITO_TIP_ROUTER_ERROR__CONSENSUS_NOT_REACHED = 0x221d; // 8733
export const JITO_TIP_ROUTER_ERROR__CONSENSUS_NOT_REACHED = 0x221e; // 8734
/** InvalidNcnFeeGroup: Not a valid NCN fee group */
export const JITO_TIP_ROUTER_ERROR__INVALID_NCN_FEE_GROUP = 0x221f; // 8735

export type JitoTipRouterError =
| typeof JITO_TIP_ROUTER_ERROR__ARITHMETIC_OVERFLOW
Expand All @@ -104,6 +108,8 @@ export type JitoTipRouterError =
| typeof JITO_TIP_ROUTER_ERROR__INCORRECT_NCN_ADMIN
| typeof JITO_TIP_ROUTER_ERROR__INCORRECT_WEIGHT_TABLE_ADMIN
| typeof JITO_TIP_ROUTER_ERROR__INVALID_MINT_FOR_WEIGHT_TABLE
| typeof JITO_TIP_ROUTER_ERROR__INVALID_NCN_FEE_GROUP
| typeof JITO_TIP_ROUTER_ERROR__MINT_ENTRY_NOT_FOUND
| typeof JITO_TIP_ROUTER_ERROR__MODULO_OVERFLOW
| typeof JITO_TIP_ROUTER_ERROR__NEW_PRECISE_NUMBER_ERROR
| typeof JITO_TIP_ROUTER_ERROR__NO_MINTS_IN_TABLE
Expand Down Expand Up @@ -143,6 +149,8 @@ if (process.env.NODE_ENV !== 'production') {
[JITO_TIP_ROUTER_ERROR__INCORRECT_NCN_ADMIN]: `Incorrect NCN Admin`,
[JITO_TIP_ROUTER_ERROR__INCORRECT_WEIGHT_TABLE_ADMIN]: `Incorrect weight table admin`,
[JITO_TIP_ROUTER_ERROR__INVALID_MINT_FOR_WEIGHT_TABLE]: `Invalid mint for weight table`,
[JITO_TIP_ROUTER_ERROR__INVALID_NCN_FEE_GROUP]: `Not a valid NCN fee group`,
[JITO_TIP_ROUTER_ERROR__MINT_ENTRY_NOT_FOUND]: `Mint Entry not found`,
[JITO_TIP_ROUTER_ERROR__MODULO_OVERFLOW]: `Modulo Overflow`,
[JITO_TIP_ROUTER_ERROR__NEW_PRECISE_NUMBER_ERROR]: `New precise number error`,
[JITO_TIP_ROUTER_ERROR__NO_MINTS_IN_TABLE]: `There are no mints in the table`,
Expand Down
25 changes: 15 additions & 10 deletions clients/js/jito_tip_router/instructions/setConfigFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,30 @@ export type SetConfigFeesInstruction<

export type SetConfigFeesInstructionData = {
discriminator: number;
newFeeWallet: Option<Address>;
newBlockEngineFeeBps: Option<bigint>;
newDaoFeeBps: Option<bigint>;
newNcnFeeBps: Option<bigint>;
newBlockEngineFeeBps: Option<bigint>;
newFeeWallet: Option<Address>;
newNcnFeeGroup: Option<number>;
};

export type SetConfigFeesInstructionDataArgs = {
newFeeWallet: OptionOrNullable<Address>;
newBlockEngineFeeBps: OptionOrNullable<number | bigint>;
newDaoFeeBps: OptionOrNullable<number | bigint>;
newNcnFeeBps: OptionOrNullable<number | bigint>;
newBlockEngineFeeBps: OptionOrNullable<number | bigint>;
newFeeWallet: OptionOrNullable<Address>;
newNcnFeeGroup: OptionOrNullable<number>;
};

export function getSetConfigFeesInstructionDataEncoder(): Encoder<SetConfigFeesInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['newFeeWallet', getOptionEncoder(getAddressEncoder())],
['newBlockEngineFeeBps', getOptionEncoder(getU64Encoder())],
['newDaoFeeBps', getOptionEncoder(getU64Encoder())],
['newNcnFeeBps', getOptionEncoder(getU64Encoder())],
['newBlockEngineFeeBps', getOptionEncoder(getU64Encoder())],
['newFeeWallet', getOptionEncoder(getAddressEncoder())],
['newNcnFeeGroup', getOptionEncoder(getU8Encoder())],
]),
(value) => ({ ...value, discriminator: SET_CONFIG_FEES_DISCRIMINATOR })
);
Expand All @@ -105,10 +108,11 @@ export function getSetConfigFeesInstructionDataEncoder(): Encoder<SetConfigFeesI
export function getSetConfigFeesInstructionDataDecoder(): Decoder<SetConfigFeesInstructionData> {
return getStructDecoder([
['discriminator', getU8Decoder()],
['newFeeWallet', getOptionDecoder(getAddressDecoder())],
['newBlockEngineFeeBps', getOptionDecoder(getU64Decoder())],
['newDaoFeeBps', getOptionDecoder(getU64Decoder())],
['newNcnFeeBps', getOptionDecoder(getU64Decoder())],
['newBlockEngineFeeBps', getOptionDecoder(getU64Decoder())],
['newFeeWallet', getOptionDecoder(getAddressDecoder())],
['newNcnFeeGroup', getOptionDecoder(getU8Decoder())],
]);
}

Expand All @@ -134,10 +138,11 @@ export type SetConfigFeesInput<
ncn: Address<TAccountNcn>;
ncnAdmin: TransactionSigner<TAccountNcnAdmin>;
restakingProgram: Address<TAccountRestakingProgram>;
newFeeWallet: SetConfigFeesInstructionDataArgs['newFeeWallet'];
newBlockEngineFeeBps: SetConfigFeesInstructionDataArgs['newBlockEngineFeeBps'];
newDaoFeeBps: SetConfigFeesInstructionDataArgs['newDaoFeeBps'];
newNcnFeeBps: SetConfigFeesInstructionDataArgs['newNcnFeeBps'];
newBlockEngineFeeBps: SetConfigFeesInstructionDataArgs['newBlockEngineFeeBps'];
newFeeWallet: SetConfigFeesInstructionDataArgs['newFeeWallet'];
newNcnFeeGroup: SetConfigFeesInstructionDataArgs['newNcnFeeGroup'];
};

export function getSetConfigFeesInstruction<
Expand Down
Loading

0 comments on commit 741362e

Please sign in to comment.