export type GetApiApiV1UsersUserIdBalanceArgs = {userId: string, spenderAddress?: string | undefined}; export type GetApiApiV1UsersUserIdBalanceOptions = {baseUrl?: string | undefined, TradingApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get account balance * * GET /api/v1/users/{userId}/balance * * Also accepts auth: TradingApiNonce, TradingApiTimestamp, TradingApiSignature, ApiChainId, ApiProductType */ export const getApiApiV1UsersUserIdBalance = async (args: GetApiApiV1UsersUserIdBalanceArgs, options?: GetApiApiV1UsersUserIdBalanceOptions) => { const {baseUrl = "https://rwa-api.anchored.finance/rwa/trading", fetch: fetchFn = fetch, TradingApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.spenderAddress != null) query.append("spenderAddress", String(args.spenderAddress)) if (TradingApiKey !== undefined) headers.set("x-api-key", TradingApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/users/${encodeURIComponent(String(args.userId))}/balance${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 res.blob() };