export type GetApiV2MarketsMintPriceArgs = {mint: string, exchange?: string | undefined, quote_mint?: string | undefined}; export type GetApiV2MarketsMintPriceOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * GET /v2/markets/{mint}/price */ export const getApiV2MarketsMintPrice = async (args: GetApiV2MarketsMintPriceArgs, options?: GetApiV2MarketsMintPriceOptions) => { const {baseUrl = "https://api.renegade.fi", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.exchange != null) query.append("exchange", String(args.exchange)) if (args.quote_mint != null) query.append("quote_mint", String(args.quote_mint)) const url = `${baseUrl.replace(/\/+$/, '')}/v2/markets/${encodeURIComponent(String(args.mint))}/price${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.text() };