/** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ import { combineCodec, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from "@solana/kit"; import { getAccountMetaFactory, getAddressFromResolvedInstructionAccount, type ResolvedInstructionAccount, } from "@solana/program-client-core"; import { findWithdrawAuthorityPda } from "../pdas/index.ts"; import { SPL_STAKE_POOL_PROGRAM_ADDRESS } from "../programs/index.ts"; export const INCREASE_ADDITIONAL_VALIDATOR_STAKE_DISCRIMINATOR = 19; export function getIncreaseAdditionalValidatorStakeDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode( INCREASE_ADDITIONAL_VALIDATOR_STAKE_DISCRIMINATOR, ); } export type IncreaseAdditionalValidatorStakeInstruction< TProgram extends string = typeof SPL_STAKE_POOL_PROGRAM_ADDRESS, TAccountStakePool extends string | AccountMeta = string, TAccountStaker extends string | AccountMeta = string, TAccountWithdrawAuthority extends string | AccountMeta = string, TAccountValidatorList extends string | AccountMeta = string, TAccountReserveStake extends string | AccountMeta = string, TAccountEphemeralStake extends string | AccountMeta = string, TAccountTransientStake extends string | AccountMeta = string, TAccountValidatorStake extends string | AccountMeta = string, TAccountValidatorVote extends string | AccountMeta = string, TAccountClockSysvar extends string | AccountMeta = "SysvarC1ock11111111111111111111111111111111", TAccountStakeHistorySysvar extends string | AccountMeta = "SysvarStakeHistory1111111111111111111111111", TAccountStakeConfigSysvar extends string | AccountMeta = "StakeConfig11111111111111111111111111111111", TAccountSystemProgram extends string | AccountMeta = "11111111111111111111111111111111", TAccountStakeProgram extends string | AccountMeta = "Stake11111111111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountStakePool extends string ? ReadonlyAccount : TAccountStakePool, TAccountStaker extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountStaker, TAccountWithdrawAuthority extends string ? ReadonlyAccount : TAccountWithdrawAuthority, TAccountValidatorList extends string ? WritableAccount : TAccountValidatorList, TAccountReserveStake extends string ? WritableAccount : TAccountReserveStake, TAccountEphemeralStake extends string ? WritableAccount : TAccountEphemeralStake, TAccountTransientStake extends string ? WritableAccount : TAccountTransientStake, TAccountValidatorStake extends string ? ReadonlyAccount : TAccountValidatorStake, TAccountValidatorVote extends string ? ReadonlyAccount : TAccountValidatorVote, TAccountClockSysvar extends string ? ReadonlyAccount : TAccountClockSysvar, TAccountStakeHistorySysvar extends string ? ReadonlyAccount : TAccountStakeHistorySysvar, TAccountStakeConfigSysvar extends string ? ReadonlyAccount : TAccountStakeConfigSysvar, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, TAccountStakeProgram extends string ? ReadonlyAccount : TAccountStakeProgram, ...TRemainingAccounts, ] >; export type IncreaseAdditionalValidatorStakeInstructionData = { discriminator: number; lamports: bigint; transientStakeSeed: bigint; ephemeralStakeSeed: bigint; }; export type IncreaseAdditionalValidatorStakeInstructionDataArgs = { lamports: number | bigint; transientStakeSeed: number | bigint; ephemeralStakeSeed: number | bigint; }; export function getIncreaseAdditionalValidatorStakeInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", getU8Encoder()], ["lamports", getU64Encoder()], ["transientStakeSeed", getU64Encoder()], ["ephemeralStakeSeed", getU64Encoder()], ]), (value) => ({ ...value, discriminator: INCREASE_ADDITIONAL_VALIDATOR_STAKE_DISCRIMINATOR, }), ); } export function getIncreaseAdditionalValidatorStakeInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", getU8Decoder()], ["lamports", getU64Decoder()], ["transientStakeSeed", getU64Decoder()], ["ephemeralStakeSeed", getU64Decoder()], ]); } export function getIncreaseAdditionalValidatorStakeInstructionDataCodec(): FixedSizeCodec< IncreaseAdditionalValidatorStakeInstructionDataArgs, IncreaseAdditionalValidatorStakeInstructionData > { return combineCodec( getIncreaseAdditionalValidatorStakeInstructionDataEncoder(), getIncreaseAdditionalValidatorStakeInstructionDataDecoder(), ); } export type IncreaseAdditionalValidatorStakeAsyncInput< TAccountStakePool extends string = string, TAccountStaker extends string = string, TAccountWithdrawAuthority extends string = string, TAccountValidatorList extends string = string, TAccountReserveStake extends string = string, TAccountEphemeralStake extends string = string, TAccountTransientStake extends string = string, TAccountValidatorStake extends string = string, TAccountValidatorVote extends string = string, TAccountClockSysvar extends string = string, TAccountStakeHistorySysvar extends string = string, TAccountStakeConfigSysvar extends string = string, TAccountSystemProgram extends string = string, TAccountStakeProgram extends string = string, > = { stakePool: Address; staker: TransactionSigner; withdrawAuthority?: Address; validatorList: Address; reserveStake: Address; ephemeralStake: Address; transientStake: Address; validatorStake: Address; validatorVote: Address; clockSysvar?: Address; stakeHistorySysvar?: Address; stakeConfigSysvar?: Address; systemProgram?: Address; stakeProgram?: Address; lamports: IncreaseAdditionalValidatorStakeInstructionDataArgs["lamports"]; transientStakeSeed: IncreaseAdditionalValidatorStakeInstructionDataArgs["transientStakeSeed"]; ephemeralStakeSeed: IncreaseAdditionalValidatorStakeInstructionDataArgs["ephemeralStakeSeed"]; }; /** * (Staker only) Increase stake on a validator again in an epoch. * Works regardless if the transient stake account exists. * Internally, this instruction splits reserve stake into an ephemeral * stake account, activates it, then merges or splits it into the * transient stake account delegated to the appropriate validator. * `UpdateValidatorListBalance` will do the work of merging once it's * ready. * The minimum amount to move is rent-exemption plus * `max(crate::MINIMUM_ACTIVE_STAKE, * solana_program::stake::tools::get_minimum_delegation())`. * 0. `[]` Stake pool * 1. `[s]` Stake pool staker * 2. `[]` Stake pool withdraw authority * 3. `[w]` Validator list * 4. `[w]` Stake pool reserve stake * 5. `[w]` Uninitialized ephemeral stake account to receive stake * 6. `[w]` Transient stake account * 7. `[]` Validator stake account * 8. `[]` Validator vote account to delegate to * 9. '[]' Clock sysvar * 10. `[]` Stake History sysvar * 11. `[]` Stake Config sysvar * 12. `[]` System program * 13. `[]` Stake program * User data: amount of lamports to increase on the given validator. * The actual amount split into the transient stake account is: * `lamports + stake_rent_exemption`. * The rent-exemption of the stake account is withdrawn back to the * reserve after it is merged. */ export async function getIncreaseAdditionalValidatorStakeInstructionAsync< TAccountStakePool extends string, TAccountStaker extends string, TAccountWithdrawAuthority extends string, TAccountValidatorList extends string, TAccountReserveStake extends string, TAccountEphemeralStake extends string, TAccountTransientStake extends string, TAccountValidatorStake extends string, TAccountValidatorVote extends string, TAccountClockSysvar extends string, TAccountStakeHistorySysvar extends string, TAccountStakeConfigSysvar extends string, TAccountSystemProgram extends string, TAccountStakeProgram extends string, TProgramAddress extends Address = typeof SPL_STAKE_POOL_PROGRAM_ADDRESS, >( input: IncreaseAdditionalValidatorStakeAsyncInput< TAccountStakePool, TAccountStaker, TAccountWithdrawAuthority, TAccountValidatorList, TAccountReserveStake, TAccountEphemeralStake, TAccountTransientStake, TAccountValidatorStake, TAccountValidatorVote, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeConfigSysvar, TAccountSystemProgram, TAccountStakeProgram >, config?: { programAddress?: TProgramAddress }, ): Promise< IncreaseAdditionalValidatorStakeInstruction< TProgramAddress, TAccountStakePool, TAccountStaker, TAccountWithdrawAuthority, TAccountValidatorList, TAccountReserveStake, TAccountEphemeralStake, TAccountTransientStake, TAccountValidatorStake, TAccountValidatorVote, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeConfigSysvar, TAccountSystemProgram, TAccountStakeProgram > > { // Program address. const programAddress = config?.programAddress ?? SPL_STAKE_POOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stakePool: { value: input.stakePool ?? null, isWritable: false }, staker: { value: input.staker ?? null, isWritable: false }, withdrawAuthority: { value: input.withdrawAuthority ?? null, isWritable: false, }, validatorList: { value: input.validatorList ?? null, isWritable: true }, reserveStake: { value: input.reserveStake ?? null, isWritable: true }, ephemeralStake: { value: input.ephemeralStake ?? null, isWritable: true }, transientStake: { value: input.transientStake ?? null, isWritable: true }, validatorStake: { value: input.validatorStake ?? null, isWritable: false }, validatorVote: { value: input.validatorVote ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, stakeHistorySysvar: { value: input.stakeHistorySysvar ?? null, isWritable: false, }, stakeConfigSysvar: { value: input.stakeConfigSysvar ?? null, isWritable: false, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, stakeProgram: { value: input.stakeProgram ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.withdrawAuthority.value) { accounts.withdrawAuthority.value = await findWithdrawAuthorityPda( { stakePoolAddress: getAddressFromResolvedInstructionAccount( "stakePool", accounts.stakePool.value, ), }, { programAddress }, ); } if (!accounts.clockSysvar.value) { accounts.clockSysvar.value = "SysvarC1ock11111111111111111111111111111111" as Address<"SysvarC1ock11111111111111111111111111111111">; } if (!accounts.stakeHistorySysvar.value) { accounts.stakeHistorySysvar.value = "SysvarStakeHistory1111111111111111111111111" as Address<"SysvarStakeHistory1111111111111111111111111">; } if (!accounts.stakeConfigSysvar.value) { accounts.stakeConfigSysvar.value = "StakeConfig11111111111111111111111111111111" as Address<"StakeConfig11111111111111111111111111111111">; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; } if (!accounts.stakeProgram.value) { accounts.stakeProgram.value = "Stake11111111111111111111111111111111111111" as Address<"Stake11111111111111111111111111111111111111">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("stakePool", accounts.stakePool), getAccountMeta("staker", accounts.staker), getAccountMeta("withdrawAuthority", accounts.withdrawAuthority), getAccountMeta("validatorList", accounts.validatorList), getAccountMeta("reserveStake", accounts.reserveStake), getAccountMeta("ephemeralStake", accounts.ephemeralStake), getAccountMeta("transientStake", accounts.transientStake), getAccountMeta("validatorStake", accounts.validatorStake), getAccountMeta("validatorVote", accounts.validatorVote), getAccountMeta("clockSysvar", accounts.clockSysvar), getAccountMeta("stakeHistorySysvar", accounts.stakeHistorySysvar), getAccountMeta("stakeConfigSysvar", accounts.stakeConfigSysvar), getAccountMeta("systemProgram", accounts.systemProgram), getAccountMeta("stakeProgram", accounts.stakeProgram), ], data: getIncreaseAdditionalValidatorStakeInstructionDataEncoder().encode( args as IncreaseAdditionalValidatorStakeInstructionDataArgs, ), programAddress, } as IncreaseAdditionalValidatorStakeInstruction< TProgramAddress, TAccountStakePool, TAccountStaker, TAccountWithdrawAuthority, TAccountValidatorList, TAccountReserveStake, TAccountEphemeralStake, TAccountTransientStake, TAccountValidatorStake, TAccountValidatorVote, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeConfigSysvar, TAccountSystemProgram, TAccountStakeProgram >); } export type IncreaseAdditionalValidatorStakeInput< TAccountStakePool extends string = string, TAccountStaker extends string = string, TAccountWithdrawAuthority extends string = string, TAccountValidatorList extends string = string, TAccountReserveStake extends string = string, TAccountEphemeralStake extends string = string, TAccountTransientStake extends string = string, TAccountValidatorStake extends string = string, TAccountValidatorVote extends string = string, TAccountClockSysvar extends string = string, TAccountStakeHistorySysvar extends string = string, TAccountStakeConfigSysvar extends string = string, TAccountSystemProgram extends string = string, TAccountStakeProgram extends string = string, > = { stakePool: Address; staker: TransactionSigner; withdrawAuthority: Address; validatorList: Address; reserveStake: Address; ephemeralStake: Address; transientStake: Address; validatorStake: Address; validatorVote: Address; clockSysvar?: Address; stakeHistorySysvar?: Address; stakeConfigSysvar?: Address; systemProgram?: Address; stakeProgram?: Address; lamports: IncreaseAdditionalValidatorStakeInstructionDataArgs["lamports"]; transientStakeSeed: IncreaseAdditionalValidatorStakeInstructionDataArgs["transientStakeSeed"]; ephemeralStakeSeed: IncreaseAdditionalValidatorStakeInstructionDataArgs["ephemeralStakeSeed"]; }; /** * (Staker only) Increase stake on a validator again in an epoch. * Works regardless if the transient stake account exists. * Internally, this instruction splits reserve stake into an ephemeral * stake account, activates it, then merges or splits it into the * transient stake account delegated to the appropriate validator. * `UpdateValidatorListBalance` will do the work of merging once it's * ready. * The minimum amount to move is rent-exemption plus * `max(crate::MINIMUM_ACTIVE_STAKE, * solana_program::stake::tools::get_minimum_delegation())`. * 0. `[]` Stake pool * 1. `[s]` Stake pool staker * 2. `[]` Stake pool withdraw authority * 3. `[w]` Validator list * 4. `[w]` Stake pool reserve stake * 5. `[w]` Uninitialized ephemeral stake account to receive stake * 6. `[w]` Transient stake account * 7. `[]` Validator stake account * 8. `[]` Validator vote account to delegate to * 9. '[]' Clock sysvar * 10. `[]` Stake History sysvar * 11. `[]` Stake Config sysvar * 12. `[]` System program * 13. `[]` Stake program * User data: amount of lamports to increase on the given validator. * The actual amount split into the transient stake account is: * `lamports + stake_rent_exemption`. * The rent-exemption of the stake account is withdrawn back to the * reserve after it is merged. */ export function getIncreaseAdditionalValidatorStakeInstruction< TAccountStakePool extends string, TAccountStaker extends string, TAccountWithdrawAuthority extends string, TAccountValidatorList extends string, TAccountReserveStake extends string, TAccountEphemeralStake extends string, TAccountTransientStake extends string, TAccountValidatorStake extends string, TAccountValidatorVote extends string, TAccountClockSysvar extends string, TAccountStakeHistorySysvar extends string, TAccountStakeConfigSysvar extends string, TAccountSystemProgram extends string, TAccountStakeProgram extends string, TProgramAddress extends Address = typeof SPL_STAKE_POOL_PROGRAM_ADDRESS, >( input: IncreaseAdditionalValidatorStakeInput< TAccountStakePool, TAccountStaker, TAccountWithdrawAuthority, TAccountValidatorList, TAccountReserveStake, TAccountEphemeralStake, TAccountTransientStake, TAccountValidatorStake, TAccountValidatorVote, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeConfigSysvar, TAccountSystemProgram, TAccountStakeProgram >, config?: { programAddress?: TProgramAddress }, ): IncreaseAdditionalValidatorStakeInstruction< TProgramAddress, TAccountStakePool, TAccountStaker, TAccountWithdrawAuthority, TAccountValidatorList, TAccountReserveStake, TAccountEphemeralStake, TAccountTransientStake, TAccountValidatorStake, TAccountValidatorVote, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeConfigSysvar, TAccountSystemProgram, TAccountStakeProgram > { // Program address. const programAddress = config?.programAddress ?? SPL_STAKE_POOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stakePool: { value: input.stakePool ?? null, isWritable: false }, staker: { value: input.staker ?? null, isWritable: false }, withdrawAuthority: { value: input.withdrawAuthority ?? null, isWritable: false, }, validatorList: { value: input.validatorList ?? null, isWritable: true }, reserveStake: { value: input.reserveStake ?? null, isWritable: true }, ephemeralStake: { value: input.ephemeralStake ?? null, isWritable: true }, transientStake: { value: input.transientStake ?? null, isWritable: true }, validatorStake: { value: input.validatorStake ?? null, isWritable: false }, validatorVote: { value: input.validatorVote ?? null, isWritable: false }, clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, stakeHistorySysvar: { value: input.stakeHistorySysvar ?? null, isWritable: false, }, stakeConfigSysvar: { value: input.stakeConfigSysvar ?? null, isWritable: false, }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, stakeProgram: { value: input.stakeProgram ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.clockSysvar.value) { accounts.clockSysvar.value = "SysvarC1ock11111111111111111111111111111111" as Address<"SysvarC1ock11111111111111111111111111111111">; } if (!accounts.stakeHistorySysvar.value) { accounts.stakeHistorySysvar.value = "SysvarStakeHistory1111111111111111111111111" as Address<"SysvarStakeHistory1111111111111111111111111">; } if (!accounts.stakeConfigSysvar.value) { accounts.stakeConfigSysvar.value = "StakeConfig11111111111111111111111111111111" as Address<"StakeConfig11111111111111111111111111111111">; } if (!accounts.systemProgram.value) { accounts.systemProgram.value = "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; } if (!accounts.stakeProgram.value) { accounts.stakeProgram.value = "Stake11111111111111111111111111111111111111" as Address<"Stake11111111111111111111111111111111111111">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("stakePool", accounts.stakePool), getAccountMeta("staker", accounts.staker), getAccountMeta("withdrawAuthority", accounts.withdrawAuthority), getAccountMeta("validatorList", accounts.validatorList), getAccountMeta("reserveStake", accounts.reserveStake), getAccountMeta("ephemeralStake", accounts.ephemeralStake), getAccountMeta("transientStake", accounts.transientStake), getAccountMeta("validatorStake", accounts.validatorStake), getAccountMeta("validatorVote", accounts.validatorVote), getAccountMeta("clockSysvar", accounts.clockSysvar), getAccountMeta("stakeHistorySysvar", accounts.stakeHistorySysvar), getAccountMeta("stakeConfigSysvar", accounts.stakeConfigSysvar), getAccountMeta("systemProgram", accounts.systemProgram), getAccountMeta("stakeProgram", accounts.stakeProgram), ], data: getIncreaseAdditionalValidatorStakeInstructionDataEncoder().encode( args as IncreaseAdditionalValidatorStakeInstructionDataArgs, ), programAddress, } as IncreaseAdditionalValidatorStakeInstruction< TProgramAddress, TAccountStakePool, TAccountStaker, TAccountWithdrawAuthority, TAccountValidatorList, TAccountReserveStake, TAccountEphemeralStake, TAccountTransientStake, TAccountValidatorStake, TAccountValidatorVote, TAccountClockSysvar, TAccountStakeHistorySysvar, TAccountStakeConfigSysvar, TAccountSystemProgram, TAccountStakeProgram >); } export type ParsedIncreaseAdditionalValidatorStakeInstruction< TProgram extends string = typeof SPL_STAKE_POOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > = { programAddress: Address; accounts: { stakePool: TAccountMetas[0]; staker: TAccountMetas[1]; withdrawAuthority: TAccountMetas[2]; validatorList: TAccountMetas[3]; reserveStake: TAccountMetas[4]; ephemeralStake: TAccountMetas[5]; transientStake: TAccountMetas[6]; validatorStake: TAccountMetas[7]; validatorVote: TAccountMetas[8]; clockSysvar: TAccountMetas[9]; stakeHistorySysvar: TAccountMetas[10]; stakeConfigSysvar: TAccountMetas[11]; systemProgram: TAccountMetas[12]; stakeProgram: TAccountMetas[13]; }; data: IncreaseAdditionalValidatorStakeInstructionData; }; export function parseIncreaseAdditionalValidatorStakeInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedIncreaseAdditionalValidatorStakeInstruction { if (instruction.accounts.length < 14) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 14, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { stakePool: getNextAccount(), staker: getNextAccount(), withdrawAuthority: getNextAccount(), validatorList: getNextAccount(), reserveStake: getNextAccount(), ephemeralStake: getNextAccount(), transientStake: getNextAccount(), validatorStake: getNextAccount(), validatorVote: getNextAccount(), clockSysvar: getNextAccount(), stakeHistorySysvar: getNextAccount(), stakeConfigSysvar: getNextAccount(), systemProgram: getNextAccount(), stakeProgram: getNextAccount(), }, data: getIncreaseAdditionalValidatorStakeInstructionDataDecoder().decode( instruction.data, ), }; }