/** * 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, AccountSignerMeta, Address, FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder, Instruction, InstructionWithAccounts, InstructionWithData, ReadonlyAccount, ReadonlySignerAccount, ReadonlyUint8Array, TransactionSigner, 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 COLLECT_FEES_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([ 164, 152, 207, 99, 30, 186, 19, 182, ]); export function getCollectFeesDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( COLLECT_FEES_DISCRIMINATOR, ); } export type CollectFeesInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountWhirlpool extends string | AccountMeta = string, TAccountPositionAuthority extends string | AccountMeta = string, TAccountPosition extends string | AccountMeta = string, TAccountPositionTokenAccount extends string | AccountMeta = string, TAccountTokenOwnerAccountA extends string | AccountMeta = string, TAccountTokenVaultA extends string | AccountMeta = string, TAccountTokenOwnerAccountB extends string | AccountMeta = string, TAccountTokenVaultB extends string | AccountMeta = string, TAccountTokenProgram extends | string | AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountWhirlpool extends string ? ReadonlyAccount : TAccountWhirlpool, TAccountPositionAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountPositionAuthority, TAccountPosition extends string ? WritableAccount : TAccountPosition, TAccountPositionTokenAccount extends string ? ReadonlyAccount : TAccountPositionTokenAccount, TAccountTokenOwnerAccountA extends string ? WritableAccount : TAccountTokenOwnerAccountA, TAccountTokenVaultA extends string ? WritableAccount : TAccountTokenVaultA, TAccountTokenOwnerAccountB extends string ? WritableAccount : TAccountTokenOwnerAccountB, TAccountTokenVaultB extends string ? WritableAccount : TAccountTokenVaultB, TAccountTokenProgram extends string ? ReadonlyAccount : TAccountTokenProgram, ...TRemainingAccounts, ] >; export interface CollectFeesInstructionData { discriminator: ReadonlyUint8Array; } export type CollectFeesInstructionDataArgs = {}; export function getCollectFeesInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: COLLECT_FEES_DISCRIMINATOR }), ); } export function getCollectFeesInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ]); } export function getCollectFeesInstructionDataCodec(): FixedSizeCodec< CollectFeesInstructionDataArgs, CollectFeesInstructionData > { return combineCodec( getCollectFeesInstructionDataEncoder(), getCollectFeesInstructionDataDecoder(), ); } export interface CollectFeesInput< TAccountWhirlpool extends string = string, TAccountPositionAuthority extends string = string, TAccountPosition extends string = string, TAccountPositionTokenAccount extends string = string, TAccountTokenOwnerAccountA extends string = string, TAccountTokenVaultA extends string = string, TAccountTokenOwnerAccountB extends string = string, TAccountTokenVaultB extends string = string, TAccountTokenProgram extends string = string, > { whirlpool: Address; positionAuthority: TransactionSigner; position: Address; positionTokenAccount: Address; tokenOwnerAccountA: Address; tokenVaultA: Address; tokenOwnerAccountB: Address; tokenVaultB: Address; tokenProgram?: Address; } export function getCollectFeesInstruction< TAccountWhirlpool extends string, TAccountPositionAuthority extends string, TAccountPosition extends string, TAccountPositionTokenAccount extends string, TAccountTokenOwnerAccountA extends string, TAccountTokenVaultA extends string, TAccountTokenOwnerAccountB extends string, TAccountTokenVaultB extends string, TAccountTokenProgram extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: CollectFeesInput< TAccountWhirlpool, TAccountPositionAuthority, TAccountPosition, TAccountPositionTokenAccount, TAccountTokenOwnerAccountA, TAccountTokenVaultA, TAccountTokenOwnerAccountB, TAccountTokenVaultB, TAccountTokenProgram >, config?: { programAddress?: TProgramAddress }, ): CollectFeesInstruction< TProgramAddress, TAccountWhirlpool, TAccountPositionAuthority, TAccountPosition, TAccountPositionTokenAccount, TAccountTokenOwnerAccountA, TAccountTokenVaultA, TAccountTokenOwnerAccountB, TAccountTokenVaultB, TAccountTokenProgram > { // Program address. const programAddress = config?.programAddress ?? WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { whirlpool: { value: input.whirlpool ?? null, isWritable: false }, positionAuthority: { value: input.positionAuthority ?? null, isWritable: false, }, position: { value: input.position ?? null, isWritable: true }, positionTokenAccount: { value: input.positionTokenAccount ?? null, isWritable: false, }, tokenOwnerAccountA: { value: input.tokenOwnerAccountA ?? null, isWritable: true, }, tokenVaultA: { value: input.tokenVaultA ?? null, isWritable: true }, tokenOwnerAccountB: { value: input.tokenOwnerAccountB ?? null, isWritable: true, }, tokenVaultB: { value: input.tokenVaultB ?? null, isWritable: true }, tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Resolve default values. if (!accounts.tokenProgram.value) { accounts.tokenProgram.value = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("whirlpool", accounts.whirlpool), getAccountMeta("positionAuthority", accounts.positionAuthority), getAccountMeta("position", accounts.position), getAccountMeta("positionTokenAccount", accounts.positionTokenAccount), getAccountMeta("tokenOwnerAccountA", accounts.tokenOwnerAccountA), getAccountMeta("tokenVaultA", accounts.tokenVaultA), getAccountMeta("tokenOwnerAccountB", accounts.tokenOwnerAccountB), getAccountMeta("tokenVaultB", accounts.tokenVaultB), getAccountMeta("tokenProgram", accounts.tokenProgram), ], data: getCollectFeesInstructionDataEncoder().encode({}), programAddress, } as CollectFeesInstruction< TProgramAddress, TAccountWhirlpool, TAccountPositionAuthority, TAccountPosition, TAccountPositionTokenAccount, TAccountTokenOwnerAccountA, TAccountTokenVaultA, TAccountTokenOwnerAccountB, TAccountTokenVaultB, TAccountTokenProgram >); } export interface ParsedCollectFeesInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { whirlpool: TAccountMetas[0]; positionAuthority: TAccountMetas[1]; position: TAccountMetas[2]; positionTokenAccount: TAccountMetas[3]; tokenOwnerAccountA: TAccountMetas[4]; tokenVaultA: TAccountMetas[5]; tokenOwnerAccountB: TAccountMetas[6]; tokenVaultB: TAccountMetas[7]; tokenProgram: TAccountMetas[8]; }; data: CollectFeesInstructionData; } export function parseCollectFeesInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedCollectFeesInstruction { if (instruction.accounts.length < 9) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 9, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { whirlpool: getNextAccount(), positionAuthority: getNextAccount(), position: getNextAccount(), positionTokenAccount: getNextAccount(), tokenOwnerAccountA: getNextAccount(), tokenVaultA: getNextAccount(), tokenOwnerAccountB: getNextAccount(), tokenVaultB: getNextAccount(), tokenProgram: getNextAccount(), }, data: getCollectFeesInstructionDataDecoder().decode(instruction.data), }; }