/** * 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 type { AccountMeta, Address, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, Instruction, InstructionWithAccounts, InstructionWithData, ReadonlyAccount, ReadonlyUint8Array, WritableAccount, } from "@solana/kit"; import type { ResolvedInstructionAccount } from "@solana/program-client-core"; import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, } from "@solana/kit"; import { getAccountMetaFactory } from "@solana/program-client-core"; import { WHIRLPOOL_PROGRAM_ADDRESS } from "../programs/index.js"; export const UPDATE_FEES_AND_REWARDS_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([154, 230, 250, 13, 236, 209, 75, 223]); export function getUpdateFeesAndRewardsDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( UPDATE_FEES_AND_REWARDS_DISCRIMINATOR, ); } export type UpdateFeesAndRewardsInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountWhirlpool extends string | AccountMeta = string, TAccountPosition extends string | AccountMeta = string, TAccountTickArrayLower extends string | AccountMeta = string, TAccountTickArrayUpper extends string | AccountMeta = string, TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountWhirlpool extends string ? WritableAccount : TAccountWhirlpool, TAccountPosition extends string ? WritableAccount : TAccountPosition, TAccountTickArrayLower extends string ? ReadonlyAccount : TAccountTickArrayLower, TAccountTickArrayUpper extends string ? ReadonlyAccount : TAccountTickArrayUpper, ...TRemainingAccounts, ] >; export interface UpdateFeesAndRewardsInstructionData { discriminator: ReadonlyUint8Array; } export type UpdateFeesAndRewardsInstructionDataArgs = {}; export function getUpdateFeesAndRewardsInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: UPDATE_FEES_AND_REWARDS_DISCRIMINATOR, }), ); } export function getUpdateFeesAndRewardsInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getUpdateFeesAndRewardsInstructionDataCodec(): FixedSizeCodec< UpdateFeesAndRewardsInstructionDataArgs, UpdateFeesAndRewardsInstructionData > { return combineCodec( getUpdateFeesAndRewardsInstructionDataEncoder(), getUpdateFeesAndRewardsInstructionDataDecoder(), ); } export interface UpdateFeesAndRewardsInput< TAccountWhirlpool extends string = string, TAccountPosition extends string = string, TAccountTickArrayLower extends string = string, TAccountTickArrayUpper extends string = string, > { whirlpool: Address; position: Address; tickArrayLower: Address; tickArrayUpper: Address; } export function getUpdateFeesAndRewardsInstruction< TAccountWhirlpool extends string, TAccountPosition extends string, TAccountTickArrayLower extends string, TAccountTickArrayUpper extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: UpdateFeesAndRewardsInput< TAccountWhirlpool, TAccountPosition, TAccountTickArrayLower, TAccountTickArrayUpper >, config?: { programAddress?: TProgramAddress }, ): UpdateFeesAndRewardsInstruction< TProgramAddress, TAccountWhirlpool, TAccountPosition, TAccountTickArrayLower, TAccountTickArrayUpper > { // Program address. const programAddress = config?.programAddress ?? WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpool: { value: input.whirlpool ?? null, isWritable: true }, position: { value: input.position ?? null, isWritable: true }, tickArrayLower: { value: input.tickArrayLower ?? null, isWritable: false }, tickArrayUpper: { value: input.tickArrayUpper ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("whirlpool", accounts.whirlpool), getAccountMeta("position", accounts.position), getAccountMeta("tickArrayLower", accounts.tickArrayLower), getAccountMeta("tickArrayUpper", accounts.tickArrayUpper), ], data: getUpdateFeesAndRewardsInstructionDataEncoder().encode({}), programAddress, } as UpdateFeesAndRewardsInstruction< TProgramAddress, TAccountWhirlpool, TAccountPosition, TAccountTickArrayLower, TAccountTickArrayUpper >); } export interface ParsedUpdateFeesAndRewardsInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { whirlpool: TAccountMetas[0]; position: TAccountMetas[1]; tickArrayLower: TAccountMetas[2]; tickArrayUpper: TAccountMetas[3]; }; data: UpdateFeesAndRewardsInstructionData; } export function parseUpdateFeesAndRewardsInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedUpdateFeesAndRewardsInstruction { if (instruction.accounts.length < 4) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 4, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { whirlpool: getNextAccount(), position: getNextAccount(), tickArrayLower: getNextAccount(), tickArrayUpper: getNextAccount(), }, data: getUpdateFeesAndRewardsInstructionDataDecoder().decode( instruction.data, ), }; }