/** * 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 { assertIsInstructionWithAccounts, containsBytes, extendClient, getU8Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, SolanaError, type Address, type ClientWithPayer, type ClientWithRpc, type ClientWithTransactionPlanning, type ClientWithTransactionSending, type ExtendedClient, type GetAccountInfoApi, type GetMultipleAccountsApi, type Instruction, type InstructionWithData, type ReadonlyUint8Array, } from "@solana/kit"; import { addSelfFetchFunctions, addSelfPlanAndSendFunctions, type SelfFetchFunctions, type SelfPlanAndSendFunctions, } from "@solana/program-client-core"; import { getStakePoolCodec, getValidatorListCodec, type StakePool, type StakePoolArgs, type ValidatorList, type ValidatorListArgs, } from "../accounts/index.ts"; import { getAddValidatorToPoolInstructionAsync, getCleanupRemovedValidatorEntriesInstruction, getCreateTokenMetadataInstructionAsync, getDecreaseAdditionalValidatorStakeInstructionAsync, getDecreaseValidatorStakeInstructionAsync, getDecreaseValidatorStakeWithReserveInstructionAsync, getDepositSolInstructionAsync, getDepositSolWithSlippageInstructionAsync, getDepositStakeInstructionAsync, getDepositStakeWithSlippageInstructionAsync, getIncreaseAdditionalValidatorStakeInstructionAsync, getIncreaseValidatorStakeInstructionAsync, getInitializeInstructionAsync, getRedelegateInstructionAsync, getRemoveValidatorFromPoolInstructionAsync, getSetFeeInstruction, getSetFundingAuthorityInstruction, getSetManagerInstruction, getSetPreferredValidatorInstruction, getSetStakerInstruction, getUpdateStakePoolBalanceInstructionAsync, getUpdateTokenMetadataInstructionAsync, getUpdateValidatorListBalanceInstructionAsync, getWithdrawSolInstructionAsync, getWithdrawSolWithSlippageInstructionAsync, getWithdrawStakeInstructionAsync, getWithdrawStakeWithSlippageInstructionAsync, parseAddValidatorToPoolInstruction, parseCleanupRemovedValidatorEntriesInstruction, parseCreateTokenMetadataInstruction, parseDecreaseAdditionalValidatorStakeInstruction, parseDecreaseValidatorStakeInstruction, parseDecreaseValidatorStakeWithReserveInstruction, parseDepositSolInstruction, parseDepositSolWithSlippageInstruction, parseDepositStakeInstruction, parseDepositStakeWithSlippageInstruction, parseIncreaseAdditionalValidatorStakeInstruction, parseIncreaseValidatorStakeInstruction, parseInitializeInstruction, parseRedelegateInstruction, parseRemoveValidatorFromPoolInstruction, parseSetFeeInstruction, parseSetFundingAuthorityInstruction, parseSetManagerInstruction, parseSetPreferredValidatorInstruction, parseSetStakerInstruction, parseUpdateStakePoolBalanceInstruction, parseUpdateTokenMetadataInstruction, parseUpdateValidatorListBalanceInstruction, parseWithdrawSolInstruction, parseWithdrawSolWithSlippageInstruction, parseWithdrawStakeInstruction, parseWithdrawStakeWithSlippageInstruction, type AddValidatorToPoolAsyncInput, type CleanupRemovedValidatorEntriesInput, type CreateTokenMetadataAsyncInput, type DecreaseAdditionalValidatorStakeAsyncInput, type DecreaseValidatorStakeAsyncInput, type DecreaseValidatorStakeWithReserveAsyncInput, type DepositSolAsyncInput, type DepositSolWithSlippageAsyncInput, type DepositStakeAsyncInput, type DepositStakeWithSlippageAsyncInput, type IncreaseAdditionalValidatorStakeAsyncInput, type IncreaseValidatorStakeAsyncInput, type InitializeAsyncInput, type ParsedAddValidatorToPoolInstruction, type ParsedCleanupRemovedValidatorEntriesInstruction, type ParsedCreateTokenMetadataInstruction, type ParsedDecreaseAdditionalValidatorStakeInstruction, type ParsedDecreaseValidatorStakeInstruction, type ParsedDecreaseValidatorStakeWithReserveInstruction, type ParsedDepositSolInstruction, type ParsedDepositSolWithSlippageInstruction, type ParsedDepositStakeInstruction, type ParsedDepositStakeWithSlippageInstruction, type ParsedIncreaseAdditionalValidatorStakeInstruction, type ParsedIncreaseValidatorStakeInstruction, type ParsedInitializeInstruction, type ParsedRedelegateInstruction, type ParsedRemoveValidatorFromPoolInstruction, type ParsedSetFeeInstruction, type ParsedSetFundingAuthorityInstruction, type ParsedSetManagerInstruction, type ParsedSetPreferredValidatorInstruction, type ParsedSetStakerInstruction, type ParsedUpdateStakePoolBalanceInstruction, type ParsedUpdateTokenMetadataInstruction, type ParsedUpdateValidatorListBalanceInstruction, type ParsedWithdrawSolInstruction, type ParsedWithdrawSolWithSlippageInstruction, type ParsedWithdrawStakeInstruction, type ParsedWithdrawStakeWithSlippageInstruction, type RedelegateAsyncInput, type RemoveValidatorFromPoolAsyncInput, type SetFeeInput, type SetFundingAuthorityInput, type SetManagerInput, type SetPreferredValidatorInput, type SetStakerInput, type UpdateStakePoolBalanceAsyncInput, type UpdateTokenMetadataAsyncInput, type UpdateValidatorListBalanceAsyncInput, type WithdrawSolAsyncInput, type WithdrawSolWithSlippageAsyncInput, type WithdrawStakeAsyncInput, type WithdrawStakeWithSlippageAsyncInput, } from "../instructions/index.ts"; import { findEphemeralStakePda, findStakePda, findTransientStakePda, findWithdrawAuthorityPda, } from "../pdas/index.ts"; import { AccountType, getAccountTypeEncoder } from "../types/index.ts"; export const SPL_STAKE_POOL_PROGRAM_ADDRESS = "SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy" as Address<"SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy">; const SplStakePoolAccountLookup = { 0: "StakePool", 1: "ValidatorList", StakePool: 0, ValidatorList: 1, } as const; export const SplStakePoolAccount: Omit< typeof SplStakePoolAccountLookup, number > = SplStakePoolAccountLookup; export type SplStakePoolAccount = (typeof SplStakePoolAccount)[keyof typeof SplStakePoolAccount]; export function identifySplStakePoolAccount( account: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): SplStakePoolAccount { const data = "data" in account ? account.data : account; if ( containsBytes( data, getAccountTypeEncoder().encode(AccountType.StakePool), 0, ) ) { return SplStakePoolAccount.StakePool; } if ( containsBytes( data, getAccountTypeEncoder().encode(AccountType.ValidatorList), 0, ) ) { return SplStakePoolAccount.ValidatorList; } throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, { accountData: data, programName: "splStakePool" }, ); } const SplStakePoolInstructionLookup = { 0: "Initialize", 1: "AddValidatorToPool", 2: "RemoveValidatorFromPool", 3: "DecreaseValidatorStake", 4: "IncreaseValidatorStake", 5: "SetPreferredValidator", 6: "UpdateValidatorListBalance", 7: "UpdateStakePoolBalance", 8: "CleanupRemovedValidatorEntries", 9: "DepositStake", 10: "WithdrawStake", 11: "SetManager", 12: "SetFee", 13: "SetStaker", 14: "DepositSol", 15: "SetFundingAuthority", 16: "WithdrawSol", 17: "CreateTokenMetadata", 18: "UpdateTokenMetadata", 19: "IncreaseAdditionalValidatorStake", 20: "DecreaseAdditionalValidatorStake", 21: "DecreaseValidatorStakeWithReserve", 22: "Redelegate", 23: "DepositStakeWithSlippage", 24: "WithdrawStakeWithSlippage", 25: "DepositSolWithSlippage", 26: "WithdrawSolWithSlippage", Initialize: 0, AddValidatorToPool: 1, RemoveValidatorFromPool: 2, DecreaseValidatorStake: 3, IncreaseValidatorStake: 4, SetPreferredValidator: 5, UpdateValidatorListBalance: 6, UpdateStakePoolBalance: 7, CleanupRemovedValidatorEntries: 8, DepositStake: 9, WithdrawStake: 10, SetManager: 11, SetFee: 12, SetStaker: 13, DepositSol: 14, SetFundingAuthority: 15, WithdrawSol: 16, CreateTokenMetadata: 17, UpdateTokenMetadata: 18, IncreaseAdditionalValidatorStake: 19, DecreaseAdditionalValidatorStake: 20, DecreaseValidatorStakeWithReserve: 21, Redelegate: 22, DepositStakeWithSlippage: 23, WithdrawStakeWithSlippage: 24, DepositSolWithSlippage: 25, WithdrawSolWithSlippage: 26, } as const; export const SplStakePoolInstruction: Omit< typeof SplStakePoolInstructionLookup, number > = SplStakePoolInstructionLookup; export type SplStakePoolInstruction = (typeof SplStakePoolInstruction)[keyof typeof SplStakePoolInstruction]; export function identifySplStakePoolInstruction( instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): SplStakePoolInstruction { const data = "data" in instruction ? instruction.data : instruction; if (containsBytes(data, getU8Encoder().encode(0), 0)) { return SplStakePoolInstruction.Initialize; } if (containsBytes(data, getU8Encoder().encode(1), 0)) { return SplStakePoolInstruction.AddValidatorToPool; } if (containsBytes(data, getU8Encoder().encode(2), 0)) { return SplStakePoolInstruction.RemoveValidatorFromPool; } if (containsBytes(data, getU8Encoder().encode(3), 0)) { return SplStakePoolInstruction.DecreaseValidatorStake; } if (containsBytes(data, getU8Encoder().encode(4), 0)) { return SplStakePoolInstruction.IncreaseValidatorStake; } if (containsBytes(data, getU8Encoder().encode(5), 0)) { return SplStakePoolInstruction.SetPreferredValidator; } if (containsBytes(data, getU8Encoder().encode(6), 0)) { return SplStakePoolInstruction.UpdateValidatorListBalance; } if (containsBytes(data, getU8Encoder().encode(7), 0)) { return SplStakePoolInstruction.UpdateStakePoolBalance; } if (containsBytes(data, getU8Encoder().encode(8), 0)) { return SplStakePoolInstruction.CleanupRemovedValidatorEntries; } if (containsBytes(data, getU8Encoder().encode(9), 0)) { return SplStakePoolInstruction.DepositStake; } if (containsBytes(data, getU8Encoder().encode(10), 0)) { return SplStakePoolInstruction.WithdrawStake; } if (containsBytes(data, getU8Encoder().encode(11), 0)) { return SplStakePoolInstruction.SetManager; } if (containsBytes(data, getU8Encoder().encode(12), 0)) { return SplStakePoolInstruction.SetFee; } if (containsBytes(data, getU8Encoder().encode(13), 0)) { return SplStakePoolInstruction.SetStaker; } if (containsBytes(data, getU8Encoder().encode(14), 0)) { return SplStakePoolInstruction.DepositSol; } if (containsBytes(data, getU8Encoder().encode(15), 0)) { return SplStakePoolInstruction.SetFundingAuthority; } if (containsBytes(data, getU8Encoder().encode(16), 0)) { return SplStakePoolInstruction.WithdrawSol; } if (containsBytes(data, getU8Encoder().encode(17), 0)) { return SplStakePoolInstruction.CreateTokenMetadata; } if (containsBytes(data, getU8Encoder().encode(18), 0)) { return SplStakePoolInstruction.UpdateTokenMetadata; } if (containsBytes(data, getU8Encoder().encode(19), 0)) { return SplStakePoolInstruction.IncreaseAdditionalValidatorStake; } if (containsBytes(data, getU8Encoder().encode(20), 0)) { return SplStakePoolInstruction.DecreaseAdditionalValidatorStake; } if (containsBytes(data, getU8Encoder().encode(21), 0)) { return SplStakePoolInstruction.DecreaseValidatorStakeWithReserve; } if (containsBytes(data, getU8Encoder().encode(22), 0)) { return SplStakePoolInstruction.Redelegate; } if (containsBytes(data, getU8Encoder().encode(23), 0)) { return SplStakePoolInstruction.DepositStakeWithSlippage; } if (containsBytes(data, getU8Encoder().encode(24), 0)) { return SplStakePoolInstruction.WithdrawStakeWithSlippage; } if (containsBytes(data, getU8Encoder().encode(25), 0)) { return SplStakePoolInstruction.DepositSolWithSlippage; } if (containsBytes(data, getU8Encoder().encode(26), 0)) { return SplStakePoolInstruction.WithdrawSolWithSlippage; } throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, { instructionData: data, programName: "splStakePool" }, ); } export type ParsedSplStakePoolInstruction< TProgram extends string = "SPoo1Ku8WFXoNDMHPsrGSTSG1Y47rzgn41SLUNakuHy", > = | ({ instructionType: typeof SplStakePoolInstruction.Initialize; } & ParsedInitializeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.AddValidatorToPool; } & ParsedAddValidatorToPoolInstruction) | ({ instructionType: typeof SplStakePoolInstruction.RemoveValidatorFromPool; } & ParsedRemoveValidatorFromPoolInstruction) | ({ instructionType: typeof SplStakePoolInstruction.DecreaseValidatorStake; } & ParsedDecreaseValidatorStakeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.IncreaseValidatorStake; } & ParsedIncreaseValidatorStakeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.SetPreferredValidator; } & ParsedSetPreferredValidatorInstruction) | ({ instructionType: typeof SplStakePoolInstruction.UpdateValidatorListBalance; } & ParsedUpdateValidatorListBalanceInstruction) | ({ instructionType: typeof SplStakePoolInstruction.UpdateStakePoolBalance; } & ParsedUpdateStakePoolBalanceInstruction) | ({ instructionType: typeof SplStakePoolInstruction.CleanupRemovedValidatorEntries; } & ParsedCleanupRemovedValidatorEntriesInstruction) | ({ instructionType: typeof SplStakePoolInstruction.DepositStake; } & ParsedDepositStakeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.WithdrawStake; } & ParsedWithdrawStakeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.SetManager; } & ParsedSetManagerInstruction) | ({ instructionType: typeof SplStakePoolInstruction.SetFee; } & ParsedSetFeeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.SetStaker; } & ParsedSetStakerInstruction) | ({ instructionType: typeof SplStakePoolInstruction.DepositSol; } & ParsedDepositSolInstruction) | ({ instructionType: typeof SplStakePoolInstruction.SetFundingAuthority; } & ParsedSetFundingAuthorityInstruction) | ({ instructionType: typeof SplStakePoolInstruction.WithdrawSol; } & ParsedWithdrawSolInstruction) | ({ instructionType: typeof SplStakePoolInstruction.CreateTokenMetadata; } & ParsedCreateTokenMetadataInstruction) | ({ instructionType: typeof SplStakePoolInstruction.UpdateTokenMetadata; } & ParsedUpdateTokenMetadataInstruction) | ({ instructionType: typeof SplStakePoolInstruction.IncreaseAdditionalValidatorStake; } & ParsedIncreaseAdditionalValidatorStakeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.DecreaseAdditionalValidatorStake; } & ParsedDecreaseAdditionalValidatorStakeInstruction) | ({ instructionType: typeof SplStakePoolInstruction.DecreaseValidatorStakeWithReserve; } & ParsedDecreaseValidatorStakeWithReserveInstruction) | ({ instructionType: typeof SplStakePoolInstruction.Redelegate; } & ParsedRedelegateInstruction) | ({ instructionType: typeof SplStakePoolInstruction.DepositStakeWithSlippage; } & ParsedDepositStakeWithSlippageInstruction) | ({ instructionType: typeof SplStakePoolInstruction.WithdrawStakeWithSlippage; } & ParsedWithdrawStakeWithSlippageInstruction) | ({ instructionType: typeof SplStakePoolInstruction.DepositSolWithSlippage; } & ParsedDepositSolWithSlippageInstruction) | ({ instructionType: typeof SplStakePoolInstruction.WithdrawSolWithSlippage; } & ParsedWithdrawSolWithSlippageInstruction); export function parseSplStakePoolInstruction( instruction: Instruction & InstructionWithData, ): ParsedSplStakePoolInstruction { const instructionType = identifySplStakePoolInstruction(instruction); switch (instructionType) { case SplStakePoolInstruction.Initialize: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.Initialize, ...parseInitializeInstruction(instruction), }; } case SplStakePoolInstruction.AddValidatorToPool: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.AddValidatorToPool, ...parseAddValidatorToPoolInstruction(instruction), }; } case SplStakePoolInstruction.RemoveValidatorFromPool: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.RemoveValidatorFromPool, ...parseRemoveValidatorFromPoolInstruction(instruction), }; } case SplStakePoolInstruction.DecreaseValidatorStake: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.DecreaseValidatorStake, ...parseDecreaseValidatorStakeInstruction(instruction), }; } case SplStakePoolInstruction.IncreaseValidatorStake: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.IncreaseValidatorStake, ...parseIncreaseValidatorStakeInstruction(instruction), }; } case SplStakePoolInstruction.SetPreferredValidator: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.SetPreferredValidator, ...parseSetPreferredValidatorInstruction(instruction), }; } case SplStakePoolInstruction.UpdateValidatorListBalance: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.UpdateValidatorListBalance, ...parseUpdateValidatorListBalanceInstruction(instruction), }; } case SplStakePoolInstruction.UpdateStakePoolBalance: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.UpdateStakePoolBalance, ...parseUpdateStakePoolBalanceInstruction(instruction), }; } case SplStakePoolInstruction.CleanupRemovedValidatorEntries: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.CleanupRemovedValidatorEntries, ...parseCleanupRemovedValidatorEntriesInstruction(instruction), }; } case SplStakePoolInstruction.DepositStake: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.DepositStake, ...parseDepositStakeInstruction(instruction), }; } case SplStakePoolInstruction.WithdrawStake: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.WithdrawStake, ...parseWithdrawStakeInstruction(instruction), }; } case SplStakePoolInstruction.SetManager: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.SetManager, ...parseSetManagerInstruction(instruction), }; } case SplStakePoolInstruction.SetFee: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.SetFee, ...parseSetFeeInstruction(instruction), }; } case SplStakePoolInstruction.SetStaker: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.SetStaker, ...parseSetStakerInstruction(instruction), }; } case SplStakePoolInstruction.DepositSol: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.DepositSol, ...parseDepositSolInstruction(instruction), }; } case SplStakePoolInstruction.SetFundingAuthority: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.SetFundingAuthority, ...parseSetFundingAuthorityInstruction(instruction), }; } case SplStakePoolInstruction.WithdrawSol: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.WithdrawSol, ...parseWithdrawSolInstruction(instruction), }; } case SplStakePoolInstruction.CreateTokenMetadata: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.CreateTokenMetadata, ...parseCreateTokenMetadataInstruction(instruction), }; } case SplStakePoolInstruction.UpdateTokenMetadata: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.UpdateTokenMetadata, ...parseUpdateTokenMetadataInstruction(instruction), }; } case SplStakePoolInstruction.IncreaseAdditionalValidatorStake: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.IncreaseAdditionalValidatorStake, ...parseIncreaseAdditionalValidatorStakeInstruction(instruction), }; } case SplStakePoolInstruction.DecreaseAdditionalValidatorStake: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.DecreaseAdditionalValidatorStake, ...parseDecreaseAdditionalValidatorStakeInstruction(instruction), }; } case SplStakePoolInstruction.DecreaseValidatorStakeWithReserve: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.DecreaseValidatorStakeWithReserve, ...parseDecreaseValidatorStakeWithReserveInstruction(instruction), }; } case SplStakePoolInstruction.Redelegate: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.Redelegate, ...parseRedelegateInstruction(instruction), }; } case SplStakePoolInstruction.DepositStakeWithSlippage: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.DepositStakeWithSlippage, ...parseDepositStakeWithSlippageInstruction(instruction), }; } case SplStakePoolInstruction.WithdrawStakeWithSlippage: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.WithdrawStakeWithSlippage, ...parseWithdrawStakeWithSlippageInstruction(instruction), }; } case SplStakePoolInstruction.DepositSolWithSlippage: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.DepositSolWithSlippage, ...parseDepositSolWithSlippageInstruction(instruction), }; } case SplStakePoolInstruction.WithdrawSolWithSlippage: { assertIsInstructionWithAccounts(instruction); return { instructionType: SplStakePoolInstruction.WithdrawSolWithSlippage, ...parseWithdrawSolWithSlippageInstruction(instruction), }; } default: throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, { instructionType: instructionType as string, programName: "splStakePool", }, ); } } export type SplStakePoolPlugin = { accounts: SplStakePoolPluginAccounts; instructions: SplStakePoolPluginInstructions; pdas: SplStakePoolPluginPdas; identifyAccount: typeof identifySplStakePoolAccount; identifyInstruction: typeof identifySplStakePoolInstruction; parseInstruction: typeof parseSplStakePoolInstruction; }; export type SplStakePoolPluginAccounts = { stakePool: ReturnType & SelfFetchFunctions; validatorList: ReturnType & SelfFetchFunctions; }; export type SplStakePoolPluginInstructions = { initialize: ( input: InitializeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; addValidatorToPool: ( input: AddValidatorToPoolAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; removeValidatorFromPool: ( input: RemoveValidatorFromPoolAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; decreaseValidatorStake: ( input: DecreaseValidatorStakeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; increaseValidatorStake: ( input: IncreaseValidatorStakeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; setPreferredValidator: ( input: SetPreferredValidatorInput, ) => ReturnType & SelfPlanAndSendFunctions; updateValidatorListBalance: ( input: UpdateValidatorListBalanceAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; updateStakePoolBalance: ( input: UpdateStakePoolBalanceAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; cleanupRemovedValidatorEntries: ( input: CleanupRemovedValidatorEntriesInput, ) => ReturnType & SelfPlanAndSendFunctions; depositStake: ( input: DepositStakeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; withdrawStake: ( input: WithdrawStakeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; setManager: ( input: SetManagerInput, ) => ReturnType & SelfPlanAndSendFunctions; setFee: ( input: SetFeeInput, ) => ReturnType & SelfPlanAndSendFunctions; setStaker: ( input: SetStakerInput, ) => ReturnType & SelfPlanAndSendFunctions; depositSol: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; setFundingAuthority: ( input: SetFundingAuthorityInput, ) => ReturnType & SelfPlanAndSendFunctions; withdrawSol: ( input: WithdrawSolAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; createTokenMetadata: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; updateTokenMetadata: ( input: UpdateTokenMetadataAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; increaseAdditionalValidatorStake: ( input: IncreaseAdditionalValidatorStakeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; decreaseAdditionalValidatorStake: ( input: DecreaseAdditionalValidatorStakeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; decreaseValidatorStakeWithReserve: ( input: DecreaseValidatorStakeWithReserveAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; redelegate: ( input: RedelegateAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; depositStakeWithSlippage: ( input: DepositStakeWithSlippageAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; withdrawStakeWithSlippage: ( input: WithdrawStakeWithSlippageAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; depositSolWithSlippage: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; withdrawSolWithSlippage: ( input: WithdrawSolWithSlippageAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; }; export type SplStakePoolPluginPdas = { withdrawAuthority: typeof findWithdrawAuthorityPda; stake: typeof findStakePda; transientStake: typeof findTransientStakePda; ephemeralStake: typeof findEphemeralStakePda; }; export type SplStakePoolPluginRequirements = ClientWithRpc< GetAccountInfoApi & GetMultipleAccountsApi > & ClientWithPayer & ClientWithTransactionPlanning & ClientWithTransactionSending; export function splStakePoolProgram() { return ( client: T, ): ExtendedClient => { return extendClient(client, { splStakePool: { accounts: { stakePool: addSelfFetchFunctions(client, getStakePoolCodec()), validatorList: addSelfFetchFunctions(client, getValidatorListCodec()), }, instructions: { initialize: (input) => addSelfPlanAndSendFunctions( client, getInitializeInstructionAsync(input), ), addValidatorToPool: (input) => addSelfPlanAndSendFunctions( client, getAddValidatorToPoolInstructionAsync(input), ), removeValidatorFromPool: (input) => addSelfPlanAndSendFunctions( client, getRemoveValidatorFromPoolInstructionAsync(input), ), decreaseValidatorStake: (input) => addSelfPlanAndSendFunctions( client, getDecreaseValidatorStakeInstructionAsync(input), ), increaseValidatorStake: (input) => addSelfPlanAndSendFunctions( client, getIncreaseValidatorStakeInstructionAsync(input), ), setPreferredValidator: (input) => addSelfPlanAndSendFunctions( client, getSetPreferredValidatorInstruction(input), ), updateValidatorListBalance: (input) => addSelfPlanAndSendFunctions( client, getUpdateValidatorListBalanceInstructionAsync(input), ), updateStakePoolBalance: (input) => addSelfPlanAndSendFunctions( client, getUpdateStakePoolBalanceInstructionAsync(input), ), cleanupRemovedValidatorEntries: (input) => addSelfPlanAndSendFunctions( client, getCleanupRemovedValidatorEntriesInstruction(input), ), depositStake: (input) => addSelfPlanAndSendFunctions( client, getDepositStakeInstructionAsync(input), ), withdrawStake: (input) => addSelfPlanAndSendFunctions( client, getWithdrawStakeInstructionAsync(input), ), setManager: (input) => addSelfPlanAndSendFunctions( client, getSetManagerInstruction(input), ), setFee: (input) => addSelfPlanAndSendFunctions(client, getSetFeeInstruction(input)), setStaker: (input) => addSelfPlanAndSendFunctions(client, getSetStakerInstruction(input)), depositSol: (input) => addSelfPlanAndSendFunctions( client, getDepositSolInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), setFundingAuthority: (input) => addSelfPlanAndSendFunctions( client, getSetFundingAuthorityInstruction(input), ), withdrawSol: (input) => addSelfPlanAndSendFunctions( client, getWithdrawSolInstructionAsync(input), ), createTokenMetadata: (input) => addSelfPlanAndSendFunctions( client, getCreateTokenMetadataInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), updateTokenMetadata: (input) => addSelfPlanAndSendFunctions( client, getUpdateTokenMetadataInstructionAsync(input), ), increaseAdditionalValidatorStake: (input) => addSelfPlanAndSendFunctions( client, getIncreaseAdditionalValidatorStakeInstructionAsync(input), ), decreaseAdditionalValidatorStake: (input) => addSelfPlanAndSendFunctions( client, getDecreaseAdditionalValidatorStakeInstructionAsync(input), ), decreaseValidatorStakeWithReserve: (input) => addSelfPlanAndSendFunctions( client, getDecreaseValidatorStakeWithReserveInstructionAsync(input), ), redelegate: (input) => addSelfPlanAndSendFunctions( client, getRedelegateInstructionAsync(input), ), depositStakeWithSlippage: (input) => addSelfPlanAndSendFunctions( client, getDepositStakeWithSlippageInstructionAsync(input), ), withdrawStakeWithSlippage: (input) => addSelfPlanAndSendFunctions( client, getWithdrawStakeWithSlippageInstructionAsync(input), ), depositSolWithSlippage: (input) => addSelfPlanAndSendFunctions( client, getDepositSolWithSlippageInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), withdrawSolWithSlippage: (input) => addSelfPlanAndSendFunctions( client, getWithdrawSolWithSlippageInstructionAsync(input), ), }, pdas: { withdrawAuthority: findWithdrawAuthorityPda, stake: findStakePda, transientStake: findTransientStakePda, ephemeralStake: findEphemeralStakePda, }, identifyAccount: identifySplStakePoolAccount, identifyInstruction: identifySplStakePoolInstruction, parseInstruction: parseSplStakePoolInstruction, } as SplStakePoolPlugin, }); }; } type MakeOptional = Omit & Partial>;