/** * 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, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, 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"; import { getFeeConfigurationDecoder, getFeeConfigurationEncoder, getFeeStateDecoder, getFeeStateEncoder, getFeeUpdateDecoder, getFeeUpdateEncoder, getHighWaterMarkDecoder, getHighWaterMarkEncoder, getLockedProfitStateDecoder, getLockedProfitStateEncoder, getVaultAssetDecoder, getVaultAssetEncoder, getVaultConfigurationDecoder, getVaultConfigurationEncoder, getVaultLpDecoder, getVaultLpEncoder, type FeeConfiguration, type FeeConfigurationArgs, type FeeState, type FeeStateArgs, type FeeUpdate, type FeeUpdateArgs, type HighWaterMark, type HighWaterMarkArgs, type LockedProfitState, type LockedProfitStateArgs, type VaultAsset, type VaultAssetArgs, type VaultConfiguration, type VaultConfigurationArgs, type VaultLp, type VaultLpArgs, } from "../types"; export const VAULT_DISCRIMINATOR = new Uint8Array([ 211, 8, 232, 43, 2, 152, 117, 119, ]); export function getVaultDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode(VAULT_DISCRIMINATOR); } export type Vault = { discriminator: ReadonlyUint8Array; /** The vault's name. */ name: ReadonlyUint8Array; /** A description or summary for this vault. */ description: ReadonlyUint8Array; /** The vault’s main asset configuration (inline nested struct). */ asset: VaultAsset; /** The vault’s LP (share) configuration (inline nested struct). */ lp: VaultLp; /** The pending admin for admin transfer. */ pendingAdmin: Address; /** The manager of this vault (has certain permissions). */ manager: Address; /** The admin of this vault (broader or fallback permissions). */ admin: Address; /** The vault fee, cap, and locked profit degradation duration configuration (inline nested struct). */ vaultConfiguration: VaultConfiguration; /** The vault fee and cap configuration (inline nested struct). */ feeConfiguration: FeeConfiguration; /** The fee update state of the vault. */ feeUpdate: FeeUpdate; /** The fee state of the vault. */ feeState: FeeState; /** The accumulated dead weight of the vault. */ deadWeight: bigint; highWaterMark: HighWaterMark; /** The last time (Unix timestamp) this vault data was updated. */ lastUpdatedTs: bigint; /** The version of the vault. */ version: number; /** Protocol-admin-controlled adaptor allowlist bypass. */ allowAnyAdaptor: number; /** Padding to keep `locked_profit_state` at its existing 8-byte-aligned offset. */ padding0: ReadonlyUint8Array; /** The locked profit state of the vault. */ lockedProfitState: LockedProfitState; /** Reserved bytes for future use. */ reserved: ReadonlyUint8Array; }; export type VaultArgs = { /** The vault's name. */ name: ReadonlyUint8Array; /** A description or summary for this vault. */ description: ReadonlyUint8Array; /** The vault’s main asset configuration (inline nested struct). */ asset: VaultAssetArgs; /** The vault’s LP (share) configuration (inline nested struct). */ lp: VaultLpArgs; /** The pending admin for admin transfer. */ pendingAdmin: Address; /** The manager of this vault (has certain permissions). */ manager: Address; /** The admin of this vault (broader or fallback permissions). */ admin: Address; /** The vault fee, cap, and locked profit degradation duration configuration (inline nested struct). */ vaultConfiguration: VaultConfigurationArgs; /** The vault fee and cap configuration (inline nested struct). */ feeConfiguration: FeeConfigurationArgs; /** The fee update state of the vault. */ feeUpdate: FeeUpdateArgs; /** The fee state of the vault. */ feeState: FeeStateArgs; /** The accumulated dead weight of the vault. */ deadWeight: number | bigint; highWaterMark: HighWaterMarkArgs; /** The last time (Unix timestamp) this vault data was updated. */ lastUpdatedTs: number | bigint; /** The version of the vault. */ version: number; /** Protocol-admin-controlled adaptor allowlist bypass. */ allowAnyAdaptor: number; /** Padding to keep `locked_profit_state` at its existing 8-byte-aligned offset. */ padding0: ReadonlyUint8Array; /** The locked profit state of the vault. */ lockedProfitState: LockedProfitStateArgs; /** Reserved bytes for future use. */ reserved: ReadonlyUint8Array; }; /** Gets the encoder for {@link VaultArgs} account data. */ export function getVaultEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["name", fixEncoderSize(getBytesEncoder(), 32)], ["description", fixEncoderSize(getBytesEncoder(), 64)], ["asset", getVaultAssetEncoder()], ["lp", getVaultLpEncoder()], ["pendingAdmin", getAddressEncoder()], ["manager", getAddressEncoder()], ["admin", getAddressEncoder()], ["vaultConfiguration", getVaultConfigurationEncoder()], ["feeConfiguration", getFeeConfigurationEncoder()], ["feeUpdate", getFeeUpdateEncoder()], ["feeState", getFeeStateEncoder()], ["deadWeight", getU64Encoder()], ["highWaterMark", getHighWaterMarkEncoder()], ["lastUpdatedTs", getU64Encoder()], ["version", getU8Encoder()], ["allowAnyAdaptor", getU8Encoder()], ["padding0", fixEncoderSize(getBytesEncoder(), 6)], ["lockedProfitState", getLockedProfitStateEncoder()], ["reserved", fixEncoderSize(getBytesEncoder(), 240)], ]), (value) => ({ ...value, discriminator: VAULT_DISCRIMINATOR }), ); } /** Gets the decoder for {@link Vault} account data. */ export function getVaultDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["name", fixDecoderSize(getBytesDecoder(), 32)], ["description", fixDecoderSize(getBytesDecoder(), 64)], ["asset", getVaultAssetDecoder()], ["lp", getVaultLpDecoder()], ["pendingAdmin", getAddressDecoder()], ["manager", getAddressDecoder()], ["admin", getAddressDecoder()], ["vaultConfiguration", getVaultConfigurationDecoder()], ["feeConfiguration", getFeeConfigurationDecoder()], ["feeUpdate", getFeeUpdateDecoder()], ["feeState", getFeeStateDecoder()], ["deadWeight", getU64Decoder()], ["highWaterMark", getHighWaterMarkDecoder()], ["lastUpdatedTs", getU64Decoder()], ["version", getU8Decoder()], ["allowAnyAdaptor", getU8Decoder()], ["padding0", fixDecoderSize(getBytesDecoder(), 6)], ["lockedProfitState", getLockedProfitStateDecoder()], ["reserved", fixDecoderSize(getBytesDecoder(), 240)], ]); } /** Gets the codec for {@link Vault} account data. */ export function getVaultCodec(): FixedSizeCodec { return combineCodec(getVaultEncoder(), getVaultDecoder()); } export function decodeVault( encodedAccount: EncodedAccount, ): Account; export function decodeVault( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeVault( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getVaultDecoder(), ); } export async function fetchVault( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeVault(rpc, address, config); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeVault( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeVault(maybeAccount); } export async function fetchAllVault( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeVault(rpc, addresses, config); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeVault( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeVault(maybeAccount)); } export function getVaultSize(): number { return 928; }