adapter.events) is your entry point for discovering what is tradeable on HIP-4. It maps raw Hyperliquid outcome metadata into structured PredictionEvent objects and typed HIP4Market objects, enriching each with live midpoint prices. Results are cached for 30 seconds, so repeated calls within that window return immediately without hitting the API.
fetchEvents(params?)
Returns a paginated, optionally filtered list of prediction events. Internally, the adapter fetches outcomeMeta and allMids in parallel, builds events from the metadata, and enriches outcome prices from the mids response.
Parameters
string
Filter events by category slug. Pass
"custom" or "recurring". Passing
"all" is treated as no filter.boolean
When
true, only events with status === "active" are returned.number
default:"50"
Maximum number of events to return.
number
default:"0"
Pagination offset. Applied after category, active, and query filters.
string
Case-insensitive search string matched against event
title and
description.Return type
Promise<PredictionEvent[]>
string
required
Event identifier. Prefix
q for question-based events (e.g. "q5"); prefix
o for standalone outcome events (e.g. "o1338").string
required
Human-readable event title.
string
required
Event description text.
string
required
Category slug:
"custom" or "recurring".PredictionMarket[]
required
Markets belonging to this event. Each market corresponds to one HIP-4 outcome.
string
required
"active" | "pending_resolution" | "resolved" | "cancelled"string
required
Expiry date string. Populated for recurring markets; empty string otherwise.
string
required
Cumulative volume across all markets. Always
"0" in the current
implementation.Example
fetchEvent(eventId)
Fetches a single event by its ID. Loads the full event list via the cache and finds the match. Throws if the event is not found.
Parameters
string
required
The event ID to look up. Use
q{n} for question-based events or o{n} for
standalone outcome events.Return type
Promise<PredictionEvent> - same shape as each element returned by fetchEvents.
Throws "HIP-4 event not found: {eventId}" if the ID does not match any event.
Example
fetchCategories()
Returns the list of available event categories. This call is synchronous under the hood - no API request is made.
Return type
Promise<PredictionCategory[]>
The response always contains exactly two entries:
Example
fetchMarkets(params?)
Returns typed HIP4Market objects for all HIP-4 outcomes. Each market is classified into one of four types based on the outcome’s metadata, and carries pre-computed side coin identifiers ready for order placement.
The return type changes depending on whether you pass groupBy:
Parameters
string
Filter to a single market type. One of
"defaultBinary", "labelledBinary",
"multiOutcome", "priceBucket".string
default:"newest"
Sort order.
"newest" | "volume" | "expiry".string
Group the results.
"type" returns a MarketsByType object keyed by market
type. "question" returns a MarketsByQuestion object keyed by question ID
(or "standalone" for unattached outcomes).number
default:"100"
Maximum number of markets to return (applied after filtering).
number
default:"0"
Pagination offset.
Market types
All four types extend a sharedBaseMarket with these fields:
Each
MarketSide exposes:
Examples
When using
groupBy, limit and offset apply to the flat list before
grouping. The resulting grouped object may therefore contain fewer items than
limit if the outcomes span multiple groups.