The Account Adapter (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.
adapter.account) gives you read access to a wallet’s state on HIP-4 prediction markets. You can fetch open positions (held outcome tokens), the last 30 days of trade activity, raw spot balances including USDH, and currently resting orders. You can also subscribe to live position updates, which the adapter delivers by polling every 10 seconds - there is no WebSocket channel for spot balances on Hyperliquid. All methods accept a wallet address parameter, so you can query any account without authentication.
fetchPositions(address)
Returns a wallet’s open HIP-4 positions. Positions are derived from the spot clearinghouse state - each non-zero outcome token balance becomes a PredictionPosition. Midpoint prices are fetched in parallel to populate currentPrice and unrealizedPnl.
Parameters
The wallet address to query.
Return type
Promise<PredictionPosition[]>
The outcome ID extracted from the token coin string.
The coin string used for lookups (e.g.
"#5160").Human-readable side name resolved from
sideSpecs (e.g. "Yes", "Hypurr"). Use this for display.Number of outcome tokens held, formatted to 6 decimal places.
Average cost per token (
entryNtl / totalShares), formatted to 6 decimal places.Current midpoint price from
allMids. "0" when no mid is available.(currentPrice − avgCost) × shares, formatted to 6 decimal places.Maximum payout if the outcome resolves in your favor. Equal to
shares (each token pays out 1 USDH).Always
"active" in the current implementation. No settlement status check is performed.Always
"". Positions are not enriched with event metadata in the current implementation.Always
"". Same reason as eventTitle.eventTitle and marketQuestion are always empty strings. If you need these values, call adapter.events.fetchEvent() using the marketId and cross-reference the result.Example
fetchActivity(address)
Returns the last 30 days of trade fills for outcome coins held by the wallet. The response is sorted newest-first. Only fills for HIP-4 outcome coins are included - regular spot trades are filtered out.
Parameters
The wallet address to query.
Return type
Promise<PredictionActivity[]>
Trade ID from the Hyperliquid
tid field.Always
"trade" in the current implementation.The outcome ID extracted from the fill’s coin.
Raw coin string (e.g.
"#5160")."buy" or "sell".Execution price.
Fill size.
Never populated in the current implementation.
Fill time in milliseconds.
Example
fetchBalance(address)
Returns the raw spot clearinghouse balances for a wallet, including USDH and all outcome tokens. Use this when you need the full picture of what the wallet holds, not just open prediction positions.
Parameters
The wallet address to query.
Return type
Promise<HLSpotClearinghouseState> - an object with a balances array. Each balance entry contains:
| Field | Type | Description |
|---|---|---|
coin | string | Token coin string (e.g. "USDH", "#5160") |
token | number | Internal token index |
hold | string | Amount currently on hold (in open orders) |
total | string | Total balance including held amount |
entryNtl | string | Total entry notional (cost basis) |
Example
fetchOpenOrders(address)
Returns the currently resting (unfilled) orders for a wallet. Use the oid field to build cancel requests.
Parameters
The wallet address to query.
Return type
Promise<HLFrontendOrder[]> - each order contains:
| Field | Type | Description |
|---|---|---|
coin | string | Coin string (e.g. "#5160") |
side | "B" | "A" | "B" = buy, "A" = sell (ask) |
limitPx | string | Limit price |
sz | string | Remaining unfilled size |
oid | number | Order ID - use this in cancelOrder |
timestamp | number | Order creation time in milliseconds |
origSz | string | Original order size |
orderType | string | Order type label |
tif | string | null | Time-in-force |
Example
subscribePositions(address, cb)
Starts polling the wallet’s positions every 10 seconds and delivers updates to your callback. Each poll makes two API calls - spotClearinghouseState and allMids. Errors during a poll are silently swallowed and the polling continues.
There is no WebSocket channel for spot balances on Hyperliquid, so polling is the only mechanism available.
Parameters
The wallet address to poll.
Callback invoked after each successful poll. Receives the current
PredictionPosition[].Return type
Unsubscribe - a () => void function. Call it to stop the polling loop.
The polling interval is fixed at 10 seconds. The first delivery occurs after the initial 10-second delay, not immediately on subscription. If you need the current positions right away, call
fetchPositions() directly first, then subscribe.