import * as anchor from "@coral-xyz/anchor"; import { BN } from "@coral-xyz/anchor"; import { Wallet } from "@coral-xyz/anchor"; import { Connection, Keypair, PublicKey, Transaction, TransactionInstruction, TransactionSignature, VersionedTransaction } from "@solana/web3.js"; import { type LookupTableInput } from "../utils/lookupTables"; import { ExtBridgeProgram, ExtEpiProgram, ExtCctpProgram, ExtJupiterProgram, ExtKaminoProgram, ExtMarinadeProgram, ExtLoopscaleProgram, ExtPhoenixProgram, ExtOrcaProgram, ExtSplProgram, ExtStakePoolProgram, GlamMintProgram, GlamProtocolProgram } from "../glamExports"; import { ClusterNetwork, GlamClientConfig } from "../clientConfig"; import { GlobalConfig } from "../globalConfig"; import { RequestQueue, StateAccount, StateModel } from "../models"; import { BlockhashWithCache } from "../utils/blockhash"; import { JupiterApiClient, PhoenixApiClient, PkMap } from "../utils"; import { AssetMeta } from "../assets"; export type TxOptions = { signer?: PublicKey; computeUnitLimit?: number; getPriorityFeeMicroLamports?: (tx: VersionedTransaction) => Promise; maxFeeLamports?: number; useMaxFee?: boolean; preInstructions?: TransactionInstruction[]; postInstructions?: TransactionInstruction[]; lookupTables?: LookupTableInput[]; simulate?: boolean; }; export interface ProtocolPolicyTxBuilder { setPolicyIx(policy: TPolicy, signer?: PublicKey): Promise; setPolicyTx(policy: TPolicy, txOptions?: TxOptions): Promise; clearPolicyIx(signer?: PublicKey): Promise; clearPolicyTx(txOptions?: TxOptions): Promise; } export interface ProtocolPolicyClient { fetchPolicy(): Promise; setPolicy(policy: TPolicy, txOptions?: TxOptions): Promise; clearPolicy(txOptions?: TxOptions): Promise; } export type TokenAccount = { owner: PublicKey; pubkey: PublicKey; mint: PublicKey; programId: PublicKey; decimals: number; amount: string; uiAmount: number; frozen: boolean; }; export declare class BaseClient { cluster: ClusterNetwork; provider: anchor.Provider; blockhashWithCache: BlockhashWithCache; jupiterApiKey?: string; jupiterApiClient?: JupiterApiClient; phoenixApiUrl?: string; phoenixApiClient?: PhoenixApiClient; onSentListeners: Set<(sig: string) => void>; readonly staging: boolean; private _protocolProgram?; private _mintProgram?; private _extSplProgram?; private _extKaminoProgram?; private _extMarinadeProgram?; private _extStakePoolProgram?; private _extCctpProgram?; private _extBridgeProgram?; private _extEpiProgram?; private _extLoopscaleProgram?; private _extPhoenixProgram?; private _extJupiterProgram?; private _extOrcaProgram?; private _statePda?; private _globalConfig?; private _globalConfigPromise?; private _assetMetas?; private _assetMetasPromise?; private _defaultLookupTablesPromise?; private _glamLookupTablesPromise?; private _glamLookupTablesCacheKey?; constructor(config?: GlamClientConfig); get protocolProgram(): GlamProtocolProgram; get mintProgram(): GlamMintProgram; get extSplProgram(): ExtSplProgram; get extKaminoProgram(): ExtKaminoProgram; get extMarinadeProgram(): ExtMarinadeProgram; get extStakePoolProgram(): ExtStakePoolProgram; get extCctpProgram(): ExtCctpProgram; get extBridgeProgram(): ExtBridgeProgram; get extEpiProgram(): ExtEpiProgram; get extLoopscaleProgram(): ExtLoopscaleProgram; get extPhoenixProgram(): ExtPhoenixProgram; get extJupiterProgram(): ExtJupiterProgram; get extOrcaProgram(): ExtOrcaProgram; get isVaultConnected(): boolean; get statePda(): PublicKey; set statePda(statePda: PublicKey); /** * Mainnet-only default lookup tables (Kamino lending, Loopscale). * Cached for the session; safe to assume static contents. */ private getDefaultLookupTables; /** * Discovers GLAM ALTs for the connected vault and caches the result for the * session. * * Call `invalidateGlamLookupTablesCache()` after creating or extending an ALT * to force a re-discovery on the next tx. */ private getGlamLookupTablesCached; invalidateGlamLookupTablesCache(): void; private warmupGlamLookupTables; get isMainnet(): boolean; /** * Converts a legacy transaction into a versioned transaction. */ intoVersionedTransaction(tx: Transaction, { lookupTables, signer, computeUnitLimit, getPriorityFeeMicroLamports, maxFeeLamports, useMaxFee, simulate, }: TxOptions): Promise; /** * Signs, sends, and confirms a transaction. * * Legacy transactions receive missing fee-payer/blockhash values here and * extra signers are applied with `partialSign` before wallet signing. * Versioned transactions are expected to be fully built by the caller; extra * signers are applied after wallet signing so this remains compatible with * transactions created by another `@solana/web3.js` package instance. * * Transactions are sent with preflight disabled because callers commonly * simulate while building compute-budget instructions. */ sendAndConfirm(tx: VersionedTransaction | Transaction, additionalSigners?: Keypair[]): Promise; private confirmTransaction; get connection(): Connection; get signer(): PublicKey; get wallet(): Wallet; get vaultPda(): PublicKey; get mintPda(): PublicKey; get escrowPda(): PublicKey; get extraMetasPda(): PublicKey; get requestQueuePda(): PublicKey; /** * Returns SOL and token balances of the given owner pubkey */ getSolAndTokenBalances(owner: PublicKey): Promise<{ balanceLamports: number; uiAmount: number; tokenAccounts: TokenAccount[]; }>; /** * Returns user's token account for the given mint and token program ID */ getAta(mint: PublicKey, owner: PublicKey, tokenProgram?: anchor.web3.PublicKey): PublicKey; /** * Returns glam vault's token account for the given mint and token program ID */ getVaultAta(mint: PublicKey, tokenProgramId?: PublicKey): PublicKey; /** * Returns user's glam mint token account */ getMintAta(user?: PublicKey): PublicKey; /** * Returns glam vault's SOL balance */ getVaultBalance(): Promise; /** * Returns glam vault's SOL balance in lamports */ getVaultLamports(): Promise; /** * Returns glam vault's token balance for the given mint */ getVaultTokenBalance(mintPubkey: PublicKey): Promise<{ amount: BN; uiAmount: number; }>; /** * Returns user's glam mint token balance */ getMintTokenBalance(owner?: PublicKey): Promise<{ amount: BN; uiAmount: number; }>; isLockupEnabled(): Promise; fetchGlobalConfig(options?: { refresh?: boolean; }): Promise; fetchAssetMetas(options?: { refresh?: boolean; }): Promise>; refreshAssetMetaCache(): Promise>; getAssetMeta(assetMint: string | PublicKey, options?: { refresh?: boolean; }): Promise; getSolOracle(options?: { refresh?: boolean; }): Promise; fetchStateAccount(statePda?: PublicKey): Promise; private getMintProgramIdForStateAccount; private getMintProgramForStateAccount; fetchRequestQueue(requestQueuePda?: PublicKey, mintProgram?: GlamMintProgram): Promise; /** * Builds a StateModel from onchain accounts (state, mint, etc) * * @param statePda Optional state PDA */ fetchStateModel(statePda?: PublicKey): Promise; /** * Fetches glam state models and applies filters * * @param filterOptions Filter options */ fetchGlamStates(filterOptions?: { owner?: PublicKey; delegate?: PublicKey; type?: string; }): Promise; fetchProtocolPolicy(integProgramId: PublicKey, protocolBitflag: number, policyClass: { decode(buffer: Buffer, staging?: boolean): T; }): Promise; } /** * Base transaction builder for sub-clients */ export declare class BaseTxBuilder { readonly client: T; constructor(client: T); clearProtocolPolicyIx(integrationProgram: PublicKey, protocolBitflag: number, signer?: PublicKey): Promise; clearProtocolPolicyTx(integrationProgram: PublicKey, protocolBitflag: number, txOptions?: TxOptions): Promise; /** * Build a legacy transaction with the given instructions. * Pre and post instructions in txOptions are preserved. */ build(ixs: TransactionInstruction[], txOptions?: TxOptions): Transaction; /** * Build a versioned transaction that is ready to be sent. */ buildVersionedTx(ixs: TransactionInstruction[], txOptions?: TxOptions): Promise; }