@liberfi.io/ui-perpetuals 0.2.21 → 0.3.0
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/README.md +9 -5
- package/dist/index.d.mts +822 -66
- package/dist/index.d.ts +822 -66
- package/dist/index.js +24 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare global {
|
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
declare const _default: "0.
|
|
15
|
+
declare const _default: "0.3.0";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Trading pair symbol format
|
|
@@ -271,6 +271,26 @@ interface AccountState {
|
|
|
271
271
|
totalUnrealizedPnl: number;
|
|
272
272
|
/** Venue-reported server time of the snapshot, if available (ms epoch). */
|
|
273
273
|
serverTime?: number;
|
|
274
|
+
/**
|
|
275
|
+
* Per-(coin) leverage configuration extracted from the underlying
|
|
276
|
+
* push. Mirrors `clearinghouseState.assetPositions[].position.leverage.value`
|
|
277
|
+
* for every coin where the user has an open position. Consumers
|
|
278
|
+
* (e.g. {@link useAccountStateSubscription}) write this through to
|
|
279
|
+
* `useActiveAssetLeverageQuery`'s cache so the place-order form can
|
|
280
|
+
* read leverage without an extra REST hop.
|
|
281
|
+
*/
|
|
282
|
+
leverageByCoin?: Record<string, {
|
|
283
|
+
value: number;
|
|
284
|
+
type: "isolated" | "cross";
|
|
285
|
+
}>;
|
|
286
|
+
/**
|
|
287
|
+
* Universe snapshot embedded in the push, when the venue's unified
|
|
288
|
+
* channel carries it (Hyperliquid `webData2` includes
|
|
289
|
+
* `meta` + `assetCtxs`). Lets {@link useAccountStateSubscription}
|
|
290
|
+
* keep `useUniverseQuery`'s cache fresh between polls without
|
|
291
|
+
* issuing extra REST traffic.
|
|
292
|
+
*/
|
|
293
|
+
universe?: UniverseSnapshot;
|
|
274
294
|
/** Raw payload from the venue (untransformed) for debugging. */
|
|
275
295
|
raw?: any;
|
|
276
296
|
}
|
|
@@ -383,6 +403,29 @@ interface Order {
|
|
|
383
403
|
* "Price above 81470" / "Price below 73761". Mostly useful for tooltips.
|
|
384
404
|
*/
|
|
385
405
|
triggerCondition?: string;
|
|
406
|
+
/**
|
|
407
|
+
* Live mark price for `coin` at parse time. Populated from
|
|
408
|
+
* `metaAndAssetCtxs[1][i].markPx` (or its `webData2` equivalent) so the
|
|
409
|
+
* Open Orders table can show a "Current Price" column without each row
|
|
410
|
+
* subscribing to the per-asset stream individually. Undefined when the
|
|
411
|
+
* market context is unavailable.
|
|
412
|
+
*/
|
|
413
|
+
markPrice?: number;
|
|
414
|
+
/**
|
|
415
|
+
* Take-profit trigger price bundled with this order via Hyperliquid's
|
|
416
|
+
* `normalTpsl` grouping. Populated by walking `children[]` on the
|
|
417
|
+
* parent Limit order: the child whose `orderType` matches
|
|
418
|
+
* `Take Profit Market` / `Take Profit Limit` contributes its
|
|
419
|
+
* `triggerPx` here. Undefined for trigger orders themselves and for
|
|
420
|
+
* limit orders without a TP child.
|
|
421
|
+
*/
|
|
422
|
+
takeProfitPrice?: number;
|
|
423
|
+
/**
|
|
424
|
+
* Stop-loss trigger price bundled with this order. Same semantics as
|
|
425
|
+
* {@link takeProfitPrice}, but for `Stop Market` / `Stop Limit`
|
|
426
|
+
* children.
|
|
427
|
+
*/
|
|
428
|
+
stopLossPrice?: number;
|
|
386
429
|
}
|
|
387
430
|
/**
|
|
388
431
|
* User trade history
|
|
@@ -408,6 +451,22 @@ interface TradeHistory {
|
|
|
408
451
|
isMaker: boolean;
|
|
409
452
|
/** Trade timestamp (milliseconds) */
|
|
410
453
|
timestamp: number;
|
|
454
|
+
/**
|
|
455
|
+
* Venue-supplied human-readable description of what this fill did to
|
|
456
|
+
* the user's position. Hyperliquid's `dir` field, e.g.
|
|
457
|
+
* `"Open Long"`, `"Close Short"`, or
|
|
458
|
+
* `"Market liquidation triggered at <px>"`. Used by the Trades panel
|
|
459
|
+
* as the row's primary descriptor so we don't have to reconstruct the
|
|
460
|
+
* action from `side` + reduceOnly heuristics.
|
|
461
|
+
*/
|
|
462
|
+
dir?: string;
|
|
463
|
+
/**
|
|
464
|
+
* Realised PnL on this fill, net of fees. For an opening trade this
|
|
465
|
+
* is essentially `-fee`; for a closing trade it's
|
|
466
|
+
* `(closePrice − entryPrice) × size − fee` (sign-flipped for shorts).
|
|
467
|
+
* Mirrors Hyperliquid's `closedPnl` exactly.
|
|
468
|
+
*/
|
|
469
|
+
closedPnl?: number;
|
|
411
470
|
}
|
|
412
471
|
/**
|
|
413
472
|
* Place order parameters
|
|
@@ -571,6 +630,52 @@ interface GetAssetMetaParams {
|
|
|
571
630
|
/** Trading pair symbol (e.g. "BTC-USDC"). */
|
|
572
631
|
symbol: string;
|
|
573
632
|
}
|
|
633
|
+
/**
|
|
634
|
+
* One coin in the venue's universe snapshot.
|
|
635
|
+
*
|
|
636
|
+
* Bundles the live market data and the static metadata (`szDecimals`,
|
|
637
|
+
* `maxLeverage`) so callers only have to round-trip through the venue
|
|
638
|
+
* once per refresh cycle. Enables {@link IPerpetualsClient.getUniverseSnapshot}
|
|
639
|
+
* which in turn powers the SDK's `useUniverseQuery` global singleton —
|
|
640
|
+
* the cure for N-ticker × M-component fan-out polling that triggers
|
|
641
|
+
* Hyperliquid 429s.
|
|
642
|
+
*
|
|
643
|
+
* `meta` is nullable because some adapters (e.g. the LiberFi backend
|
|
644
|
+
* before it surfaces `szDecimals`) cannot fill it. Consumers fall back
|
|
645
|
+
* to their own heuristics in that case.
|
|
646
|
+
*/
|
|
647
|
+
interface UniverseAssetEntry {
|
|
648
|
+
/** Bare coin symbol (e.g. "BTC"). */
|
|
649
|
+
coin: string;
|
|
650
|
+
/** Unified trading pair symbol (e.g. "BTC-USDC"). */
|
|
651
|
+
symbol: string;
|
|
652
|
+
/** Live market snapshot (price, funding, OI, 24h vol, ...). */
|
|
653
|
+
market: MarketData;
|
|
654
|
+
/** Static venue metadata when the adapter exposes it. */
|
|
655
|
+
meta: AssetMeta | null;
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Whole-universe snapshot returned by
|
|
659
|
+
* {@link IPerpetualsClient.getUniverseSnapshot}. Indexed by symbol for
|
|
660
|
+
* O(1) lookup so derived hooks (`useMarketQuery`, `useAssetMetaQuery`,
|
|
661
|
+
* ticker bars) can pick a slice without iterating.
|
|
662
|
+
*
|
|
663
|
+
* Treat the contained `Map` as read-only — React Query's structural
|
|
664
|
+
* sharing optimisations don't apply to Maps, but the snapshot is
|
|
665
|
+
* refreshed wholesale once per refresh cycle so identity comparisons
|
|
666
|
+
* naturally invalidate dependants.
|
|
667
|
+
*/
|
|
668
|
+
interface UniverseSnapshot {
|
|
669
|
+
/** Every asset the venue currently lists, in venue-published order. */
|
|
670
|
+
assets: UniverseAssetEntry[];
|
|
671
|
+
/** O(1) symbol → entry lookup (e.g. "BTC-USDC" → entry). */
|
|
672
|
+
bySymbol: Map<string, UniverseAssetEntry>;
|
|
673
|
+
/**
|
|
674
|
+
* Snapshot timestamp (ms epoch). Sourced from the venue's
|
|
675
|
+
* `serverTime` when available, otherwise the local clock at parse.
|
|
676
|
+
*/
|
|
677
|
+
fetchedAt: number;
|
|
678
|
+
}
|
|
574
679
|
/**
|
|
575
680
|
* Get open orders parameters
|
|
576
681
|
*/
|
|
@@ -806,6 +911,28 @@ interface IPerpetualsClient {
|
|
|
806
911
|
* @throws {Error} Network error or API error
|
|
807
912
|
*/
|
|
808
913
|
getAssetMeta(params: GetAssetMetaParams): Promise<AssetMeta | null>;
|
|
914
|
+
/**
|
|
915
|
+
* Optional: fetch the venue's complete universe in a single call.
|
|
916
|
+
*
|
|
917
|
+
* When implemented, the SDK uses this to back `useUniverseQuery` —
|
|
918
|
+
* a global singleton that refreshes once per minute and feeds every
|
|
919
|
+
* per-symbol consumer (`useMarketQuery`, `useMarketsQuery`,
|
|
920
|
+
* `useAssetMetaQuery`, ticker bars, ...) from the same snapshot.
|
|
921
|
+
*
|
|
922
|
+
* The contract: one network round-trip returns every asset's market
|
|
923
|
+
* data + (when known) static metadata. This collapses the
|
|
924
|
+
* "100 tickers × 60s polling" pattern into a single 60s poll —
|
|
925
|
+
* essential for keeping Hyperliquid `/info` weight under the 1200
|
|
926
|
+
* weight/min/IP cap.
|
|
927
|
+
*
|
|
928
|
+
* Implementations that cannot deliver the entire universe in one
|
|
929
|
+
* call may omit this method; consumers fall back to per-symbol
|
|
930
|
+
* polling in that case (legacy behaviour).
|
|
931
|
+
*
|
|
932
|
+
* @returns The full universe snapshot.
|
|
933
|
+
* @throws {Error} Network error or API error.
|
|
934
|
+
*/
|
|
935
|
+
getUniverseSnapshot?(): Promise<UniverseSnapshot>;
|
|
809
936
|
/**
|
|
810
937
|
* Connect to WebSocket server
|
|
811
938
|
* @throws {Error} Connection failed
|
|
@@ -871,6 +998,62 @@ interface IPerpetualsClient {
|
|
|
871
998
|
unsubscribe(subscriptionId: string): void;
|
|
872
999
|
}
|
|
873
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
* Configuration for {@link RateLimiter}.
|
|
1003
|
+
*
|
|
1004
|
+
* Defaults track Hyperliquid's documented `/info` budget (1200 weight
|
|
1005
|
+
* per minute per IP) and the per-type weight table reverse-engineered
|
|
1006
|
+
* from axiom.trade's deployed `hyperliquid-ts-sdk`. The defaults are
|
|
1007
|
+
* conservative — leaving the same headroom Axiom does — but every
|
|
1008
|
+
* field is overridable so consumers can tighten the budget under
|
|
1009
|
+
* shared egress IPs.
|
|
1010
|
+
*/
|
|
1011
|
+
interface RateLimiterConfig {
|
|
1012
|
+
/** Total weight the bucket can spend per window. Default 1200. */
|
|
1013
|
+
capacity?: number;
|
|
1014
|
+
/** Window duration in milliseconds. Default 60_000 (1 minute). */
|
|
1015
|
+
windowMs?: number;
|
|
1016
|
+
}
|
|
1017
|
+
/**
|
|
1018
|
+
* Browser-side token bucket aligned with HL's `/info` weight budget.
|
|
1019
|
+
*
|
|
1020
|
+
* Mirrors the `RateLimiter` in axiom.trade's deployed
|
|
1021
|
+
* `hyperliquid-ts-sdk` byte-for-byte: capacity 1200, refill once per
|
|
1022
|
+
* minute (not continuous), `waitForToken(weight)` blocks until the
|
|
1023
|
+
* next refill when the bucket is empty.
|
|
1024
|
+
*
|
|
1025
|
+
* Treat this as a process-wide singleton — all calls into the same
|
|
1026
|
+
* Hyperliquid REST client share one bucket so concurrent ticker /
|
|
1027
|
+
* order-form / portfolio components cooperate against the upstream
|
|
1028
|
+
* cap.
|
|
1029
|
+
*/
|
|
1030
|
+
declare class RateLimiter {
|
|
1031
|
+
private readonly capacity;
|
|
1032
|
+
private readonly windowMs;
|
|
1033
|
+
private tokens;
|
|
1034
|
+
private lastRefill;
|
|
1035
|
+
constructor(config?: RateLimiterConfig);
|
|
1036
|
+
/**
|
|
1037
|
+
* Reset the bucket to full capacity. Useful for tests; production
|
|
1038
|
+
* callers should not need this.
|
|
1039
|
+
*/
|
|
1040
|
+
reset(): void;
|
|
1041
|
+
/**
|
|
1042
|
+
* Block until `weight` tokens are available, then deduct them and
|
|
1043
|
+
* resolve. Re-checks the refill boundary each pass so a long sleep
|
|
1044
|
+
* never spins past more than one window.
|
|
1045
|
+
*/
|
|
1046
|
+
waitForToken(weight: number): Promise<void>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Top up the bucket if a full window has elapsed since the last
|
|
1049
|
+
* refill. Mirrors axiom's discrete-window refill (vs continuous
|
|
1050
|
+
* refill) so the bucket never lets a request through that HL would
|
|
1051
|
+
* reject — the upstream weight counter snaps back at the same
|
|
1052
|
+
* boundary.
|
|
1053
|
+
*/
|
|
1054
|
+
private refill;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
874
1057
|
/**
|
|
875
1058
|
* Hyperliquid `l2Book` aggregation parameters.
|
|
876
1059
|
*
|
|
@@ -919,6 +1102,19 @@ interface HyperliquidClientConfig {
|
|
|
919
1102
|
* @default 30000
|
|
920
1103
|
*/
|
|
921
1104
|
timeout?: number;
|
|
1105
|
+
/**
|
|
1106
|
+
* Outbound rate-limiter configuration. Defaults align with HL's
|
|
1107
|
+
* documented `/info` budget (1200 weight per minute per IP) and the
|
|
1108
|
+
* per-type weight table reverse-engineered from axiom.trade's
|
|
1109
|
+
* deployed hyperliquid-ts-sdk.
|
|
1110
|
+
*
|
|
1111
|
+
* Pass `false` to disable client-side rate limiting (e.g. when
|
|
1112
|
+
* a server-side proxy is already throttling on our behalf). Pass an
|
|
1113
|
+
* existing {@link RateLimiter} instance to share a bucket across
|
|
1114
|
+
* multiple client instances. Pass a partial config to tune capacity
|
|
1115
|
+
* / window for a custom IP egress topology.
|
|
1116
|
+
*/
|
|
1117
|
+
rateLimit?: RateLimiter | RateLimiterConfig | false;
|
|
922
1118
|
}
|
|
923
1119
|
/**
|
|
924
1120
|
* HyperliquidPerpetualsClient 类
|
|
@@ -955,12 +1151,58 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
955
1151
|
* collapse onto a single network request when the cache misses.
|
|
956
1152
|
*/
|
|
957
1153
|
private assetMetaPending;
|
|
1154
|
+
/**
|
|
1155
|
+
* Process-local cache of the venue's universe snapshot. Concurrent
|
|
1156
|
+
* `getUniverseSnapshot()` callers within {@link UNIVERSE_SNAPSHOT_TTL_MS}
|
|
1157
|
+
* share the same parsed object (and the underlying
|
|
1158
|
+
* `metaAndAssetCtxs` HTTP call) instead of each firing their own.
|
|
1159
|
+
*/
|
|
1160
|
+
private universeSnapshotCache;
|
|
1161
|
+
/**
|
|
1162
|
+
* In-flight `getUniverseSnapshot` request, deduped via
|
|
1163
|
+
* singleflight semantics so concurrent fan-outs (e.g.
|
|
1164
|
+
* `useUniverseQuery` + `getPositions()` + `getOpenOrders()` mounted
|
|
1165
|
+
* in the same render tick) collapse onto a single network request.
|
|
1166
|
+
*/
|
|
1167
|
+
private universeSnapshotPending;
|
|
1168
|
+
/**
|
|
1169
|
+
* Process-local cache of per-user state snapshots
|
|
1170
|
+
* (`clearinghouseState` + `frontendOpenOrders`), keyed by lowercased
|
|
1171
|
+
* user address. Concurrent `getPositions(user)` / `getOpenOrders(user)`
|
|
1172
|
+
* callers within {@link USER_STATE_SNAPSHOT_TTL_MS} share the same
|
|
1173
|
+
* parsed object (and the underlying two HL round-trips) instead of
|
|
1174
|
+
* each firing their own pair.
|
|
1175
|
+
*/
|
|
1176
|
+
private userStateCache;
|
|
1177
|
+
/**
|
|
1178
|
+
* In-flight `getUserStateSnapshot` requests, deduped per user via
|
|
1179
|
+
* singleflight semantics. Keyed the same way as
|
|
1180
|
+
* {@link userStateCache}.
|
|
1181
|
+
*/
|
|
1182
|
+
private userStatePending;
|
|
1183
|
+
/**
|
|
1184
|
+
* Outbound rate limiter shared across every REST call this client
|
|
1185
|
+
* issues. `null` when explicitly disabled via
|
|
1186
|
+
* `config.rateLimit === false` — the request path then becomes a
|
|
1187
|
+
* straight fetch with no bucket bookkeeping.
|
|
1188
|
+
*/
|
|
1189
|
+
private readonly rateLimiter;
|
|
958
1190
|
/**
|
|
959
1191
|
* 构造 Hyperliquid 客户端
|
|
960
1192
|
*
|
|
961
1193
|
* @param config 客户端配置,不传则使用默认配置(testnet)
|
|
962
1194
|
*/
|
|
963
1195
|
constructor(config?: HyperliquidClientConfig);
|
|
1196
|
+
/**
|
|
1197
|
+
* Compute the bucket weight to charge for a given endpoint + body.
|
|
1198
|
+
*
|
|
1199
|
+
* Mirrors axiom.trade's `hyperliquid-ts-sdk` weight table:
|
|
1200
|
+
* - `/info` payload `type` → see {@link weightForInfoType}
|
|
1201
|
+
* - `/exchange` (signed actions) → 1
|
|
1202
|
+
* - everything else → default 2 (matches HL's "miscellaneous read"
|
|
1203
|
+
* weight)
|
|
1204
|
+
*/
|
|
1205
|
+
private weightFor;
|
|
964
1206
|
/**
|
|
965
1207
|
* 内部 HTTP 请求方法
|
|
966
1208
|
*
|
|
@@ -997,11 +1239,64 @@ declare class HyperliquidPerpetualsClient implements IPerpetualsClient {
|
|
|
997
1239
|
getMarket(symbol: string): Promise<MarketData | null>;
|
|
998
1240
|
/**
|
|
999
1241
|
* 获取多个或所有币种的市场数据
|
|
1000
|
-
*
|
|
1001
|
-
* @
|
|
1002
|
-
*
|
|
1242
|
+
*
|
|
1243
|
+
* Backed by {@link getUniverseSnapshot} so this and `useMarketsQuery`
|
|
1244
|
+
* share the same single `metaAndAssetCtxs` round-trip — keeps the
|
|
1245
|
+
* legacy contract green while the SDK migrates to the universe
|
|
1246
|
+
* singleton.
|
|
1003
1247
|
*/
|
|
1004
1248
|
getMarkets(symbols?: string[]): Promise<MarketData[]>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Snapshot the venue's full perp universe in a single network call.
|
|
1251
|
+
*
|
|
1252
|
+
* Mirrors axiom.trade's `SymbolConversion.refreshAssetMaps()` — one
|
|
1253
|
+
* `metaAndAssetCtxs` round-trip yields both the live market context
|
|
1254
|
+
* (price / funding / OI / 24h vol) AND the static metadata
|
|
1255
|
+
* (`szDecimals` / `maxLeverage`) for every coin. The SDK funnels every
|
|
1256
|
+
* per-symbol consumer (`useMarketQuery`, `useAssetMetaQuery`,
|
|
1257
|
+
* ticker bars, `getPositions()` / `getOpenOrders()` mark price
|
|
1258
|
+
* enrichment, ...) through this, so 100 components watching the
|
|
1259
|
+
* universe still trigger only one HL request per refresh cycle.
|
|
1260
|
+
*
|
|
1261
|
+
* Backed by a 1.5 s TTL + singleflight cache on the client instance,
|
|
1262
|
+
* so concurrent direct callers within the same tick collapse onto a
|
|
1263
|
+
* single in-flight request — the React Query layer above adds
|
|
1264
|
+
* another tier of dedup keyed by `staleTime`, but caching here too
|
|
1265
|
+
* keeps the contract correct for non-React callers and for
|
|
1266
|
+
* cross-method fan-outs (positions / orders / markets) that go
|
|
1267
|
+
* through `client.*` directly.
|
|
1268
|
+
*
|
|
1269
|
+
* @see {@link IPerpetualsClient.getUniverseSnapshot}
|
|
1270
|
+
*/
|
|
1271
|
+
getUniverseSnapshot(): Promise<UniverseSnapshot>;
|
|
1272
|
+
/**
|
|
1273
|
+
* Internal: actually fetch and parse a fresh universe snapshot.
|
|
1274
|
+
* Always issues one `metaAndAssetCtxs` round-trip — call
|
|
1275
|
+
* {@link getUniverseSnapshot} (which guards this with TTL +
|
|
1276
|
+
* singleflight) instead of invoking directly.
|
|
1277
|
+
*/
|
|
1278
|
+
private fetchUniverseSnapshot;
|
|
1279
|
+
/**
|
|
1280
|
+
* Snapshot the user's full venue state (`clearinghouseState` +
|
|
1281
|
+
* `frontendOpenOrders`) in a single coordinated fetch, with an
|
|
1282
|
+
* instance-level TTL + singleflight cache.
|
|
1283
|
+
*
|
|
1284
|
+
* Why this exists: `getPositions()` and `getOpenOrders()` each
|
|
1285
|
+
* naturally fan out a `clearinghouseState` and a
|
|
1286
|
+
* `frontendOpenOrders` request to enrich their respective return
|
|
1287
|
+
* shapes. When `usePositionsQuery` and `useOrdersQuery` mount in
|
|
1288
|
+
* the same render tick, that's 2× CHS + 2× FOO over the wire, all
|
|
1289
|
+
* for the same user. Routing both through this snapshot collapses
|
|
1290
|
+
* the burst into a single pair of HL calls (per
|
|
1291
|
+
* {@link USER_STATE_SNAPSHOT_TTL_MS} window). When `webData2` is
|
|
1292
|
+
* online it overwrites the React Query caches directly, so this
|
|
1293
|
+
* REST path stops firing entirely after the first WS frame.
|
|
1294
|
+
*
|
|
1295
|
+
* `clearinghouseState` is mandatory; `frontendOpenOrders` is
|
|
1296
|
+
* fault-tolerant — the venue occasionally errors on the second leg
|
|
1297
|
+
* for fresh users, and we still want positions to render.
|
|
1298
|
+
*/
|
|
1299
|
+
private getUserStateSnapshot;
|
|
1005
1300
|
/**
|
|
1006
1301
|
* Fetch kline / candlestick data.
|
|
1007
1302
|
*
|
|
@@ -1545,6 +1840,20 @@ declare class LiberFiPerpetualsClient implements IPerpetualsClient {
|
|
|
1545
1840
|
getSupportedCoins(): Promise<string[]>;
|
|
1546
1841
|
getMarket(symbol: string): Promise<MarketData | null>;
|
|
1547
1842
|
getMarkets(symbols?: string[]): Promise<MarketData[]>;
|
|
1843
|
+
/**
|
|
1844
|
+
* Snapshot the venue's full perp universe via a single `/v1/markets`
|
|
1845
|
+
* call.
|
|
1846
|
+
*
|
|
1847
|
+
* Hosts the SDK's `useUniverseQuery` global singleton — every
|
|
1848
|
+
* per-symbol consumer (ticker bars, market headers, asset meta
|
|
1849
|
+
* lookups, ...) derives from this so 100 components watching the
|
|
1850
|
+
* universe still trigger only one request per refresh cycle.
|
|
1851
|
+
*
|
|
1852
|
+
* `meta` stays `null` because the LiberFi backend does not yet
|
|
1853
|
+
* expose `szDecimals` / `maxLeverage`. Consumers that need that data
|
|
1854
|
+
* fall back to their own heuristics (the form already does this).
|
|
1855
|
+
*/
|
|
1856
|
+
getUniverseSnapshot(): Promise<UniverseSnapshot>;
|
|
1548
1857
|
getKlines(symbol: string, interval: KlineInterval, limitOrOptions?: number | KlineQueryOptions): Promise<Kline[]>;
|
|
1549
1858
|
getOrderBook(symbol: string, maxLevel?: number, options?: {
|
|
1550
1859
|
nSigFigs?: number;
|
|
@@ -1951,6 +2260,16 @@ interface UseMarketQueryParams {
|
|
|
1951
2260
|
}
|
|
1952
2261
|
declare function marketQueryKey(params: UseMarketQueryParams): string[];
|
|
1953
2262
|
declare function fetchMarket(client: IPerpetualsClient, { symbol }: UseMarketQueryParams): Promise<MarketData | null>;
|
|
2263
|
+
/**
|
|
2264
|
+
* Read the live market snapshot for `symbol`.
|
|
2265
|
+
*
|
|
2266
|
+
* When the active adapter exposes {@link IPerpetualsClient.getUniverseSnapshot}
|
|
2267
|
+
* (Hyperliquid + LiberFi today), this hook becomes a thin selector
|
|
2268
|
+
* over the global {@link useUniverseQuery} cache — every ticker /
|
|
2269
|
+
* header / order form in the page shares the same single 60s poll.
|
|
2270
|
+
* Otherwise we fall back to the legacy per-symbol REST query so older
|
|
2271
|
+
* deployments keep working unchanged.
|
|
2272
|
+
*/
|
|
1954
2273
|
declare function useMarketQuery(params: UseMarketQueryParams, options?: Omit<UseQueryOptions<MarketData | null, Error, MarketData | null, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<MarketData | null, Error>;
|
|
1955
2274
|
|
|
1956
2275
|
interface UseMarketsQueryParams {
|
|
@@ -1958,8 +2277,65 @@ interface UseMarketsQueryParams {
|
|
|
1958
2277
|
}
|
|
1959
2278
|
declare function marketsQueryKey(params?: UseMarketsQueryParams): string[];
|
|
1960
2279
|
declare function fetchMarkets(client: IPerpetualsClient, { symbols }?: UseMarketsQueryParams): Promise<MarketData[]>;
|
|
2280
|
+
/**
|
|
2281
|
+
* Read live market snapshots for one or more symbols.
|
|
2282
|
+
*
|
|
2283
|
+
* When the active adapter exposes
|
|
2284
|
+
* {@link IPerpetualsClient.getUniverseSnapshot}, this is a derived
|
|
2285
|
+
* read over the global {@link useUniverseQuery} cache — a 100-ticker
|
|
2286
|
+
* bar still triggers only one HL `metaAndAssetCtxs` request per 60s.
|
|
2287
|
+
* Otherwise we fall back to the legacy `getMarkets()` REST poll.
|
|
2288
|
+
*/
|
|
1961
2289
|
declare function useMarketsQuery(params?: UseMarketsQueryParams, options?: Omit<UseQueryOptions<MarketData[], Error, MarketData[], string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<MarketData[], Error>;
|
|
1962
2290
|
|
|
2291
|
+
/**
|
|
2292
|
+
* Stable React Query key for the global universe snapshot.
|
|
2293
|
+
*
|
|
2294
|
+
* The key is intentionally argument-free so every consumer in the
|
|
2295
|
+
* application reads from the same cache slot. Hooks like
|
|
2296
|
+
* {@link useMarketQuery}, {@link useMarketsQuery},
|
|
2297
|
+
* {@link useAssetMetaQuery} and ticker bars derive their data from
|
|
2298
|
+
* here via `select`, sharing one network round-trip per refresh cycle.
|
|
2299
|
+
*/
|
|
2300
|
+
declare function universeQueryKey(): string[];
|
|
2301
|
+
/**
|
|
2302
|
+
* Fetch the venue's universe snapshot through the active client.
|
|
2303
|
+
*
|
|
2304
|
+
* Throws when the active adapter doesn't implement
|
|
2305
|
+
* `getUniverseSnapshot` — callers should gate on
|
|
2306
|
+
* {@link supportsUniverseSnapshot} first or rely on
|
|
2307
|
+
* {@link useUniverseQuery}'s `enabled` guard, which checks the same
|
|
2308
|
+
* thing.
|
|
2309
|
+
*/
|
|
2310
|
+
declare function fetchUniverse(client: IPerpetualsClient): Promise<UniverseSnapshot>;
|
|
2311
|
+
/**
|
|
2312
|
+
* Reports whether the active client can back {@link useUniverseQuery}.
|
|
2313
|
+
*
|
|
2314
|
+
* Adapters that omit `getUniverseSnapshot` (e.g. legacy LiberFi
|
|
2315
|
+
* deployments that still proxy market data per symbol) leave
|
|
2316
|
+
* `useUniverseQuery` disabled; consumers gracefully fall back to the
|
|
2317
|
+
* legacy per-symbol queries in that case.
|
|
2318
|
+
*/
|
|
2319
|
+
declare function supportsUniverseSnapshot(client: IPerpetualsClient): boolean;
|
|
2320
|
+
/**
|
|
2321
|
+
* Subscribe to the venue's universe snapshot.
|
|
2322
|
+
*
|
|
2323
|
+
* One global singleton: every {@link useUniverseQuery} call shares the
|
|
2324
|
+
* same `["perps", "universe"]` cache slot, so React Query collapses
|
|
2325
|
+
* concurrent consumers onto a single in-flight request and a single
|
|
2326
|
+
* 60-second polling timer regardless of how many components mount.
|
|
2327
|
+
*
|
|
2328
|
+
* Per-symbol hooks (`useMarketQuery`, `useMarketsQuery`,
|
|
2329
|
+
* `useAssetMetaQuery`) read this cache via `select` so they don't
|
|
2330
|
+
* issue their own network requests — the cure for the N-ticker fan-out
|
|
2331
|
+
* pattern that triggers Hyperliquid 429s.
|
|
2332
|
+
*
|
|
2333
|
+
* The cache is also populated by `useAccountStateSubscription` when
|
|
2334
|
+
* `webData2` pushes meta / assetCtxs, so an active WebSocket session
|
|
2335
|
+
* keeps the universe fresh between polls without extra REST traffic.
|
|
2336
|
+
*/
|
|
2337
|
+
declare function useUniverseQuery(options?: Omit<UseQueryOptions<UniverseSnapshot, Error, UniverseSnapshot, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<UniverseSnapshot, Error>;
|
|
2338
|
+
|
|
1963
2339
|
interface UseKlinesQueryParams {
|
|
1964
2340
|
symbol: string;
|
|
1965
2341
|
interval: KlineInterval;
|
|
@@ -1994,14 +2370,34 @@ declare function useRecentTradesQuery(params: UseRecentTradesQueryParams, option
|
|
|
1994
2370
|
interface UsePositionsQueryParams extends GetPositionsParams {
|
|
1995
2371
|
enabled?: boolean;
|
|
1996
2372
|
}
|
|
1997
|
-
|
|
2373
|
+
/**
|
|
2374
|
+
* Canonical query key for the user's full positions snapshot. Always
|
|
2375
|
+
* keyed by `userAddress` only — per-symbol consumers derive a filtered
|
|
2376
|
+
* view via TanStack Query's `select` option so the entire app shares
|
|
2377
|
+
* one in-flight request per user, regardless of how many symbol-scoped
|
|
2378
|
+
* widgets are mounted (positions table + order form + position card +
|
|
2379
|
+
* ...).
|
|
2380
|
+
*
|
|
2381
|
+
* Backwards-compatibility: callers that previously passed a `symbol`
|
|
2382
|
+
* still get the same shape they expect (filtered positions), just
|
|
2383
|
+
* without firing an extra `clearinghouseState` / `frontendOpenOrders` /
|
|
2384
|
+
* `metaAndAssetCtxs` round-trip.
|
|
2385
|
+
*/
|
|
2386
|
+
declare function positionsQueryKey(params: Omit<UsePositionsQueryParams, "enabled" | "symbol">): string[];
|
|
1998
2387
|
declare function fetchPositions(client: IPerpetualsClient, params: GetPositionsParams): Promise<GetPositionsResult>;
|
|
1999
2388
|
declare function usePositionsQuery(params: UsePositionsQueryParams, options?: Omit<UseQueryOptions<GetPositionsResult, Error, GetPositionsResult, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<GetPositionsResult, Error>;
|
|
2000
2389
|
|
|
2001
2390
|
interface UseOrdersQueryParams extends GetOpenOrdersParams {
|
|
2002
2391
|
enabled?: boolean;
|
|
2003
2392
|
}
|
|
2004
|
-
|
|
2393
|
+
/**
|
|
2394
|
+
* Canonical query key for the user's full open-orders snapshot. Like
|
|
2395
|
+
* {@link positionsQueryKey}, the symbol is intentionally absent from
|
|
2396
|
+
* the key — per-symbol callers derive a filtered view via `select`
|
|
2397
|
+
* so the entire app shares one in-flight `frontendOpenOrders` /
|
|
2398
|
+
* `clearinghouseState` / `metaAndAssetCtxs` fan-out per user.
|
|
2399
|
+
*/
|
|
2400
|
+
declare function ordersQueryKey(params: Omit<UseOrdersQueryParams, "enabled" | "symbol">): string[];
|
|
2005
2401
|
declare function fetchOrders(client: IPerpetualsClient, params: GetOpenOrdersParams): Promise<GetOpenOrdersResult>;
|
|
2006
2402
|
declare function useOrdersQuery(params: UseOrdersQueryParams, options?: Omit<UseQueryOptions<GetOpenOrdersResult, Error, GetOpenOrdersResult, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<GetOpenOrdersResult, Error>;
|
|
2007
2403
|
|
|
@@ -2066,15 +2462,17 @@ declare function assetMetaQueryKey(params: {
|
|
|
2066
2462
|
declare function fetchAssetMeta(client: IPerpetualsClient, params: GetAssetMetaParams): Promise<AssetMeta | null>;
|
|
2067
2463
|
/**
|
|
2068
2464
|
* Read the venue's static metadata (`szDecimals`, `maxLeverage`) for
|
|
2069
|
-
* `symbol`.
|
|
2070
|
-
* active provider is Hyperliquid; the LiberFi adapter currently
|
|
2071
|
-
* returns `null` (the form falls back to an adaptive precision rule).
|
|
2465
|
+
* `symbol`.
|
|
2072
2466
|
*
|
|
2073
|
-
*
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2076
|
-
*
|
|
2077
|
-
*
|
|
2467
|
+
* When the active adapter exposes `getUniverseSnapshot` (Hyperliquid +
|
|
2468
|
+
* LiberFi today), this is a derived read over the
|
|
2469
|
+
* {@link useUniverseQuery} cache — no extra `meta` round-trip is
|
|
2470
|
+
* issued per symbol. Otherwise we fall back to the legacy
|
|
2471
|
+
* `client.getAssetMeta(...)` call.
|
|
2472
|
+
*
|
|
2473
|
+
* The data is process-stable for minutes at a time, so the fallback
|
|
2474
|
+
* uses a 60s `staleTime`; consumers don't need to invalidate this on
|
|
2475
|
+
* user actions — the data is keyed on symbol alone.
|
|
2078
2476
|
*/
|
|
2079
2477
|
declare function useAssetMetaQuery(params: UseAssetMetaQueryParams, options?: Omit<UseQueryOptions<AssetMeta | null, Error, AssetMeta | null, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<AssetMeta | null, Error>;
|
|
2080
2478
|
|
|
@@ -2232,6 +2630,50 @@ declare function accountStateQueryKey(params: Pick<UseAccountStateQueryParams, "
|
|
|
2232
2630
|
*/
|
|
2233
2631
|
declare function useAccountStateQuery(params: UseAccountStateQueryParams, options?: Omit<UseQueryOptions<AccountState | null, Error, AccountState | null, string[]>, "queryKey" | "queryFn">): _tanstack_react_query.UseQueryResult<AccountState | null, Error>;
|
|
2234
2632
|
|
|
2633
|
+
interface UseHyperliquidUserBootstrapParams {
|
|
2634
|
+
/**
|
|
2635
|
+
* Wallet address whose positions / open orders should be seeded.
|
|
2636
|
+
* The hook is a no-op when undefined or empty so it's safe to mount
|
|
2637
|
+
* before authentication completes.
|
|
2638
|
+
*/
|
|
2639
|
+
userAddress?: string;
|
|
2640
|
+
/**
|
|
2641
|
+
* Disable the bootstrap entirely (useful for SSR). Defaults to true.
|
|
2642
|
+
*/
|
|
2643
|
+
enabled?: boolean;
|
|
2644
|
+
/**
|
|
2645
|
+
* Grace period before falling back to REST. webData2's initial
|
|
2646
|
+
* snapshot typically lands within ~500ms; we wait a little longer
|
|
2647
|
+
* to cover slow WS handshakes / network blips before paying for a
|
|
2648
|
+
* REST round-trip. Defaults to 3 000 ms.
|
|
2649
|
+
*/
|
|
2650
|
+
timeoutMs?: number;
|
|
2651
|
+
}
|
|
2652
|
+
/**
|
|
2653
|
+
* One-shot REST bootstrap for the user's perpetuals state.
|
|
2654
|
+
*
|
|
2655
|
+
* Mirrors axiom.trade's first-connect behaviour: when the page
|
|
2656
|
+
* mounts, the WS singleton (`useAccountStateSubscription`) is the
|
|
2657
|
+
* primary channel for positions / orders / spot balances, and any
|
|
2658
|
+
* subsequent updates are pushed via `webData2`. The first frame
|
|
2659
|
+
* usually arrives before any UI gating matters, but on slow WS
|
|
2660
|
+
* handshakes the place-order form can blink a "loading" state for
|
|
2661
|
+
* seconds.
|
|
2662
|
+
*
|
|
2663
|
+
* This hook covers that gap: after `timeoutMs` of inactivity it
|
|
2664
|
+
* issues exactly **one** REST round-trip (positions + open orders) to
|
|
2665
|
+
* seed the React Query cache, then stops. If `webData2`'s initial
|
|
2666
|
+
* snapshot has already populated the cache by the time the timer
|
|
2667
|
+
* fires, the fallback is skipped — keeping HL `/info` traffic at a
|
|
2668
|
+
* minimum even on cold pages.
|
|
2669
|
+
*
|
|
2670
|
+
* Mount this hook **once** at the same level as
|
|
2671
|
+
* `useAccountStateSubscription` (typically the perpetuals shell /
|
|
2672
|
+
* layout). Children read positions / orders through the existing
|
|
2673
|
+
* query hooks; nothing else needs to know the bootstrap exists.
|
|
2674
|
+
*/
|
|
2675
|
+
declare function useHyperliquidUserBootstrap(params: UseHyperliquidUserBootstrapParams): void;
|
|
2676
|
+
|
|
2235
2677
|
/**
|
|
2236
2678
|
* Hook to access the deposit client from `PerpetualsProvider`.
|
|
2237
2679
|
*
|
|
@@ -2841,6 +3283,8 @@ type UsePlaceOrderFormScriptResult = {
|
|
|
2841
3283
|
handleSubmit: (data: PlaceOrderFormData) => Promise<void>;
|
|
2842
3284
|
isSubmitting: boolean;
|
|
2843
3285
|
currentPrice?: number;
|
|
3286
|
+
/** Raw venue mark price, unaffected by user's limit price input. */
|
|
3287
|
+
marketPrice: number;
|
|
2844
3288
|
estimatedFee: number;
|
|
2845
3289
|
estimatedTotal: number;
|
|
2846
3290
|
liquidationPrice?: number;
|
|
@@ -2915,6 +3359,8 @@ type PlaceOrderFormUIProps = {
|
|
|
2915
3359
|
isSubmitting: boolean;
|
|
2916
3360
|
symbol: string;
|
|
2917
3361
|
currentPrice?: number;
|
|
3362
|
+
/** Raw venue mark price for display reference (unaffected by limit price input). */
|
|
3363
|
+
marketPrice?: number;
|
|
2918
3364
|
estimatedFee: number;
|
|
2919
3365
|
estimatedTotal: number;
|
|
2920
3366
|
liquidationPrice?: number;
|
|
@@ -2976,24 +3422,74 @@ type PlaceOrderFormUIProps = {
|
|
|
2976
3422
|
*/
|
|
2977
3423
|
onUpdateLeverage?: (leverage: number) => Promise<void>;
|
|
2978
3424
|
};
|
|
2979
|
-
declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, isLeverageReady, hasOpenOrdersForSymbol, szDecimals, onAddFunds, onUpdateLeverage, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
|
|
3425
|
+
declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, marketPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, isLeverageReady, hasOpenOrdersForSymbol, szDecimals, onAddFunds, onUpdateLeverage, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
|
|
3426
|
+
|
|
3427
|
+
type CloseType = "market" | "limit";
|
|
3428
|
+
type UseClosePositionParams = {
|
|
3429
|
+
userAddress?: string;
|
|
3430
|
+
onCloseSuccess?: () => void;
|
|
3431
|
+
onCloseError?: (error: Error) => void;
|
|
3432
|
+
/**
|
|
3433
|
+
* Optional callback that bypasses the SDK's internal mutation and lets
|
|
3434
|
+
* the host sign + relay the close order itself (same pattern as the
|
|
3435
|
+
* place-order form's `onPlaceOrder`).
|
|
3436
|
+
*/
|
|
3437
|
+
onPlaceOrder?: (params: {
|
|
3438
|
+
symbol: string;
|
|
3439
|
+
side: "long" | "short";
|
|
3440
|
+
orderType: OrderType;
|
|
3441
|
+
amount: number;
|
|
3442
|
+
price?: number;
|
|
3443
|
+
leverage: number;
|
|
3444
|
+
reduceOnly: boolean;
|
|
3445
|
+
userAddress: string;
|
|
3446
|
+
}) => Promise<PlaceOrderResult>;
|
|
3447
|
+
};
|
|
3448
|
+
type UseClosePositionResult = {
|
|
3449
|
+
isModalOpen: boolean;
|
|
3450
|
+
selectedPosition: Position | null;
|
|
3451
|
+
closeType: CloseType;
|
|
3452
|
+
isClosing: boolean;
|
|
3453
|
+
openMarketClose: (position: Position) => void;
|
|
3454
|
+
openLimitClose: (position: Position) => void;
|
|
3455
|
+
handleConfirm: (size: number, price?: number) => Promise<void>;
|
|
3456
|
+
closeModal: () => void;
|
|
3457
|
+
};
|
|
3458
|
+
/**
|
|
3459
|
+
* Hook that owns the close-position modal lifecycle:
|
|
3460
|
+
* - Which position is selected and which close type (market / limit)
|
|
3461
|
+
* - Submitting the close order via `useCreateOrderMutation`
|
|
3462
|
+
*
|
|
3463
|
+
* The UI layer (modal component) owns the size / percentage / price
|
|
3464
|
+
* input state — this hook only cares about the final confirmed values.
|
|
3465
|
+
*/
|
|
3466
|
+
declare function useClosePosition({ userAddress, onCloseSuccess, onCloseError, onPlaceOrder, }: UseClosePositionParams): UseClosePositionResult;
|
|
2980
3467
|
|
|
2981
3468
|
type PositionsWidgetProps = {
|
|
2982
3469
|
userAddress?: string;
|
|
2983
3470
|
symbol?: string;
|
|
2984
3471
|
onCloseSuccess?: () => void;
|
|
2985
3472
|
onCloseError?: (error: Error) => void;
|
|
3473
|
+
onPlaceOrder?: UseClosePositionParams["onPlaceOrder"];
|
|
2986
3474
|
className?: string;
|
|
2987
3475
|
};
|
|
2988
3476
|
/**
|
|
2989
3477
|
* Positions table widget. Owns no business logic — wires the
|
|
2990
|
-
* `usePositionsScript` data layer (sort + close-
|
|
2991
|
-
* presentational `PositionsUI`. The host
|
|
2992
|
-
* connected wallet address and (optionally) a
|
|
2993
|
-
* widget handles everything else
|
|
2994
|
-
* close-position toasts in the consumer's mutation lifecycle).
|
|
3478
|
+
* `usePositionsScript` data layer (sort + close-modal) to the
|
|
3479
|
+
* presentational `PositionsUI` and the `ClosePositionModal`. The host
|
|
3480
|
+
* page just provides the connected wallet address and (optionally) a
|
|
3481
|
+
* symbol filter; the widget handles everything else.
|
|
2995
3482
|
*/
|
|
2996
|
-
declare function PositionsWidget({ userAddress, symbol, onCloseSuccess, onCloseError, className, }: PositionsWidgetProps): react_jsx_runtime.JSX.Element;
|
|
3483
|
+
declare function PositionsWidget({ userAddress, symbol, onCloseSuccess, onCloseError, onPlaceOrder, className, }: PositionsWidgetProps): react_jsx_runtime.JSX.Element;
|
|
3484
|
+
|
|
3485
|
+
/**
|
|
3486
|
+
* Two-state sort direction. We deliberately do not model a "no sort"
|
|
3487
|
+
* state: when a user clicks a fresh column the table starts at `asc`
|
|
3488
|
+
* (or `desc` if that's the column's natural default) and toggles
|
|
3489
|
+
* between `asc` ↔ `desc` thereafter — mirroring Axiom's UX so users
|
|
3490
|
+
* never have to click three times to clear an accidental sort.
|
|
3491
|
+
*/
|
|
3492
|
+
type SortDirection = "asc" | "desc";
|
|
2997
3493
|
|
|
2998
3494
|
/**
|
|
2999
3495
|
* Stable identifier for a sortable column. Mirrors Axiom's set: 7 of the
|
|
@@ -3005,7 +3501,7 @@ declare function PositionsWidget({ userAddress, symbol, onCloseSuccess, onCloseE
|
|
|
3005
3501
|
* insulated from enum-numbering churn.
|
|
3006
3502
|
*/
|
|
3007
3503
|
type PositionSortKey = "asset" | "position" | "value" | "entry" | "mark" | "liq" | "marginPnl";
|
|
3008
|
-
|
|
3504
|
+
|
|
3009
3505
|
type PositionsUIProps = {
|
|
3010
3506
|
/** Already-sorted positions. The script layer owns sort state. */
|
|
3011
3507
|
positions: Position[];
|
|
@@ -3013,12 +3509,13 @@ type PositionsUIProps = {
|
|
|
3013
3509
|
sortKey: PositionSortKey | null;
|
|
3014
3510
|
sortDir: SortDirection;
|
|
3015
3511
|
onSort: (key: PositionSortKey) => void;
|
|
3016
|
-
|
|
3512
|
+
onMarketClose: (position: Position) => void;
|
|
3513
|
+
onLimitClose: (position: Position) => void;
|
|
3017
3514
|
isClosing: boolean;
|
|
3018
3515
|
/** Optional className for the outer container. */
|
|
3019
3516
|
className?: string;
|
|
3020
3517
|
};
|
|
3021
|
-
declare function PositionsUI({ positions, sortKey, sortDir, onSort,
|
|
3518
|
+
declare function PositionsUI({ positions, sortKey, sortDir, onSort, onMarketClose, onLimitClose, isClosing, className, }: PositionsUIProps): react_jsx_runtime.JSX.Element;
|
|
3022
3519
|
/** Loading skeleton for positions panel */
|
|
3023
3520
|
declare function PositionsSkeleton(): react_jsx_runtime.JSX.Element;
|
|
3024
3521
|
/**
|
|
@@ -3033,6 +3530,7 @@ type UsePositionsScriptParams = {
|
|
|
3033
3530
|
symbol?: string;
|
|
3034
3531
|
onCloseSuccess?: () => void;
|
|
3035
3532
|
onCloseError?: (error: Error) => void;
|
|
3533
|
+
onPlaceOrder?: UseClosePositionParams["onPlaceOrder"];
|
|
3036
3534
|
};
|
|
3037
3535
|
type UsePositionsScriptResult = {
|
|
3038
3536
|
/** Positions already sorted by the active `sortKey` / `sortDir`. */
|
|
@@ -3046,8 +3544,8 @@ type UsePositionsScriptResult = {
|
|
|
3046
3544
|
* first click on a new column → asc, subsequent clicks toggle asc ↔
|
|
3047
3545
|
* desc. There is no "no-sort" state. */
|
|
3048
3546
|
onSort: (key: PositionSortKey) => void;
|
|
3049
|
-
|
|
3050
|
-
|
|
3547
|
+
/** Close-position modal lifecycle (market + limit). */
|
|
3548
|
+
closePosition: UseClosePositionResult;
|
|
3051
3549
|
};
|
|
3052
3550
|
/**
|
|
3053
3551
|
* Container hook for the positions table. Responsibilities:
|
|
@@ -3059,85 +3557,343 @@ type UsePositionsScriptResult = {
|
|
|
3059
3557
|
* - own sort state (default `marginPnl ↓` — biggest margin first).
|
|
3060
3558
|
* - expose a `handleClosePosition` shim over `useCreateOrderMutation`.
|
|
3061
3559
|
*/
|
|
3062
|
-
declare function usePositionsScript({ userAddress, symbol, onCloseSuccess, onCloseError, }: UsePositionsScriptParams): UsePositionsScriptResult;
|
|
3560
|
+
declare function usePositionsScript({ userAddress, symbol, onCloseSuccess, onCloseError, onPlaceOrder, }: UsePositionsScriptParams): UsePositionsScriptResult;
|
|
3063
3561
|
|
|
3064
|
-
type
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3562
|
+
type ClosePositionModalProps = {
|
|
3563
|
+
isOpen: boolean;
|
|
3564
|
+
position: Position | null;
|
|
3565
|
+
closeType: CloseType;
|
|
3566
|
+
isSubmitting: boolean;
|
|
3567
|
+
onClose: () => void;
|
|
3568
|
+
onConfirm: (size: number, price?: number) => Promise<void>;
|
|
3070
3569
|
};
|
|
3071
|
-
declare function
|
|
3570
|
+
declare function ClosePositionModal({ isOpen, position, closeType, isSubmitting, onClose, onConfirm, }: ClosePositionModalProps): react_jsx_runtime.JSX.Element;
|
|
3571
|
+
|
|
3572
|
+
/**
|
|
3573
|
+
* Stable identifier for a sortable column. 9 of the 12 columns are
|
|
3574
|
+
* sortable; `triggerCondition`, `tpsl`, `cancel` are interaction-only.
|
|
3575
|
+
*
|
|
3576
|
+
* Kept as a discriminated string union (rather than an enum) so it
|
|
3577
|
+
* survives a tsup build to a stable runtime string — consumers that
|
|
3578
|
+
* persist the active sort key to local-storage / URL params are
|
|
3579
|
+
* insulated from enum-numbering churn.
|
|
3580
|
+
*/
|
|
3581
|
+
type OpenOrderSortKey = "time" | "size" | "asset" | "direction" | "type" | "leverage" | "orderValue" | "executePrice" | "currentPrice";
|
|
3072
3582
|
|
|
3073
3583
|
type OpenOrdersUIProps = {
|
|
3584
|
+
/** Already-sorted orders. The script layer owns sort state. */
|
|
3074
3585
|
orders: Order[];
|
|
3586
|
+
/** Currently active sort column, or `null` when no sort applied. */
|
|
3587
|
+
sortKey: OpenOrderSortKey | null;
|
|
3588
|
+
sortDir: SortDirection;
|
|
3589
|
+
onSort: (key: OpenOrderSortKey) => void;
|
|
3075
3590
|
onCancelOrder: (order: Order) => void;
|
|
3076
|
-
|
|
3591
|
+
onCancelAll: () => void;
|
|
3592
|
+
/**
|
|
3593
|
+
* Set of order ids currently being cancelled via the per-row path.
|
|
3594
|
+
* The row whose id is present in the set renders an inline spinner
|
|
3595
|
+
* in place of its `x` icon; sibling rows stay clickable so the
|
|
3596
|
+
* user can cancel several orders concurrently.
|
|
3597
|
+
*/
|
|
3598
|
+
cancelingOrderIds: ReadonlySet<string>;
|
|
3599
|
+
/**
|
|
3600
|
+
* `true` while a `Cancel All` batch is in flight. Drives the
|
|
3601
|
+
* header button's spinner and gates *every* row's cancel button
|
|
3602
|
+
* (mid-batch, individual rows shouldn't accept new clicks).
|
|
3603
|
+
*/
|
|
3604
|
+
isCancelingAll: boolean;
|
|
3605
|
+
/** Optional className for the outer container. */
|
|
3606
|
+
className?: string;
|
|
3077
3607
|
};
|
|
3078
|
-
declare function OpenOrdersUI({ orders, onCancelOrder,
|
|
3608
|
+
declare function OpenOrdersUI({ orders, sortKey, sortDir, onSort, onCancelOrder, onCancelAll, cancelingOrderIds, isCancelingAll, className, }: OpenOrdersUIProps): react_jsx_runtime.JSX.Element;
|
|
3609
|
+
/** Loading skeleton for open orders panel */
|
|
3079
3610
|
declare function OpenOrdersSkeleton(): react_jsx_runtime.JSX.Element;
|
|
3611
|
+
/**
|
|
3612
|
+
* Standalone empty-state component. The main `OpenOrdersUI` renders
|
|
3613
|
+
* its own empty layout (header + centred message) so this export
|
|
3614
|
+
* exists for consumers that wire their own empty state outside the
|
|
3615
|
+
* widget.
|
|
3616
|
+
*/
|
|
3080
3617
|
declare function OpenOrdersEmpty(): react_jsx_runtime.JSX.Element;
|
|
3081
3618
|
|
|
3619
|
+
/**
|
|
3620
|
+
* Caller-provided cancel implementation for a single order. Mirrors
|
|
3621
|
+
* the `onPlaceOrder` IoC point on the place-order form: when supplied,
|
|
3622
|
+
* the script / widget delegates the actual signing + submit to the
|
|
3623
|
+
* host instead of routing through the active
|
|
3624
|
+
* `IPerpetualsClient.cancelOrder`.
|
|
3625
|
+
*
|
|
3626
|
+
* Hosts that talk directly to a venue from the browser (e.g. signing
|
|
3627
|
+
* Hyperliquid `cancel` actions with the user's wallet) inject this
|
|
3628
|
+
* to bypass the SDK's read-only `HyperliquidPerpetualsClient.cancelOrder`
|
|
3629
|
+
* stub. Hosts that proxy through perpetuals-server (LiberFi TEE) leave
|
|
3630
|
+
* it undefined and let the default path run.
|
|
3631
|
+
*/
|
|
3632
|
+
type CancelOrderImpl = (params: CancelOrderParams) => Promise<CancelOrderResult>;
|
|
3633
|
+
/**
|
|
3634
|
+
* Optional batch counterpart to {@link CancelOrderImpl}. When supplied,
|
|
3635
|
+
* `handleCancelAll` invokes this once with every leg, so direct-venue
|
|
3636
|
+
* hosts (Hyperliquid, Lighter, etc.) can issue a single signature
|
|
3637
|
+
* covering all cancels rather than prompting the user N times.
|
|
3638
|
+
*
|
|
3639
|
+
* When omitted, the script falls back to
|
|
3640
|
+
* `Promise.allSettled(orders.map(cancelOrder))` — correct behaviour
|
|
3641
|
+
* for backends like perpetuals-server that own the signature flow
|
|
3642
|
+
* (each leg is a no-op API call), but a UX trap when the host signs
|
|
3643
|
+
* locally because every leg will trigger a fresh wallet prompt.
|
|
3644
|
+
*/
|
|
3645
|
+
type CancelOrdersImpl = (params: CancelOrderParams[]) => Promise<CancelOrderResult[]>;
|
|
3082
3646
|
type UseOpenOrdersScriptParams = {
|
|
3083
3647
|
userAddress?: string;
|
|
3084
3648
|
symbol?: string;
|
|
3085
3649
|
onCancelSuccess?: () => void;
|
|
3086
3650
|
onCancelError?: (error: Error) => void;
|
|
3651
|
+
/**
|
|
3652
|
+
* Optional host-provided single-order cancel implementation. When
|
|
3653
|
+
* omitted, the script falls back to {@link useCancelOrderMutation}
|
|
3654
|
+
* which routes through the active client — appropriate for backends
|
|
3655
|
+
* that own the signature flow (e.g. LiberFi perpetuals-server). For
|
|
3656
|
+
* direct-venue setups (consumer holds the wallet keys), pass an
|
|
3657
|
+
* implementation that signs + relays the cancel itself.
|
|
3658
|
+
*/
|
|
3659
|
+
cancelOrder?: CancelOrderImpl;
|
|
3660
|
+
/**
|
|
3661
|
+
* Optional host-provided batch cancel implementation. When supplied
|
|
3662
|
+
* it is used by `handleCancelAll` (and by single cancels too —
|
|
3663
|
+
* the script wraps the param into a 1-element array so the host
|
|
3664
|
+
* can keep one entry point). When omitted, batch cancels fan out to
|
|
3665
|
+
* the per-order path with `Promise.allSettled`.
|
|
3666
|
+
*/
|
|
3667
|
+
cancelOrders?: CancelOrdersImpl;
|
|
3087
3668
|
};
|
|
3088
3669
|
type UseOpenOrdersScriptResult = {
|
|
3670
|
+
/** Orders already sorted by the active `sortKey` / `sortDir`. */
|
|
3089
3671
|
orders: Order[];
|
|
3090
3672
|
isLoading: boolean;
|
|
3091
3673
|
error: Error | null;
|
|
3674
|
+
/** Active sort column. Default: `time` desc — newest first, like Axiom. */
|
|
3675
|
+
sortKey: OpenOrderSortKey | null;
|
|
3676
|
+
sortDir: SortDirection;
|
|
3677
|
+
/**
|
|
3678
|
+
* Toggle the sort column / direction. Mirrors Axiom's 2-state cycle:
|
|
3679
|
+
* first click on a new column → asc, subsequent clicks toggle asc ↔
|
|
3680
|
+
* desc. There is no "no-sort" state.
|
|
3681
|
+
*/
|
|
3682
|
+
onSort: (key: OpenOrderSortKey) => void;
|
|
3683
|
+
/** Cancel a single order by id. */
|
|
3092
3684
|
handleCancelOrder: (order: Order) => Promise<void>;
|
|
3685
|
+
/**
|
|
3686
|
+
* Cancel every currently-loaded order. Resolves once every leg has
|
|
3687
|
+
* finished (success **or** failure — leg failures are reported via
|
|
3688
|
+
* `onCancelError` per-leg, but do not abort the batch). The widget's
|
|
3689
|
+
* confirmation dialog calls this only after the user explicitly
|
|
3690
|
+
* confirms — the script does not gate on a dialog itself.
|
|
3691
|
+
*/
|
|
3692
|
+
handleCancelAll: () => Promise<void>;
|
|
3693
|
+
/**
|
|
3694
|
+
* `true` while *any* cancel mutation (single OR batch) is in flight.
|
|
3695
|
+
* Kept for backwards-compatibility with hosts that only need the
|
|
3696
|
+
* coarse-grained "is anything cancelling?" signal. New UI surfaces
|
|
3697
|
+
* (per-row spinners, header `Cancel All` spinner) should prefer
|
|
3698
|
+
* the more specific signals below — this flag is intentionally
|
|
3699
|
+
* **not** the recommended way to drive a row's spinner because it
|
|
3700
|
+
* would light up every row whenever any row is cancelling.
|
|
3701
|
+
*/
|
|
3093
3702
|
isCanceling: boolean;
|
|
3703
|
+
/**
|
|
3704
|
+
* Set of order ids currently being cancelled via the per-row path.
|
|
3705
|
+
* The UI uses this to render an inline spinner on the exact row(s)
|
|
3706
|
+
* the user clicked while leaving sibling rows untouched — clicks
|
|
3707
|
+
* on different rows can run concurrently, so a single boolean
|
|
3708
|
+
* would conflate them.
|
|
3709
|
+
*
|
|
3710
|
+
* Returned as a `ReadonlySet` so consumers can't accidentally
|
|
3711
|
+
* mutate the script's internal state. `Set` (not `Array`) keeps
|
|
3712
|
+
* `has(orderId)` O(1) for the row-render hot path.
|
|
3713
|
+
*/
|
|
3714
|
+
cancelingOrderIds: ReadonlySet<string>;
|
|
3715
|
+
/**
|
|
3716
|
+
* `true` while a `Cancel All` batch is in flight (regardless of
|
|
3717
|
+
* whether the host injected a batch impl or we fanned out to
|
|
3718
|
+
* per-leg cancels). The UI uses this to swap the header's
|
|
3719
|
+
* `Cancel All` text for a spinner so the user gets feedback the
|
|
3720
|
+
* click was registered. Distinct from `cancelingOrderIds` so the
|
|
3721
|
+
* header spinner doesn't fire when only a single per-row cancel
|
|
3722
|
+
* is running, and vice versa.
|
|
3723
|
+
*/
|
|
3724
|
+
isCancelingAll: boolean;
|
|
3094
3725
|
};
|
|
3095
|
-
|
|
3726
|
+
/**
|
|
3727
|
+
* Container hook for the Open Orders table.
|
|
3728
|
+
*
|
|
3729
|
+
* Responsibilities:
|
|
3730
|
+
* - Read open orders via {@link useOrdersQuery}. The consumer's
|
|
3731
|
+
* `useAccountStateSubscription` keeps the cache live via the
|
|
3732
|
+
* `webData2` write-through path, which already enriches each
|
|
3733
|
+
* order with leverage / mark-price / bundled TP/SL — so we
|
|
3734
|
+
* deliberately do **not** subscribe to a per-order user-data
|
|
3735
|
+
* stream here. Doing so would clobber that enrichment.
|
|
3736
|
+
* - Own sort state (default `time ↓` — newest order first).
|
|
3737
|
+
* - Expose `handleCancelOrder` (single) and `handleCancelAll`
|
|
3738
|
+
* (batch) shims over `useCancelOrderMutation`.
|
|
3739
|
+
*
|
|
3740
|
+
* Cancel-all does not present a confirmation prompt itself — that
|
|
3741
|
+
* responsibility lives in the widget, which renders the dialog and
|
|
3742
|
+
* only calls `handleCancelAll()` after the user confirms. Keeping the
|
|
3743
|
+
* confirmation in the widget makes the script trivially testable
|
|
3744
|
+
* (deterministic mutation calls) and lets headless consumers skip the
|
|
3745
|
+
* dialog entirely.
|
|
3746
|
+
*/
|
|
3747
|
+
declare function useOpenOrdersScript({ userAddress, symbol, onCancelSuccess, onCancelError, cancelOrder: cancelOrderImpl, cancelOrders: cancelOrdersImpl, }: UseOpenOrdersScriptParams): UseOpenOrdersScriptResult;
|
|
3096
3748
|
|
|
3097
|
-
type
|
|
3098
|
-
type UseTradeHistoryScriptParams = {
|
|
3749
|
+
type OpenOrdersWidgetProps = {
|
|
3099
3750
|
userAddress?: string;
|
|
3100
3751
|
symbol?: string;
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3752
|
+
onCancelSuccess?: () => void;
|
|
3753
|
+
onCancelError?: (error: Error) => void;
|
|
3754
|
+
/**
|
|
3755
|
+
* Optional host-provided single-order cancel implementation — see
|
|
3756
|
+
* {@link CancelOrderImpl}. Forwarded verbatim to
|
|
3757
|
+
* {@link useOpenOrdersScript}. Hosts that own the wallet keys
|
|
3758
|
+
* (direct-venue setups) inject this; hosts that proxy via a
|
|
3759
|
+
* server with TEE signing leave it undefined.
|
|
3760
|
+
*/
|
|
3761
|
+
cancelOrder?: CancelOrderImpl;
|
|
3762
|
+
/**
|
|
3763
|
+
* Optional host-provided batch cancel implementation — see
|
|
3764
|
+
* {@link CancelOrdersImpl}. When supplied, `Cancel All` issues a
|
|
3765
|
+
* single signature for every open order at once (the recommended
|
|
3766
|
+
* UX for direct-venue setups; perpetuals-server proxies don't need
|
|
3767
|
+
* it because each leg is a no-op API call from the user's
|
|
3768
|
+
* perspective).
|
|
3769
|
+
*/
|
|
3770
|
+
cancelOrders?: CancelOrdersImpl;
|
|
3771
|
+
className?: string;
|
|
3115
3772
|
};
|
|
3116
|
-
|
|
3773
|
+
/**
|
|
3774
|
+
* Convenience widget that wires {@link useOpenOrdersScript} (data + sort
|
|
3775
|
+
* + cancel mutations) to {@link OpenOrdersUI} (presentation), and adds
|
|
3776
|
+
* a confirmation dialog for the destructive `Cancel All` action.
|
|
3777
|
+
*
|
|
3778
|
+
* The dialog state lives here (not in the script) so:
|
|
3779
|
+
* - The script stays trivially testable — its `handleCancelAll` is a
|
|
3780
|
+
* deterministic mutation call without any UI side effects.
|
|
3781
|
+
* - Headless / programmatic callers that import the script directly
|
|
3782
|
+
* can skip the dialog entirely (e.g. CI tooling, batch scripts).
|
|
3783
|
+
*
|
|
3784
|
+
* Single-order cancels go through directly: clicking the per-row `x`
|
|
3785
|
+
* button is already an explicit, low-impact gesture, and adding a
|
|
3786
|
+
* second prompt for every row would feel obstructive — matches Axiom.
|
|
3787
|
+
*
|
|
3788
|
+
* The confirm dialog matches the visual language of the place-order
|
|
3789
|
+
* `LeverageModal` and `DepositHyperliquidUsdcModal` (zinc-900 surface,
|
|
3790
|
+
* 14px corner radius, soft shadow, custom 5-px-padded header with an
|
|
3791
|
+
* X close button) so all destructive / confirm modals in the
|
|
3792
|
+
* perpetuals UI feel like one family.
|
|
3793
|
+
*/
|
|
3794
|
+
declare function OpenOrdersWidget({ userAddress, symbol, onCancelSuccess, onCancelError, cancelOrder, cancelOrders, className, }: OpenOrdersWidgetProps): react_jsx_runtime.JSX.Element;
|
|
3117
3795
|
|
|
3118
3796
|
type TradeHistoryWidgetProps = {
|
|
3797
|
+
/** User wallet address. The widget gates the underlying query on this. */
|
|
3119
3798
|
userAddress?: string;
|
|
3799
|
+
/**
|
|
3800
|
+
* Optional venue-side filter. Omit to show fills from every coin —
|
|
3801
|
+
* Axiom's bottom-Trades panel is all-coin, and the consumer-facing
|
|
3802
|
+
* widgets (Positions / Open Orders / Trades) follow the same
|
|
3803
|
+
* convention so the three tabs share a coherent UX.
|
|
3804
|
+
*/
|
|
3120
3805
|
symbol?: string;
|
|
3121
|
-
|
|
3122
|
-
pageSize?: number;
|
|
3806
|
+
/** Optional className on the outermost container. */
|
|
3123
3807
|
className?: string;
|
|
3124
3808
|
};
|
|
3125
|
-
|
|
3809
|
+
/**
|
|
3810
|
+
* Convenience widget that wires {@link useTradeHistoryScript} (data +
|
|
3811
|
+
* sort) to {@link TradeHistoryUI} (presentation). Intentionally thin —
|
|
3812
|
+
* unlike Open Orders there's no destructive action to gate behind a
|
|
3813
|
+
* confirmation dialog, so the widget is just a pass-through.
|
|
3814
|
+
*
|
|
3815
|
+
* Headless callers (CI, programmatic exports) can import the script
|
|
3816
|
+
* directly without the UI; the script's return shape is the public
|
|
3817
|
+
* contract.
|
|
3818
|
+
*/
|
|
3819
|
+
declare function TradeHistoryWidget({ userAddress, symbol, className, }: TradeHistoryWidgetProps): react_jsx_runtime.JSX.Element;
|
|
3820
|
+
|
|
3821
|
+
/**
|
|
3822
|
+
* Stable identifier for a sortable column. All 7 visible columns are
|
|
3823
|
+
* sortable; mirrors Axiom's bottom-Trades panel 1:1. Using a discriminated
|
|
3824
|
+
* string union (rather than an enum) so the value survives a tsup build
|
|
3825
|
+
* to a stable runtime string — consumers persisting the active sort to
|
|
3826
|
+
* local-storage / URL params don't pay an enum-numbering tax.
|
|
3827
|
+
*/
|
|
3828
|
+
type TradeHistorySortKey = "time" | "size" | "asset" | "description" | "price" | "tradeValue" | "closedPnl";
|
|
3126
3829
|
|
|
3127
3830
|
type TradeHistoryUIProps = {
|
|
3831
|
+
/** Already-sorted trades. The script layer owns sort state. */
|
|
3128
3832
|
trades: TradeHistory[];
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3833
|
+
/** Currently active sort column. Always non-null — Axiom never exits
|
|
3834
|
+
* the sort state, defaulting to `Time ↓`. */
|
|
3835
|
+
sortKey: TradeHistorySortKey;
|
|
3836
|
+
sortDir: SortDirection;
|
|
3837
|
+
onSort: (key: TradeHistorySortKey) => void;
|
|
3838
|
+
/** Optional className on the outermost container. */
|
|
3839
|
+
className?: string;
|
|
3136
3840
|
};
|
|
3137
|
-
declare function TradeHistoryUI({ trades,
|
|
3841
|
+
declare function TradeHistoryUI({ trades, sortKey, sortDir, onSort, className, }: TradeHistoryUIProps): react_jsx_runtime.JSX.Element;
|
|
3842
|
+
/** Loading skeleton for the trade-history panel. */
|
|
3138
3843
|
declare function TradeHistorySkeleton(): react_jsx_runtime.JSX.Element;
|
|
3844
|
+
/**
|
|
3845
|
+
* Standalone empty-state component. The main `TradeHistoryUI` renders
|
|
3846
|
+
* its own empty layout (header + centred message) so this export
|
|
3847
|
+
* exists for consumers wiring their own empty state outside the widget.
|
|
3848
|
+
*/
|
|
3139
3849
|
declare function TradeHistoryEmpty(): react_jsx_runtime.JSX.Element;
|
|
3140
3850
|
|
|
3851
|
+
type UseTradeHistoryScriptParams = {
|
|
3852
|
+
userAddress?: string;
|
|
3853
|
+
/**
|
|
3854
|
+
* Optional venue-side filter. Omit (the default consumed by
|
|
3855
|
+
* `TradeHistoryWidget`) to surface fills from every coin — Axiom's
|
|
3856
|
+
* bottom Trades tab is all-coin, and our Positions / Open Orders
|
|
3857
|
+
* widgets follow the same convention.
|
|
3858
|
+
*/
|
|
3859
|
+
symbol?: string;
|
|
3860
|
+
};
|
|
3861
|
+
type UseTradeHistoryScriptResult = {
|
|
3862
|
+
/** Trades already sorted by the active `sortKey` / `sortDir`. */
|
|
3863
|
+
trades: TradeHistory[];
|
|
3864
|
+
isLoading: boolean;
|
|
3865
|
+
error: Error | null;
|
|
3866
|
+
/**
|
|
3867
|
+
* Active sort column. Defaults to `time` — Axiom never exits the sort
|
|
3868
|
+
* state, so we model this as a non-nullable union (the UI assumes
|
|
3869
|
+
* a column is always active).
|
|
3870
|
+
*/
|
|
3871
|
+
sortKey: TradeHistorySortKey;
|
|
3872
|
+
sortDir: SortDirection;
|
|
3873
|
+
/**
|
|
3874
|
+
* Toggle the sort column / direction. Mirrors Axiom's 2-state cycle:
|
|
3875
|
+
* clicking the active column flips `asc` ↔ `desc`; clicking a fresh
|
|
3876
|
+
* column starts at `desc` (newest / largest first — the natural
|
|
3877
|
+
* default for time, money, and PnL columns alike).
|
|
3878
|
+
*/
|
|
3879
|
+
onSort: (key: TradeHistorySortKey) => void;
|
|
3880
|
+
};
|
|
3881
|
+
/**
|
|
3882
|
+
* Container hook for the Trade History (user fills) table.
|
|
3883
|
+
*
|
|
3884
|
+
* Responsibilities:
|
|
3885
|
+
* - Read fills via {@link useTradesQuery}. Hyperliquid's `webData2`
|
|
3886
|
+
* stream does **not** carry fill events (only state snapshots), so
|
|
3887
|
+
* we can't piggy-back on the same WS write-through path used by
|
|
3888
|
+
* Positions / Open Orders. Instead the query uses a tighter
|
|
3889
|
+
* `staleTime` so refocusing the tab triggers a near-instant
|
|
3890
|
+
* refresh — close enough to real-time for a fills view that the
|
|
3891
|
+
* user only consults episodically.
|
|
3892
|
+
* - Own sort state (default `time ↓` — newest fill first, Axiom-
|
|
3893
|
+
* style).
|
|
3894
|
+
*/
|
|
3895
|
+
declare function useTradeHistoryScript({ userAddress, symbol, }: UseTradeHistoryScriptParams): UseTradeHistoryScriptResult;
|
|
3896
|
+
|
|
3141
3897
|
/**
|
|
3142
3898
|
* Highest-level deposit widget. Wires the three presentational
|
|
3143
3899
|
* components (form / confirm / status) to the deposit hooks +
|
|
@@ -3374,4 +4130,4 @@ interface HyperliquidInitWidgetProps extends Pick<UseHyperliquidSetupOptions, "a
|
|
|
3374
4130
|
}
|
|
3375
4131
|
declare function HyperliquidInitWidget({ adapter, userAddress, steps, autoLoad, onComplete, onError, onDismiss, className, }: HyperliquidInitWidgetProps): react_jsx_runtime.JSX.Element;
|
|
3376
4132
|
|
|
3377
|
-
export { type Account, type AccountState, type ActiveAssetLeverage, type ApproveBuilderFeeParams, type AssetMeta, type CancelOrderParams, type CancelOrderResult, type Coin, CoinInfoNotFoundUI, CoinInfoSkeletonsUI, CoinInfoUI, type CoinInfoUIProps, CoinInfoWidget, type CoinInfoWidgetProps, DEFAULT_ORDER_BOOK_PRECISION_OPTIONS, type DepositBreakdown, DepositConfirmUI, type DepositConfirmUIProps, type DepositErrorInfo, type DepositEvent, DepositFlowWidget, type DepositFlowWidgetProps, DepositFormUI, type DepositFormUIProps, type DepositPhase, type DepositQuoteRequest, type DepositQuoteResponse, type DepositSource, type DepositState, type DepositStatus, type DepositStatusResponse, type DepositStatusTransition, DepositStatusUI, type DepositStatusUIProps, type DepositSubmitRequest, type DepositSubmitResponse, type ExecuteDepositInput, type GetActiveAssetLeverageParams, type GetAssetMetaParams, type GetOpenOrdersParams, type GetOpenOrdersResult, type GetPositionsParams, type GetPositionsResult, type GetTradesParams, type GetTradesResult, HL_USDC_DECIMALS, type HyperliquidAccountState, HyperliquidApiError, type HyperliquidClientConfig, type HyperliquidEnvironment, HyperliquidInitUI, type HyperliquidInitUIProps, HyperliquidInitWidget, type HyperliquidInitWidgetProps, HyperliquidPerpetualsClient, type HyperliquidSetupActionResult, type IHyperliquidSetupAdapter, type IPerpDepositClient, type IPerpetualsClient, type Kline, type KlineInterval, type KlineQueryOptions, LiberFiApiError, type LiberFiHttpMethod, type RequestOptions as LiberFiHttpRequestOptions, LiberFiHttpTransport, type LiberFiHttpTransportConfig, LiberFiPerpDepositClient, type LiberFiPerpDepositClientConfig, LiberFiPerpetualsClient, type LiberFiPerpetualsClientConfig, type MarketData, type MarketDataType, OpenOrdersEmpty, OpenOrdersSkeleton, OpenOrdersUI, type OpenOrdersUIProps, OpenOrdersWidget, type OpenOrdersWidgetProps, type Order, type OrderBook, type OrderBookAggregationOptions, type OrderBookLevel, OrderBookUI, type OrderBookUIProps, OrderBookWidget, type OrderBookWidgetProps, type OrderSide, type OrderStatus, type OrderType, PerpetualsContext, type PerpetualsContextValue, PerpetualsProvider, type PerpetualsProviderProps, type PlaceOrderFormData, PlaceOrderFormUI, type PlaceOrderFormUIProps, PlaceOrderFormWidget, type PlaceOrderFormWidgetProps, type PlaceOrderParams, type PlaceOrderRequest, type PlaceOrderResult, type Position, type PositionSortKey, PositionsEmpty, PositionsSkeleton, PositionsUI, type PositionsUIProps, PositionsWidget, type PositionsWidgetProps, type PriceLevel, SearchCoinsUI, type SearchCoinsUIProps, SearchCoinsWidget, type SearchCoinsWidgetProps, type SetReferrerParams, type SetupAction, type SetupPhase, type SetupState, type SetupStep, type SetupStepId, type SignAndBroadcastSolanaTx, type SignTypedDataFn, type SortDirection, type SpotBalance, type StepRecord, type StepStatus, type Symbol, TERMINAL_DEPOSIT_STATUSES, type
|
|
4133
|
+
export { type Account, type AccountState, type ActiveAssetLeverage, type ApproveBuilderFeeParams, type AssetMeta, type CancelOrderImpl, type CancelOrderParams, type CancelOrderResult, type CancelOrdersImpl, ClosePositionModal, type ClosePositionModalProps, type CloseType, type Coin, CoinInfoNotFoundUI, CoinInfoSkeletonsUI, CoinInfoUI, type CoinInfoUIProps, CoinInfoWidget, type CoinInfoWidgetProps, DEFAULT_ORDER_BOOK_PRECISION_OPTIONS, type DepositBreakdown, DepositConfirmUI, type DepositConfirmUIProps, type DepositErrorInfo, type DepositEvent, DepositFlowWidget, type DepositFlowWidgetProps, DepositFormUI, type DepositFormUIProps, type DepositPhase, type DepositQuoteRequest, type DepositQuoteResponse, type DepositSource, type DepositState, type DepositStatus, type DepositStatusResponse, type DepositStatusTransition, DepositStatusUI, type DepositStatusUIProps, type DepositSubmitRequest, type DepositSubmitResponse, type ExecuteDepositInput, type GetActiveAssetLeverageParams, type GetAssetMetaParams, type GetOpenOrdersParams, type GetOpenOrdersResult, type GetPositionsParams, type GetPositionsResult, type GetTradesParams, type GetTradesResult, HL_USDC_DECIMALS, type HyperliquidAccountState, HyperliquidApiError, type HyperliquidClientConfig, type HyperliquidEnvironment, HyperliquidInitUI, type HyperliquidInitUIProps, HyperliquidInitWidget, type HyperliquidInitWidgetProps, HyperliquidPerpetualsClient, type HyperliquidSetupActionResult, type IHyperliquidSetupAdapter, type IPerpDepositClient, type IPerpetualsClient, type Kline, type KlineInterval, type KlineQueryOptions, LiberFiApiError, type LiberFiHttpMethod, type RequestOptions as LiberFiHttpRequestOptions, LiberFiHttpTransport, type LiberFiHttpTransportConfig, LiberFiPerpDepositClient, type LiberFiPerpDepositClientConfig, LiberFiPerpetualsClient, type LiberFiPerpetualsClientConfig, type MarketData, type MarketDataType, type OpenOrderSortKey, OpenOrdersEmpty, OpenOrdersSkeleton, OpenOrdersUI, type OpenOrdersUIProps, OpenOrdersWidget, type OpenOrdersWidgetProps, type Order, type OrderBook, type OrderBookAggregationOptions, type OrderBookLevel, OrderBookUI, type OrderBookUIProps, OrderBookWidget, type OrderBookWidgetProps, type OrderSide, type OrderStatus, type OrderType, PerpetualsContext, type PerpetualsContextValue, PerpetualsProvider, type PerpetualsProviderProps, type PlaceOrderFormData, PlaceOrderFormUI, type PlaceOrderFormUIProps, PlaceOrderFormWidget, type PlaceOrderFormWidgetProps, type PlaceOrderParams, type PlaceOrderRequest, type PlaceOrderResult, type Position, type PositionSortKey, PositionsEmpty, PositionsSkeleton, PositionsUI, type PositionsUIProps, PositionsWidget, type PositionsWidgetProps, type PriceLevel, SearchCoinsUI, type SearchCoinsUIProps, SearchCoinsWidget, type SearchCoinsWidgetProps, type SetReferrerParams, type SetupAction, type SetupPhase, type SetupState, type SetupStep, type SetupStepId, type SignAndBroadcastSolanaTx, type SignTypedDataFn, type SortDirection, type SpotBalance, type StepRecord, type StepStatus, type Symbol, TERMINAL_DEPOSIT_STATUSES, type Trade, type TradeHistory, TradeHistoryEmpty, TradeHistorySkeleton, type TradeHistorySortKey, TradeHistoryUI, type TradeHistoryUIProps, TradeHistoryWidget, type TradeHistoryWidgetProps, type TradeSide, TradesUI, type TradesUIProps, TradesWidget, type TradesWidgetProps, type TradingProvider, type UniverseAssetEntry, type UniverseSnapshot, type UpdateLeverageParams, type UseAccountStateQueryParams, type UseAccountStateSubscriptionParams, type UseAccountStateSubscriptionResult, type UseActiveAssetLeverageQueryParams, type UseAssetMetaQueryParams, type UseCancelOrderMutationParams, type UseCandlesSubscriptionParams, type UseCandlesSubscriptionResult, type UseClosePositionParams, type UseClosePositionResult, type UseCoinInfoReturnType, type UseCreateOrderMutationParams, type UseHyperliquidSetupOptions, type UseHyperliquidSetupResult, type UseHyperliquidUserBootstrapParams, type UseKlinesQueryParams, type UseMarketDataSubscriptionParams, type UseMarketDataSubscriptionResult, type UseMarketQueryParams, type UseMarketsQueryParams, type UseOpenOrdersScriptParams, type UseOpenOrdersScriptResult, type UseOrderBookQueryParams, type UseOrderBookScriptParams, type UseOrderBookScriptResult, type UseOrdersQueryParams, type UsePerpDepositExecuteResult, type UsePerpDepositQuoteOptions, type UsePerpDepositStatusOptions, type UsePlaceOrderFormScriptParams, type UsePlaceOrderFormScriptResult, type UsePositionsQueryParams, type UsePositionsScriptParams, type UsePositionsScriptResult, type UseRecentTradesQueryParams, type UseSearchCoinsScriptParams, type UseSearchCoinsScriptResult, type UseTradeHistoryScriptParams, type UseTradeHistoryScriptResult, type UseTradesQueryParams, type UseTradesScriptParams, type UseTradesScriptResult, type UseUserDataSubscriptionParams, type UseUserDataSubscriptionResult, type UserDataType, accountStateQueryKey, activeAssetLeverageQueryKey, aggregationFromStep, assetMetaQueryKey, cancelOrder, classifyStep, coinsQueryKey, createOrder, currentBreakdown as currentDepositBreakdown, currentStatus as currentDepositStatus, fetchActiveAssetLeverage, fetchAssetMeta, fetchCoins, fetchKlines, fetchMarket, fetchMarkets, fetchOrderBook, fetchOrders, fetchPerpDepositQuote, fetchPerpDepositStatus, fetchPositions, fetchRecentTrades, fetchTrades, fetchUniverse, hlUsdcRawToUsdc, initialDepositState, initialSetupState, isPolling as isDepositPolling, isTerminal as isDepositTerminal, isTerminalLifecycle as isTerminalDepositLifecycle, klinesQueryKey, lamportsToSol, marketQueryKey, marketsQueryKey, microUsdcToUsdc, nextRunnableStep, orderBookQueryKey, ordersQueryKey, perpDepositQuoteQueryKey, perpDepositStatusQueryKey, positionsQueryKey, recentTradesQueryKey, reduceDepositState, reduceSetupState, secondsUntil, shortAddress, solToLamports, supportsUniverseSnapshot, tradesQueryKey, universeQueryKey, useAccountStateQuery, useAccountStateSubscription, useActiveAssetLeverageQuery, useAssetMetaQuery, useCancelOrderMutation, useCandlesSubscription, useClosePosition, useCoinInfo, useCoinsQuery, useCreateOrderMutation, useHyperliquidSetup, useHyperliquidUserBootstrap, useKlinesQuery, useMarketDataSubscription, useMarketQuery, useMarketsQuery, useOpenOrdersScript, useOrderBookQuery, useOrderBookScript, useOrdersQuery, usePerpDepositClient, usePerpDepositClientMaybe, usePerpDepositExecute, usePerpDepositQuote, usePerpDepositStatus, usePerpetualsClient, usePlaceOrderFormScript, usePositionsQuery, usePositionsScript, useRecentTradesQuery, useSearchCoinsScript, useTradeHistoryScript, useTradesQuery, useTradesScript, useUniverseQuery, useUserDataSubscription, _default as version };
|