/** * 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, fixEncoderSize, getBytesEncoder, 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 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 { getAdaptorAddReceiptCodec, getDirectWithdrawInitReceiptCodec, getProtocolCodec, getRequestWithdrawVaultReceiptCodec, getStrategyInitReceiptCodec, getVaultCodec, type AdaptorAddReceipt, type AdaptorAddReceiptArgs, type DirectWithdrawInitReceipt, type DirectWithdrawInitReceiptArgs, type Protocol, type ProtocolArgs, type RequestWithdrawVaultReceipt, type RequestWithdrawVaultReceiptArgs, type StrategyInitReceipt, type StrategyInitReceiptArgs, type Vault, type VaultArgs, } from "../accounts"; import { getAcceptProtocolAdminInstructionAsync, getAcceptVaultAdminInstruction, getAddAdaptorInstructionAsync, getCalibrateHighWaterMarkInstructionAsync, getCalibrateHighWaterMarkUnsafeInstructionAsync, getCancelRequestWithdrawVaultInstructionAsync, getCloseStrategyInstructionAsync, getCreateLpMetadataInstructionAsync, getDepositStrategyInstructionAsync, getDepositVaultInstructionAsync, getDirectWithdrawStrategyInstructionAsync, getDirectWithdrawStrategyWithToleranceInstructionAsync, getHarvestFeeInstructionAsync, getInitializeDirectWithdrawStrategyInstructionAsync, getInitializeStrategyInstructionAsync, getInitializeVaultInstructionAsync, getInitProtocolInstructionAsync, getInstantWithdrawStrategyInstructionAsync, getInstantWithdrawStrategyWithToleranceInstructionAsync, getInstantWithdrawVaultInstructionAsync, getRemoveAdaptorInstructionAsync, getRequestWithdrawVaultInstructionAsync, getUpdateProtocolInstructionAsync, getUpdateVaultAdaptorPolicyInstructionAsync, getUpdateVaultConfigInstructionAsync, getUpdateVaultProtocolFeeInstructionAsync, getWithdrawStrategyInstructionAsync, getWithdrawVaultInstructionAsync, parseAcceptProtocolAdminInstruction, parseAcceptVaultAdminInstruction, parseAddAdaptorInstruction, parseCalibrateHighWaterMarkInstruction, parseCalibrateHighWaterMarkUnsafeInstruction, parseCancelRequestWithdrawVaultInstruction, parseCloseStrategyInstruction, parseCreateLpMetadataInstruction, parseDepositStrategyInstruction, parseDepositVaultInstruction, parseDirectWithdrawStrategyInstruction, parseDirectWithdrawStrategyWithToleranceInstruction, parseHarvestFeeInstruction, parseInitializeDirectWithdrawStrategyInstruction, parseInitializeStrategyInstruction, parseInitializeVaultInstruction, parseInitProtocolInstruction, parseInstantWithdrawStrategyInstruction, parseInstantWithdrawStrategyWithToleranceInstruction, parseInstantWithdrawVaultInstruction, parseRemoveAdaptorInstruction, parseRequestWithdrawVaultInstruction, parseUpdateProtocolInstruction, parseUpdateVaultAdaptorPolicyInstruction, parseUpdateVaultConfigInstruction, parseUpdateVaultProtocolFeeInstruction, parseWithdrawStrategyInstruction, parseWithdrawVaultInstruction, type AcceptProtocolAdminAsyncInput, type AcceptVaultAdminInput, type AddAdaptorAsyncInput, type CalibrateHighWaterMarkAsyncInput, type CalibrateHighWaterMarkUnsafeAsyncInput, type CancelRequestWithdrawVaultAsyncInput, type CloseStrategyAsyncInput, type CreateLpMetadataAsyncInput, type DepositStrategyAsyncInput, type DepositVaultAsyncInput, type DirectWithdrawStrategyAsyncInput, type DirectWithdrawStrategyWithToleranceAsyncInput, type HarvestFeeAsyncInput, type InitializeDirectWithdrawStrategyAsyncInput, type InitializeStrategyAsyncInput, type InitializeVaultAsyncInput, type InitProtocolAsyncInput, type InstantWithdrawStrategyAsyncInput, type InstantWithdrawStrategyWithToleranceAsyncInput, type InstantWithdrawVaultAsyncInput, type ParsedAcceptProtocolAdminInstruction, type ParsedAcceptVaultAdminInstruction, type ParsedAddAdaptorInstruction, type ParsedCalibrateHighWaterMarkInstruction, type ParsedCalibrateHighWaterMarkUnsafeInstruction, type ParsedCancelRequestWithdrawVaultInstruction, type ParsedCloseStrategyInstruction, type ParsedCreateLpMetadataInstruction, type ParsedDepositStrategyInstruction, type ParsedDepositVaultInstruction, type ParsedDirectWithdrawStrategyInstruction, type ParsedDirectWithdrawStrategyWithToleranceInstruction, type ParsedHarvestFeeInstruction, type ParsedInitializeDirectWithdrawStrategyInstruction, type ParsedInitializeStrategyInstruction, type ParsedInitializeVaultInstruction, type ParsedInitProtocolInstruction, type ParsedInstantWithdrawStrategyInstruction, type ParsedInstantWithdrawStrategyWithToleranceInstruction, type ParsedInstantWithdrawVaultInstruction, type ParsedRemoveAdaptorInstruction, type ParsedRequestWithdrawVaultInstruction, type ParsedUpdateProtocolInstruction, type ParsedUpdateVaultAdaptorPolicyInstruction, type ParsedUpdateVaultConfigInstruction, type ParsedUpdateVaultProtocolFeeInstruction, type ParsedWithdrawStrategyInstruction, type ParsedWithdrawVaultInstruction, type RemoveAdaptorAsyncInput, type RequestWithdrawVaultAsyncInput, type UpdateProtocolAsyncInput, type UpdateVaultAdaptorPolicyAsyncInput, type UpdateVaultConfigAsyncInput, type UpdateVaultProtocolFeeAsyncInput, type WithdrawStrategyAsyncInput, type WithdrawVaultAsyncInput, } from "../instructions"; import { findAdaptorAddReceiptPda, findDirectWithdrawInitReceiptPda, findProtocolPda, findRequestWithdrawVaultReceiptPda, findStrategyInitReceiptPda, findVaultAssetIdleAuthPda, findVaultLpMintAuthPda, findVaultLpMintPda, findVaultStrategyAuthPda, } from "../pdas"; export const VOLTR_VAULT_PROGRAM_ADDRESS = "vVoLTRjQmtFpiYoegx285Ze4gsLJ8ZxgFKVcuvmG1a8" as Address<"vVoLTRjQmtFpiYoegx285Ze4gsLJ8ZxgFKVcuvmG1a8">; export enum VoltrVaultAccount { AdaptorAddReceipt, DirectWithdrawInitReceipt, Protocol, RequestWithdrawVaultReceipt, StrategyInitReceipt, Vault, } export function identifyVoltrVaultAccount( account: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): VoltrVaultAccount { const data = "data" in account ? account.data : account; if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([105, 99, 219, 155, 77, 241, 7, 119]), ), 0, ) ) { return VoltrVaultAccount.AdaptorAddReceipt; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([206, 77, 207, 208, 25, 244, 81, 172]), ), 0, ) ) { return VoltrVaultAccount.DirectWithdrawInitReceipt; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([45, 39, 101, 43, 115, 72, 131, 40]), ), 0, ) ) { return VoltrVaultAccount.Protocol; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([203, 81, 223, 141, 175, 108, 101, 114]), ), 0, ) ) { return VoltrVaultAccount.RequestWithdrawVaultReceipt; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([51, 8, 192, 253, 115, 78, 112, 214]), ), 0, ) ) { return VoltrVaultAccount.StrategyInitReceipt; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([211, 8, 232, 43, 2, 152, 117, 119]), ), 0, ) ) { return VoltrVaultAccount.Vault; } throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT, { accountData: data, programName: "voltrVault" }, ); } export enum VoltrVaultInstruction { AcceptProtocolAdmin, AcceptVaultAdmin, AddAdaptor, CalibrateHighWaterMark, CalibrateHighWaterMarkUnsafe, CancelRequestWithdrawVault, CloseStrategy, CreateLpMetadata, DepositStrategy, DepositVault, DirectWithdrawStrategy, DirectWithdrawStrategyWithTolerance, HarvestFee, InitProtocol, InitializeDirectWithdrawStrategy, InitializeStrategy, InitializeVault, InstantWithdrawStrategy, InstantWithdrawStrategyWithTolerance, InstantWithdrawVault, RemoveAdaptor, RequestWithdrawVault, UpdateProtocol, UpdateVaultAdaptorPolicy, UpdateVaultConfig, UpdateVaultProtocolFee, WithdrawStrategy, WithdrawVault, } export function identifyVoltrVaultInstruction( instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array, ): VoltrVaultInstruction { const data = "data" in instruction ? instruction.data : instruction; if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([76, 35, 211, 183, 82, 72, 131, 36]), ), 0, ) ) { return VoltrVaultInstruction.AcceptProtocolAdmin; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([214, 137, 204, 56, 78, 214, 90, 125]), ), 0, ) ) { return VoltrVaultInstruction.AcceptVaultAdmin; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([161, 145, 203, 248, 211, 202, 203, 67]), ), 0, ) ) { return VoltrVaultInstruction.AddAdaptor; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([178, 116, 38, 9, 23, 20, 91, 154]), ), 0, ) ) { return VoltrVaultInstruction.CalibrateHighWaterMark; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([162, 16, 96, 202, 178, 8, 187, 235]), ), 0, ) ) { return VoltrVaultInstruction.CalibrateHighWaterMarkUnsafe; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([231, 54, 14, 6, 223, 124, 127, 238]), ), 0, ) ) { return VoltrVaultInstruction.CancelRequestWithdrawVault; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([56, 247, 170, 246, 89, 221, 134, 200]), ), 0, ) ) { return VoltrVaultInstruction.CloseStrategy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([148, 193, 160, 116, 87, 25, 123, 103]), ), 0, ) ) { return VoltrVaultInstruction.CreateLpMetadata; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([246, 82, 57, 226, 131, 222, 253, 249]), ), 0, ) ) { return VoltrVaultInstruction.DepositStrategy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([126, 224, 21, 255, 228, 53, 117, 33]), ), 0, ) ) { return VoltrVaultInstruction.DepositVault; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([119, 33, 54, 52, 194, 8, 211, 239]), ), 0, ) ) { return VoltrVaultInstruction.DirectWithdrawStrategy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([207, 51, 234, 8, 76, 164, 10, 250]), ), 0, ) ) { return VoltrVaultInstruction.DirectWithdrawStrategyWithTolerance; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([32, 59, 42, 128, 246, 73, 255, 47]), ), 0, ) ) { return VoltrVaultInstruction.HarvestFee; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([3, 188, 141, 237, 225, 226, 232, 210]), ), 0, ) ) { return VoltrVaultInstruction.InitProtocol; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([248, 207, 228, 15, 13, 191, 43, 58]), ), 0, ) ) { return VoltrVaultInstruction.InitializeDirectWithdrawStrategy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([208, 119, 144, 145, 178, 57, 105, 252]), ), 0, ) ) { return VoltrVaultInstruction.InitializeStrategy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([48, 191, 163, 44, 71, 129, 63, 164]), ), 0, ) ) { return VoltrVaultInstruction.InitializeVault; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([105, 57, 166, 130, 147, 221, 250, 189]), ), 0, ) ) { return VoltrVaultInstruction.InstantWithdrawStrategy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([91, 21, 70, 163, 84, 67, 106, 181]), ), 0, ) ) { return VoltrVaultInstruction.InstantWithdrawStrategyWithTolerance; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([221, 56, 115, 168, 128, 220, 235, 245]), ), 0, ) ) { return VoltrVaultInstruction.InstantWithdrawVault; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([161, 199, 99, 22, 25, 193, 61, 193]), ), 0, ) ) { return VoltrVaultInstruction.RemoveAdaptor; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([248, 225, 47, 22, 116, 144, 23, 143]), ), 0, ) ) { return VoltrVaultInstruction.RequestWithdrawVault; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([206, 25, 218, 114, 109, 41, 74, 173]), ), 0, ) ) { return VoltrVaultInstruction.UpdateProtocol; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([20, 101, 232, 123, 189, 18, 133, 230]), ), 0, ) ) { return VoltrVaultInstruction.UpdateVaultAdaptorPolicy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([122, 3, 21, 222, 158, 255, 238, 157]), ), 0, ) ) { return VoltrVaultInstruction.UpdateVaultConfig; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([62, 83, 22, 192, 137, 86, 74, 18]), ), 0, ) ) { return VoltrVaultInstruction.UpdateVaultProtocolFee; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([31, 45, 162, 5, 193, 217, 134, 188]), ), 0, ) ) { return VoltrVaultInstruction.WithdrawStrategy; } if ( containsBytes( data, fixEncoderSize(getBytesEncoder(), 8).encode( new Uint8Array([135, 7, 237, 120, 149, 94, 95, 7]), ), 0, ) ) { return VoltrVaultInstruction.WithdrawVault; } throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION, { instructionData: data, programName: "voltrVault" }, ); } export type ParsedVoltrVaultInstruction< TProgram extends string = "vVoLTRjQmtFpiYoegx285Ze4gsLJ8ZxgFKVcuvmG1a8", > = | ({ instructionType: VoltrVaultInstruction.AcceptProtocolAdmin; } & ParsedAcceptProtocolAdminInstruction) | ({ instructionType: VoltrVaultInstruction.AcceptVaultAdmin; } & ParsedAcceptVaultAdminInstruction) | ({ instructionType: VoltrVaultInstruction.AddAdaptor; } & ParsedAddAdaptorInstruction) | ({ instructionType: VoltrVaultInstruction.CalibrateHighWaterMark; } & ParsedCalibrateHighWaterMarkInstruction) | ({ instructionType: VoltrVaultInstruction.CalibrateHighWaterMarkUnsafe; } & ParsedCalibrateHighWaterMarkUnsafeInstruction) | ({ instructionType: VoltrVaultInstruction.CancelRequestWithdrawVault; } & ParsedCancelRequestWithdrawVaultInstruction) | ({ instructionType: VoltrVaultInstruction.CloseStrategy; } & ParsedCloseStrategyInstruction) | ({ instructionType: VoltrVaultInstruction.CreateLpMetadata; } & ParsedCreateLpMetadataInstruction) | ({ instructionType: VoltrVaultInstruction.DepositStrategy; } & ParsedDepositStrategyInstruction) | ({ instructionType: VoltrVaultInstruction.DepositVault; } & ParsedDepositVaultInstruction) | ({ instructionType: VoltrVaultInstruction.DirectWithdrawStrategy; } & ParsedDirectWithdrawStrategyInstruction) | ({ instructionType: VoltrVaultInstruction.DirectWithdrawStrategyWithTolerance; } & ParsedDirectWithdrawStrategyWithToleranceInstruction) | ({ instructionType: VoltrVaultInstruction.HarvestFee; } & ParsedHarvestFeeInstruction) | ({ instructionType: VoltrVaultInstruction.InitProtocol; } & ParsedInitProtocolInstruction) | ({ instructionType: VoltrVaultInstruction.InitializeDirectWithdrawStrategy; } & ParsedInitializeDirectWithdrawStrategyInstruction) | ({ instructionType: VoltrVaultInstruction.InitializeStrategy; } & ParsedInitializeStrategyInstruction) | ({ instructionType: VoltrVaultInstruction.InitializeVault; } & ParsedInitializeVaultInstruction) | ({ instructionType: VoltrVaultInstruction.InstantWithdrawStrategy; } & ParsedInstantWithdrawStrategyInstruction) | ({ instructionType: VoltrVaultInstruction.InstantWithdrawStrategyWithTolerance; } & ParsedInstantWithdrawStrategyWithToleranceInstruction) | ({ instructionType: VoltrVaultInstruction.InstantWithdrawVault; } & ParsedInstantWithdrawVaultInstruction) | ({ instructionType: VoltrVaultInstruction.RemoveAdaptor; } & ParsedRemoveAdaptorInstruction) | ({ instructionType: VoltrVaultInstruction.RequestWithdrawVault; } & ParsedRequestWithdrawVaultInstruction) | ({ instructionType: VoltrVaultInstruction.UpdateProtocol; } & ParsedUpdateProtocolInstruction) | ({ instructionType: VoltrVaultInstruction.UpdateVaultAdaptorPolicy; } & ParsedUpdateVaultAdaptorPolicyInstruction) | ({ instructionType: VoltrVaultInstruction.UpdateVaultConfig; } & ParsedUpdateVaultConfigInstruction) | ({ instructionType: VoltrVaultInstruction.UpdateVaultProtocolFee; } & ParsedUpdateVaultProtocolFeeInstruction) | ({ instructionType: VoltrVaultInstruction.WithdrawStrategy; } & ParsedWithdrawStrategyInstruction) | ({ instructionType: VoltrVaultInstruction.WithdrawVault; } & ParsedWithdrawVaultInstruction); export function parseVoltrVaultInstruction( instruction: Instruction & InstructionWithData, ): ParsedVoltrVaultInstruction { const instructionType = identifyVoltrVaultInstruction(instruction); switch (instructionType) { case VoltrVaultInstruction.AcceptProtocolAdmin: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.AcceptProtocolAdmin, ...parseAcceptProtocolAdminInstruction(instruction), }; } case VoltrVaultInstruction.AcceptVaultAdmin: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.AcceptVaultAdmin, ...parseAcceptVaultAdminInstruction(instruction), }; } case VoltrVaultInstruction.AddAdaptor: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.AddAdaptor, ...parseAddAdaptorInstruction(instruction), }; } case VoltrVaultInstruction.CalibrateHighWaterMark: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.CalibrateHighWaterMark, ...parseCalibrateHighWaterMarkInstruction(instruction), }; } case VoltrVaultInstruction.CalibrateHighWaterMarkUnsafe: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.CalibrateHighWaterMarkUnsafe, ...parseCalibrateHighWaterMarkUnsafeInstruction(instruction), }; } case VoltrVaultInstruction.CancelRequestWithdrawVault: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.CancelRequestWithdrawVault, ...parseCancelRequestWithdrawVaultInstruction(instruction), }; } case VoltrVaultInstruction.CloseStrategy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.CloseStrategy, ...parseCloseStrategyInstruction(instruction), }; } case VoltrVaultInstruction.CreateLpMetadata: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.CreateLpMetadata, ...parseCreateLpMetadataInstruction(instruction), }; } case VoltrVaultInstruction.DepositStrategy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.DepositStrategy, ...parseDepositStrategyInstruction(instruction), }; } case VoltrVaultInstruction.DepositVault: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.DepositVault, ...parseDepositVaultInstruction(instruction), }; } case VoltrVaultInstruction.DirectWithdrawStrategy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.DirectWithdrawStrategy, ...parseDirectWithdrawStrategyInstruction(instruction), }; } case VoltrVaultInstruction.DirectWithdrawStrategyWithTolerance: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.DirectWithdrawStrategyWithTolerance, ...parseDirectWithdrawStrategyWithToleranceInstruction(instruction), }; } case VoltrVaultInstruction.HarvestFee: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.HarvestFee, ...parseHarvestFeeInstruction(instruction), }; } case VoltrVaultInstruction.InitProtocol: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.InitProtocol, ...parseInitProtocolInstruction(instruction), }; } case VoltrVaultInstruction.InitializeDirectWithdrawStrategy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.InitializeDirectWithdrawStrategy, ...parseInitializeDirectWithdrawStrategyInstruction(instruction), }; } case VoltrVaultInstruction.InitializeStrategy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.InitializeStrategy, ...parseInitializeStrategyInstruction(instruction), }; } case VoltrVaultInstruction.InitializeVault: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.InitializeVault, ...parseInitializeVaultInstruction(instruction), }; } case VoltrVaultInstruction.InstantWithdrawStrategy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.InstantWithdrawStrategy, ...parseInstantWithdrawStrategyInstruction(instruction), }; } case VoltrVaultInstruction.InstantWithdrawStrategyWithTolerance: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.InstantWithdrawStrategyWithTolerance, ...parseInstantWithdrawStrategyWithToleranceInstruction(instruction), }; } case VoltrVaultInstruction.InstantWithdrawVault: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.InstantWithdrawVault, ...parseInstantWithdrawVaultInstruction(instruction), }; } case VoltrVaultInstruction.RemoveAdaptor: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.RemoveAdaptor, ...parseRemoveAdaptorInstruction(instruction), }; } case VoltrVaultInstruction.RequestWithdrawVault: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.RequestWithdrawVault, ...parseRequestWithdrawVaultInstruction(instruction), }; } case VoltrVaultInstruction.UpdateProtocol: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.UpdateProtocol, ...parseUpdateProtocolInstruction(instruction), }; } case VoltrVaultInstruction.UpdateVaultAdaptorPolicy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.UpdateVaultAdaptorPolicy, ...parseUpdateVaultAdaptorPolicyInstruction(instruction), }; } case VoltrVaultInstruction.UpdateVaultConfig: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.UpdateVaultConfig, ...parseUpdateVaultConfigInstruction(instruction), }; } case VoltrVaultInstruction.UpdateVaultProtocolFee: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.UpdateVaultProtocolFee, ...parseUpdateVaultProtocolFeeInstruction(instruction), }; } case VoltrVaultInstruction.WithdrawStrategy: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.WithdrawStrategy, ...parseWithdrawStrategyInstruction(instruction), }; } case VoltrVaultInstruction.WithdrawVault: { assertIsInstructionWithAccounts(instruction); return { instructionType: VoltrVaultInstruction.WithdrawVault, ...parseWithdrawVaultInstruction(instruction), }; } default: throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE, { instructionType: instructionType as string, programName: "voltrVault", }, ); } } export type VoltrVaultPlugin = { accounts: VoltrVaultPluginAccounts; instructions: VoltrVaultPluginInstructions; pdas: VoltrVaultPluginPdas; }; export type VoltrVaultPluginAccounts = { adaptorAddReceipt: ReturnType & SelfFetchFunctions; directWithdrawInitReceipt: ReturnType< typeof getDirectWithdrawInitReceiptCodec > & SelfFetchFunctions< DirectWithdrawInitReceiptArgs, DirectWithdrawInitReceipt >; protocol: ReturnType & SelfFetchFunctions; requestWithdrawVaultReceipt: ReturnType< typeof getRequestWithdrawVaultReceiptCodec > & SelfFetchFunctions< RequestWithdrawVaultReceiptArgs, RequestWithdrawVaultReceipt >; strategyInitReceipt: ReturnType & SelfFetchFunctions; vault: ReturnType & SelfFetchFunctions; }; export type VoltrVaultPluginInstructions = { acceptProtocolAdmin: ( input: AcceptProtocolAdminAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; acceptVaultAdmin: ( input: AcceptVaultAdminInput, ) => ReturnType & SelfPlanAndSendFunctions; addAdaptor: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; calibrateHighWaterMark: ( input: CalibrateHighWaterMarkAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; calibrateHighWaterMarkUnsafe: ( input: CalibrateHighWaterMarkUnsafeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; cancelRequestWithdrawVault: ( input: CancelRequestWithdrawVaultAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; closeStrategy: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; createLpMetadata: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; depositStrategy: ( input: DepositStrategyAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; depositVault: ( input: DepositVaultAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; directWithdrawStrategy: ( input: DirectWithdrawStrategyAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; directWithdrawStrategyWithTolerance: ( input: DirectWithdrawStrategyWithToleranceAsyncInput, ) => ReturnType< typeof getDirectWithdrawStrategyWithToleranceInstructionAsync > & SelfPlanAndSendFunctions; harvestFee: ( input: HarvestFeeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; initProtocol: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; initializeDirectWithdrawStrategy: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; initializeStrategy: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; initializeVault: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; instantWithdrawStrategy: ( input: InstantWithdrawStrategyAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; instantWithdrawStrategyWithTolerance: ( input: InstantWithdrawStrategyWithToleranceAsyncInput, ) => ReturnType< typeof getInstantWithdrawStrategyWithToleranceInstructionAsync > & SelfPlanAndSendFunctions; instantWithdrawVault: ( input: InstantWithdrawVaultAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; removeAdaptor: ( input: RemoveAdaptorAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; requestWithdrawVault: ( input: MakeOptional, ) => ReturnType & SelfPlanAndSendFunctions; updateProtocol: ( input: UpdateProtocolAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; updateVaultAdaptorPolicy: ( input: UpdateVaultAdaptorPolicyAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; updateVaultConfig: ( input: UpdateVaultConfigAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; updateVaultProtocolFee: ( input: UpdateVaultProtocolFeeAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; withdrawStrategy: ( input: WithdrawStrategyAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; withdrawVault: ( input: WithdrawVaultAsyncInput, ) => ReturnType & SelfPlanAndSendFunctions; }; export type VoltrVaultPluginPdas = { protocol: typeof findProtocolPda; adaptorAddReceipt: typeof findAdaptorAddReceiptPda; vaultLpMint: typeof findVaultLpMintPda; requestWithdrawVaultReceipt: typeof findRequestWithdrawVaultReceiptPda; strategyInitReceipt: typeof findStrategyInitReceiptPda; vaultLpMintAuth: typeof findVaultLpMintAuthPda; vaultAssetIdleAuth: typeof findVaultAssetIdleAuthPda; vaultStrategyAuth: typeof findVaultStrategyAuthPda; directWithdrawInitReceipt: typeof findDirectWithdrawInitReceiptPda; }; export type VoltrVaultPluginRequirements = ClientWithRpc< GetAccountInfoApi & GetMultipleAccountsApi > & ClientWithPayer & ClientWithTransactionPlanning & ClientWithTransactionSending; export function voltrVaultProgram() { return (client: T) => { return { ...client, voltrVault: { accounts: { adaptorAddReceipt: addSelfFetchFunctions( client, getAdaptorAddReceiptCodec(), ), directWithdrawInitReceipt: addSelfFetchFunctions( client, getDirectWithdrawInitReceiptCodec(), ), protocol: addSelfFetchFunctions(client, getProtocolCodec()), requestWithdrawVaultReceipt: addSelfFetchFunctions( client, getRequestWithdrawVaultReceiptCodec(), ), strategyInitReceipt: addSelfFetchFunctions( client, getStrategyInitReceiptCodec(), ), vault: addSelfFetchFunctions(client, getVaultCodec()), }, instructions: { acceptProtocolAdmin: (input) => addSelfPlanAndSendFunctions( client, getAcceptProtocolAdminInstructionAsync(input), ), acceptVaultAdmin: (input) => addSelfPlanAndSendFunctions( client, getAcceptVaultAdminInstruction(input), ), addAdaptor: (input) => addSelfPlanAndSendFunctions( client, getAddAdaptorInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), calibrateHighWaterMark: (input) => addSelfPlanAndSendFunctions( client, getCalibrateHighWaterMarkInstructionAsync(input), ), calibrateHighWaterMarkUnsafe: (input) => addSelfPlanAndSendFunctions( client, getCalibrateHighWaterMarkUnsafeInstructionAsync(input), ), cancelRequestWithdrawVault: (input) => addSelfPlanAndSendFunctions( client, getCancelRequestWithdrawVaultInstructionAsync(input), ), closeStrategy: (input) => addSelfPlanAndSendFunctions( client, getCloseStrategyInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), createLpMetadata: (input) => addSelfPlanAndSendFunctions( client, getCreateLpMetadataInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), depositStrategy: (input) => addSelfPlanAndSendFunctions( client, getDepositStrategyInstructionAsync(input), ), depositVault: (input) => addSelfPlanAndSendFunctions( client, getDepositVaultInstructionAsync(input), ), directWithdrawStrategy: (input) => addSelfPlanAndSendFunctions( client, getDirectWithdrawStrategyInstructionAsync(input), ), directWithdrawStrategyWithTolerance: (input) => addSelfPlanAndSendFunctions( client, getDirectWithdrawStrategyWithToleranceInstructionAsync(input), ), harvestFee: (input) => addSelfPlanAndSendFunctions( client, getHarvestFeeInstructionAsync(input), ), initProtocol: (input) => addSelfPlanAndSendFunctions( client, getInitProtocolInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), initializeDirectWithdrawStrategy: (input) => addSelfPlanAndSendFunctions( client, getInitializeDirectWithdrawStrategyInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), initializeStrategy: (input) => addSelfPlanAndSendFunctions( client, getInitializeStrategyInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), initializeVault: (input) => addSelfPlanAndSendFunctions( client, getInitializeVaultInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), instantWithdrawStrategy: (input) => addSelfPlanAndSendFunctions( client, getInstantWithdrawStrategyInstructionAsync(input), ), instantWithdrawStrategyWithTolerance: (input) => addSelfPlanAndSendFunctions( client, getInstantWithdrawStrategyWithToleranceInstructionAsync(input), ), instantWithdrawVault: (input) => addSelfPlanAndSendFunctions( client, getInstantWithdrawVaultInstructionAsync(input), ), removeAdaptor: (input) => addSelfPlanAndSendFunctions( client, getRemoveAdaptorInstructionAsync(input), ), requestWithdrawVault: (input) => addSelfPlanAndSendFunctions( client, getRequestWithdrawVaultInstructionAsync({ ...input, payer: input.payer ?? client.payer, }), ), updateProtocol: (input) => addSelfPlanAndSendFunctions( client, getUpdateProtocolInstructionAsync(input), ), updateVaultAdaptorPolicy: (input) => addSelfPlanAndSendFunctions( client, getUpdateVaultAdaptorPolicyInstructionAsync(input), ), updateVaultConfig: (input) => addSelfPlanAndSendFunctions( client, getUpdateVaultConfigInstructionAsync(input), ), updateVaultProtocolFee: (input) => addSelfPlanAndSendFunctions( client, getUpdateVaultProtocolFeeInstructionAsync(input), ), withdrawStrategy: (input) => addSelfPlanAndSendFunctions( client, getWithdrawStrategyInstructionAsync(input), ), withdrawVault: (input) => addSelfPlanAndSendFunctions( client, getWithdrawVaultInstructionAsync(input), ), }, pdas: { protocol: findProtocolPda, adaptorAddReceipt: findAdaptorAddReceiptPda, vaultLpMint: findVaultLpMintPda, requestWithdrawVaultReceipt: findRequestWithdrawVaultReceiptPda, strategyInitReceipt: findStrategyInitReceiptPda, vaultLpMintAuth: findVaultLpMintAuthPda, vaultAssetIdleAuth: findVaultAssetIdleAuthPda, vaultStrategyAuth: findVaultStrategyAuthPda, directWithdrawInitReceipt: findDirectWithdrawInitReceiptPda, }, }, }; }; } type MakeOptional = Omit & Partial>;