1Branch0Tags
GL
glucryptouse HIP-4 series key identity
e149f868 days ago3Commits
typescript
import type { Hip4EdgeBotConfig } from "../config"; import type { Hip4GatewayAnalytics } from "./types"; function resolveGatewayBase() { const base = process.env.OPENPOND_GATEWAY_URL; if (!base) { throw new Error("OPENPOND_GATEWAY_URL is required for HIP-4 Edge Bot."); } return base.replace(/\/$/, ""); } async function fetchJson<T>(url: string): Promise<T> { const response = await fetch(url, { method: "GET", headers: { Accept: "application/json" }, }); const data = (await response.json().catch(() => null)) as T | { message?: string } | null; if (!response.ok) { const message = data && typeof data === "object" && "message" in data && typeof data.message === "string" ? data.message : `HTTP ${response.status}`; throw new Error(`HIP-4 edge gateway request failed: ${message}`); } return data as T; } export async function fetchHip4EdgeAnalytics(config: Hip4EdgeBotConfig) { const query = new URLSearchParams({ environment: config.execution.environment, underlying: config.model.underlying, model: config.model.selectedModel, depthUsd: String(config.model.depthUsd), includeExpired: String(config.model.includeExpired), }); const url = `${resolveGatewayBase()}/v1/hyperliquid/hip4-edge?${query.toString()}`; return fetchJson<Hip4GatewayAnalytics>(url); }