/** * 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, WritableSignerAccount, } from "@solana/kit"; import type { ResolvedInstructionAccount } from "@solana/program-client-core"; import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getI32Decoder, getI32Encoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, 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 OPEN_BUNDLED_POSITION_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([169, 113, 126, 171, 213, 172, 212, 49]); export function getOpenBundledPositionDiscriminatorBytes(): ReadonlyUint8Array { return fixEncoderSize(getBytesEncoder(), 8).encode( OPEN_BUNDLED_POSITION_DISCRIMINATOR, ); } export type OpenBundledPositionInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountBundledPosition extends string | AccountMeta = string, TAccountPositionBundle extends string | AccountMeta = string, TAccountPositionBundleTokenAccount extends string | AccountMeta = string, TAccountPositionBundleAuthority extends string | AccountMeta = string, TAccountWhirlpool extends string | AccountMeta = string, TAccountFunder extends string | AccountMeta = string, TAccountSystemProgram extends | string | AccountMeta = "11111111111111111111111111111111", TAccountRent extends | string | AccountMeta = "SysvarRent111111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta[] = [], > = Instruction & InstructionWithData & InstructionWithAccounts< [ TAccountBundledPosition extends string ? WritableAccount : TAccountBundledPosition, TAccountPositionBundle extends string ? WritableAccount : TAccountPositionBundle, TAccountPositionBundleTokenAccount extends string ? ReadonlyAccount : TAccountPositionBundleTokenAccount, TAccountPositionBundleAuthority extends string ? ReadonlySignerAccount & AccountSignerMeta : TAccountPositionBundleAuthority, TAccountWhirlpool extends string ? ReadonlyAccount : TAccountWhirlpool, TAccountFunder extends string ? WritableSignerAccount & AccountSignerMeta : TAccountFunder, TAccountSystemProgram extends string ? ReadonlyAccount : TAccountSystemProgram, TAccountRent extends string ? ReadonlyAccount : TAccountRent, ...TRemainingAccounts, ] >; export interface OpenBundledPositionInstructionData { discriminator: ReadonlyUint8Array; bundleIndex: number; tickLowerIndex: number; tickUpperIndex: number; } export interface OpenBundledPositionInstructionDataArgs { bundleIndex: number; tickLowerIndex: number; tickUpperIndex: number; } export function getOpenBundledPositionInstructionDataEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["bundleIndex", getU16Encoder()], ["tickLowerIndex", getI32Encoder()], ["tickUpperIndex", getI32Encoder()], ]), (value) => ({ ...value, discriminator: OPEN_BUNDLED_POSITION_DISCRIMINATOR, }), ); } export function getOpenBundledPositionInstructionDataDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["bundleIndex", getU16Decoder()], ["tickLowerIndex", getI32Decoder()], ["tickUpperIndex", getI32Decoder()], ]); } export function getOpenBundledPositionInstructionDataCodec(): FixedSizeCodec< OpenBundledPositionInstructionDataArgs, OpenBundledPositionInstructionData > { return combineCodec( getOpenBundledPositionInstructionDataEncoder(), getOpenBundledPositionInstructionDataDecoder(), ); } export interface OpenBundledPositionInput< TAccountBundledPosition extends string = string, TAccountPositionBundle extends string = string, TAccountPositionBundleTokenAccount extends string = string, TAccountPositionBundleAuthority extends string = string, TAccountWhirlpool extends string = string, TAccountFunder extends string = string, TAccountSystemProgram extends string = string, TAccountRent extends string = string, > { bundledPosition: Address; positionBundle: Address; positionBundleTokenAccount: Address; positionBundleAuthority: TransactionSigner; whirlpool: Address; funder: TransactionSigner; systemProgram?: Address; rent?: Address; bundleIndex: OpenBundledPositionInstructionDataArgs["bundleIndex"]; tickLowerIndex: OpenBundledPositionInstructionDataArgs["tickLowerIndex"]; tickUpperIndex: OpenBundledPositionInstructionDataArgs["tickUpperIndex"]; } export function getOpenBundledPositionInstruction< TAccountBundledPosition extends string, TAccountPositionBundle extends string, TAccountPositionBundleTokenAccount extends string, TAccountPositionBundleAuthority extends string, TAccountWhirlpool extends string, TAccountFunder extends string, TAccountSystemProgram extends string, TAccountRent extends string, TProgramAddress extends Address = typeof WHIRLPOOL_PROGRAM_ADDRESS, >( input: OpenBundledPositionInput< TAccountBundledPosition, TAccountPositionBundle, TAccountPositionBundleTokenAccount, TAccountPositionBundleAuthority, TAccountWhirlpool, TAccountFunder, TAccountSystemProgram, TAccountRent >, config?: { programAddress?: TProgramAddress }, ): OpenBundledPositionInstruction< TProgramAddress, TAccountBundledPosition, TAccountPositionBundle, TAccountPositionBundleTokenAccount, TAccountPositionBundleAuthority, TAccountWhirlpool, TAccountFunder, TAccountSystemProgram, TAccountRent > { // Program address. const programAddress = config?.programAddress ?? WHIRLPOOL_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { bundledPosition: { value: input.bundledPosition ?? null, isWritable: true }, positionBundle: { value: input.positionBundle ?? null, isWritable: true }, positionBundleTokenAccount: { value: input.positionBundleTokenAccount ?? null, isWritable: false, }, positionBundleAuthority: { value: input.positionBundleAuthority ?? null, isWritable: false, }, whirlpool: { value: input.whirlpool ?? null, isWritable: false }, funder: { value: input.funder ?? null, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isWritable: false }, rent: { value: input.rent ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, ResolvedInstructionAccount >; // Original args. const args = { ...input }; // Resolve default values. if (!accounts.systemProgram.value) { accounts.systemProgram.value = "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">; } if (!accounts.rent.value) { accounts.rent.value = "SysvarRent111111111111111111111111111111111" as Address<"SysvarRent111111111111111111111111111111111">; } const getAccountMeta = getAccountMetaFactory(programAddress, "programId"); return Object.freeze({ accounts: [ getAccountMeta("bundledPosition", accounts.bundledPosition), getAccountMeta("positionBundle", accounts.positionBundle), getAccountMeta( "positionBundleTokenAccount", accounts.positionBundleTokenAccount, ), getAccountMeta( "positionBundleAuthority", accounts.positionBundleAuthority, ), getAccountMeta("whirlpool", accounts.whirlpool), getAccountMeta("funder", accounts.funder), getAccountMeta("systemProgram", accounts.systemProgram), getAccountMeta("rent", accounts.rent), ], data: getOpenBundledPositionInstructionDataEncoder().encode( args as OpenBundledPositionInstructionDataArgs, ), programAddress, } as OpenBundledPositionInstruction< TProgramAddress, TAccountBundledPosition, TAccountPositionBundle, TAccountPositionBundleTokenAccount, TAccountPositionBundleAuthority, TAccountWhirlpool, TAccountFunder, TAccountSystemProgram, TAccountRent >); } export interface ParsedOpenBundledPositionInstruction< TProgram extends string = typeof WHIRLPOOL_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], > { programAddress: Address; accounts: { bundledPosition: TAccountMetas[0]; positionBundle: TAccountMetas[1]; positionBundleTokenAccount: TAccountMetas[2]; positionBundleAuthority: TAccountMetas[3]; whirlpool: TAccountMetas[4]; funder: TAccountMetas[5]; systemProgram: TAccountMetas[6]; rent: TAccountMetas[7]; }; data: OpenBundledPositionInstructionData; } export function parseOpenBundledPositionInstruction< TProgram extends string, TAccountMetas extends readonly AccountMeta[], >( instruction: Instruction & InstructionWithAccounts & InstructionWithData, ): ParsedOpenBundledPositionInstruction { if (instruction.accounts.length < 8) { throw new SolanaError( SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 8, }, ); } let accountIndex = 0; const getNextAccount = () => { const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!; accountIndex += 1; return accountMeta; }; return { programAddress: instruction.programAddress, accounts: { bundledPosition: getNextAccount(), positionBundle: getNextAccount(), positionBundleTokenAccount: getNextAccount(), positionBundleAuthority: getNextAccount(), whirlpool: getNextAccount(), funder: getNextAccount(), systemProgram: getNextAccount(), rent: getNextAccount(), }, data: getOpenBundledPositionInstructionDataDecoder().decode( instruction.data, ), }; }