/**
 * 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 { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlySignerAccount, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount } from '@solana/kit';
import { LB_CLMM_PROGRAM_ADDRESS } from '../programs';
import { getAccountMetaFactory, type ResolvedAccount } from '../shared';

export const TOGGLE_PAIR_STATUS_DISCRIMINATOR = new Uint8Array([61, 115, 52, 23, 46, 13, 31, 144]);

export function getTogglePairStatusDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(TOGGLE_PAIR_STATUS_DISCRIMINATOR); }

export type TogglePairStatusInstruction<TProgram extends string = typeof LB_CLMM_PROGRAM_ADDRESS, TAccountLbPair extends string | AccountMeta<string> = string, TAccountAdmin extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountLbPair extends string ? WritableAccount<TAccountLbPair> : TAccountLbPair, TAccountAdmin extends string ? ReadonlySignerAccount<TAccountAdmin> & AccountSignerMeta<TAccountAdmin> : TAccountAdmin, ...TRemainingAccounts]>;

export type TogglePairStatusInstructionData = { discriminator: ReadonlyUint8Array;  };

export type TogglePairStatusInstructionDataArgs = {  };

export function getTogglePairStatusInstructionDataEncoder(): FixedSizeEncoder<TogglePairStatusInstructionDataArgs> {
    return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({ ...value, discriminator: TOGGLE_PAIR_STATUS_DISCRIMINATOR }));
}

export function getTogglePairStatusInstructionDataDecoder(): FixedSizeDecoder<TogglePairStatusInstructionData> {
    return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)]]);
}

export function getTogglePairStatusInstructionDataCodec(): FixedSizeCodec<TogglePairStatusInstructionDataArgs, TogglePairStatusInstructionData> {
    return combineCodec(getTogglePairStatusInstructionDataEncoder(), getTogglePairStatusInstructionDataDecoder());
}

export type TogglePairStatusInput<TAccountLbPair extends string = string, TAccountAdmin extends string = string> =  {
  lbPair: Address<TAccountLbPair>;
admin: TransactionSigner<TAccountAdmin>;
}

export function getTogglePairStatusInstruction<TAccountLbPair extends string, TAccountAdmin extends string, TProgramAddress extends Address = typeof LB_CLMM_PROGRAM_ADDRESS>(input: TogglePairStatusInput<TAccountLbPair, TAccountAdmin>, config?: { programAddress?: TProgramAddress } ): TogglePairStatusInstruction<TProgramAddress, TAccountLbPair, TAccountAdmin> {
  // Program address.
const programAddress = config?.programAddress ?? LB_CLMM_PROGRAM_ADDRESS;

 // Original accounts.
const originalAccounts = { lbPair: { value: input.lbPair ?? null, isWritable: true }, admin: { value: input.admin ?? null, isWritable: false } }
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedAccount>;




const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
return Object.freeze({ accounts: [getAccountMeta(accounts.lbPair), getAccountMeta(accounts.admin)], data: getTogglePairStatusInstructionDataEncoder().encode({}), programAddress } as TogglePairStatusInstruction<TProgramAddress, TAccountLbPair, TAccountAdmin>);
}

export type ParsedTogglePairStatusInstruction<TProgram extends string = typeof LB_CLMM_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
accounts: {
lbPair: TAccountMetas[0];
admin: TAccountMetas[1];
};
data: TogglePairStatusInstructionData; };

export function parseTogglePairStatusInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedTogglePairStatusInstruction<TProgram, TAccountMetas> {
  if (instruction.accounts.length < 2) {
  // TODO: Coded error.
  throw new Error('Not enough accounts');
}
let accountIndex = 0;
const getNextAccount = () => {
  const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
  accountIndex += 1;
  return accountMeta;
}
  return { programAddress: instruction.programAddress, accounts: { lbPair: getNextAccount(), admin: getNextAccount() }, data: getTogglePairStatusInstructionDataDecoder().decode(instruction.data) };
}