export type GetApiAssetRegistryPriceHistoryArgs = {assetKey?: string | undefined, chainId?: number | undefined, address?: string | undefined, window: '24h' | '1w' | '1m' | '3m' | '6m' | '1y' | 'all'}; export type GetApiAssetRegistryPriceHistoryOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Persisted price history for one active registry asset * * GET /asset-registry/price/history */ export const getApiAssetRegistryPriceHistory = async (args: GetApiAssetRegistryPriceHistoryArgs, options: GetApiAssetRegistryPriceHistoryOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.assetKey != null) query.append("assetKey", String(args.assetKey)) if (args.chainId != null) query.append("chainId", String(args.chainId)) if (args.address != null) query.append("address", String(args.address)) if (args.window != null) query.append("window", String(args.window)) const url = `${baseUrl.replace(/\/+$/, '')}/asset-registry/price/history${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };