export type GetApiApiTradesArgs = {page?: number | undefined, limit?: number | undefined, userAddress?: string | undefined, pairName?: string | undefined}; export type GetApiApiTradesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get list trade * * GET /api/trades */ export const getApiApiTrades = async (args: GetApiApiTradesArgs, options: GetApiApiTradesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.userAddress != null) query.append("userAddress", String(args.userAddress)) if (args.pairName != null) query.append("pairName", String(args.pairName)) const url = `${baseUrl.replace(/\/+$/, '')}/api/trades${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 };