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 USDC, 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
string
required
The wallet address to query.
Return type
Promise<PredictionPosition[]>
string
required
The outcome ID extracted from the token coin string.
string
required
The coin string used for lookups (e.g.
"#5160").string
required
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.
string
required
Average cost per token (
entryNtl / totalShares), formatted to 6 decimal
places.string
required
Current midpoint price from
allMids. "0" when no mid is available.string
required
(currentPrice − avgCost) × shares, formatted to 6 decimal places.string
required
Maximum payout if the outcome resolves in your favor. Equal to
shares (each
token pays out 1 USDC).string
required
Always
"active" in the current implementation. No settlement status check is
performed.string
required
Always
"". Positions are not enriched with event metadata in the current
implementation.string
required
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
string
required
The wallet address to query.
Return type
Promise<PredictionActivity[]>
string
required
Trade ID from the Hyperliquid
tid field.string
required
Always
"trade" in the current implementation.string
The outcome ID extracted from the fill’s coin.
string
Raw coin string (e.g.
"#5160").string
"buy" or "sell".string
Execution price.
string
Fill size.
string
Never populated in the current implementation.
number
required
Fill time in milliseconds.
Example
fetchBalance(address)
Returns the raw spot clearinghouse balances for a wallet, including USDC and all outcome tokens. Use this when you need the full picture of what the wallet holds, not just open prediction positions.
Parameters
string
required
The wallet address to query.
Return type
Promise<HLSpotClearinghouseState> - an object with a balances array. Each balance entry contains:
Example
fetchOpenOrders(address)
Returns the currently resting (unfilled) orders for a wallet. Use the oid field to build cancel requests.
Parameters
string
required
The wallet address to query.
Return type
Promise<HLFrontendOrder[]> - each order contains:
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
string
required
The wallet address to poll.
(positions: PredictionPosition[]) => void
required
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.