/** * 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, getArrayDecoder, getArrayEncoder, getBytesDecoder, getBytesEncoder, getI32Decoder, getI32Encoder, getStructDecoder, getStructEncoder, getU128Decoder, getU128Encoder, 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 { getPositionRewardInfoDecoder, getPositionRewardInfoEncoder, type PositionRewardInfo, type PositionRewardInfoArgs, } from "../types"; export const PERSONAL_POSITION_STATE_DISCRIMINATOR = new Uint8Array([ 70, 111, 150, 126, 230, 15, 25, 117, ]); export function getPersonalPositionStateDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( PERSONAL_POSITION_STATE_DISCRIMINATOR, ); } export type PersonalPositionState = { discriminator: ReadonlyUint8Array; /** Bump to identify PDA */ bump: number; /** Mint address of the tokenized position */ nftMint: Address; /** The ID of the pool with which this token is connected */ poolId: Address; /** The lower bound tick of the position */ tickLowerIndex: number; /** The upper bound tick of the position */ tickUpperIndex: number; /** The amount of liquidity owned by this position */ liquidity: bigint; /** The token_0 fee growth of the aggregate position as of the last action on the individual position */ feeGrowthInside0LastX64: bigint; /** The token_1 fee growth of the aggregate position as of the last action on the individual position */ feeGrowthInside1LastX64: bigint; /** The fees owed to the position owner in token_0, as of the last computation */ tokenFeesOwed0: bigint; /** The fees owed to the position owner in token_1, as of the last computation */ tokenFeesOwed1: bigint; rewardInfos: Array; padding: Array; }; export type PersonalPositionStateArgs = { /** Bump to identify PDA */ bump: number; /** Mint address of the tokenized position */ nftMint: Address; /** The ID of the pool with which this token is connected */ poolId: Address; /** The lower bound tick of the position */ tickLowerIndex: number; /** The upper bound tick of the position */ tickUpperIndex: number; /** The amount of liquidity owned by this position */ liquidity: number | bigint; /** The token_0 fee growth of the aggregate position as of the last action on the individual position */ feeGrowthInside0LastX64: number | bigint; /** The token_1 fee growth of the aggregate position as of the last action on the individual position */ feeGrowthInside1LastX64: number | bigint; /** The fees owed to the position owner in token_0, as of the last computation */ tokenFeesOwed0: number | bigint; /** The fees owed to the position owner in token_1, as of the last computation */ tokenFeesOwed1: number | bigint; rewardInfos: Array; padding: Array; }; /** Gets the encoder for {@link PersonalPositionStateArgs} account data. */ export function getPersonalPositionStateEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["bump", getU8Encoder()], ["nftMint", getAddressEncoder()], ["poolId", getAddressEncoder()], ["tickLowerIndex", getI32Encoder()], ["tickUpperIndex", getI32Encoder()], ["liquidity", getU128Encoder()], ["feeGrowthInside0LastX64", getU128Encoder()], ["feeGrowthInside1LastX64", getU128Encoder()], ["tokenFeesOwed0", getU64Encoder()], ["tokenFeesOwed1", getU64Encoder()], [ "rewardInfos", getArrayEncoder(getPositionRewardInfoEncoder(), { size: 3 }), ], ["padding", getArrayEncoder(getU64Encoder(), { size: 8 })], ]), (value) => ({ ...value, discriminator: PERSONAL_POSITION_STATE_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link PersonalPositionState} account data. */ export function getPersonalPositionStateDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["bump", getU8Decoder()], ["nftMint", getAddressDecoder()], ["poolId", getAddressDecoder()], ["tickLowerIndex", getI32Decoder()], ["tickUpperIndex", getI32Decoder()], ["liquidity", getU128Decoder()], ["feeGrowthInside0LastX64", getU128Decoder()], ["feeGrowthInside1LastX64", getU128Decoder()], ["tokenFeesOwed0", getU64Decoder()], ["tokenFeesOwed1", getU64Decoder()], [ "rewardInfos", getArrayDecoder(getPositionRewardInfoDecoder(), { size: 3 }), ], ["padding", getArrayDecoder(getU64Decoder(), { size: 8 })], ]); } /** Gets the codec for {@link PersonalPositionState} account data. */ export function getPersonalPositionStateCodec(): FixedSizeCodec< PersonalPositionStateArgs, PersonalPositionState > { return combineCodec( getPersonalPositionStateEncoder(), getPersonalPositionStateDecoder(), ); } export function decodePersonalPositionState( encodedAccount: EncodedAccount, ): Account; export function decodePersonalPositionState( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodePersonalPositionState( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getPersonalPositionStateDecoder(), ); } export async function fetchPersonalPositionState< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybePersonalPositionState( rpc, address, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybePersonalPositionState< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodePersonalPositionState(maybeAccount); } export async function fetchAllPersonalPositionState( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybePersonalPositionState( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybePersonalPositionState( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodePersonalPositionState(maybeAccount), ); } export function getPersonalPositionStateSize(): number { return 281; }