get_markets
Retrieve perpetual futures market data from exchanges, including prices, funding rates, volumes, and leverage limits for trading analysis.
Instructions
Get all available perpetual futures markets on an exchange, including price, funding rate, volume, and max leverage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchange | Yes | Exchange name: pacifica, hyperliquid, or lighter |
Implementation Reference
- src/exchanges/hyperliquid.ts:189-231 (handler)Implementation of `getMarkets()` in `HyperliquidAdapter` which fetches market information from the Hyperliquid API, supporting both native and HIP-3 dex-specific queries.
async getMarkets(): Promise<ExchangeMarketInfo[]> { let universe: Record<string, unknown>[]; let ctxs: Record<string, unknown>[]; let mids: Record<string, string> = {}; if (this._dex) { // HIP-3: use raw info POST with dex param const meta = await this._infoPost({ type: "metaAndAssetCtxs", dex: this._dex }) as [{ universe: Record<string, unknown>[] }, Record<string, unknown>[]]; universe = meta[0]?.universe ?? []; ctxs = meta[1] ?? []; } else { const [meta, allMids] = await Promise.all([ this.sdk.info.perpetuals.getMetaAndAssetCtxs(), this.sdk.info.getAllMids(), ]); universe = meta[0]?.universe ?? []; ctxs = meta[1] ?? []; mids = allMids as Record<string, string>; } // Rebuild asset map if empty (fallback — normally populated by init/_loadAssetMap) if (this._assetMap.size === 0 && !this._dex) { universe.forEach((asset, i) => { const sym = String(asset.name); this._assetMap.set(sym, i); this._assetMapReverse.set(i, sym); }); } return universe.map((asset: Record<string, unknown>, i: number) => { const ctx = (ctxs[i] ?? {}) as Record<string, unknown>; const sym = String(asset.name); return { symbol: sym, markPrice: String(ctx.markPx ?? mids[sym] ?? "0"), indexPrice: String(ctx.oraclePx ?? "0"), fundingRate: String(ctx.funding ?? "0"), volume24h: String(ctx.dayNtlVlm ?? "0"), openInterest: String(ctx.openInterest ?? "0"), maxLeverage: Number(asset.maxLeverage ?? 50), }; }); }