UNPKG

@quartz-labs/sdk

Version:

SDK for interacting with the Quartz Protocol

37 lines 3.35 kB
import { PublicKey, type Connection, type TransactionInstruction } from "@solana/web3.js"; import type { AccountMeta } from "../types/interfaces/AccountMeta.interface.js"; import { MarketIndex } from "../config/tokens.js"; import type { AddressLookupTableAccount } from "@solana/web3.js"; import { VersionedTransaction } from "@solana/web3.js"; import { type BN, type WithdrawOrder } from "../index.browser.js"; export declare function delay(ms: number): Promise<unknown>; export declare function getComputeUnitLimit(connection: Connection, instructions: TransactionInstruction[], address: PublicKey, blockhash: string, lookupTables?: AddressLookupTableAccount[]): Promise<number>; export declare function getComputeUnitLimitIx(connection: Connection, instructions: TransactionInstruction[], address: PublicKey, blockhash: string, lookupTables?: AddressLookupTableAccount[]): Promise<TransactionInstruction>; export declare function getComputeUnitPrice(connection: Connection, instructions: TransactionInstruction[]): Promise<number>; export declare function getComputeUnitPriceIx(connection: Connection, instructions: TransactionInstruction[]): Promise<TransactionInstruction>; export declare function buildTransaction(connection: Connection, instructions: TransactionInstruction[], payer: PublicKey, lookupTables?: AddressLookupTableAccount[]): Promise<{ transaction: VersionedTransaction; gasLamports: number; }>; export declare const toRemainingAccount: (pubkey: PublicKey, isSigner: boolean, isWritable: boolean) => AccountMeta; export declare const getTokenProgram: (connection: Connection, mint: PublicKey) => Promise<PublicKey>; export declare function makeCreateAtaIxIfNeeded(connection: Connection, ata: PublicKey, authority: PublicKey, mint: PublicKey, tokenProgramId: PublicKey, payer: PublicKey): Promise<TransactionInstruction[]>; export declare function baseUnitToDecimal(baseUnits: number, marketIndex: MarketIndex): number; export declare function decimalToBaseUnit(decimal: number, marketIndex: MarketIndex): number; export declare function isMarketIndex(index: number): boolean; /** * Retries a function with exponential backoff, retries if an error is thrown. * @param fn - The function to retry. * @param retries - The number of retries, defaults to 5. * @param initialDelay - The initial delay in milliseconds, defaults to 1_000. * @param retryCallback - A callback function that is called on each retry. * @returns The result of the function. */ export declare function retryWithBackoff<T>(fn: () => Promise<T>, retries?: number, initialDelay?: number, retryCallback?: (error: unknown, delayMs: number) => void): Promise<T>; export declare function evmAddressToSolana(evmAddress: string): PublicKey; export declare function calculateWithdrawOrderBalances(withdrawOrders: WithdrawOrder[]): Record<MarketIndex, BN>; export declare function getPrices(pythFirst?: boolean, marketIndices?: MarketIndex[]): Promise<Record<MarketIndex, number>>; export declare function getTokenAccountBalance(connection: Connection, tokenAccount: PublicKey): Promise<number>; export declare function fetchAndParse<T>(url: string, req?: RequestInit | undefined, retries?: number): Promise<T>; export declare function buildEndpointURL(baseEndpoint: string, params?: Record<string, string>): string; //# sourceMappingURL=helpers.d.ts.map