Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.outcome.xyz/llms.txt

Use this file to discover all available pages before exploring further.

This page documents all exported TypeScript types from @outcome.xyz/hip4. Every type listed here is importable from the main entry point. If you only need types without pulling in any runtime code - for example in a shared type package - use the dedicated types entry point instead.
Import types without any runtime cost using @outcome.xyz/hip4/types:
import type { HIP4Market, MarketType } from "@outcome.xyz/hip4/types";

Market types

HIP-4 markets are represented as a discriminated union. Every market carries a type field you can use to narrow to the correct variant.

MarketType

type MarketType = "defaultBinary" | "labelledBinary" | "multiOutcome" | "priceBucket";

HIP4Market

The top-level discriminated union covering all four market variants:
type HIP4Market =
  | DefaultBinaryMarket
  | LabelledBinaryMarket
  | MultiOutcomeMarket
  | PriceBucketMarket;

BaseMarket

Fields shared across all market types:
FieldTypeDescription
typeMarketTypeDiscriminant for narrowing the union
outcomeIdnumberHyperliquid outcome ID
namestringHuman-readable market name
descriptionstringHuman-readable market description
sides[MarketSide, MarketSide]Both tradeable sides with pre-computed identifiers
rawHLOutcomeRaw Hyperliquid API response, for escape-hatch access

MarketSide

FieldTypeDescription
namestringSide label (e.g. "Yes", "No", "Hypurr")
coinNumnumberRaw coin number: outcomeId * 10 + sideIndex
coinstringCoin string for API calls (e.g. "#5160")
assetnumberOrder asset field: 100_000_000 + coinNum

DefaultBinaryMarket

Recurring price binary markets with a structured pipe-delimited description. Extends BaseMarket.
FieldTypeDescription
type"defaultBinary"Type discriminant
underlyingstringUnderlying asset symbol (e.g. "BTC", "ETH")
targetPricenumberStrike price
expiryDateExpiry timestamp in UTC
periodstringMarket period (e.g. "15m", "1h", "1d")

LabelledBinaryMarket

Standalone binary markets with custom side names. Extends BaseMarket with no additional fields.
FieldTypeDescription
type"labelledBinary"Type discriminant

MultiOutcomeMarket

Outcomes grouped under a parent question, with a fallback outcome representing “none of the above”. Extends BaseMarket.
FieldTypeDescription
type"multiOutcome"Type discriminant
questionIdnumberParent question ID
questionNamestringParent question name
isFallbackbooleantrue if this is the fallback (“Other”) outcome

PriceBucketMarket

Multi-bucket price range markets where each outcome covers a specific price band. Extends BaseMarket.
FieldTypeDescription
type"priceBucket"Type discriminant
underlyingstringUnderlying asset symbol
expiryDateExpiry timestamp in UTC
priceThresholdsnumber[]Sorted ascending price boundaries; N thresholds produce N+1 buckets
periodstringMarket period (e.g. "15m")
questionIdnumberParent question ID
questionNamestringParent question name
isFallbackbooleantrue if this is the settlement fallback outcome
bucketIndexnumberIndex within the question’s named outcomes; -1 for fallback
lowerBound`numbernull`Inclusive lower bound; null = unbounded below
upperBound`numbernull`Exclusive upper bound; null = unbounded above

Event types

Events are the top-level grouping for prediction markets.

PredictionEvent

FieldTypeDescription
idstringEvent ID ("q<n>" for questions, "o<n>" for standalone outcomes)
titlestringDisplay title
descriptionstringFull description
categorystringCategory slug ("custom" or "recurring")
marketsPredictionMarket[]Markets belonging to this event
totalVolumestringTotal trading volume across all markets
endDatestringExpiry date string; populated for recurring markets, empty otherwise
statusPredictionEventStatusCurrent lifecycle status
imageUrl?stringOptional cover image URL
resolutionSource?stringOptional link to resolution criteria

PredictionMarket

A single question within an event containing tradeable outcome tokens.
FieldTypeDescription
idstringMarket ID (the outcome ID as a string)
eventIdstringParent event ID
questionstringMarket question text
outcomesPredictionOutcome[]Tradeable sides
volumestringTrading volume
liquiditystringCurrent liquidity
isNegRisk?booleanWhether the market uses negative-risk (multi-outcome) pricing

PredictionOutcome

One tradeable side of a prediction market.
FieldTypeDescription
namestringSide name (e.g. "Yes", "No")
tokenIdstringSide coin identifier (e.g. "#5160")
pricestringCurrent mid-price (0–1 range)

