/** * 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 { Account, Context, Pda, PublicKey, RpcAccount, RpcGetAccountOptions, RpcGetAccountsOptions, assertAccountExists, deserializeAccount, gpaBuilder, publicKey as toPublicKey, } from '@metaplex-foundation/umi'; import { Serializer, bytes, i32, i64, mapSerializer, publicKey as publicKeySerializer, string, struct, u16, u64, u8, } from '@metaplex-foundation/umi/serializers'; export type Pair = Account; export type PairAccountData = { discriminator: Uint8Array; pairBump: number; lstMintBump: number; baseTokenMint: PublicKey; baseMintDecimals: number; lstMint: PublicKey; lstMintDecimals: number; lstSymbol: string; intervalAprRate: bigint; secondsPerInterval: number; initialExchangeRate: bigint; lastYieldChangeExchangeRate: bigint; lastYieldChangeTimestamp: bigint; depositCap: bigint; minimumDeposit: bigint; stakeFeeBps: number; swapFeeBps: number; withdrawFeeBps: number; }; export type PairAccountDataArgs = { pairBump: number; lstMintBump: number; baseTokenMint: PublicKey; baseMintDecimals: number; lstMint: PublicKey; lstMintDecimals: number; lstSymbol: string; intervalAprRate: number | bigint; secondsPerInterval: number; initialExchangeRate: number | bigint; lastYieldChangeExchangeRate: number | bigint; lastYieldChangeTimestamp: number | bigint; depositCap: number | bigint; minimumDeposit: number | bigint; stakeFeeBps: number; swapFeeBps: number; withdrawFeeBps: number; }; export function getPairAccountDataSerializer(): Serializer< PairAccountDataArgs, PairAccountData > { return mapSerializer( struct( [ ['discriminator', bytes({ size: 8 })], ['pairBump', u8()], ['lstMintBump', u8()], ['baseTokenMint', publicKeySerializer()], ['baseMintDecimals', u8()], ['lstMint', publicKeySerializer()], ['lstMintDecimals', u8()], ['lstSymbol', string()], ['intervalAprRate', u64()], ['secondsPerInterval', i32()], ['initialExchangeRate', u64()], ['lastYieldChangeExchangeRate', u64()], ['lastYieldChangeTimestamp', i64()], ['depositCap', u64()], ['minimumDeposit', u64()], ['stakeFeeBps', u16()], ['swapFeeBps', u16()], ['withdrawFeeBps', u16()], ], { description: 'PairAccountData' } ), (value) => ({ ...value, discriminator: new Uint8Array([85, 72, 49, 176, 182, 228, 141, 82]), }) ) as Serializer; } export function deserializePair(rawAccount: RpcAccount): Pair { return deserializeAccount(rawAccount, getPairAccountDataSerializer()); } export async function fetchPair( context: Pick, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions ): Promise { const maybeAccount = await context.rpc.getAccount( toPublicKey(publicKey, false), options ); assertAccountExists(maybeAccount, 'Pair'); return deserializePair(maybeAccount); } export async function safeFetchPair( context: Pick, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions ): Promise { const maybeAccount = await context.rpc.getAccount( toPublicKey(publicKey, false), options ); return maybeAccount.exists ? deserializePair(maybeAccount) : null; } export async function fetchAllPair( context: Pick, publicKeys: Array, options?: RpcGetAccountsOptions ): Promise { const maybeAccounts = await context.rpc.getAccounts( publicKeys.map((key) => toPublicKey(key, false)), options ); return maybeAccounts.map((maybeAccount) => { assertAccountExists(maybeAccount, 'Pair'); return deserializePair(maybeAccount); }); } export async function safeFetchAllPair( context: Pick, publicKeys: Array, options?: RpcGetAccountsOptions ): Promise { const maybeAccounts = await context.rpc.getAccounts( publicKeys.map((key) => toPublicKey(key, false)), options ); return maybeAccounts .filter((maybeAccount) => maybeAccount.exists) .map((maybeAccount) => deserializePair(maybeAccount as RpcAccount)); } export function getPairGpaBuilder(context: Pick) { const programId = context.programs.getPublicKey( 'liquidStaking', 'par1tyqusak2f2DXg9RHv78SVHNWXkJLSbtJZQSuWjV' ); return gpaBuilder(context, programId) .registerFields<{ discriminator: Uint8Array; pairBump: number; lstMintBump: number; baseTokenMint: PublicKey; baseMintDecimals: number; lstMint: PublicKey; lstMintDecimals: number; lstSymbol: string; intervalAprRate: number | bigint; secondsPerInterval: number; initialExchangeRate: number | bigint; lastYieldChangeExchangeRate: number | bigint; lastYieldChangeTimestamp: number | bigint; depositCap: number | bigint; minimumDeposit: number | bigint; stakeFeeBps: number; swapFeeBps: number; withdrawFeeBps: number; }>({ discriminator: [0, bytes({ size: 8 })], pairBump: [8, u8()], lstMintBump: [9, u8()], baseTokenMint: [10, publicKeySerializer()], baseMintDecimals: [42, u8()], lstMint: [43, publicKeySerializer()], lstMintDecimals: [75, u8()], lstSymbol: [76, string()], intervalAprRate: [null, u64()], secondsPerInterval: [null, i32()], initialExchangeRate: [null, u64()], lastYieldChangeExchangeRate: [null, u64()], lastYieldChangeTimestamp: [null, i64()], depositCap: [null, u64()], minimumDeposit: [null, u64()], stakeFeeBps: [null, u16()], swapFeeBps: [null, u16()], withdrawFeeBps: [null, u16()], }) .deserializeUsing((account) => deserializePair(account)) .whereField( 'discriminator', new Uint8Array([85, 72, 49, 176, 182, 228, 141, 82]) ); }