@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.
- package/LICENSE +101 -0
- package/README.md +224 -0
- package/dist/index-ubGjjLVg.d.cts +799 -0
- package/dist/index-ubGjjLVg.d.ts +799 -0
- package/dist/index.cjs +4244 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1058 -0
- package/dist/index.d.ts +1058 -0
- package/dist/index.js +4169 -0
- package/dist/index.js.map +1 -0
- package/dist/types.cjs +4 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +82 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1058 @@
|
|
|
1
|
+
import { ac as PredictionEvent, ab as PredictionCategory, F as FetchMarketsParams, H as HIP4Market, a5 as MarketsByType, a4 as MarketsByQuestion, ai as PredictionOrderParams, aj as PredictionOrderResult, a9 as PredictionBatchOrderResult, aa as PredictionCancelParams, f as HLCancelResponse, af as PredictionModifyParams, a8 as PredictionAuthState, al as PredictionPosition, a7 as PredictionActivity, ag as PredictionOrderBook, am as PredictionPrice, an as PredictionTrade, O as HLWsAllMidsData, N as HLWsActiveSpotAssetCtxData, Z as HLWsSpotAssetCtxsData, M as HLWsActivePerpAssetCtxData, v as HLOutcomeMeta, z as HLSettledOutcome, n as HLL2Book, G as HLTrade, c as HLAllMids, h as HLCandle, i as HLClearinghouseState, l as HLFill, E as HLSpotClearinghouseState, k as HLExtraAgent, x as HLReferralState, L as HLUserRoleResponse, J as HLUserFees, I as HLUserAbstraction, m as HLFrontendOrder, t as HLOrderAction, A as HLSignature, j as HLExchangeResponse, e as HLCancelAction, q as HLModifyAction, r as HLModifyResponse, d as HLBatchModifyAction, U as HLWsOutcomeMetaUpdate, b as HIP4Signer, w as HLQuestion, u as HLOutcome, Y as HLWsSpotAssetCtxItem } from './index-ubGjjLVg.cjs';
|
|
2
|
+
export { B as BaseMarket, D as DefaultBinaryMarket, a as FetchMarketsResult, g as HLCancelStatus, o as HLMergeOutcomeAction, p as HLMergeQuestionAction, s as HLNegateOutcomeAction, y as HLScheduleCancelAction, C as HLSplitOutcomeAction, K as HLUserOutcomeAction, P as HLWsBboData, Q as HLWsClearinghouseStateEvent, R as HLWsL2BookData, S as HLWsOpenOrdersEvent, T as HLWsOutcomeMetaSideSpec, V as HLWsOutcomeMetaUpdates, W as HLWsOutcomeSpec, X as HLWsQuestionSpec, _ as HLWsSpotStateEvent, $ as HLWsTradesEvent, a0 as HLWsUserFillsEvent, a1 as LabelledBinaryMarket, a2 as MarketSide, a3 as MarketType, a6 as MultiOutcomeMarket, ad as PredictionEventStatus, ae as PredictionMarket, ah as PredictionOrderBookLevel, ak as PredictionOutcome, ao as PriceBucketMarket, ap as normalizeSignature, aq as splitHexSignature } from './index-ubGjjLVg.cjs';
|
|
3
|
+
|
|
4
|
+
/** Callback returned by subscribe methods; call it to unsubscribe. */
|
|
5
|
+
type Unsubscribe = () => void;
|
|
6
|
+
/** Top-level adapter that groups all prediction-market sub-adapters. */
|
|
7
|
+
interface PredictionsAdapter {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly events: PredictionEventAdapter;
|
|
11
|
+
readonly marketData: PredictionMarketDataAdapter;
|
|
12
|
+
readonly account: PredictionAccountAdapter;
|
|
13
|
+
readonly trading: PredictionTradingAdapter;
|
|
14
|
+
readonly auth: PredictionAuthAdapter;
|
|
15
|
+
readonly wallet: PredictionWalletAdapter;
|
|
16
|
+
/** Initialize connections and internal state. Must be called before use. */
|
|
17
|
+
initialize(): Promise<void>;
|
|
18
|
+
/** Tear down connections and clean up subscriptions. */
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
interface PredictionEventAdapter {
|
|
22
|
+
/** List events with optional filters (category, active, limit, offset, query). */
|
|
23
|
+
fetchEvents(params?: {
|
|
24
|
+
category?: string;
|
|
25
|
+
active?: boolean;
|
|
26
|
+
limit?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
query?: string;
|
|
29
|
+
}): Promise<PredictionEvent[]>;
|
|
30
|
+
/** Fetch a single event by ID. IDs are "q<n>" for questions, "o<n>" for standalone outcomes. */
|
|
31
|
+
fetchEvent(eventId: string): Promise<PredictionEvent>;
|
|
32
|
+
/** List available categories (e.g. "custom", "recurring"). */
|
|
33
|
+
fetchCategories(): Promise<PredictionCategory[]>;
|
|
34
|
+
/** Fetch typed HIP-4 markets with optional type filtering, grouping, and pagination. */
|
|
35
|
+
fetchMarkets(params?: FetchMarketsParams): Promise<HIP4Market[] | MarketsByType | MarketsByQuestion>;
|
|
36
|
+
}
|
|
37
|
+
interface PredictionMarketDataAdapter {
|
|
38
|
+
/** Fetch the order book for a market. marketId is the outcome ID as string; sideIndex defaults to 0 (Yes). */
|
|
39
|
+
fetchOrderBook(marketId: string, sideIndex?: number): Promise<PredictionOrderBook>;
|
|
40
|
+
/** Fetch the current price for both sides of a market. Names are generic ("Side 0"/"Side 1") - use event.markets[].outcomes[].name for real names. */
|
|
41
|
+
fetchPrice(marketId: string): Promise<PredictionPrice>;
|
|
42
|
+
/** Fetch recent trades for a market. */
|
|
43
|
+
fetchTrades(marketId: string, limit?: number): Promise<PredictionTrade[]>;
|
|
44
|
+
/** Fetch OHLCV candles for a market. Defaults to 1h interval, 14 days lookback. */
|
|
45
|
+
fetchCandles(marketId: string, interval?: string, startTime?: number, endTime?: number): Promise<Array<{
|
|
46
|
+
time: number;
|
|
47
|
+
open: number;
|
|
48
|
+
high: number;
|
|
49
|
+
low: number;
|
|
50
|
+
close: number;
|
|
51
|
+
volume: number;
|
|
52
|
+
}>>;
|
|
53
|
+
/** Subscribe to real-time order book updates. Returns an unsubscribe callback. */
|
|
54
|
+
subscribeOrderBook(marketId: string, onData: (book: PredictionOrderBook) => void): Unsubscribe;
|
|
55
|
+
/** Subscribe to real-time price updates. Returns an unsubscribe callback. */
|
|
56
|
+
subscribePrice(marketId: string, onData: (price: PredictionPrice) => void): Unsubscribe;
|
|
57
|
+
/** Subscribe to real-time trade updates. Returns an unsubscribe callback. */
|
|
58
|
+
subscribeTrades(marketId: string, onData: (trade: PredictionTrade) => void): Unsubscribe;
|
|
59
|
+
/** Subscribe to all mid-price updates across every market. Returns an unsubscribe callback. */
|
|
60
|
+
subscribeAllMids(onData: (data: HLWsAllMidsData) => void): Unsubscribe;
|
|
61
|
+
/** Subscribe to real-time asset context (volume, OI, mark price) for a spot coin. Returns an unsubscribe callback. */
|
|
62
|
+
subscribeActiveAssetCtx(coin: string, onData: (data: HLWsActiveSpotAssetCtxData) => void): Unsubscribe;
|
|
63
|
+
/** Subscribe to bulk spot asset context updates for all spot coins. Returns an unsubscribe callback. */
|
|
64
|
+
subscribeSpotAssetCtxs(onData: (data: HLWsSpotAssetCtxsData) => void): Unsubscribe;
|
|
65
|
+
/** Subscribe to real-time perp asset context (mark price, oracle, funding) for a perp coin. Returns an unsubscribe callback. */
|
|
66
|
+
subscribePerpAssetCtx(coin: string, onData: (data: HLWsActivePerpAssetCtxData) => void): Unsubscribe;
|
|
67
|
+
}
|
|
68
|
+
interface PredictionAccountAdapter {
|
|
69
|
+
/** Fetch all open positions for an address. */
|
|
70
|
+
fetchPositions(address: string): Promise<PredictionPosition[]>;
|
|
71
|
+
/** Fetch account activity (trades, redeems, deposits, withdrawals) for an address. */
|
|
72
|
+
fetchActivity(address: string): Promise<PredictionActivity[]>;
|
|
73
|
+
/** Fetch raw spot balances (including USDH) for an address. */
|
|
74
|
+
fetchBalance(address: string): Promise<Array<{
|
|
75
|
+
coin: string;
|
|
76
|
+
total: string;
|
|
77
|
+
hold: string;
|
|
78
|
+
}>>;
|
|
79
|
+
/** Fetch resting limit orders from frontendOpenOrders for an address. */
|
|
80
|
+
fetchOpenOrders(address: string): Promise<Array<{
|
|
81
|
+
coin: string;
|
|
82
|
+
side: "B" | "A";
|
|
83
|
+
limitPx: string;
|
|
84
|
+
sz: string;
|
|
85
|
+
oid: number;
|
|
86
|
+
timestamp: number;
|
|
87
|
+
}>>;
|
|
88
|
+
/** Subscribe to position changes. Polls at 10s interval (no WS channel for spot). */
|
|
89
|
+
subscribePositions(address: string, onData: (positions: PredictionPosition[]) => void): Unsubscribe;
|
|
90
|
+
}
|
|
91
|
+
interface PredictionTradingAdapter {
|
|
92
|
+
/** Place a market or limit order. Returns { success, orderId?, status?, shares?, error? }. Never throws. */
|
|
93
|
+
placeOrder(params: PredictionOrderParams): Promise<PredictionOrderResult>;
|
|
94
|
+
/** Place multiple orders in a single batched request. Never throws. */
|
|
95
|
+
placeOrders(params: PredictionOrderParams[]): Promise<PredictionBatchOrderResult>;
|
|
96
|
+
/** Cancel one or more resting orders in a single request. */
|
|
97
|
+
cancelOrder(params: PredictionCancelParams[]): Promise<HLCancelResponse>;
|
|
98
|
+
/**
|
|
99
|
+
* Modify a resting order (price and/or size). Preserves queue priority
|
|
100
|
+
* when only size changes. Returns the same shape as placeOrder so the
|
|
101
|
+
* result carries the (potentially new) order id. Never throws.
|
|
102
|
+
*/
|
|
103
|
+
modifyOrder(params: PredictionModifyParams): Promise<PredictionOrderResult>;
|
|
104
|
+
}
|
|
105
|
+
interface PredictionAuthAdapter {
|
|
106
|
+
/** Initialize auth with a wallet. Accepts a viem PrivateKeyAccount or ethers Signer. */
|
|
107
|
+
initAuth(walletAddress: string, signer: unknown): Promise<PredictionAuthState>;
|
|
108
|
+
/** Return the current authentication state. */
|
|
109
|
+
getAuthStatus(): PredictionAuthState;
|
|
110
|
+
/** Clear stored auth credentials and reset state to disconnected. */
|
|
111
|
+
clearAuth(): void;
|
|
112
|
+
}
|
|
113
|
+
interface WalletActionResult$1 {
|
|
114
|
+
success: boolean;
|
|
115
|
+
error?: string;
|
|
116
|
+
filledSz?: string;
|
|
117
|
+
avgPx?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Order id of the resulting fill (set only on `success: true` for actions
|
|
120
|
+
* that produce a fill - `buyUsdh`, `sellUsdh`, etc). Callers use this to
|
|
121
|
+
* look up the realized fee in `userFills` / `userFillsByTime`, since the
|
|
122
|
+
* synchronous order ack does not carry fee.
|
|
123
|
+
*/
|
|
124
|
+
oid?: number;
|
|
125
|
+
}
|
|
126
|
+
interface PredictionWalletAdapter {
|
|
127
|
+
/** Set the user's wallet signer for EIP-712 operations (transfers, withdrawals). */
|
|
128
|
+
setSigner(signer: {
|
|
129
|
+
address: string;
|
|
130
|
+
signTypedData: (...args: unknown[]) => Promise<string>;
|
|
131
|
+
} | unknown): void;
|
|
132
|
+
/** Buy USDH on the spot market. Uses L1 agent signing. */
|
|
133
|
+
buyUsdh(amount: string): Promise<WalletActionResult$1>;
|
|
134
|
+
/** Sell USDH on the spot market. Uses L1 agent signing. */
|
|
135
|
+
sellUsdh(amount: string): Promise<WalletActionResult$1>;
|
|
136
|
+
/** Transfer USDC from Perp to Spot account. */
|
|
137
|
+
transferToSpot(amount: string): Promise<WalletActionResult$1>;
|
|
138
|
+
/** Transfer USDC from Spot to Perp account. */
|
|
139
|
+
transferToPerps(amount: string): Promise<WalletActionResult$1>;
|
|
140
|
+
/** Withdraw USDC to an external address. */
|
|
141
|
+
withdraw(params: {
|
|
142
|
+
destination: string;
|
|
143
|
+
amount: string;
|
|
144
|
+
}): Promise<WalletActionResult$1>;
|
|
145
|
+
/** Send USDC to another Hyperliquid address. */
|
|
146
|
+
usdSend(params: {
|
|
147
|
+
destination: string;
|
|
148
|
+
amount: string;
|
|
149
|
+
}): Promise<WalletActionResult$1>;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
declare class HLApiError extends Error {
|
|
153
|
+
readonly status: number;
|
|
154
|
+
constructor(status: number, message: string);
|
|
155
|
+
}
|
|
156
|
+
interface HIP4ClientConfig {
|
|
157
|
+
testnet?: boolean;
|
|
158
|
+
infoUrl?: string;
|
|
159
|
+
exchangeUrl?: string;
|
|
160
|
+
/** Optional logger. Default: no-op. */
|
|
161
|
+
logger?: (level: "debug" | "info" | "warn" | "error", msg: string, data?: unknown) => void;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Canonical value for info queries that should span every perp dex.
|
|
165
|
+
* Replaces reliance on DEX abstraction, which Hyperliquid is deprecating.
|
|
166
|
+
*/
|
|
167
|
+
declare const ALL_DEXS = "ALL_DEXS";
|
|
168
|
+
/**
|
|
169
|
+
* Predicate: does this abstraction mode require a `usdClassTransfer`
|
|
170
|
+
* step to move USDC between spot and perps silos?
|
|
171
|
+
*
|
|
172
|
+
* - `disabled` (Standard): spot/perp split, transfer required.
|
|
173
|
+
* - `dexAbstraction`: unifies multiple perp DEXes only - spot/perp
|
|
174
|
+
* split is preserved, transfer still required. Verified empirically:
|
|
175
|
+
* addresses on `dexAbstraction` carry independent spot-USDC and
|
|
176
|
+
* perp-`withdrawable` balances.
|
|
177
|
+
* - `unifiedAccount` / `portfolioMargin`: spot↔perp merged into a
|
|
178
|
+
* single balance - `usdClassTransfer` is rejected with `"Action
|
|
179
|
+
* disabled when unified account is active"`.
|
|
180
|
+
*/
|
|
181
|
+
declare function isUsdClassTransferRequired(abstraction: HLUserAbstraction): boolean;
|
|
182
|
+
/** Outcome-level coin name (AMM instrument) */
|
|
183
|
+
declare function outcomeCoin(outcomeId: number): string;
|
|
184
|
+
/** Per-side probability coin name */
|
|
185
|
+
declare function sideCoin(outcomeId: number, sideIndex: number): string;
|
|
186
|
+
/** Asset ID for order placement: 100_000_000 + outcomeId * 10 + sideIndex */
|
|
187
|
+
declare function sideAssetId(outcomeId: number, sideIndex: number): number;
|
|
188
|
+
/** Parse a side coin like "#5160" or "+5160" into {outcomeId, sideIndex} */
|
|
189
|
+
declare function parseSideCoin(coin: string): {
|
|
190
|
+
outcomeId: number;
|
|
191
|
+
sideIndex: number;
|
|
192
|
+
} | null;
|
|
193
|
+
/** Parse an outcome-level coin like "@1338" into {outcomeId} */
|
|
194
|
+
declare function parseOutcomeCoin(coin: string): {
|
|
195
|
+
outcomeId: number;
|
|
196
|
+
} | null;
|
|
197
|
+
declare class HIP4Client {
|
|
198
|
+
readonly infoUrl: string;
|
|
199
|
+
readonly exchangeUrl: string;
|
|
200
|
+
readonly wsUrl: string;
|
|
201
|
+
readonly testnet: boolean;
|
|
202
|
+
readonly log: (level: "debug" | "info" | "warn" | "error", msg: string, data?: unknown) => void;
|
|
203
|
+
constructor(config?: HIP4ClientConfig);
|
|
204
|
+
fetchOutcomeMeta(): Promise<HLOutcomeMeta>;
|
|
205
|
+
fetchSettledOutcome(outcome: number): Promise<HLSettledOutcome | null>;
|
|
206
|
+
fetchL2Book(coin: string): Promise<HLL2Book>;
|
|
207
|
+
fetchRecentTrades(coin: string): Promise<HLTrade[]>;
|
|
208
|
+
fetchAllMids(): Promise<HLAllMids>;
|
|
209
|
+
fetchCandleSnapshot(coin: string, interval: string, startTime: number, endTime: number): Promise<HLCandle[]>;
|
|
210
|
+
fetchClearinghouseState(user: string): Promise<HLClearinghouseState>;
|
|
211
|
+
fetchUserFills(user: string): Promise<HLFill[]>;
|
|
212
|
+
/** Spot meta + asset contexts (includes markPx / oracle price for each spot asset) */
|
|
213
|
+
fetchSpotAssetCtx(spotIndex: number): Promise<{
|
|
214
|
+
markPx: string;
|
|
215
|
+
midPx: string;
|
|
216
|
+
} | null>;
|
|
217
|
+
/** Spot balances - HIP-4 prediction market positions live here (USDH, outcome tokens) */
|
|
218
|
+
fetchSpotClearinghouseState(user: string): Promise<HLSpotClearinghouseState>;
|
|
219
|
+
/** Trade fills with time range filtering */
|
|
220
|
+
fetchUserFillsByTime(user: string, startTime: number, endTime: number): Promise<HLFill[]>;
|
|
221
|
+
/** Approved extra agents for a user */
|
|
222
|
+
fetchExtraAgents(user: string): Promise<HLExtraAgent[]>;
|
|
223
|
+
/**
|
|
224
|
+
* Check the maximum builder fee a user has approved for a given builder.
|
|
225
|
+
* Returns the approved fee in tenths of a basis point (e.g. 100 = 0.1%).
|
|
226
|
+
* Returns 0 if no approval exists.
|
|
227
|
+
*/
|
|
228
|
+
fetchMaxBuilderFee(user: string, builder: string): Promise<number>;
|
|
229
|
+
/**
|
|
230
|
+
* Fetch all approved builder addresses for a user.
|
|
231
|
+
* Hyperliquid limits each address to a maximum of 3 approved builders.
|
|
232
|
+
*/
|
|
233
|
+
fetchApprovedBuilders(user: string): Promise<string[]>;
|
|
234
|
+
/**
|
|
235
|
+
* Fetch a user's referral state from Hyperliquid.
|
|
236
|
+
* Returns the referral state object, or null if no referrer is set.
|
|
237
|
+
*/
|
|
238
|
+
fetchReferralState(user: string): Promise<HLReferralState>;
|
|
239
|
+
/**
|
|
240
|
+
* Fetch the role assigned to a user by Hyperliquid.
|
|
241
|
+
* `role === "missing"` indicates the wallet has never interacted with HL.
|
|
242
|
+
*/
|
|
243
|
+
fetchUserRole(user: string): Promise<HLUserRoleResponse>;
|
|
244
|
+
/**
|
|
245
|
+
* Fetch the user's effective fee schedule (post-discount).
|
|
246
|
+
* Spot rates (`userSpotCrossRate` / `userSpotAddRate`) are what apply to
|
|
247
|
+
* HIP-4 outcome closes; opens are 0-fee.
|
|
248
|
+
*/
|
|
249
|
+
fetchUserFees(user: string): Promise<HLUserFees>;
|
|
250
|
+
/**
|
|
251
|
+
* Fetch the user's account abstraction mode.
|
|
252
|
+
*
|
|
253
|
+
* Returns one of `"default" | "disabled" | "dexAbstraction" |
|
|
254
|
+
* "unifiedAccount" | "portfolioMargin"`. Standard accounts return
|
|
255
|
+
* `"default"` (or `"disabled"`); both keep spot and perp as separate
|
|
256
|
+
* silos and require a `usdClassTransfer` before `withdraw3`. Only
|
|
257
|
+
* `"unifiedAccount"` / `"portfolioMargin"` merge the balances and reject
|
|
258
|
+
* `usdClassTransfer`. Use {@link isUsdClassTransferRequired} to gate the
|
|
259
|
+
* spot↔perp transfer step in deposit/withdraw flows.
|
|
260
|
+
*
|
|
261
|
+
* Endpoint: `POST /info` body `{ type: "userAbstraction", user }`.
|
|
262
|
+
*/
|
|
263
|
+
fetchUserAbstraction(user: string): Promise<HLUserAbstraction>;
|
|
264
|
+
/** Frontend-formatted open orders */
|
|
265
|
+
fetchFrontendOpenOrders(user: string): Promise<HLFrontendOrder[]>;
|
|
266
|
+
placeOrder(action: HLOrderAction, nonce: number, signature: HLSignature, vaultAddress?: string | null): Promise<HLExchangeResponse>;
|
|
267
|
+
cancelOrder(action: HLCancelAction, nonce: number, signature: HLSignature, vaultAddress?: string | null): Promise<HLCancelResponse>;
|
|
268
|
+
modifyOrder(action: HLModifyAction, nonce: number, signature: HLSignature, vaultAddress?: string | null): Promise<HLModifyResponse>;
|
|
269
|
+
batchModifyOrders(action: HLBatchModifyAction, nonce: number, signature: HLSignature, vaultAddress?: string | null): Promise<HLModifyResponse>;
|
|
270
|
+
/** Submit a user-signed action (withdraw, usdClassTransfer, etc.) */
|
|
271
|
+
submitUserSignedAction(action: Record<string, unknown>, nonce: number, signature: HLSignature): Promise<{
|
|
272
|
+
status: string;
|
|
273
|
+
response?: unknown;
|
|
274
|
+
}>;
|
|
275
|
+
private ws;
|
|
276
|
+
private wsPendingMessages;
|
|
277
|
+
/** Callbacks keyed by response channel (for message routing). */
|
|
278
|
+
private wsCallbacks;
|
|
279
|
+
/** Active subscribe messages as JSON strings (for reconnection). */
|
|
280
|
+
private wsActiveSubs;
|
|
281
|
+
/**
|
|
282
|
+
* Subscribe to a Hyperliquid WebSocket channel.
|
|
283
|
+
* Returns an unsubscribe function.
|
|
284
|
+
*
|
|
285
|
+
* @param options.responseChannel Channel name HL uses in response messages
|
|
286
|
+
* when it differs from `subscription.type` (e.g. subscribe as
|
|
287
|
+
* "activeAssetCtx" but receive on "activeSpotAssetCtx").
|
|
288
|
+
*/
|
|
289
|
+
subscribe(subscription: {
|
|
290
|
+
type: string;
|
|
291
|
+
[key: string]: unknown;
|
|
292
|
+
}, onData: (data: unknown) => void, options?: {
|
|
293
|
+
responseChannel?: string;
|
|
294
|
+
}): () => void;
|
|
295
|
+
/** Tear down WebSocket and clear all subscriptions. */
|
|
296
|
+
closeWs(): void;
|
|
297
|
+
private ensureWs;
|
|
298
|
+
private wsReconnectAttempts;
|
|
299
|
+
private wsReconnectTimer;
|
|
300
|
+
private wsDestroyed;
|
|
301
|
+
private scheduleReconnect;
|
|
302
|
+
private infoPost;
|
|
303
|
+
private doInfoPost;
|
|
304
|
+
private exchangePost;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Resolve side names for an outcome by ID.
|
|
309
|
+
* Returns [side0Name, side1Name] (e.g. ["Yes", "No"] or ["Hypurr", "Usain Bolt"]).
|
|
310
|
+
* Returns null if the outcome ID is unknown.
|
|
311
|
+
*/
|
|
312
|
+
type SideNameResolver = (outcomeId: number) => [string, string] | null;
|
|
313
|
+
declare class HIP4EventAdapter implements PredictionEventAdapter {
|
|
314
|
+
private readonly client;
|
|
315
|
+
private cache;
|
|
316
|
+
private metaCache;
|
|
317
|
+
private static readonly CACHE_TTL_MS;
|
|
318
|
+
/** Side names from outcomeMeta. Populated once, never cleared (sideSpecs don't change). */
|
|
319
|
+
private sideNames;
|
|
320
|
+
constructor(client: HIP4Client);
|
|
321
|
+
/** Returns a resolver function that looks up side names by outcome ID. */
|
|
322
|
+
getSideNameResolver(): SideNameResolver;
|
|
323
|
+
/** Ensure sideNames are loaded. Call before using the resolver if data may not be cached yet. */
|
|
324
|
+
ensureSideNames(): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Subscribe to live outcome-meta updates (HIP-4 catalog changes).
|
|
327
|
+
*
|
|
328
|
+
* Each frame is an array of one or more updates. The handler is invoked
|
|
329
|
+
* once per update with the discriminated payload. Internally we also:
|
|
330
|
+
* - extend `sideNames` for newly created outcomes (so `getSideNameResolver`
|
|
331
|
+
* returns real names instead of falling back to "Side 0/1")
|
|
332
|
+
* - invalidate the events + markets caches so the next read refetches
|
|
333
|
+
* and reflects the change
|
|
334
|
+
*
|
|
335
|
+
* Returns an unsubscribe callback.
|
|
336
|
+
*/
|
|
337
|
+
subscribeOutcomeMetaUpdates(onData: (update: HLWsOutcomeMetaUpdate) => void): Unsubscribe;
|
|
338
|
+
private applyMetaUpdate;
|
|
339
|
+
private populateSideNames;
|
|
340
|
+
fetchEvents(params?: {
|
|
341
|
+
category?: string;
|
|
342
|
+
active?: boolean;
|
|
343
|
+
limit?: number;
|
|
344
|
+
offset?: number;
|
|
345
|
+
query?: string;
|
|
346
|
+
}): Promise<PredictionEvent[]>;
|
|
347
|
+
fetchEvent(eventId: string): Promise<PredictionEvent>;
|
|
348
|
+
fetchCategories(): Promise<PredictionCategory[]>;
|
|
349
|
+
/**
|
|
350
|
+
* Fetch and classify all HIP-4 markets.
|
|
351
|
+
*
|
|
352
|
+
* Supports optional type filtering, groupBy, limit, and offset.
|
|
353
|
+
* Results are cached for CACHE_TTL_MS alongside the events cache.
|
|
354
|
+
*/
|
|
355
|
+
fetchMarkets(params?: FetchMarketsParams): Promise<HIP4Market[] | MarketsByType | MarketsByQuestion>;
|
|
356
|
+
private loadMarkets;
|
|
357
|
+
private loadEvents;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
declare class HIP4Auth implements PredictionAuthAdapter {
|
|
361
|
+
private state;
|
|
362
|
+
private signer;
|
|
363
|
+
initAuth(walletAddress: string, signer: unknown): Promise<PredictionAuthState>;
|
|
364
|
+
getAuthStatus(): PredictionAuthState;
|
|
365
|
+
clearAuth(): void;
|
|
366
|
+
/** Internal - used by the trading adapter to get the active signer */
|
|
367
|
+
getSigner(): HIP4Signer | null;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
interface SplitOutcomeParams {
|
|
371
|
+
/** Outcome ID (numeric, matches HL's `outcomeMeta.outcomes[].outcome`). */
|
|
372
|
+
outcome: number;
|
|
373
|
+
/** Amount of quote tokens to split. Decimal string (e.g. "12.5"). */
|
|
374
|
+
amount: string;
|
|
375
|
+
}
|
|
376
|
+
interface MergeOutcomeParams {
|
|
377
|
+
outcome: number;
|
|
378
|
+
/** Amount of paired Yes+No shares to merge. `null` means max available. */
|
|
379
|
+
amount: string | null;
|
|
380
|
+
}
|
|
381
|
+
interface MergeQuestionParams {
|
|
382
|
+
/** Question ID (numeric, matches HL's `outcomeMeta.questions[].question`). */
|
|
383
|
+
question: number;
|
|
384
|
+
/** Yes-share count to redeem from each member outcome. `null` = max. */
|
|
385
|
+
amount: string | null;
|
|
386
|
+
}
|
|
387
|
+
interface NegateOutcomeParams {
|
|
388
|
+
question: number;
|
|
389
|
+
/** Source outcome whose No shares are being converted. */
|
|
390
|
+
outcome: number;
|
|
391
|
+
/** No-share count to convert. */
|
|
392
|
+
amount: string;
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* @deprecated Use {@link formatPrice} from pricing.ts instead.
|
|
396
|
+
*/
|
|
397
|
+
declare function formatPredictionPrice(price: number): string;
|
|
398
|
+
interface TradingAdapterConfig {
|
|
399
|
+
builderAddress?: string;
|
|
400
|
+
builderFee?: number;
|
|
401
|
+
}
|
|
402
|
+
declare class HIP4TradingAdapter implements PredictionTradingAdapter {
|
|
403
|
+
private readonly client;
|
|
404
|
+
private readonly auth;
|
|
405
|
+
private readonly builderAddress?;
|
|
406
|
+
private readonly builderFee?;
|
|
407
|
+
constructor(client: HIP4Client, auth: HIP4Auth, config?: TradingAdapterConfig);
|
|
408
|
+
private buildOrderWire;
|
|
409
|
+
placeOrder(params: PredictionOrderParams): Promise<PredictionOrderResult>;
|
|
410
|
+
placeOrders(params: PredictionOrderParams[]): Promise<PredictionBatchOrderResult>;
|
|
411
|
+
cancelOrder(params: PredictionCancelParams[]): Promise<HLCancelResponse>;
|
|
412
|
+
modifyOrder(params: PredictionModifyParams): Promise<PredictionOrderResult>;
|
|
413
|
+
/** Split X quote tokens into X Yes + X No shares of one outcome. */
|
|
414
|
+
splitOutcome(params: SplitOutcomeParams): Promise<WalletActionResult$1>;
|
|
415
|
+
/** Merge X Yes + X No shares of one outcome back into X quote tokens. */
|
|
416
|
+
mergeOutcome(params: MergeOutcomeParams): Promise<WalletActionResult$1>;
|
|
417
|
+
/** Merge X Yes shares from every outcome of a question into X quote tokens. */
|
|
418
|
+
mergeQuestion(params: MergeQuestionParams): Promise<WalletActionResult$1>;
|
|
419
|
+
/**
|
|
420
|
+
* Convert X No shares of one outcome into X Yes shares of every *other*
|
|
421
|
+
* outcome belonging to the same question (including the fallback). The
|
|
422
|
+
* wire sub-key is `negateOutcome` - confirmed against HL's own testnet
|
|
423
|
+
* "Convert Outcomes" UI; their docs body's `negateQuestion` is a typo.
|
|
424
|
+
*/
|
|
425
|
+
negateOutcome(params: NegateOutcomeParams): Promise<WalletActionResult$1>;
|
|
426
|
+
private submitUserOutcomeAction;
|
|
427
|
+
scheduleCancel(time: number | null): Promise<WalletActionResult$1>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
interface UsdClassTransferParams {
|
|
431
|
+
amount: string;
|
|
432
|
+
toPerp: boolean;
|
|
433
|
+
}
|
|
434
|
+
declare const USDH_SPOT_INDEX_TESTNET = 1338;
|
|
435
|
+
declare const USDH_SPOT_INDEX_MAINNET = 230;
|
|
436
|
+
declare const USDH_ASSET_ID_TESTNET: number;
|
|
437
|
+
declare const USDH_ASSET_ID_MAINNET: number;
|
|
438
|
+
declare const USDH_SPOT_PAIR_TESTNET = "@1338";
|
|
439
|
+
declare const USDH_SPOT_PAIR_MAINNET = "@230";
|
|
440
|
+
declare const USDH_TOKEN_INDEX_MAINNET = 360;
|
|
441
|
+
declare const USDH_TOKEN_INDEX_TESTNET = 1452;
|
|
442
|
+
declare const USDH_TOKEN_HASH_MAINNET = "0x54e00a5988577cb0b0c9ab0cb6ef7f4b";
|
|
443
|
+
declare const USDH_TOKEN_HASH_TESTNET = "0x471fd4480bb9943a1fe080ab0d4ff36c";
|
|
444
|
+
declare const USDH_HL_TOKEN_MAINNET = "USDH:0x54e00a5988577cb0b0c9ab0cb6ef7f4b";
|
|
445
|
+
declare const USDH_HL_TOKEN_TESTNET = "USDH:0x471fd4480bb9943a1fe080ab0d4ff36c";
|
|
446
|
+
declare const USDH_EVM_ADDRESS_MAINNET = "0x111111a1a0667d36bD57c0A9f569b98057111111";
|
|
447
|
+
declare const USDH_EVM_ADDRESS_TESTNET = "0x22222245c52c817F95b74664Ae8546B490222222";
|
|
448
|
+
declare const USDH_CORE_DECIMALS = 8;
|
|
449
|
+
declare const USDH_EVM_DECIMALS = 6;
|
|
450
|
+
/** HL spot USDC token identifier. Mainnet index 0, testnet index 0.
|
|
451
|
+
* Format: `"NAME:0xHEX"` per sendToEvmWithData / spotSend spec. */
|
|
452
|
+
declare const USDC_HL_TOKEN_MAINNET = "USDC:0x6d1e7cde53ba9467b783cb7c530ce054";
|
|
453
|
+
declare const USDC_HL_TOKEN_TESTNET = "USDC:0xeb62eee3685fc4c43992febcd9e75443";
|
|
454
|
+
/** @deprecated Use network-specific variants (TESTNET/MAINNET) instead */
|
|
455
|
+
declare const USDH_ASSET_ID: number;
|
|
456
|
+
/** @deprecated Use network-specific variants (TESTNET/MAINNET) instead */
|
|
457
|
+
declare const USDH_SPOT_PAIR = "@1338";
|
|
458
|
+
interface WithdrawParams {
|
|
459
|
+
destination: string;
|
|
460
|
+
amount: string;
|
|
461
|
+
}
|
|
462
|
+
interface UsdSendParams {
|
|
463
|
+
destination: string;
|
|
464
|
+
amount: string;
|
|
465
|
+
}
|
|
466
|
+
interface SpotSendParams {
|
|
467
|
+
destination: string;
|
|
468
|
+
/** Token identifier in Hyperliquid format "NAME:0xHEX" (e.g. "USDH:0x471fd4480bb9943a1fe080ab0d4ff36c"). */
|
|
469
|
+
token: string;
|
|
470
|
+
amount: string;
|
|
471
|
+
}
|
|
472
|
+
interface SendAssetParams {
|
|
473
|
+
destination: string;
|
|
474
|
+
/** Token identifier "NAME:0xHEX". */
|
|
475
|
+
token: string;
|
|
476
|
+
amount: string;
|
|
477
|
+
/** Source silo: `""` = perp USDC, `"spot"` = spot, or a perp DEX name. Defaults to `"spot"`. */
|
|
478
|
+
sourceDex?: string;
|
|
479
|
+
/** Destination silo: `""` = perp USDC / EVM system address, `"spot"` = spot, or a perp DEX name. Defaults to `""`. */
|
|
480
|
+
destinationDex?: string;
|
|
481
|
+
/** Sub-account to debit. Empty string = main account. */
|
|
482
|
+
fromSubAccount?: string;
|
|
483
|
+
}
|
|
484
|
+
interface SendSpotTokenToEvmParams {
|
|
485
|
+
/** Token index from `info: spotMeta → tokens[].index`. NOT the spot-pair
|
|
486
|
+
* market index. Passing a pair index routes funds to the wrong token. */
|
|
487
|
+
tokenIndex: number;
|
|
488
|
+
/** Token identifier `"SYMBOL:0x<32-hex>"` from the same spotMeta entry. */
|
|
489
|
+
tokenId: string;
|
|
490
|
+
/** Decimal amount in the token's display decimals, as a string. */
|
|
491
|
+
amount: string;
|
|
492
|
+
/** HYPE bypasses index-derived address at `0x2222…2222`. */
|
|
493
|
+
isHype?: boolean;
|
|
494
|
+
}
|
|
495
|
+
interface SendToEvmWithDataParams {
|
|
496
|
+
/** Token identifier "NAME:0xHEX". */
|
|
497
|
+
token: string;
|
|
498
|
+
/** Decimal amount as a string, in the token's display decimals. */
|
|
499
|
+
amount: string;
|
|
500
|
+
/** Recipient on the destination chain (hex for EVM, base58 for Solana). */
|
|
501
|
+
destinationRecipient: string;
|
|
502
|
+
/** CCTP domain ID of the destination chain (0=Eth, 3=Arb, 6=Base, ...). */
|
|
503
|
+
destinationChainId: number;
|
|
504
|
+
/** Gas budget for the `coreReceiveWithData` call on HyperEVM. Empirical
|
|
505
|
+
* ceiling of the Circle `CoreDepositWallet` path is ~289k; 350k is a
|
|
506
|
+
* safe default. Under-provisioning reverts and funds land badly. */
|
|
507
|
+
gasLimit: number;
|
|
508
|
+
/** Hook data passed to the linked contract. "0x" = default Circle forwarder
|
|
509
|
+
* on Arbitrum. Non-magic bytes disable forwarding (user self-attests on
|
|
510
|
+
* destination, not recommended for UX). */
|
|
511
|
+
data?: string;
|
|
512
|
+
/** Hyperliquid perp dex name or "spot". Defaults to "spot". */
|
|
513
|
+
sourceDex?: string;
|
|
514
|
+
/** Recipient address encoding. Defaults to "hex". */
|
|
515
|
+
addressEncoding?: "hex" | "base58";
|
|
516
|
+
}
|
|
517
|
+
interface WalletActionResult {
|
|
518
|
+
success: boolean;
|
|
519
|
+
error?: string;
|
|
520
|
+
filledSz?: string;
|
|
521
|
+
avgPx?: string;
|
|
522
|
+
/**
|
|
523
|
+
* Order id of the resulting fill (set only on `success: true` for actions
|
|
524
|
+
* that produce a fill - `buyUsdh`, `sellUsdh`, etc). Callers use this to
|
|
525
|
+
* look up the realized fee in `userFills` / `userFillsByTime`, since the
|
|
526
|
+
* synchronous order ack does not carry fee.
|
|
527
|
+
*/
|
|
528
|
+
oid?: number;
|
|
529
|
+
}
|
|
530
|
+
declare class HIP4WalletAdapter {
|
|
531
|
+
private readonly client;
|
|
532
|
+
private readonly auth;
|
|
533
|
+
private signer;
|
|
534
|
+
constructor(client: HIP4Client, auth: HIP4Auth);
|
|
535
|
+
setSigner(signer: HIP4Signer | {
|
|
536
|
+
address: string;
|
|
537
|
+
signTypedData: (...args: unknown[]) => Promise<string>;
|
|
538
|
+
}): void;
|
|
539
|
+
buyUsdh(amount: string): Promise<WalletActionResult>;
|
|
540
|
+
sellUsdh(amount: string): Promise<WalletActionResult>;
|
|
541
|
+
transferToSpot(amount: string): Promise<WalletActionResult>;
|
|
542
|
+
transferToPerps(amount: string): Promise<WalletActionResult>;
|
|
543
|
+
usdClassTransfer(params: UsdClassTransferParams): Promise<WalletActionResult>;
|
|
544
|
+
withdraw(params: WithdrawParams): Promise<WalletActionResult>;
|
|
545
|
+
usdSend(params: UsdSendParams): Promise<WalletActionResult>;
|
|
546
|
+
spotSend(params: SpotSendParams): Promise<WalletActionResult>;
|
|
547
|
+
/**
|
|
548
|
+
* Unified-account-compatible transfer primitive. Supersedes `spotSend`,
|
|
549
|
+
* `usdSend`, `usdClassTransfer`, and `subAccountSpotTransfer` when the
|
|
550
|
+
* account is in `unifiedAccount` or `portfolioMargin` abstraction mode
|
|
551
|
+
* (where silo-specific actions return "Action disabled when unified
|
|
552
|
+
* account is active").
|
|
553
|
+
*
|
|
554
|
+
* Use cases:
|
|
555
|
+
* - User → user spot transfer: `sourceDex: "spot", destinationDex: "spot"`
|
|
556
|
+
* - Core → HyperEVM bridge: `destination = systemAddress`, both dex = `""`
|
|
557
|
+
* - Spot → perp silo move: `sourceDex: "spot", destinationDex: ""`
|
|
558
|
+
*/
|
|
559
|
+
sendAsset(params: SendAssetParams): Promise<WalletActionResult>;
|
|
560
|
+
/**
|
|
561
|
+
* Move a spot token from HyperCore to HyperEVM.
|
|
562
|
+
*
|
|
563
|
+
* Mechanism: `sendAsset` to the token's system address, with
|
|
564
|
+
* `sourceDex = "spot"` and `destinationDex = ""`. HL credits the sender's
|
|
565
|
+
* HyperEVM address by calling `transfer(sender, amount)` on the token's
|
|
566
|
+
* linked ERC-20 contract. No hook data, no CCTP - the token stays as the
|
|
567
|
+
* same token on HyperEVM.
|
|
568
|
+
*
|
|
569
|
+
* Why `sendAsset` and not `spotSend`: `spotSend` is rejected under
|
|
570
|
+
* `unifiedAccount` / `portfolioMargin` abstraction modes with "Action
|
|
571
|
+
* disabled when unified account is active". Unified is the app default
|
|
572
|
+
* for new accounts, so `sendAsset` is the only flow that works for both
|
|
573
|
+
* modes.
|
|
574
|
+
*
|
|
575
|
+
* Use this for USDH (and any non-USDC spot token). For USDC destinations
|
|
576
|
+
* on other EVM chains, use `sendUsdcToEvm` instead (CCTP is strictly
|
|
577
|
+
* cheaper + faster than sendAsset-to-HyperEVM + bridge).
|
|
578
|
+
*
|
|
579
|
+
* HYPE is the documented exception: callers must set `isHype: true` so
|
|
580
|
+
* the destination resolves to the hardcoded `0x2222…2222` slot rather
|
|
581
|
+
* than the index-derived address.
|
|
582
|
+
*/
|
|
583
|
+
sendSpotTokenToEvm(params: SendSpotTokenToEvmParams): Promise<WalletActionResult>;
|
|
584
|
+
/**
|
|
585
|
+
* Transfer a spot token from HyperCore to the EVM side, invoking the
|
|
586
|
+
* linked contract's `coreReceiveWithData` hook with user-provided data.
|
|
587
|
+
*
|
|
588
|
+
* For Circle-managed tokens (USDC), this bridges via CCTP directly to
|
|
589
|
+
* `destinationChainId` - `destinationRecipient` receives USDC there. No
|
|
590
|
+
* secondary `withdraw3` or Across hop needed to land on Arbitrum.
|
|
591
|
+
*
|
|
592
|
+
* Fee model: HyperEVM gas (`gasLimit × baseFee × HYPE/USDC_oracle`,
|
|
593
|
+
* deducted from L1 USDC) + Circle forwarder fee on destination (0.2 USDC
|
|
594
|
+
* flat, subtracted from amount). CCTP protocol fee is 0.
|
|
595
|
+
*/
|
|
596
|
+
sendToEvmWithData(params: SendToEvmWithDataParams): Promise<WalletActionResult>;
|
|
597
|
+
/**
|
|
598
|
+
* Convenience wrapper: `sendToEvmWithData` with the USDC token string
|
|
599
|
+
* for the current network auto-filled. Circle's CoreDepositWallet picks
|
|
600
|
+
* up the call and CCTPs USDC to `destinationChainId`.
|
|
601
|
+
*/
|
|
602
|
+
sendUsdcToEvm(params: Omit<SendToEvmWithDataParams, "token">): Promise<WalletActionResult>;
|
|
603
|
+
private executeSpotOrder;
|
|
604
|
+
/**
|
|
605
|
+
* Set a referral code on Hyperliquid.
|
|
606
|
+
* Uses L1 agent signing (requires auth to be initialized).
|
|
607
|
+
*/
|
|
608
|
+
setReferrer(code: string): Promise<WalletActionResult>;
|
|
609
|
+
private executeUserSigned;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
declare class HyperliquidHip4Adapter implements PredictionsAdapter {
|
|
613
|
+
readonly id = "hyperliquid";
|
|
614
|
+
readonly name: string;
|
|
615
|
+
readonly events: HIP4EventAdapter;
|
|
616
|
+
readonly marketData: PredictionsAdapter["marketData"];
|
|
617
|
+
readonly account: PredictionsAdapter["account"];
|
|
618
|
+
readonly trading: HIP4TradingAdapter;
|
|
619
|
+
readonly auth: PredictionsAdapter["auth"];
|
|
620
|
+
readonly wallet: HIP4WalletAdapter;
|
|
621
|
+
readonly client: HIP4Client;
|
|
622
|
+
private readonly _marketData;
|
|
623
|
+
constructor(config?: CreateHIP4AdapterConfig);
|
|
624
|
+
initialize(): Promise<void>;
|
|
625
|
+
destroy(): void;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** Configuration for creating a HIP-4 prediction market adapter. */
|
|
629
|
+
interface CreateHIP4AdapterConfig {
|
|
630
|
+
testnet?: boolean;
|
|
631
|
+
infoUrl?: string;
|
|
632
|
+
exchangeUrl?: string;
|
|
633
|
+
/**
|
|
634
|
+
* Builder address for fee collection.
|
|
635
|
+
* When set, all orders will include this builder address.
|
|
636
|
+
*/
|
|
637
|
+
builderAddress?: string;
|
|
638
|
+
/**
|
|
639
|
+
* Builder fee in tenths of a basis point (0-1000).
|
|
640
|
+
* 0 = no fee. 100 = 0.1%. 1000 = 1.0% (maximum).
|
|
641
|
+
*/
|
|
642
|
+
builderFee?: number;
|
|
643
|
+
/** Optional logger. Default: no-op. */
|
|
644
|
+
logger?: (level: "debug" | "info" | "warn" | "error", msg: string, data?: unknown) => void;
|
|
645
|
+
}
|
|
646
|
+
/** Create a PredictionsAdapter backed by Hyperliquid HIP-4 spot markets. */
|
|
647
|
+
declare function createHIP4Adapter(config?: CreateHIP4AdapterConfig): HyperliquidHip4Adapter;
|
|
648
|
+
|
|
649
|
+
/** Build EIP-712 typed data for an agent-wallet approval signature. */
|
|
650
|
+
declare function getAgentApprovalTypedData(agentAddress: `0x${string}`, agentName: string, nonce: number, isMainnet?: boolean): {
|
|
651
|
+
domain: {
|
|
652
|
+
readonly name: "HyperliquidSignTransaction";
|
|
653
|
+
readonly version: "1";
|
|
654
|
+
readonly chainId: 42161 | 421614;
|
|
655
|
+
readonly verifyingContract: `0x${string}`;
|
|
656
|
+
};
|
|
657
|
+
types: {
|
|
658
|
+
"HyperliquidTransaction:ApproveAgent": {
|
|
659
|
+
name: string;
|
|
660
|
+
type: string;
|
|
661
|
+
}[];
|
|
662
|
+
};
|
|
663
|
+
primaryType: "HyperliquidTransaction:ApproveAgent";
|
|
664
|
+
message: {
|
|
665
|
+
hyperliquidChain: string;
|
|
666
|
+
agentAddress: `0x${string}`;
|
|
667
|
+
agentName: string;
|
|
668
|
+
nonce: bigint;
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
/** Build EIP-712 typed data for a builder-fee approval signature. */
|
|
672
|
+
declare function getBuilderFeeApprovalTypedData(builderAddress: `0x${string}`, maxFeeRate: string, nonce: number, isMainnet?: boolean): {
|
|
673
|
+
domain: {
|
|
674
|
+
readonly name: "HyperliquidSignTransaction";
|
|
675
|
+
readonly version: "1";
|
|
676
|
+
readonly chainId: 42161 | 421614;
|
|
677
|
+
readonly verifyingContract: `0x${string}`;
|
|
678
|
+
};
|
|
679
|
+
types: Record<string, {
|
|
680
|
+
name: string;
|
|
681
|
+
type: string;
|
|
682
|
+
}[]>;
|
|
683
|
+
primaryType: string;
|
|
684
|
+
message: {
|
|
685
|
+
hyperliquidChain: string;
|
|
686
|
+
maxFeeRate: string;
|
|
687
|
+
builder: `0x${string}`;
|
|
688
|
+
nonce: bigint;
|
|
689
|
+
};
|
|
690
|
+
};
|
|
691
|
+
/** Submit a signed builder-fee approval to the Hyperliquid exchange API. */
|
|
692
|
+
declare function submitBuilderFeeApproval(signature: `0x${string}`, builderAddress: `0x${string}`, maxFeeRate: string, nonce: number, isMainnet?: boolean, exchangeUrl?: string): Promise<{
|
|
693
|
+
success: boolean;
|
|
694
|
+
error?: string;
|
|
695
|
+
}>;
|
|
696
|
+
/** Submit a signed agent-approval transaction to the Hyperliquid exchange API. */
|
|
697
|
+
declare function submitAgentApproval(signature: `0x${string}`, agentAddress: `0x${string}`, agentName: string, nonce: number, isMainnet?: boolean, exchangeUrl?: string): Promise<{
|
|
698
|
+
success: boolean;
|
|
699
|
+
error?: string;
|
|
700
|
+
}>;
|
|
701
|
+
|
|
702
|
+
interface ParsedDescription {
|
|
703
|
+
class: "priceBinary";
|
|
704
|
+
underlying: string;
|
|
705
|
+
expiry: Date;
|
|
706
|
+
targetPrice: number;
|
|
707
|
+
period: string;
|
|
708
|
+
}
|
|
709
|
+
interface ParsedPriceBucketDescription {
|
|
710
|
+
class: "priceBucket";
|
|
711
|
+
underlying: string;
|
|
712
|
+
expiry: Date;
|
|
713
|
+
/** Sorted ascending price thresholds. N thresholds → N+1 buckets. */
|
|
714
|
+
priceThresholds: number[];
|
|
715
|
+
period: string;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* A single active HIP-4 recurring price binary market.
|
|
719
|
+
*
|
|
720
|
+
* Coin naming conventions:
|
|
721
|
+
* #<coinNum> - API coin used in allMids, l2Book, candle, recentTrades
|
|
722
|
+
* @<pairNum> - Token pair (EMPTY orderbook - not traded directly)
|
|
723
|
+
* +<coinNum> - Token balance key in spotClearinghouseState
|
|
724
|
+
* a = 100000000 + coinNum - order asset field
|
|
725
|
+
*/
|
|
726
|
+
interface PriceBinaryMarket {
|
|
727
|
+
outcomeId: number;
|
|
728
|
+
underlying: string;
|
|
729
|
+
targetPrice: number;
|
|
730
|
+
expiry: Date;
|
|
731
|
+
period: string;
|
|
732
|
+
yesCoinNum: number;
|
|
733
|
+
noCoinNum: number;
|
|
734
|
+
yesCoin: string;
|
|
735
|
+
noCoin: string;
|
|
736
|
+
yesAsset: number;
|
|
737
|
+
noAsset: number;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Parse a pipe-delimited outcome description string.
|
|
741
|
+
*
|
|
742
|
+
* Format: "class:priceBinary|underlying:BTC|expiry:20260310-0300|targetPrice:66200|period:15m"
|
|
743
|
+
*
|
|
744
|
+
* Returns null if not a valid priceBinary description.
|
|
745
|
+
*/
|
|
746
|
+
declare function parseDescription(desc: string): ParsedDescription | null;
|
|
747
|
+
/**
|
|
748
|
+
* Parse a pipe-delimited priceBucket description string.
|
|
749
|
+
*
|
|
750
|
+
* Format: "class:priceBucket|underlying:BTC|expiry:20260505-1700|priceThresholds:81015.3,81258.7|period:15m"
|
|
751
|
+
*
|
|
752
|
+
* Returns null if not a valid priceBucket description.
|
|
753
|
+
*/
|
|
754
|
+
declare function parsePriceBucketDescription(desc: string): ParsedPriceBucketDescription | null;
|
|
755
|
+
interface OutcomeMeta {
|
|
756
|
+
outcomes: Array<{
|
|
757
|
+
outcome: number;
|
|
758
|
+
name: string;
|
|
759
|
+
description: string;
|
|
760
|
+
sideSpecs: Array<{
|
|
761
|
+
name: string;
|
|
762
|
+
}>;
|
|
763
|
+
}>;
|
|
764
|
+
questions: unknown[];
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Discover all active priceBinary markets from outcomeMeta + allMids.
|
|
768
|
+
*
|
|
769
|
+
* A market is included when:
|
|
770
|
+
* 1. Its description parses as class:priceBinary
|
|
771
|
+
* 2. Expiry is in the future
|
|
772
|
+
* 3. A live price exists in mids for the underlying
|
|
773
|
+
*/
|
|
774
|
+
declare function discoverPriceBinaryMarkets(meta: OutcomeMeta, mids: Record<string, string>): PriceBinaryMarket[];
|
|
775
|
+
/** Minutes until market expires. Negative means already expired. */
|
|
776
|
+
declare function timeToExpiry(market: PriceBinaryMarket): number;
|
|
777
|
+
/**
|
|
778
|
+
* Parse a period string to minutes.
|
|
779
|
+
* "1m"→1, "5m"→5, "15m"→15, "1h"→60, "4h"→240, "1d"→1440
|
|
780
|
+
*/
|
|
781
|
+
declare function periodMinutes(period: string): number;
|
|
782
|
+
/** Human-readable label: "BTC-1d", "HYPE-15m" */
|
|
783
|
+
declare function formatMarketLabel(market: PriceBinaryMarket): string;
|
|
784
|
+
|
|
785
|
+
interface QuestionEntry {
|
|
786
|
+
question: HLQuestion;
|
|
787
|
+
isFallback: boolean;
|
|
788
|
+
/** Index in question.namedOutcomes; -1 for fallback */
|
|
789
|
+
bucketIndex: number;
|
|
790
|
+
/** Pre-parsed priceBucket spec on the question, if any */
|
|
791
|
+
bucket: ParsedPriceBucketDescription | null;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Pre-computed lookup from outcomeId → parent question metadata.
|
|
795
|
+
* Reuse across multiple `classifyOutcome` calls to avoid O(N) rebuilds per
|
|
796
|
+
* call (see {@link buildQuestionIndex}).
|
|
797
|
+
*/
|
|
798
|
+
interface QuestionIndex {
|
|
799
|
+
/** outcomeId → entry */
|
|
800
|
+
byOutcome: Map<number, QuestionEntry>;
|
|
801
|
+
}
|
|
802
|
+
/**
|
|
803
|
+
* Build the question index once and reuse it when classifying many outcomes
|
|
804
|
+
* via `classifyOutcome`. `classifyAllOutcomes` builds its own index
|
|
805
|
+
* internally - this helper exists for callers that need per-outcome
|
|
806
|
+
* classification in a loop.
|
|
807
|
+
*/
|
|
808
|
+
declare function buildQuestionIndex(questions: HLQuestion[]): QuestionIndex;
|
|
809
|
+
/**
|
|
810
|
+
* Resolve the [lowerBound, upperBound) for a bucket within a priceBucket
|
|
811
|
+
* question, given the question's `priceThresholds`. Bounds are half-open:
|
|
812
|
+
* `lowerBound` is inclusive, `upperBound` is exclusive.
|
|
813
|
+
*
|
|
814
|
+
* bucketIndex < 0 → both null (fallback bucket)
|
|
815
|
+
* bucketIndex === 0 → lowerBound is null (unbounded below)
|
|
816
|
+
* bucketIndex >= len → upperBound is null (unbounded above)
|
|
817
|
+
*
|
|
818
|
+
* @param thresholds Sorted list of bucket boundaries from the question.
|
|
819
|
+
* @param bucketIndex Position in the question's namedOutcomes array.
|
|
820
|
+
*/
|
|
821
|
+
declare function getPriceBucketBounds(thresholds: readonly number[], bucketIndex: number): {
|
|
822
|
+
lowerBound: number | null;
|
|
823
|
+
upperBound: number | null;
|
|
824
|
+
};
|
|
825
|
+
/**
|
|
826
|
+
* Classify a single HLOutcome into a typed HIP4Market.
|
|
827
|
+
*
|
|
828
|
+
* Detection priority:
|
|
829
|
+
* 1. Description parses as class:priceBinary → defaultBinary
|
|
830
|
+
* 2. Outcome is in a question → multiOutcome (or priceBucket)
|
|
831
|
+
* 3. Everything else → labelledBinary
|
|
832
|
+
*
|
|
833
|
+
* For batch classification, prefer `classifyAllOutcomes` (builds the index
|
|
834
|
+
* once). When calling `classifyOutcome` repeatedly, pass a pre-built
|
|
835
|
+
* `precomputedIndex` to avoid rebuilding it on every call:
|
|
836
|
+
*
|
|
837
|
+
* const index = buildQuestionIndex(questions);
|
|
838
|
+
* for (const o of outcomes) classifyOutcome(o, questions, index);
|
|
839
|
+
*/
|
|
840
|
+
declare function classifyOutcome(outcome: HLOutcome, questions: HLQuestion[], precomputedIndex?: QuestionIndex): HIP4Market;
|
|
841
|
+
/**
|
|
842
|
+
* Classify all outcomes in one pass.
|
|
843
|
+
* Builds the question index once and reuses it.
|
|
844
|
+
*/
|
|
845
|
+
declare function classifyAllOutcomes(outcomes: HLOutcome[], questions: HLQuestion[]): HIP4Market[];
|
|
846
|
+
|
|
847
|
+
declare const MIN_NOTIONAL = 10;
|
|
848
|
+
declare function computeTickSize(price: number): number;
|
|
849
|
+
declare function roundToTick(price: number): number;
|
|
850
|
+
declare function formatPrice(price: number): string;
|
|
851
|
+
declare function stripZeros(s: string): string;
|
|
852
|
+
declare function getMinShares(markPx: number): number;
|
|
853
|
+
|
|
854
|
+
/** HYPE is the one documented exception to the 0x20-prefix rule. */
|
|
855
|
+
declare const HYPE_CORE_EVM_SYSTEM_ADDRESS: "0x2222222222222222222222222222222222222222";
|
|
856
|
+
/**
|
|
857
|
+
* Upper bound on derivable token indices. 19-byte big-endian can hold values
|
|
858
|
+
* up to 2^152 - 1, which overflows JS numbers. We clamp to MAX_SAFE_INTEGER
|
|
859
|
+
* so the derivation math stays exact; every real Hyperliquid token index is
|
|
860
|
+
* orders of magnitude below this.
|
|
861
|
+
*/
|
|
862
|
+
declare const MAX_CORE_EVM_TOKEN_INDEX: number;
|
|
863
|
+
/**
|
|
864
|
+
* Derive the HyperCore system address for a given spot token index.
|
|
865
|
+
*
|
|
866
|
+
* IMPORTANT: `tokenIndex` is the value from `info: spotMeta → tokens[].index`,
|
|
867
|
+
* not the spot-pair/market index from `universe[]`. Passing the wrong one
|
|
868
|
+
* sends funds to an unrelated token's system address.
|
|
869
|
+
*
|
|
870
|
+
* For HYPE, import `HYPE_CORE_EVM_SYSTEM_ADDRESS` directly - there is no
|
|
871
|
+
* derivable address.
|
|
872
|
+
*/
|
|
873
|
+
declare function deriveCoreEvmSystemAddress(tokenIndex: number): string;
|
|
874
|
+
|
|
875
|
+
/** HL-canonical gas budget for Core→HyperEVM system-tx credit. Fixed, from
|
|
876
|
+
* the docs. Over/under-provisioning at the action level is not applicable
|
|
877
|
+
* - the protocol uses exactly this value. */
|
|
878
|
+
declare const CORE_TO_EVM_GAS_LIMIT = 200000n;
|
|
879
|
+
interface CoreToEvmFeeInputs {
|
|
880
|
+
/** HyperEVM block baseFee in wei. Prefer a median-over-history sample
|
|
881
|
+
* (`medianBaseFeeWei`) to stay robust against single-block MEV spikes. */
|
|
882
|
+
readonly baseFeeWei: bigint;
|
|
883
|
+
/** User's HYPE balance on HL Core spot, as a decimal number. */
|
|
884
|
+
readonly hypeCoreSpotBalance: number;
|
|
885
|
+
/** HYPE/USDC spot `markPx` in USD. Source: HL info endpoint,
|
|
886
|
+
* `{"type":"spotMetaAndAssetCtxs"}`, pair `@107` mainnet / `@1035` testnet.
|
|
887
|
+
* Using midPx or perp mark diverges from HL's actual debit. */
|
|
888
|
+
readonly hypeSpotMarkPxUsd: number;
|
|
889
|
+
/** USD price of the token being sent (USDH ≈ 1.0). Used only in the
|
|
890
|
+
* source-token fallback path - ignored when the user has HYPE. */
|
|
891
|
+
readonly sourceTokenPriceUsd: number;
|
|
892
|
+
}
|
|
893
|
+
interface CoreToEvmFeeBreakdown {
|
|
894
|
+
/** Which balance HL will actually debit. */
|
|
895
|
+
readonly currency: "HYPE" | "source";
|
|
896
|
+
/** Fee amount if debited in HYPE. Zero in the source-token path. */
|
|
897
|
+
readonly amountHype: number;
|
|
898
|
+
/** Fee amount if debited in the source token. Zero in the HYPE path. */
|
|
899
|
+
readonly amountSourceToken: number;
|
|
900
|
+
/** USD-equivalent of the fee. Identical between both paths. */
|
|
901
|
+
readonly usd: number;
|
|
902
|
+
/** Echoed back for UI tooltips / audit. */
|
|
903
|
+
readonly gasLimit: bigint;
|
|
904
|
+
readonly baseFeeWei: bigint;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Estimate the Core→HyperEVM transfer fee and which balance will be debited.
|
|
908
|
+
*
|
|
909
|
+
* Pure, synchronous. Call once per quote with freshly-fetched inputs.
|
|
910
|
+
*/
|
|
911
|
+
declare function estimateCoreToEvmFee(inputs: CoreToEvmFeeInputs): CoreToEvmFeeBreakdown;
|
|
912
|
+
/**
|
|
913
|
+
* Median over an `eth_feeHistory` baseFee sample.
|
|
914
|
+
*
|
|
915
|
+
* Why median, not max: a single MEV-saturated block can spike baseFee briefly
|
|
916
|
+
* before mean-reverting under EIP-1559's 12.5%-per-block decay. `max` lets
|
|
917
|
+
* one outlier dominate the UI quote; `median` is robust in both directions
|
|
918
|
+
* while still tracking genuine trends over a few blocks' lag.
|
|
919
|
+
*
|
|
920
|
+
* Why not a safety multiplier on top: the fee we display is the fee the
|
|
921
|
+
* user pays. Padding the display hides the true accounting - users compare
|
|
922
|
+
* UI fee vs ledger debit and notice. Accuracy over pessimism.
|
|
923
|
+
*/
|
|
924
|
+
declare function medianBaseFeeWei(samples: readonly bigint[]): bigint;
|
|
925
|
+
|
|
926
|
+
declare const HYPE_USDC_SPOT_PAIR_MAINNET: "@107";
|
|
927
|
+
declare const HYPE_USDC_SPOT_PAIR_TESTNET: "@1035";
|
|
928
|
+
interface SelectHypeSpotMarkPxOptions {
|
|
929
|
+
readonly testnet?: boolean;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Pull the HYPE/USDC `markPx` (USD) from a bulk spotAssetCtxs store map.
|
|
933
|
+
*
|
|
934
|
+
* Returns `null` when the pair entry is missing or its markPx is not a
|
|
935
|
+
* positive finite number. Callers should treat `null` as "price not yet
|
|
936
|
+
* available" (pre-WS-hydration) rather than zero.
|
|
937
|
+
*
|
|
938
|
+
* Deliberately does NOT fall back to midPx when markPx is absent - midPx
|
|
939
|
+
* diverges from markPx during volatile periods and using it would misprice
|
|
940
|
+
* the fee relative to HL's actual debit.
|
|
941
|
+
*/
|
|
942
|
+
declare function selectHypeSpotMarkPx(ctxs: Record<string, HLWsSpotAssetCtxItem | undefined>, options?: SelectHypeSpotMarkPxOptions): number | null;
|
|
943
|
+
interface SpotMetaShape {
|
|
944
|
+
readonly tokens: ReadonlyArray<{
|
|
945
|
+
name: string;
|
|
946
|
+
index: number;
|
|
947
|
+
}>;
|
|
948
|
+
readonly universe: ReadonlyArray<{
|
|
949
|
+
index: number;
|
|
950
|
+
tokens: readonly [number, number];
|
|
951
|
+
}>;
|
|
952
|
+
}
|
|
953
|
+
/**
|
|
954
|
+
* Discover the HYPE/USDC pair coin string (`@N`) dynamically from spotMeta.
|
|
955
|
+
*
|
|
956
|
+
* Belt-and-suspenders against HL renumbering. The hardcoded constants above
|
|
957
|
+
* are the steady-state truth; this helper lets a caller recover gracefully
|
|
958
|
+
* if HL ever reindexes a pair. USDC is always token index 0.
|
|
959
|
+
*/
|
|
960
|
+
declare function findHypeUsdcSpotPairCoin(meta: SpotMetaShape): string | null;
|
|
961
|
+
|
|
962
|
+
interface PriceFeedCandle {
|
|
963
|
+
/** Unix timestamp in **seconds** (matches fetchCandles convention). */
|
|
964
|
+
time: number;
|
|
965
|
+
open: number;
|
|
966
|
+
high: number;
|
|
967
|
+
low: number;
|
|
968
|
+
close: number;
|
|
969
|
+
volume: number;
|
|
970
|
+
}
|
|
971
|
+
/** Convert an interval string like `"1h"` to milliseconds. Falls back to 1 h. */
|
|
972
|
+
declare function intervalToMs(interval: string): number;
|
|
973
|
+
/** Floor a millisecond timestamp to its candle boundary (in ms). */
|
|
974
|
+
declare function candleBoundaryMs(timestampMs: number, intervalMs: number): number;
|
|
975
|
+
/**
|
|
976
|
+
* Process a price tick against a mutable candle array.
|
|
977
|
+
* Either updates the last candle's OHLC or appends a new one.
|
|
978
|
+
* Returns `true` if the tick was applied (not stale).
|
|
979
|
+
*
|
|
980
|
+
* Internal mutable accumulator - callers own the array and snapshot via
|
|
981
|
+
* `candles.map(c => ({ ...c }))` before emitting to consumers.
|
|
982
|
+
*/
|
|
983
|
+
declare function processTick(candles: PriceFeedCandle[], price: number, timestampMs: number, intervalMs: number): boolean;
|
|
984
|
+
|
|
985
|
+
interface PerpPriceFeedOptions {
|
|
986
|
+
/** Candle interval string accepted by Hyperliquid (e.g. "1m", "5m", "1h", "1d"). Default: `"1h"`. */
|
|
987
|
+
interval?: string;
|
|
988
|
+
/** How far back to fetch historical candles, in milliseconds. Default: 14 days. */
|
|
989
|
+
lookbackMs?: number;
|
|
990
|
+
}
|
|
991
|
+
interface PerpPriceFeedSnapshot {
|
|
992
|
+
coin: string;
|
|
993
|
+
/** Full candle array (historical + live). */
|
|
994
|
+
candles: PriceFeedCandle[];
|
|
995
|
+
/** Latest mid-price received (may be newer than the last candle close). */
|
|
996
|
+
currentMid: number | null;
|
|
997
|
+
/** `false` until the initial candle fetch resolves. */
|
|
998
|
+
ready: boolean;
|
|
999
|
+
}
|
|
1000
|
+
/**
|
|
1001
|
+
* Create a live price feed for a perpetual market coin.
|
|
1002
|
+
*
|
|
1003
|
+
* 1. Subscribes to `allMids` for live mid-price updates (currentMid).
|
|
1004
|
+
* 2. Subscribes to `candle` WS for authoritative OHLCV candle updates.
|
|
1005
|
+
* 3. Fetches historical candles for the lookback window.
|
|
1006
|
+
* 4. After historical fetch, replays buffered data and emits snapshots
|
|
1007
|
+
* on every candle WS update or allMids tick.
|
|
1008
|
+
*
|
|
1009
|
+
* Returns an **unsubscribe** function - call it to stop the feed.
|
|
1010
|
+
*/
|
|
1011
|
+
declare function createPerpPriceFeed(client: HIP4Client, coin: string, onSnapshot: (snapshot: PerpPriceFeedSnapshot) => void, options?: PerpPriceFeedOptions): () => void;
|
|
1012
|
+
|
|
1013
|
+
interface PriceFeedOptions {
|
|
1014
|
+
/** Candle interval string accepted by Hyperliquid (e.g. "1m", "5m", "1h", "1d"). Default: `"1h"`. */
|
|
1015
|
+
interval?: string;
|
|
1016
|
+
/** How far back to fetch historical candles, in milliseconds. Default: 14 days. */
|
|
1017
|
+
lookbackMs?: number;
|
|
1018
|
+
/** Which side to track - 0 for Yes, 1 for No. Default: `0`. */
|
|
1019
|
+
sideIndex?: number;
|
|
1020
|
+
}
|
|
1021
|
+
interface PriceFeedSnapshot {
|
|
1022
|
+
marketId: string;
|
|
1023
|
+
/** Full candle array (historical + live). */
|
|
1024
|
+
candles: PriceFeedCandle[];
|
|
1025
|
+
/** Latest mid-price received (may be newer than the last candle close). */
|
|
1026
|
+
currentMid: number | null;
|
|
1027
|
+
/** `false` until the initial candle fetch resolves. */
|
|
1028
|
+
ready: boolean;
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Create a live price feed for a single prediction market.
|
|
1032
|
+
*
|
|
1033
|
+
* 1. Immediately subscribes to real-time mid-price updates (ticks are buffered
|
|
1034
|
+
* until the historical fetch completes).
|
|
1035
|
+
* 2. Fetches historical candles for the lookback window.
|
|
1036
|
+
* 3. Merges buffered ticks into the candle array.
|
|
1037
|
+
* 4. On every subsequent tick, updates the latest candle or appends a new one,
|
|
1038
|
+
* then emits a {@link PriceFeedSnapshot}.
|
|
1039
|
+
*
|
|
1040
|
+
* Returns an **unsubscribe** function - call it to stop the feed.
|
|
1041
|
+
*/
|
|
1042
|
+
declare function createPriceFeed(marketData: PredictionMarketDataAdapter, marketId: string, onSnapshot: (snapshot: PriceFeedSnapshot) => void, options?: PriceFeedOptions): Unsubscribe;
|
|
1043
|
+
|
|
1044
|
+
interface TradeCostResult {
|
|
1045
|
+
readonly estimatedCost: number;
|
|
1046
|
+
readonly potentialReturn: number;
|
|
1047
|
+
readonly displayShares: number;
|
|
1048
|
+
}
|
|
1049
|
+
declare function computeEstimatedCost(tokenAmount: number, orderType: "market" | "limit", limitPriceCents: number | null, marketPriceCents?: number): number;
|
|
1050
|
+
declare function computeTradeCost(params: {
|
|
1051
|
+
tokenAmount: number;
|
|
1052
|
+
orderType: "market" | "limit";
|
|
1053
|
+
limitPriceCents: number | null;
|
|
1054
|
+
marketPriceCents?: number;
|
|
1055
|
+
}): TradeCostResult;
|
|
1056
|
+
declare function computePotentialReturn(tokenAmount: number): number;
|
|
1057
|
+
|
|
1058
|
+
export { ALL_DEXS, CORE_TO_EVM_GAS_LIMIT, type CoreToEvmFeeBreakdown, type CoreToEvmFeeInputs, type CreateHIP4AdapterConfig, FetchMarketsParams, HIP4Client, type HIP4ClientConfig, HIP4EventAdapter, HIP4Market, HIP4Signer, HIP4TradingAdapter, HIP4WalletAdapter, HLApiError, HLCancelResponse, HLCandle, HLExtraAgent, HLFill, HLOutcome, HLOutcomeMeta, HLQuestion, HLReferralState, HLSettledOutcome, HLSignature, HLSpotClearinghouseState, HLUserAbstraction, HLUserFees, HLUserRoleResponse, HLWsActivePerpAssetCtxData, HLWsActiveSpotAssetCtxData, HLWsAllMidsData, HLWsOutcomeMetaUpdate, HLWsSpotAssetCtxItem, HLWsSpotAssetCtxsData, HYPE_CORE_EVM_SYSTEM_ADDRESS, HYPE_USDC_SPOT_PAIR_MAINNET, HYPE_USDC_SPOT_PAIR_TESTNET, MAX_CORE_EVM_TOKEN_INDEX, MIN_NOTIONAL, MarketsByQuestion, MarketsByType, type MergeOutcomeParams, type MergeQuestionParams, type NegateOutcomeParams, type ParsedDescription, type ParsedPriceBucketDescription, type PerpPriceFeedOptions, type PerpPriceFeedSnapshot, type PredictionAccountAdapter, PredictionActivity, type PredictionAuthAdapter, PredictionAuthState, PredictionBatchOrderResult, PredictionCancelParams, PredictionCategory, PredictionEvent, type PredictionEventAdapter, type PredictionMarketDataAdapter, PredictionModifyParams, PredictionOrderBook, PredictionOrderParams, PredictionOrderResult, PredictionPosition, PredictionPrice, PredictionTrade, type PredictionTradingAdapter, type PredictionWalletAdapter, type PredictionsAdapter, type PriceBinaryMarket, type PriceFeedCandle, type PriceFeedOptions, type PriceFeedSnapshot, type QuestionIndex, type SelectHypeSpotMarkPxOptions, type SplitOutcomeParams, type SpotMetaShape, type SpotSendParams, type TradeCostResult, USDC_HL_TOKEN_MAINNET, USDC_HL_TOKEN_TESTNET, USDH_ASSET_ID, USDH_ASSET_ID_MAINNET, USDH_ASSET_ID_TESTNET, USDH_CORE_DECIMALS, USDH_EVM_ADDRESS_MAINNET, USDH_EVM_ADDRESS_TESTNET, USDH_EVM_DECIMALS, USDH_HL_TOKEN_MAINNET, USDH_HL_TOKEN_TESTNET, USDH_SPOT_INDEX_MAINNET, USDH_SPOT_INDEX_TESTNET, USDH_SPOT_PAIR, USDH_SPOT_PAIR_MAINNET, USDH_SPOT_PAIR_TESTNET, USDH_TOKEN_HASH_MAINNET, USDH_TOKEN_HASH_TESTNET, USDH_TOKEN_INDEX_MAINNET, USDH_TOKEN_INDEX_TESTNET, type Unsubscribe, type UsdClassTransferParams, type UsdSendParams, type WalletActionResult$1 as WalletActionResult, type WithdrawParams, buildQuestionIndex, candleBoundaryMs, classifyAllOutcomes, classifyOutcome, computeEstimatedCost, computePotentialReturn, computeTickSize, computeTradeCost, createHIP4Adapter, createPerpPriceFeed, createPriceFeed, deriveCoreEvmSystemAddress, discoverPriceBinaryMarkets, estimateCoreToEvmFee, findHypeUsdcSpotPairCoin, formatMarketLabel, formatPredictionPrice, formatPrice, getAgentApprovalTypedData, getBuilderFeeApprovalTypedData, getMinShares, getPriceBucketBounds, intervalToMs, isUsdClassTransferRequired, medianBaseFeeWei, outcomeCoin, parseDescription, parseOutcomeCoin, parsePriceBucketDescription, parseSideCoin, periodMinutes, processTick, roundToTick, selectHypeSpotMarkPx, sideAssetId, sideCoin, stripZeros, submitAgentApproval, submitBuilderFeeApproval, timeToExpiry };
|