PredictionCategory

FieldTypeDescription
idstringCategory identifier
namestringDisplay name
slugstringURL-safe slug
The SDK defines two built-in categories: "custom" (manually created markets) and "recurring" (automated recurring markets).

PredictionEventStatus

type PredictionEventStatus = "active" | "pending_resolution" | "resolved" | "cancelled";

Trading types

PredictionOrderParams

Parameters for placing an order via hip4.trading.placeOrder.
FieldTypeRequiredDescription
marketIdstringYesOutcome ID string (e.g. "516")
outcomestringYesSide coin (e.g. "#5160")
side`“buy""sell”`YesTrade direction
type`“market""limit”`YesOrder type
pricestringFor limitLimit price in 0–1 range (e.g. "0.65")
amountstringYesNumber of shares as a string
timeInForce`“GTC""GTD""FOK""FAK""ALO”`NoDefault: "GTC" for limit orders
expirationstringNoGTD expiry (currently maps to GTC behavior)
markPxnumberNoMark price; enables min-shares validation when provided
builderAddressstringNoReferral address for builder fees
builderFeenumberNoFee in tenths of a basis point (100 = 0.1%, max 1000)
skipMinNotionalCheckbooleanNoSkip the $10 minimum check; use for position-closing flows

PredictionOrderResult

Returned by hip4.trading.placeOrder. Never throws - always check success.
FieldTypeDescription
successbooleanWhether the order was accepted
orderId?stringOrder ID for resting orders
status?stringExchange status string ("filled", "resting", "error")
shares?stringFilled size (for filled orders)
error?stringRejection reason (when success is false)

PredictionBatchOrderResult

Returned by hip4.trading.placeOrders (batch). Results are index-matched to the input params array.
FieldTypeDescription
successbooleantrue only when every individual order succeeded
resultsPredictionOrderResult[]Per-order results in input order

PredictionCancelParams

Parameters for cancelling a resting order via hip4.trading.cancelOrder.
FieldTypeDescription
marketIdstringThe outcome ID string
orderIdstringThe order ID to cancel
outcome?stringSide coin (e.g. "#5160"); used to resolve the correct asset ID. Defaults to side 0 if omitted

Account types

PredictionPosition

An open position in a prediction market outcome, derived from spot balances.
FieldTypeDescription
marketIdstringOutcome ID
eventTitlestringTitle of the parent event
marketQuestionstringQuestion text of the parent market
outcomestringCoin identifier (e.g. "#90")
outcomeNamestringResolved side name (e.g. "Hypurr", "Yes")
sharesstringNumber of shares held
avgCoststringAverage entry cost per share (entry notional / shares)
currentPricestringCurrent mid-price
unrealizedPnlstringUnrealized profit/loss in USDH
potentialPayoutstringMaximum payout if the outcome resolves in your favor
eventStatus`“active""pending_resolution""resolved”`Current event lifecycle state

PredictionActivity

A historical account activity record.
FieldTypeDescription
idstringActivity record ID
type`“trade""redeem""deposit""withdrawal”`Activity type
marketId?stringOutcome ID (for trade and redeem entries)
outcome?stringSide coin (for trade entries)
side?`“buy""sell”`Trade direction (for trade entries)
price?stringFill price (for trade entries)
size?stringFill size (for trade entries)
amount?stringUSDC amount (for deposit and withdrawal entries)
timestampnumberUnix timestamp in milliseconds

PredictionAuthState

The current authentication state of the trading adapter.
FieldTypeDescription
status`“disconnected""pending_approval""ready”`Auth lifecycle state
address?stringThe user’s wallet address, set after initAuth

Market data types

PredictionOrderBook

FieldTypeDescription
marketIdstringOutcome ID
bidsPredictionOrderBookLevel[]Buy-side price levels, best bid first
asksPredictionOrderBookLevel[]Sell-side price levels, best ask first
timestampnumberSnapshot timestamp in milliseconds

PredictionOrderBookLevel

FieldTypeDescription
pricestringPrice level
sizestringAggregate size at this level

PredictionPrice

FieldTypeDescription
marketIdstringOutcome ID
outcomesArray<{ name: string; price: string; midpoint: string }>Current prices for both sides
timestampnumberPrice snapshot timestamp in milliseconds

PredictionTrade

FieldTypeDescription
idstringTrade ID
marketIdstringOutcome ID
outcomestringSide coin name
side`“buy""sell”`Trade direction
pricestringFill price
sizestringFill size
timestampnumberFill timestamp in milliseconds