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.

@outcome.xyz/hip4 — a modular stack of HIP-4 & its financial primitives.
pnpm add @outcome.xyz/hip4
HIP-4 SDK stack: outcome.xyz consumes the SDK, which composes six sub-adapters atop a single HIP-4 client

Key features

Market discovery

Fetch and filter prediction markets by type (defaultBinding, labelledBinding, priceBucket), category, or status. Paginate results and group by type or parent question.

Real-time data

Subscribe to live order books, mid prices, and trade streams via WebSocket. The SDK handles connection management and auto-reconnect with exponential backoff.

Order trading

Place limit and market orders with tick-aligned pricing, min-notional validation, and optional builder fee configuration. Cancel resting orders by ID.

Fund management

Deposit USDC to your prediction account, buy USDH, and withdraw funds back to your wallet. Uses EIP-712 signing for transfers and L1 agent signing for spot trades.

Architecture

The SDK is organized around a single HIP4Client that handles HTTP routing, 5xx retry logic, and WebSocket connection management. Six sub-adapters wrap that client and expose domain-specific methods:
AdapterPropertyResponsibility
HIP4EventAdapterhip4.eventsMarket discovery and event listing
HIP4MarketDataAdapterhip4.marketDataOrder books, prices, trades, candles
HIP4AccountAdapterhip4.accountPositions, balances, open orders
HIP4TradingAdapterhip4.tradingPlace and cancel orders
HIP4Authhip4.authAgent key approval and auth state
HIP4WalletAdapterhip4.walletUSDH deposits, withdrawals, transfers
You create the adapter with createHIP4Adapter() and call initialize() once to warm up the event cache. After that, all sub-adapters are accessible as properties on the returned object.
import { createHIP4Adapter } from "@outcome.xyz/hip4";

const hip4 = createHIP4Adapter({ testnet: true });
await hip4.initialize();

// All sub-adapters are now ready
const markets = await hip4.events.fetchMarkets();
const book    = await hip4.marketData.fetchOrderBook("516", 0);
const status  = hip4.auth.getAuthStatus();
The SDK has zero runtime dependencies. All signing - including L1 agent signing (MessagePack + keccak-256 + EIP-712) and user-signed EIP-712 operations - is implemented from scratch in TypeScript with no third-party libraries.
Both testnet and mainnet are supported. Pass { testnet: true } (the default) to target the Hyperliquid testnet, or { testnet: false } for mainnet. The SDK automatically routes REST and WebSocket connections to the correct endpoints.