UNPKG

@kamino-finance/kliquidity-sdk

Version:

Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol

80 lines (66 loc) 4.98 kB
/** * 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 { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, transformEncoder, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit'; export const WHIRLPOOLS_CONFIG_EXTENSION_DISCRIMINATOR = new Uint8Array([2, 99, 215, 163, 240, 26, 153, 58]); export function getWhirlpoolsConfigExtensionDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(WHIRLPOOLS_CONFIG_EXTENSION_DISCRIMINATOR); } export type WhirlpoolsConfigExtension = { discriminator: ReadonlyUint8Array; whirlpoolsConfig: Address; configExtensionAuthority: Address; tokenBadgeAuthority: Address; }; export type WhirlpoolsConfigExtensionArgs = { whirlpoolsConfig: Address; configExtensionAuthority: Address; tokenBadgeAuthority: Address; }; /** Gets the encoder for {@link WhirlpoolsConfigExtensionArgs} account data. */ export function getWhirlpoolsConfigExtensionEncoder(): FixedSizeEncoder<WhirlpoolsConfigExtensionArgs> { return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)], ['whirlpoolsConfig', getAddressEncoder()], ['configExtensionAuthority', getAddressEncoder()], ['tokenBadgeAuthority', getAddressEncoder()]]), (value) => ({ ...value, discriminator: WHIRLPOOLS_CONFIG_EXTENSION_DISCRIMINATOR })); } /** Gets the decoder for {@link WhirlpoolsConfigExtension} account data. */ export function getWhirlpoolsConfigExtensionDecoder(): FixedSizeDecoder<WhirlpoolsConfigExtension> { return getStructDecoder([['discriminator', fixDecoderSize(getBytesDecoder(), 8)], ['whirlpoolsConfig', getAddressDecoder()], ['configExtensionAuthority', getAddressDecoder()], ['tokenBadgeAuthority', getAddressDecoder()]]); } /** Gets the codec for {@link WhirlpoolsConfigExtension} account data. */ export function getWhirlpoolsConfigExtensionCodec(): FixedSizeCodec<WhirlpoolsConfigExtensionArgs, WhirlpoolsConfigExtension> { return combineCodec(getWhirlpoolsConfigExtensionEncoder(), getWhirlpoolsConfigExtensionDecoder()); } export function decodeWhirlpoolsConfigExtension<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<WhirlpoolsConfigExtension, TAddress>; export function decodeWhirlpoolsConfigExtension<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<WhirlpoolsConfigExtension, TAddress>; export function decodeWhirlpoolsConfigExtension<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>): Account<WhirlpoolsConfigExtension, TAddress> | MaybeAccount<WhirlpoolsConfigExtension, TAddress> { return decodeAccount(encodedAccount as MaybeEncodedAccount<TAddress>, getWhirlpoolsConfigExtensionDecoder()); } export async function fetchWhirlpoolsConfigExtension<TAddress extends string = string>( rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig, ): Promise<Account<WhirlpoolsConfigExtension, TAddress>> { const maybeAccount = await fetchMaybeWhirlpoolsConfigExtension(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeWhirlpoolsConfigExtension<TAddress extends string = string>( rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig, ): Promise<MaybeAccount<WhirlpoolsConfigExtension, TAddress>> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeWhirlpoolsConfigExtension(maybeAccount); } export async function fetchAllWhirlpoolsConfigExtension( rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig, ): Promise<Account<WhirlpoolsConfigExtension>[]> { const maybeAccounts = await fetchAllMaybeWhirlpoolsConfigExtension(rpc, addresses, config); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeWhirlpoolsConfigExtension( rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig, ): Promise<MaybeAccount<WhirlpoolsConfigExtension>[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeWhirlpoolsConfigExtension(maybeAccount)); } export function getWhirlpoolsConfigExtensionSize(): number { return 104; }