/** * Error class hierarchy for the SDK. All subclasses extend `AugustSDKError`, * which extends the native `Error`. * * ```ts * import { AugustAuthError, AugustTimeoutError } from '@augustdigital/sdk'; * * try { * await sdk.getVault(...); * } catch (err) { * if (err instanceof AugustAuthError) refreshKey(); * else if (err instanceof AugustTimeoutError) retry(); * else throw err; * } * ``` */ /** Stable error codes attached to SDK errors. */ export type AugustErrorCode = 'AUTH_MISSING_KEY' | 'AUTH_INVALID_KEY' | 'AUTH_FORBIDDEN' | 'AUTH_UNAUTHORIZED' | 'INVALID_URL' | 'INVALID_INPUT' | 'INVALID_CHAIN' | 'INVALID_ADDRESS' | 'ACCOUNT_NOT_FUNDED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RATE_LIMITED' | 'SERVER_ERROR' | 'TRANSACTION_UNCONFIRMED' | 'HISTORY_UNAVAILABLE' | 'PRICE_UNAVAILABLE' | 'UNKNOWN'; /** Options accepted by every SDK error constructor. */ export interface AugustErrorOptions { /** Original error preserved for stack-trace chaining. */ cause?: unknown; /** Set from the response `x-correlation-id` header when available. */ correlationId?: string; /** Structured context attached to the error for logging. */ context?: Record; } /** Base class for all SDK errors. */ export declare class AugustSDKError extends Error { readonly code: AugustErrorCode; readonly correlationId?: string; readonly context?: Record; constructor(code: AugustErrorCode, message: string, options?: AugustErrorOptions); /** * Serialize own properties to a plain object. Native `Error` enumerates * nothing, so `JSON.stringify(err)` returns `"{}"` without this. */ toJSON(): Record; } /** Authentication/authorization failure: missing key, invalid key, forbidden. */ export declare class AugustAuthError extends AugustSDKError { constructor(code: Extract, message: string, options?: AugustErrorOptions); } /** Network-level failure: connection refused, DNS, fetch failed. */ export declare class AugustNetworkError extends AugustSDKError { constructor(message: string, options?: AugustErrorOptions); } /** Request exceeded its deadline. */ export declare class AugustTimeoutError extends AugustSDKError { /** Time elapsed (ms) before the request was aborted. */ readonly timeoutMs: number; constructor(message: string, timeoutMs: number, options?: AugustErrorOptions); toJSON(): Record; } /** Caller-side input failed validation. */ export declare class AugustValidationError extends AugustSDKError { constructor(code: Extract, message: string, options?: AugustErrorOptions); } /** Backend rate-limited the request (HTTP 429 or equivalent). */ export declare class AugustRateLimitError extends AugustSDKError { /** Suggested wait before retrying, in milliseconds. */ readonly retryAfterMs?: number; constructor(message: string, options?: AugustErrorOptions & { retryAfterMs?: number; }); toJSON(): Record; } /** Backend returned a non-OK status that isn't auth, rate-limit, or timeout. */ export declare class AugustServerError extends AugustSDKError { /** HTTP status code returned by the backend. */ readonly status: number; constructor(status: number, message: string, options?: AugustErrorOptions); toJSON(): Record; } /** * Transaction/position history required to compute a value could not be * retrieved or was empty, so the computed result would be wrong rather than * merely missing. * * Motivation — the 2026-07-09 lifetime-PnL over-inflation incident. Lifetime * PnL is `currentPosition + totalWithdrawn - totalDeposited`. Every * history-fetch failure (deleted subgraph, subgraph deployed against the wrong * ABI, missing archive backfill, deposits indexed on a different * chain/contract) collapses the deposit/withdrawal history to empty. With * `deposited = 0` and `withdrawn = 0` but a live on-chain `position > 0`, the * formula degenerates to reporting the entire position as profit. Throwing this * typed error makes that unrecoverable state fail loudly instead of returning * an inflated number that looks plausible. * * @example * ```ts * try { * await sdk.vaults.getVaultUserLifetimePnl({ vault, wallet, options }); * } catch (err) { * if (err instanceof AugustHistoryUnavailableError) { * // History backfill is broken — surface "temporarily unavailable", * // never a fabricated PnL number. * showUnavailable(err.context); * } else throw err; * } * ``` */ export declare class AugustHistoryUnavailableError extends AugustSDKError { /** * @param message - Human-readable description of the missing history. Callers * pass the same `#::::` prefix the surrounding getter * uses so log grouping stays consistent. * @param options - Standard SDK error options. `context` should carry the * `{ vault, wallet }` (or equivalent) identifiers that scope the failure. */ constructor(message: string, options?: AugustErrorOptions); } /** * The USD price needed to convert a computed value could not be resolved, so * any USD figure derived from it would be fabricated rather than merely * missing. * * Motivation — `getVaultUserLifetimePnl` used to substitute a price of `1` * whenever the price server returned nothing, which reported every * USD field of a non-dollar vault (lsETH, tETH, BTC) at $1 per asset: a * position worth ~$40k read as ~$13, indistinguishable from a real result. * Throwing this typed error makes a missing price explicit so callers can hide * the USD value instead of displaying a wrong one. * * @example * ```ts * try { * await sdk.getVaultUserLifetimePnl({ vault, wallet, chainId }); * } catch (err) { * if (err instanceof AugustPriceUnavailableError) { * // No USD price for the vault asset — hide the USD figures rather than * // show a fabricated one. * hideUsd(err.context); * } else throw err; * } * ``` */ export declare class AugustPriceUnavailableError extends AugustSDKError { /** * @param message - Human-readable description of the missing price. Callers * pass the same `#::::` prefix the surrounding getter * uses so log grouping stays consistent. * @param options - Standard SDK error options. `context` should carry the * identifiers that scope the failure (e.g. `{ vault, wallet, asset }`). */ constructor(message: string, options?: AugustErrorOptions); } /** * A transaction was sent but its outcome could not be established * (`TRANSACTION_UNCONFIRMED`). It may have landed: check {@link signature} * before resubmitting, or a deposit or redeem can execute twice. * `context.reason` says what was seen (e.g. `expired_not_found`: the blockhash * expired and no lookup found it, so it very likely never landed). * * @example * ```ts * try { * await sdk.solana.vaultDeposit(programId, idl, wallet, amount, undefined, vault); * } catch (err) { * if (err instanceof AugustTransactionError) showPending(err.signature); * else throw err; * } * ``` */ export declare class AugustTransactionError extends AugustSDKError { /** Signature of the transaction that was sent. */ readonly signature: string; /** * @param message - Human-readable description, naming the signature. * @param signature - Signature of the transaction that was sent. * @param options - Standard SDK error options. */ constructor(message: string, signature: string, options?: AugustErrorOptions); toJSON(): Record; } /** Type guard. Works across realms (e.g. Web Worker / VM contexts). */ export declare function isAugustSDKError(err: unknown): err is AugustSDKError;