import { type PerpsProviderPlugin, type StorageAdapter } from '@lifi/perps-sdk'; import type { Address } from 'viem'; import { type LighterDeployment } from './constants.js'; /** * Consumer-level overrides for a ready-made Lighter provider plugin. Every * deployment fact — provider key, endpoints, signing chain id, collateral * asset, explorer — belongs to the SDK's {@link LighterDeployment} descriptor * and is not settable here; the signer, API-key store and read-only token * manager are created per plugin instance. * * Auth-token resolution order for the auth-gated reads: * 1. Per-call `options.lighterAuthToken` * 2. Constructor `authToken` (string or async factory) * 3. Persisted long-lived read-only token, keyed on the resolved Lighter * `accountIndex` * 4. Fresh 1h create via this instance's WASM signer + the user's registered * API key * * When none of these yields a token the auth-gated reads degrade gracefully: * - `getOrders`, `getActivity` return empty results (mirrors backend behaviour) * - `getOrder` throws `Unauthorized` * - `getAccount` returns zero fee tier rather than failing * * @public */ export interface LighterProviderOptions { /** * Persistence backend for this instance's Lighter API keypair and read-only * token. Defaults to browser `localStorage` (encrypted at rest). Pass a * custom adapter for SSR / non-browser hosts or another storage backend. */ storage?: StorageAdapter; /** * Lighter REST base URL. Defaults to the deployment's own endpoint; override * to point at a reverse proxy, self-hosted mirror or rate-limit gateway. The * instance's signer and read-only token manager follow this URL. */ restUrl?: string; /** Pre-created Lighter read-only bearer, bypassing SDK token resolution. */ authToken?: string | (() => string | Promise); /** Token lifetime for on-demand standard-token creates (Lighter caps at 8h). Default 1h. */ tokenLifetimeSeconds?: number; /** Re-create when the cached standard token's remaining life is below this. Default 60s. */ tokenRenewBufferSeconds?: number; } /** * Lighter provider plugin extended with a public `resolveAuthToken` so the * WS layer can share the same token-resolution closure that the read methods * use internally. The base {@link PerpsProviderPlugin} contract stays * provider-agnostic — this extension is opt-in for callers that explicitly * type against it. * * @public */ export interface LighterPerpsProvider extends PerpsProviderPlugin { /** * Resolve a Lighter auth token for `address`, following the resolution order * documented on {@link LighterProviderOptions} (the per-call override does not * apply here). Returns `undefined` when no source can produce a token — * callers degrade gracefully. */ resolveAuthToken(address: Address): Promise; } /** * Build a Lighter provider plugin for one deployment. The deployment * descriptor is SDK-owned, so this stays package-internal: consumers reach it * through {@link lighterProvider} / {@link lighterRhProvider}. * * @internal */ export declare const createLighterProvider: (deployment: LighterDeployment, options?: LighterProviderOptions) => LighterPerpsProvider; /** * Lighter mainnet provider plugin. Returns an object implementing * {@link PerpsProviderPlugin}, mirroring the `EthereumProvider()` / * `hyperliquidProvider()` shape used by the rest of the LI.FI SDK family. * * Read functions call Lighter's REST API directly with no LI.FI backend hop; * auth-gated reads resolve their token via the order documented on * {@link LighterProviderOptions}. Write actions (`WASM_BLOB` and `EVM_TX` * signing) are dispatched via `signActions` — `PerpsClient.execute` delegates * those arms here. The instance owns its WASM signer, API-key store and * read-only token manager. * * @example * ```ts * const client = createPerpsClient({ * apiKey: 'your-api-key', * providers: [lighterProvider()], * }) * ``` * @public */ export declare const lighterProvider: (options?: LighterProviderOptions) => LighterPerpsProvider; /** * Lighter-on-Robinhood-chain provider plugin. Same contract as * {@link lighterProvider}, bound to the RH deployment: its own endpoints, * zkLighter signing chain id, USDG collateral, and its own signer, API-key * store and read-only token manager. Registering both factories on one client * keeps their credentials and caches separate. * * @example * ```ts * const client = createPerpsClient({ * apiKey: 'your-api-key', * providers: [lighterProvider(), lighterRhProvider()], * }) * ``` * @public */ export declare const lighterRhProvider: (options?: LighterProviderOptions) => LighterPerpsProvider; /** * Alias matching `@lifi/sdk`'s capitalised factory naming (`EVM()`, `EthereumProvider()`). * * @public */ export declare const Lighter: (options?: LighterProviderOptions) => LighterPerpsProvider; //# sourceMappingURL=LighterProvider.d.ts.map