src/rest/types.ts
v0.2.1 · 1.6 KB
// Shared REST contract: instance hosts, fetch signature, paths.
/**
* Base URLs of the two independent deployments (knowledge base: instances-and-api.md §1).
* Different markets, accounts, account_index values and write windows.
* The robinhoodchain host comes from the front-end JS bundle, not from its HTML.
*/
export const INSTANCE_URLS = {
/** zkLighter mainnet. Everything about it in the knowledge base is "by documentation", never run live. */
mainnet: 'https://mainnet.zklighter.elliot.ai',
/** The robinhoodchain instance. */
robinhoodchain: 'https://api.rh.lighter.xyz',
} as const;
export type LighterInstance = keyof typeof INSTANCE_URLS;
/** Minimal fetch signature the client needs; the global `fetch` satisfies it. */
export type FetchLike = (input: string, init: RequestInit) => Promise<Response>;
/** REST paths used by the kit (all under `/api/v1`). */
export const REST_PATHS = {
orderBooks: '/api/v1/orderBooks',
orderBookDetails: '/api/v1/orderBookDetails',
account: (accountIndex: number) => `/api/v1/account?by=index&value=${accountIndex}`,
/** Without `market_id` (or with 255) the exchange returns orders of ALL markets in one call. */
accountActiveOrders: (accountIndex: number, marketIndex?: number) =>
marketIndex === undefined
? `/api/v1/accountActiveOrders?account_index=${accountIndex}`
: `/api/v1/accountActiveOrders?account_index=${accountIndex}&market_id=${marketIndex}`,
} as const;
/** `market_id` value meaning "all markets" in `accountActiveOrders` (verified live 2026-08-20). */
export const ALL_MARKETS_ID = 255;