export type GetApiDefiHistoricalPriceUnixArgs = {'x-chain'?: 'solana' | undefined, address: string, unixtime?: number | undefined, ui_amount_mode?: ('raw' | 'scaled' | 'both') | undefined}; export type GetApiDefiHistoricalPriceUnixOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Price - Historical by unix time * * GET /defi/historical_price_unix */ export const getApiDefiHistoricalPriceUnix = async (args: GetApiDefiHistoricalPriceUnixArgs, options?: GetApiDefiHistoricalPriceUnixOptions) => { const {baseUrl = "https://public-api.birdeye.so", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-chain'] != null) headers.set("x-chain", String(args['x-chain'])) if (args.address != null) query.append("address", String(args.address)) if (args.unixtime != null) query.append("unixtime", String(args.unixtime)) if (args.ui_amount_mode != null) query.append("ui_amount_mode", String(args.ui_amount_mode)) if (apiKeyAuth !== undefined) headers.set("X-API-KEY", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/defi/historical_price_unix${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 (await res.json()) as unknown };