import { PerpsError, type ResolvedRetryPolicy } from '@lifi/perps-sdk'; /** @internal */ export type ApiParams = Record; /** * Auth-gated read whose token Lighter rejected. Distinct from a generic * {@link PerpsError} so callers can evict the stored read-only token and retry * with a freshly-created one. Lighter signals this on either channel: an HTTP * 401/403, or an HTTP 200 carrying an error `code` in the body. * @internal */ export declare class LighterAuthRejectedError extends PerpsError { } /** @internal */ export declare const LIGHTER_RETRY_DEFAULTS: ResolvedRetryPolicy; /** @internal */ export interface LighterApiClientOptions { signal?: AbortSignal; policy?: ResolvedRetryPolicy; fetchImpl?: typeof fetch; } /** * HTTP boundary against Lighter's REST API. * * Browser-direct by design: no LI.FI backend hop, no caching shim — caller * supplies the REST base URL, the path, and any query params, and we return * the parsed JSON body. Lighter advertises CORS headers on every public * endpoint so a vanilla `fetch` from the widget works. * * Auth-gated endpoints (accountLimits, accountActiveOrders, deposit/history, * withdraw/history, positionFunding, liquidations, transfer/history) take the * Lighter read-only token as the `auth` query parameter — NOT as an * `Authorization` header. This matches Lighter's OpenAPI spec and lets the * same call work browser-direct and from server-side proxies. * * Lighter signals rate limiting via 429 OR 405 (documented behaviour) with a * documented 60s firewall cooldown. The default {@link ResolvedRetryPolicy} * waits long enough to avoid hammering through the cooldown. * @public */ export declare class LighterApiClient { private readonly baseUrl; private readonly signal; private readonly policy; private readonly fetchImpl; constructor(baseUrl: string, options?: LighterApiClientOptions); private buildUrl; get(path: string, params?: ApiParams): Promise; /** * Auth-gated GET. The token is appended as the `auth` query parameter (per * Lighter's OpenAPI spec); the `Authorization` header is intentionally NOT * used — Lighter rejects it. */ getAuthed(path: string, authToken: string, params?: ApiParams): Promise; /** * GET that surfaces the raw `{status, body}` pair without throwing on * non-2xx — used for endpoints (account lookup by L1 address) where the * caller distinguishes specific Lighter error codes from generic failures. */ getWithStatus(path: string, params?: ApiParams): Promise<{ status: number; data: T; }>; /** * Form-encoded POST to a Lighter mutation endpoint. Single-shot — never * retried, since these are money/state writes whose outcome is unknown on a * transport failure. Surfaces the raw `{status, body}` pair so the caller can * map Lighter's per-endpoint business-rule `code` to a domain error verbatim. */ postForm(path: string, params: ApiParams): Promise<{ status: number; data: T; }>; private getChecked; /** * Post-parse validation shared by every checked read: rejects a non-2xx HTTP * status and a 200 body carrying a non-success `code`. Callers that surface a * distinct auth-rejection error must run that check before this one. */ private assertOk; } //# sourceMappingURL=apiClient.d.ts.map