/** * 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"; export const PROTOCOL_POSITION_STATE_DISCRIMINATOR = new Uint8Array([ 100, 226, 145, 99, 146, 218, 160, 106, ]); export function getProtocolPositionStateDiscriminatorBytes() { return fixEncoderSize(getBytesEncoder(), 8).encode( PROTOCOL_POSITION_STATE_DISCRIMINATOR, ); } export type ProtocolPositionState = { discriminator: ReadonlyUint8Array; /** Bump to identify PDA */ bump: number; /** 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 per unit of liquidity as of the last update to liquidity or fees owed */ feeGrowthInside0LastX64: bigint; /** The token_1 fee growth per unit of liquidity as of the last update to liquidity or fees owed */ feeGrowthInside1LastX64: bigint; /** The fees owed to the position owner in token_0 */ tokenFeesOwed0: bigint; /** The fees owed to the position owner in token_1 */ tokenFeesOwed1: bigint; /** The reward growth per unit of liquidity as of the last update to liquidity */ rewardGrowthInside: Array; padding: Array; }; export type ProtocolPositionStateArgs = { /** Bump to identify PDA */ bump: number; /** 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 per unit of liquidity as of the last update to liquidity or fees owed */ feeGrowthInside0LastX64: number | bigint; /** The token_1 fee growth per unit of liquidity as of the last update to liquidity or fees owed */ feeGrowthInside1LastX64: number | bigint; /** The fees owed to the position owner in token_0 */ tokenFeesOwed0: number | bigint; /** The fees owed to the position owner in token_1 */ tokenFeesOwed1: number | bigint; /** The reward growth per unit of liquidity as of the last update to liquidity */ rewardGrowthInside: Array; padding: Array; }; /** Gets the encoder for {@link ProtocolPositionStateArgs} account data. */ export function getProtocolPositionStateEncoder(): FixedSizeEncoder { return transformEncoder( getStructEncoder([ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)], ["bump", getU8Encoder()], ["poolId", getAddressEncoder()], ["tickLowerIndex", getI32Encoder()], ["tickUpperIndex", getI32Encoder()], ["liquidity", getU128Encoder()], ["feeGrowthInside0LastX64", getU128Encoder()], ["feeGrowthInside1LastX64", getU128Encoder()], ["tokenFeesOwed0", getU64Encoder()], ["tokenFeesOwed1", getU64Encoder()], ["rewardGrowthInside", getArrayEncoder(getU128Encoder(), { size: 3 })], ["padding", getArrayEncoder(getU64Encoder(), { size: 8 })], ]), (value) => ({ ...value, discriminator: PROTOCOL_POSITION_STATE_DISCRIMINATOR, }), ); } /** Gets the decoder for {@link ProtocolPositionState} account data. */ export function getProtocolPositionStateDecoder(): FixedSizeDecoder { return getStructDecoder([ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)], ["bump", getU8Decoder()], ["poolId", getAddressDecoder()], ["tickLowerIndex", getI32Decoder()], ["tickUpperIndex", getI32Decoder()], ["liquidity", getU128Decoder()], ["feeGrowthInside0LastX64", getU128Decoder()], ["feeGrowthInside1LastX64", getU128Decoder()], ["tokenFeesOwed0", getU64Decoder()], ["tokenFeesOwed1", getU64Decoder()], ["rewardGrowthInside", getArrayDecoder(getU128Decoder(), { size: 3 })], ["padding", getArrayDecoder(getU64Decoder(), { size: 8 })], ]); } /** Gets the codec for {@link ProtocolPositionState} account data. */ export function getProtocolPositionStateCodec(): FixedSizeCodec< ProtocolPositionStateArgs, ProtocolPositionState > { return combineCodec( getProtocolPositionStateEncoder(), getProtocolPositionStateDecoder(), ); } export function decodeProtocolPositionState( encodedAccount: EncodedAccount, ): Account; export function decodeProtocolPositionState( encodedAccount: MaybeEncodedAccount, ): MaybeAccount; export function decodeProtocolPositionState( encodedAccount: EncodedAccount | MaybeEncodedAccount, ): | Account | MaybeAccount { return decodeAccount( encodedAccount as MaybeEncodedAccount, getProtocolPositionStateDecoder(), ); } export async function fetchProtocolPositionState< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchMaybeProtocolPositionState( rpc, address, config, ); assertAccountExists(maybeAccount); return maybeAccount; } export async function fetchMaybeProtocolPositionState< TAddress extends string = string, >( rpc: Parameters[0], address: Address, config?: FetchAccountConfig, ): Promise> { const maybeAccount = await fetchEncodedAccount(rpc, address, config); return decodeProtocolPositionState(maybeAccount); } export async function fetchAllProtocolPositionState( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchAllMaybeProtocolPositionState( rpc, addresses, config, ); assertAccountsExist(maybeAccounts); return maybeAccounts; } export async function fetchAllMaybeProtocolPositionState( rpc: Parameters[0], addresses: Array
, config?: FetchAccountsConfig, ): Promise[]> { const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); return maybeAccounts.map((maybeAccount) => decodeProtocolPositionState(maybeAccount), ); } export function getProtocolPositionStateSize(): number { return 225; }