@outcome.xyz/hip4 1.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,799 @@
1
+ /** An open position in a prediction market outcome. */
2
+ interface PredictionPosition {
3
+ marketId: string;
4
+ eventTitle: string;
5
+ marketQuestion: string;
6
+ /** Coin identifier (e.g. "#90" or "#91"). Use for lookups. */
7
+ outcome: string;
8
+ /** Human-readable side name from sideSpecs (e.g. "Hypurr", "Yes"). Use for display. */
9
+ outcomeName: string;
10
+ shares: string;
11
+ avgCost: string;
12
+ currentPrice: string;
13
+ unrealizedPnl: string;
14
+ potentialPayout: string;
15
+ eventStatus: "active" | "pending_resolution" | "resolved";
16
+ }
17
+ /** A historical account activity entry (trade, redeem, deposit, or withdrawal). */
18
+ interface PredictionActivity {
19
+ id: string;
20
+ type: "trade" | "redeem" | "deposit" | "withdrawal";
21
+ marketId?: string;
22
+ outcome?: string;
23
+ side?: "buy" | "sell";
24
+ price?: string;
25
+ size?: string;
26
+ amount?: string;
27
+ timestamp: number;
28
+ }
29
+ /** Current authentication state for the trading adapter. */
30
+ interface PredictionAuthState {
31
+ status: "disconnected" | "pending_approval" | "ready";
32
+ address?: string;
33
+ apiKey?: string;
34
+ }
35
+
36
+ /** A prediction event containing one or more markets. */
37
+ interface PredictionEvent {
38
+ /** Unique event ID (e.g. "q123" for questions, "o456" for standalone outcomes). */
39
+ id: string;
40
+ title: string;
41
+ description: string;
42
+ category: string;
43
+ markets: PredictionMarket[];
44
+ /** Cumulative volume across all markets in the event. */
45
+ totalVolume: string;
46
+ endDate: string;
47
+ status: PredictionEventStatus;
48
+ imageUrl?: string;
49
+ resolutionSource?: string;
50
+ }
51
+ type PredictionEventStatus = "active" | "pending_resolution" | "resolved" | "cancelled";
52
+ /** A single market (question) within a prediction event. */
53
+ interface PredictionMarket {
54
+ id: string;
55
+ eventId: string;
56
+ question: string;
57
+ outcomes: PredictionOutcome[];
58
+ volume: string;
59
+ liquidity: string;
60
+ /** True if this market uses neg-risk framing. */
61
+ isNegRisk?: boolean;
62
+ }
63
+ /** One side of a prediction market (e.g. "Yes" or "No"). */
64
+ interface PredictionOutcome {
65
+ name: string;
66
+ /** The spot token ID used for trading this outcome. */
67
+ tokenId: string;
68
+ /** Current price as a decimal string (0-1). */
69
+ price: string;
70
+ }
71
+ /** A category used to group prediction events. */
72
+ interface PredictionCategory {
73
+ id: string;
74
+ name: string;
75
+ slug: string;
76
+ }
77
+
78
+ interface HLOutcomeMeta {
79
+ outcomes: HLOutcome[];
80
+ questions: HLQuestion[];
81
+ }
82
+ interface HLOutcome {
83
+ outcome: number;
84
+ name: string;
85
+ description: string;
86
+ sideSpecs: HLSideSpec[];
87
+ }
88
+ interface HLSideSpec {
89
+ name: string;
90
+ token?: number;
91
+ }
92
+ interface HLQuestion {
93
+ question: number;
94
+ name: string;
95
+ description: string;
96
+ fallbackOutcome: number;
97
+ namedOutcomes: number[];
98
+ settledNamedOutcomes: number[];
99
+ }
100
+ interface HLSettledOutcome {
101
+ spec: HLOutcome;
102
+ settleFraction: string;
103
+ details: string;
104
+ /**
105
+ * Parent question, returned by HL for outcomes that belong to a question
106
+ * group (priceBucket, multiOutcome). Omitted for standalone priceBinary
107
+ * outcomes. The `description` here is the parent question's description
108
+ * (e.g. `class:priceBucket|underlying:BTC|...`), which is what consumers
109
+ * need to recover bucket bounds after the question itself has been
110
+ * removed from `outcomeMeta`.
111
+ */
112
+ question?: {
113
+ /** Inner shape mirrors HL's API: `{ settled: <questionId> }`. */
114
+ question: {
115
+ settled: number;
116
+ };
117
+ name: string;
118
+ description: string;
119
+ };
120
+ }
121
+ interface HLL2Book {
122
+ coin: string;
123
+ time: number;
124
+ levels: [HLL2Level[], HLL2Level[]];
125
+ }
126
+ interface HLL2Level {
127
+ px: string;
128
+ sz: string;
129
+ n: number;
130
+ }
131
+ interface HLTrade {
132
+ coin: string;
133
+ side: "B" | "A";
134
+ px: string;
135
+ sz: string;
136
+ time: number;
137
+ hash: string;
138
+ tid: number;
139
+ users: [string, string];
140
+ }
141
+ interface HLCandle {
142
+ t: number;
143
+ T: number;
144
+ s: string;
145
+ i: string;
146
+ o: string;
147
+ c: string;
148
+ h: string;
149
+ l: string;
150
+ v: string;
151
+ n: number;
152
+ }
153
+ type HLAllMids = Record<string, string>;
154
+ interface HLClearinghouseState {
155
+ marginSummary: {
156
+ accountValue: string;
157
+ totalNtlPos: string;
158
+ totalRawUsd: string;
159
+ totalMarginUsed: string;
160
+ };
161
+ crossMarginSummary: {
162
+ accountValue: string;
163
+ totalNtlPos: string;
164
+ totalRawUsd: string;
165
+ totalMarginUsed: string;
166
+ };
167
+ crossMaintenanceMarginUsed: string;
168
+ withdrawable: string;
169
+ assetPositions: HLAssetPosition[];
170
+ time: number;
171
+ }
172
+ interface HLAssetPosition {
173
+ type: string;
174
+ position: {
175
+ coin: string;
176
+ szi: string;
177
+ entryPx: string;
178
+ positionValue: string;
179
+ unrealizedPnl: string;
180
+ returnOnEquity: string;
181
+ liquidationPx: string | null;
182
+ marginUsed: string;
183
+ maxLeverage: number;
184
+ leverage: {
185
+ type: string;
186
+ value: number;
187
+ rawUsd?: string;
188
+ };
189
+ cumFunding: {
190
+ allTime: string;
191
+ sinceOpen: string;
192
+ sinceChange: string;
193
+ };
194
+ };
195
+ }
196
+ /** Spot clearinghouse state - HIP-4 prediction balances live here */
197
+ interface HLSpotClearinghouseState {
198
+ balances: Array<{
199
+ coin: string;
200
+ token: number;
201
+ hold: string;
202
+ total: string;
203
+ entryNtl: string;
204
+ }>;
205
+ }
206
+ /** Frontend-formatted open order */
207
+ interface HLFrontendOrder {
208
+ coin: string;
209
+ side: "B" | "A";
210
+ limitPx: string;
211
+ sz: string;
212
+ oid: number;
213
+ timestamp: number;
214
+ origSz: string;
215
+ reduceOnly: boolean;
216
+ orderType: string;
217
+ tif: string | null;
218
+ cloid: string | null;
219
+ triggerCondition?: string;
220
+ isTrigger?: boolean;
221
+ triggerPx?: string;
222
+ children?: unknown[];
223
+ isPositionTpsl?: boolean;
224
+ }
225
+ interface HLFill {
226
+ coin: string;
227
+ px: string;
228
+ sz: string;
229
+ side: "B" | "A";
230
+ time: number;
231
+ startPosition: string;
232
+ dir: string;
233
+ closedPnl: string;
234
+ hash: string;
235
+ oid: number;
236
+ crossed: boolean;
237
+ fee: string;
238
+ tid: number;
239
+ feeToken: string;
240
+ }
241
+ interface HLWsUserFillsEvent {
242
+ readonly isSnapshot: boolean;
243
+ readonly user: string;
244
+ readonly fills: HLFill[];
245
+ }
246
+ interface HLOrderAction {
247
+ type: "order";
248
+ orders: HLOrderWire[];
249
+ grouping: "na";
250
+ }
251
+ interface HLOrderWire {
252
+ a: number;
253
+ b: boolean;
254
+ p: string;
255
+ s: string;
256
+ r: boolean;
257
+ t: HLOrderType;
258
+ /** Client order ID (hex string). Optional. */
259
+ c?: string;
260
+ }
261
+ type HLOrderType = {
262
+ limit: {
263
+ tif: "Gtc" | "Ioc" | "Alo" | "FrontendMarket";
264
+ };
265
+ } | {
266
+ trigger: {
267
+ triggerPx: string;
268
+ isMarket: boolean;
269
+ tpsl: "tp" | "sl";
270
+ };
271
+ };
272
+ interface HLSignature {
273
+ r: string;
274
+ s: string;
275
+ v: number;
276
+ }
277
+ interface HLExchangeResponse {
278
+ status: "ok" | "err";
279
+ response?: {
280
+ type: "order";
281
+ data: {
282
+ statuses: HLOrderStatus[];
283
+ };
284
+ };
285
+ }
286
+ type HLOrderStatus = {
287
+ filled: {
288
+ totalSz: string;
289
+ avgPx: string;
290
+ oid: number;
291
+ };
292
+ } | {
293
+ resting: {
294
+ oid: number;
295
+ };
296
+ } | {
297
+ error: string;
298
+ };
299
+ interface HLSplitOutcomeAction {
300
+ type: "userOutcome";
301
+ splitOutcome: {
302
+ outcome: number;
303
+ amount: string;
304
+ };
305
+ }
306
+ interface HLMergeOutcomeAction {
307
+ type: "userOutcome";
308
+ mergeOutcome: {
309
+ outcome: number;
310
+ amount: string | null;
311
+ };
312
+ }
313
+ interface HLMergeQuestionAction {
314
+ type: "userOutcome";
315
+ mergeQuestion: {
316
+ question: number;
317
+ amount: string | null;
318
+ };
319
+ }
320
+ /**
321
+ * The on-wire sub-key is `negateOutcome` (matching the page heading), NOT
322
+ * `negateQuestion` as the docs body's example renders it. Confirmed by
323
+ * inspecting Hyperliquid's own testnet "Convert Outcomes" UI on 2026-05-07
324
+ * - its `/exchange` POST sends `{ negateOutcome: { question, outcome,
325
+ * amount } }`. The docs body is a typo; the heading is correct.
326
+ */
327
+ interface HLNegateOutcomeAction {
328
+ type: "userOutcome";
329
+ negateOutcome: {
330
+ question: number;
331
+ outcome: number;
332
+ amount: string;
333
+ };
334
+ }
335
+ type HLUserOutcomeAction = HLSplitOutcomeAction | HLMergeOutcomeAction | HLMergeQuestionAction | HLNegateOutcomeAction;
336
+ interface HLScheduleCancelAction {
337
+ type: "scheduleCancel";
338
+ /** Unix milliseconds at which HL cancels every open order from this agent. `null` clears. */
339
+ time: number | null;
340
+ }
341
+ interface HLCancelAction {
342
+ type: "cancel";
343
+ cancels: Array<{
344
+ a: number;
345
+ o: number;
346
+ }>;
347
+ }
348
+ type HLCancelStatus = "success" | {
349
+ error: string;
350
+ };
351
+ interface HLCancelResponse {
352
+ status: "ok" | "err";
353
+ response?: {
354
+ type: "cancel";
355
+ data: {
356
+ statuses: HLCancelStatus[];
357
+ };
358
+ };
359
+ }
360
+ /**
361
+ * Modify an existing order. HL preserves queue priority for size-only
362
+ * changes; price changes move the order to the back of the queue at the
363
+ * new level. See https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint
364
+ */
365
+ interface HLModifyAction {
366
+ type: "modify";
367
+ oid: number;
368
+ order: HLOrderWire;
369
+ }
370
+ interface HLBatchModifyAction {
371
+ type: "batchModify";
372
+ modifies: Array<{
373
+ oid: number;
374
+ order: HLOrderWire;
375
+ }>;
376
+ }
377
+ /**
378
+ * HL's modify response. On success, `response` is the structured object
379
+ * with per-order statuses. On failure (`status: "err"`), HL returns the
380
+ * error reason as a plain string in `response` - surface it instead of
381
+ * discarding the payload.
382
+ */
383
+ interface HLModifyResponse {
384
+ status: "ok" | "err";
385
+ response?: {
386
+ type: "modify" | "batchModify";
387
+ data: {
388
+ statuses: HLOrderStatus[];
389
+ };
390
+ } | string;
391
+ }
392
+ interface HLWsL2BookData {
393
+ coin: string;
394
+ time: number;
395
+ levels: [
396
+ Array<{
397
+ px: string;
398
+ sz: string;
399
+ n: number;
400
+ }>,
401
+ Array<{
402
+ px: string;
403
+ sz: string;
404
+ n: number;
405
+ }>
406
+ ];
407
+ spread?: string;
408
+ }
409
+ /** BBO (Best Bid and Offer) WebSocket data - sent when the top-of-book changes. */
410
+ interface HLWsBboData {
411
+ coin: string;
412
+ time: number;
413
+ bbo: [HLWsBboLevel | null, HLWsBboLevel | null];
414
+ }
415
+ interface HLWsBboLevel {
416
+ px: string;
417
+ sz: string;
418
+ n: number;
419
+ }
420
+ interface HLWsAllMidsData {
421
+ mids: Record<string, string>;
422
+ }
423
+ interface HLWsActiveSpotAssetCtxData {
424
+ coin: string;
425
+ ctx: {
426
+ dayNtlVlm: string;
427
+ markPx: string;
428
+ midPx: string | null;
429
+ prevDayPx: string;
430
+ circulatingSupply: string;
431
+ coin: string;
432
+ totalSupply: string;
433
+ dayBaseVlm: string;
434
+ };
435
+ }
436
+ /** Single item from the bulk spotAssetCtxs WS subscription (flat, no ctx wrapper). */
437
+ interface HLWsSpotAssetCtxItem {
438
+ coin: string;
439
+ dayNtlVlm: string;
440
+ markPx: string;
441
+ midPx: string | null;
442
+ prevDayPx: string;
443
+ circulatingSupply: string;
444
+ totalSupply: string;
445
+ dayBaseVlm: string;
446
+ }
447
+ /** Bulk spot asset context WS response - flat array from spotAssetCtxs subscription. */
448
+ type HLWsSpotAssetCtxsData = HLWsSpotAssetCtxItem[];
449
+ interface HLWsActivePerpAssetCtxData {
450
+ coin: string;
451
+ ctx: {
452
+ markPx: string;
453
+ oraclePx: string;
454
+ funding: string;
455
+ openInterest: string;
456
+ dayNtlVlm: string;
457
+ premium: string;
458
+ prevDayPx: string;
459
+ };
460
+ }
461
+ type HLWsTradesEvent = HLTrade[];
462
+ interface HLWsOutcomeMetaSideSpec {
463
+ name: string;
464
+ }
465
+ interface HLWsOutcomeSpec {
466
+ outcome: number;
467
+ name: string;
468
+ description: string;
469
+ sideSpecs: [HLWsOutcomeMetaSideSpec, HLWsOutcomeMetaSideSpec];
470
+ }
471
+ interface HLWsQuestionSpec {
472
+ question: number;
473
+ name: string;
474
+ description: string;
475
+ fallbackOutcome: number;
476
+ namedOutcomes: number[];
477
+ settledNamedOutcomes: number[];
478
+ }
479
+ type HLWsOutcomeMetaUpdate = {
480
+ outcomeCreated: HLWsOutcomeSpec;
481
+ } | {
482
+ outcomeSettled: number;
483
+ } | {
484
+ questionUpdated: HLWsQuestionSpec;
485
+ } | {
486
+ questionSettled: number;
487
+ };
488
+ type HLWsOutcomeMetaUpdates = HLWsOutcomeMetaUpdate[];
489
+ interface HLWsSpotStateEvent {
490
+ user: `0x${string}`;
491
+ spotState: HLSpotClearinghouseState;
492
+ }
493
+ interface HLWsOpenOrdersEvent {
494
+ dex: string;
495
+ user: `0x${string}`;
496
+ orders: HLFrontendOrder[];
497
+ }
498
+ interface HLWsClearinghouseStateEvent {
499
+ dex: string;
500
+ user: `0x${string}`;
501
+ clearinghouseState: HLClearinghouseState;
502
+ }
503
+ interface HLExtraAgent {
504
+ address: `0x${string}`;
505
+ name: string;
506
+ validUntil: number;
507
+ }
508
+ interface HLUserRoleResponse {
509
+ /** Role assigned to the address by Hyperliquid (e.g. "user", "subAccount", "missing"). */
510
+ role?: string;
511
+ }
512
+ /**
513
+ * Account abstraction mode reported by the `userAbstraction` info endpoint.
514
+ *
515
+ * - `default` - standard mode returned by HL for regular accounts. Spot
516
+ * and per-perp-DEX wallets are separate. `usdClassTransfer` required.
517
+ * - `disabled` - legacy name for the same classic Standard mode; treated
518
+ * identically to `"default"`. Kept for backwards compatibility.
519
+ * - `dexAbstraction` - unifies multiple perp DEXes into one balance, but
520
+ * the spot/perp split is preserved. `usdClassTransfer` is still
521
+ * required and still allowed.
522
+ * - `unifiedAccount` - spot ↔ perps balances merged into a single balance.
523
+ * `usdClassTransfer` is rejected.
524
+ * - `portfolioMargin` - unified account plus cross-asset portfolio margin.
525
+ * `usdClassTransfer` is rejected.
526
+ *
527
+ * Only `unifiedAccount` and `portfolioMargin` trigger the API rejection
528
+ * `"Action disabled when unified account is active"`.
529
+ */
530
+ type HLUserAbstraction = "default" | "disabled" | "dexAbstraction" | "unifiedAccount" | "portfolioMargin";
531
+ /**
532
+ * Response shape of Hyperliquid's `userFees` info request.
533
+ * Rates are decimal strings (e.g. "0.000538" = 0.0538%).
534
+ *
535
+ * For HIP-4 outcome markets (spot-style), use `userSpotCrossRate`
536
+ * (taker) and `userSpotAddRate` (maker) - these already include
537
+ * tier, referral, staking, and aligned-quote-asset discounts.
538
+ */
539
+ interface HLUserFees {
540
+ userCrossRate: string;
541
+ userAddRate: string;
542
+ userSpotCrossRate: string;
543
+ userSpotAddRate: string;
544
+ activeReferralDiscount?: string;
545
+ activeStakingDiscount?: {
546
+ discount: string;
547
+ bpsOfMaxSupply: string;
548
+ } | null;
549
+ }
550
+ interface HLReferralState {
551
+ /** The referrer's address, if set */
552
+ referredBy?: {
553
+ code: string;
554
+ referrer: string;
555
+ } | null;
556
+ /** Cumulative referral rewards info */
557
+ cumVlm?: string;
558
+ unclaimedRewards?: string;
559
+ claimedRewards?: string;
560
+ }
561
+ interface HIP4Signer {
562
+ getAddress(): string | Promise<string>;
563
+ /**
564
+ * Sign a typed-data payload (EIP-712).
565
+ * Can return either:
566
+ * - HLSignature ({r, s, v}) directly
567
+ * - A hex string "0x..." which will be split into {r, s, v}
568
+ */
569
+ signTypedData(domain: Record<string, unknown>, types: Record<string, Array<{
570
+ name: string;
571
+ type: string;
572
+ }>>, value: Record<string, unknown>): Promise<HLSignature | string>;
573
+ }
574
+ /**
575
+ * Convert a viem hex signature (0x + 32 bytes r + 32 bytes s + 1 byte v)
576
+ * into the {r, s, v} format HL expects.
577
+ */
578
+ declare function splitHexSignature(hex: string): HLSignature;
579
+ /**
580
+ * Normalize a signature that may be hex or already split.
581
+ */
582
+ declare function normalizeSignature(sig: HLSignature | string): HLSignature;
583
+
584
+ type MarketType = "defaultBinary" | "labelledBinary" | "multiOutcome" | "priceBucket";
585
+ interface MarketSide {
586
+ /** Human-readable side name (e.g. "Yes", "No", "Hypurr") */
587
+ name: string;
588
+ /** Raw coin number: outcomeId * 10 + sideIndex */
589
+ coinNum: number;
590
+ /** Coin string for API calls: "#<coinNum>" */
591
+ coin: string;
592
+ /** Order asset field: 100_000_000 + coinNum */
593
+ asset: number;
594
+ }
595
+ interface BaseMarket {
596
+ type: MarketType;
597
+ /** HL outcome ID */
598
+ outcomeId: number;
599
+ /** Human-readable name */
600
+ name: string;
601
+ /** Human-readable description */
602
+ description: string;
603
+ /** Both sides with pre-computed coin/asset identifiers */
604
+ sides: [MarketSide, MarketSide];
605
+ /** Raw HL API response - always attached for escape-hatch access */
606
+ raw: HLOutcome;
607
+ }
608
+ interface DefaultBinaryMarket extends BaseMarket {
609
+ type: "defaultBinary";
610
+ /** Underlying asset symbol (e.g. "BTC", "ETH", "HYPE") */
611
+ underlying: string;
612
+ /** Strike price */
613
+ targetPrice: number;
614
+ /** Expiry timestamp as Date (UTC) */
615
+ expiry: Date;
616
+ /** Period string (e.g. "15m", "1h", "1d") */
617
+ period: string;
618
+ }
619
+ interface LabelledBinaryMarket extends BaseMarket {
620
+ type: "labelledBinary";
621
+ }
622
+ interface MultiOutcomeMarket extends BaseMarket {
623
+ type: "multiOutcome";
624
+ /** Parent question ID */
625
+ questionId: number;
626
+ /** Parent question name */
627
+ questionName: string;
628
+ /** Parent question description */
629
+ questionDescription: string;
630
+ /** Whether this is the fallback ("Other") outcome */
631
+ isFallback: boolean;
632
+ /** Raw question from API */
633
+ rawQuestion: HLQuestion;
634
+ }
635
+ interface PriceBucketMarket extends BaseMarket {
636
+ type: "priceBucket";
637
+ /** Underlying asset symbol (e.g. "BTC") */
638
+ underlying: string;
639
+ /** Expiry timestamp as Date (UTC) */
640
+ expiry: Date;
641
+ /** Sorted ascending price thresholds. N thresholds → N+1 buckets. */
642
+ priceThresholds: number[];
643
+ /** Period string (e.g. "15m", "1h", "1d") */
644
+ period: string;
645
+ /** Parent question ID */
646
+ questionId: number;
647
+ /** Parent question name */
648
+ questionName: string;
649
+ /** Parent question description (the raw priceBucket spec) */
650
+ questionDescription: string;
651
+ /** Whether this is the settlement fallback outcome */
652
+ isFallback: boolean;
653
+ /**
654
+ * Index of this bucket within the question's namedOutcomes array.
655
+ * -1 when this is the fallback outcome.
656
+ */
657
+ bucketIndex: number;
658
+ /** Lower bound of this bucket (inclusive). null = unbounded below. */
659
+ lowerBound: number | null;
660
+ /** Upper bound of this bucket (exclusive). null = unbounded above. */
661
+ upperBound: number | null;
662
+ /** Raw question from API */
663
+ rawQuestion: HLQuestion;
664
+ }
665
+ type HIP4Market = DefaultBinaryMarket | LabelledBinaryMarket | MultiOutcomeMarket | PriceBucketMarket;
666
+ interface FetchMarketsParams {
667
+ /** Filter to a specific market type */
668
+ type?: MarketType;
669
+ /** Sort order. Default: "newest" */
670
+ sortBy?: "volume" | "expiry" | "newest";
671
+ /** Group results by key */
672
+ groupBy?: "type" | "question";
673
+ /** Max results (after filtering). Default: 100 */
674
+ limit?: number;
675
+ /** Offset for pagination. Default: 0 */
676
+ offset?: number;
677
+ }
678
+ /** Result when groupBy is "type" */
679
+ type MarketsByType = Partial<Record<MarketType, HIP4Market[]>>;
680
+ /** Result when groupBy is "question" - keyed by questionId or "standalone" */
681
+ type MarketsByQuestion = Record<string, HIP4Market[]>;
682
+ /** Return type varies based on groupBy */
683
+ type FetchMarketsResult<T extends FetchMarketsParams> = T extends {
684
+ groupBy: "type";
685
+ } ? MarketsByType : T extends {
686
+ groupBy: "question";
687
+ } ? MarketsByQuestion : HIP4Market[];
688
+
689
+ /** Snapshot of the order book for one side of a prediction market. */
690
+ interface PredictionOrderBook {
691
+ marketId: string;
692
+ bids: PredictionOrderBookLevel[];
693
+ asks: PredictionOrderBookLevel[];
694
+ timestamp: number;
695
+ }
696
+ /** A single price level in the order book. */
697
+ interface PredictionOrderBookLevel {
698
+ price: string;
699
+ size: string;
700
+ }
701
+ /** A filled trade on a prediction market. */
702
+ interface PredictionTrade {
703
+ id: string;
704
+ marketId: string;
705
+ outcome: string;
706
+ side: "buy" | "sell";
707
+ price: string;
708
+ size: string;
709
+ timestamp: number;
710
+ }
711
+ /** Current price information for both sides of a prediction market. */
712
+ interface PredictionPrice {
713
+ marketId: string;
714
+ /** Price data for each side. Names are generic ("Side 0"/"Side 1") - use event.markets[].outcomes[].name for real names. */
715
+ outcomes: Array<{
716
+ name: string;
717
+ price: string;
718
+ midpoint: string;
719
+ }>;
720
+ timestamp: number;
721
+ }
722
+
723
+ /** Parameters for placing a prediction market order. */
724
+ interface PredictionOrderParams {
725
+ marketId: string;
726
+ outcome: string;
727
+ side: "buy" | "sell";
728
+ type: "market" | "limit";
729
+ /** Required for limit orders. */
730
+ price?: string;
731
+ amount: string;
732
+ timeInForce?: "GTC" | "GTD" | "FOK" | "FAK" | "ALO";
733
+ expiration?: string;
734
+ /**
735
+ * Mark price of the coin (0-1), used for minimum notional validation.
736
+ * When provided, getMinShares(markPx) is enforced before submission.
737
+ */
738
+ markPx?: number;
739
+ /**
740
+ * Builder address for referral fees.
741
+ * Will be lowercased - checksummed addresses are accepted.
742
+ */
743
+ builderAddress?: string;
744
+ /**
745
+ * Builder fee in tenths of a basis point.
746
+ * 0 = no fee. 100 = 0.1%. 1000 = 1.0% (maximum).
747
+ */
748
+ builderFee?: number;
749
+ /**
750
+ * When true, skips the SDK's local minimum-notional and minimum-shares
751
+ * pre-checks. Use for position-closing flows (close, close-all) where
752
+ * the residual notional may be under $10 but Hyperliquid still accepts
753
+ * the order.
754
+ */
755
+ skipMinNotionalCheck?: boolean;
756
+ }
757
+ /** Result returned by placeOrder. Never throws. Check success/error fields. */
758
+ interface PredictionOrderResult {
759
+ success: boolean;
760
+ orderId?: string;
761
+ status?: string;
762
+ shares?: string;
763
+ error?: string;
764
+ }
765
+ /** Result returned by placeOrders (batch). One entry per input order, index-matched. */
766
+ interface PredictionBatchOrderResult {
767
+ /** True when every individual order succeeded. */
768
+ success: boolean;
769
+ /** Per-order results, indexed to match the input params array. */
770
+ results: PredictionOrderResult[];
771
+ }
772
+ /** Parameters for cancelling a resting order. */
773
+ interface PredictionCancelParams {
774
+ marketId: string;
775
+ orderId: string;
776
+ /** Optional outcome identifier (e.g. "#5160") to resolve the correct side asset ID. */
777
+ outcome?: string;
778
+ }
779
+ /**
780
+ * Parameters for modifying an existing resting order. Hyperliquid preserves
781
+ * queue priority when only the size is changed; price changes move the order
782
+ * to the back of the queue at the new level.
783
+ *
784
+ * Note: HL's modify endpoint only accepts resting limit orders (market orders
785
+ * never rest). `type` is locked to "limit" accordingly.
786
+ */
787
+ interface PredictionModifyParams {
788
+ marketId: string;
789
+ outcome: string;
790
+ orderId: string;
791
+ side: "buy" | "sell";
792
+ type: "limit";
793
+ price: string;
794
+ amount: string;
795
+ timeInForce?: "GTC" | "GTD" | "FOK" | "FAK" | "ALO";
796
+ markPx?: number;
797
+ }
798
+
799
+ export { type HLWsTradesEvent as $, type HLSignature as A, type BaseMarket as B, type HLSplitOutcomeAction as C, type DefaultBinaryMarket as D, type HLSpotClearinghouseState as E, type FetchMarketsParams as F, type HLTrade as G, type HIP4Market as H, type HLUserAbstraction as I, type HLUserFees as J, type HLUserOutcomeAction as K, type HLUserRoleResponse as L, type HLWsActivePerpAssetCtxData as M, type HLWsActiveSpotAssetCtxData as N, type HLWsAllMidsData as O, type HLWsBboData as P, type HLWsClearinghouseStateEvent as Q, type HLWsL2BookData as R, type HLWsOpenOrdersEvent as S, type HLWsOutcomeMetaSideSpec as T, type HLWsOutcomeMetaUpdate as U, type HLWsOutcomeMetaUpdates as V, type HLWsOutcomeSpec as W, type HLWsQuestionSpec as X, type HLWsSpotAssetCtxItem as Y, type HLWsSpotAssetCtxsData as Z, type HLWsSpotStateEvent as _, type FetchMarketsResult as a, type HLWsUserFillsEvent as a0, type LabelledBinaryMarket as a1, type MarketSide as a2, type MarketType as a3, type MarketsByQuestion as a4, type MarketsByType as a5, type MultiOutcomeMarket as a6, type PredictionActivity as a7, type PredictionAuthState as a8, type PredictionBatchOrderResult as a9, type PredictionCancelParams as aa, type PredictionCategory as ab, type PredictionEvent as ac, type PredictionEventStatus as ad, type PredictionMarket as ae, type PredictionModifyParams as af, type PredictionOrderBook as ag, type PredictionOrderBookLevel as ah, type PredictionOrderParams as ai, type PredictionOrderResult as aj, type PredictionOutcome as ak, type PredictionPosition as al, type PredictionPrice as am, type PredictionTrade as an, type PriceBucketMarket as ao, normalizeSignature as ap, splitHexSignature as aq, type HIP4Signer as b, type HLAllMids as c, type HLBatchModifyAction as d, type HLCancelAction as e, type HLCancelResponse as f, type HLCancelStatus as g, type HLCandle as h, type HLClearinghouseState as i, type HLExchangeResponse as j, type HLExtraAgent as k, type HLFill as l, type HLFrontendOrder as m, type HLL2Book as n, type HLMergeOutcomeAction as o, type HLMergeQuestionAction as p, type HLModifyAction as q, type HLModifyResponse as r, type HLNegateOutcomeAction as s, type HLOrderAction as t, type HLOutcome as u, type HLOutcomeMeta as v, type HLQuestion as w, type HLReferralState as x, type HLScheduleCancelAction as y, type HLSettledOutcome as z };