@0xarchive/sdk 0.9.1 → 1.2.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/dist/index.mjs CHANGED
@@ -45,6 +45,14 @@ var HttpClient = class {
45
45
  get validationEnabled() {
46
46
  return this.validate;
47
47
  }
48
+ /** Base URL for raw requests (used by web3 subscribe) */
49
+ getBaseUrl() {
50
+ return this.baseUrl;
51
+ }
52
+ /** Timeout in ms for raw requests (used by web3 subscribe) */
53
+ getTimeout() {
54
+ return this.timeout;
55
+ }
48
56
  /**
49
57
  * Make a GET request to the API
50
58
  *
@@ -115,6 +123,66 @@ var HttpClient = class {
115
123
  );
116
124
  }
117
125
  }
126
+ /**
127
+ * Make a POST request to the API
128
+ *
129
+ * @param path - API endpoint path
130
+ * @param body - JSON request body
131
+ * @param schema - Optional Zod schema for validation (used when validation is enabled)
132
+ */
133
+ async post(path, body, schema) {
134
+ const url = `${this.baseUrl}${path}`;
135
+ const controller = new AbortController();
136
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
137
+ try {
138
+ const response = await fetch(url, {
139
+ method: "POST",
140
+ headers: {
141
+ "X-API-Key": this.apiKey,
142
+ "Content-Type": "application/json"
143
+ },
144
+ body: body ? JSON.stringify(body) : void 0,
145
+ signal: controller.signal
146
+ });
147
+ clearTimeout(timeoutId);
148
+ const rawData = await response.json();
149
+ const data = transformKeys(rawData);
150
+ if (!response.ok) {
151
+ const error = data;
152
+ const apiResponse = data;
153
+ throw new OxArchiveError(
154
+ error.error || `Request failed with status ${response.status}`,
155
+ response.status,
156
+ apiResponse.meta?.requestId
157
+ );
158
+ }
159
+ if (this.validate && schema) {
160
+ const result = schema.safeParse(data);
161
+ if (!result.success) {
162
+ const apiResponse = data;
163
+ throw new OxArchiveError(
164
+ `Response validation failed: ${result.error.message}`,
165
+ 422,
166
+ apiResponse.meta?.requestId
167
+ );
168
+ }
169
+ return result.data;
170
+ }
171
+ return data;
172
+ } catch (error) {
173
+ clearTimeout(timeoutId);
174
+ if (error instanceof OxArchiveError) {
175
+ throw error;
176
+ }
177
+ if (error instanceof Error && error.name === "AbortError") {
178
+ throw new OxArchiveError(`Request timeout after ${this.timeout}ms`, 408);
179
+ }
180
+ throw new OxArchiveError(
181
+ error instanceof Error ? error.message : "Unknown error",
182
+ 500
183
+ );
184
+ }
185
+ }
118
186
  };
119
187
 
120
188
  // src/schemas.ts
@@ -613,15 +681,15 @@ var OrderBookResource = class {
613
681
  this.coinTransform = coinTransform;
614
682
  }
615
683
  /**
616
- * Get order book snapshot for a coin
684
+ * Get order book snapshot for a symbol
617
685
  *
618
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
686
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
619
687
  * @param params - Optional parameters
620
688
  * @returns Order book snapshot
621
689
  */
622
- async get(coin, params) {
690
+ async get(symbol, params) {
623
691
  const response = await this.http.get(
624
- `${this.basePath}/orderbook/${this.coinTransform(coin)}`,
692
+ `${this.basePath}/orderbook/${this.coinTransform(symbol)}`,
625
693
  params,
626
694
  this.http.validationEnabled ? OrderBookResponseSchema : void 0
627
695
  );
@@ -630,7 +698,7 @@ var OrderBookResource = class {
630
698
  /**
631
699
  * Get historical order book snapshots with cursor-based pagination
632
700
  *
633
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
701
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
634
702
  * @param params - Time range and cursor pagination parameters (start and end are required)
635
703
  * @returns CursorResponse with order book snapshots and nextCursor for pagination
636
704
  *
@@ -654,9 +722,9 @@ var OrderBookResource = class {
654
722
  * }
655
723
  * ```
656
724
  */
657
- async history(coin, params) {
725
+ async history(symbol, params) {
658
726
  const response = await this.http.get(
659
- `${this.basePath}/orderbook/${this.coinTransform(coin)}/history`,
727
+ `${this.basePath}/orderbook/${this.coinTransform(symbol)}/history`,
660
728
  params,
661
729
  this.http.validationEnabled ? OrderBookArrayResponseSchema : void 0
662
730
  );
@@ -674,7 +742,7 @@ var OrderBookResource = class {
674
742
  *
675
743
  * For automatic reconstruction, use `historyReconstructed()` instead.
676
744
  *
677
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
745
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
678
746
  * @param params - Time range parameters
679
747
  * @returns Tick data with checkpoint and deltas
680
748
  *
@@ -694,9 +762,9 @@ var OrderBookResource = class {
694
762
  * }
695
763
  * ```
696
764
  */
697
- async historyTick(coin, params) {
765
+ async historyTick(symbol, params) {
698
766
  const response = await this.http.get(
699
- `${this.basePath}/orderbook/${this.coinTransform(coin)}/history`,
767
+ `${this.basePath}/orderbook/${this.coinTransform(symbol)}/history`,
700
768
  {
701
769
  ...params,
702
770
  granularity: "tick"
@@ -721,7 +789,7 @@ var OrderBookResource = class {
721
789
  * For large time ranges, consider using `historyTick()` with the
722
790
  * `OrderBookReconstructor.iterate()` method for memory efficiency.
723
791
  *
724
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
792
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
725
793
  * @param params - Time range parameters
726
794
  * @param options - Reconstruction options
727
795
  * @returns Array of reconstructed orderbook snapshots
@@ -745,8 +813,8 @@ var OrderBookResource = class {
745
813
  * );
746
814
  * ```
747
815
  */
748
- async historyReconstructed(coin, params, options = {}) {
749
- const tickData = await this.historyTick(coin, params);
816
+ async historyReconstructed(symbol, params, options = {}) {
817
+ const tickData = await this.historyTick(symbol, params);
750
818
  const reconstructor = new OrderBookReconstructor();
751
819
  return reconstructor.reconstructAll(tickData.checkpoint, tickData.deltas, options);
752
820
  }
@@ -786,7 +854,7 @@ var OrderBookResource = class {
786
854
  * per API request and yielding reconstructed orderbook snapshots one at a time.
787
855
  * Memory-efficient for processing large time ranges.
788
856
  *
789
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
857
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
790
858
  * @param params - Time range parameters
791
859
  * @param depth - Maximum price levels to include in output snapshots
792
860
  * @yields Reconstructed orderbook snapshots
@@ -809,7 +877,7 @@ var OrderBookResource = class {
809
877
  * }
810
878
  * ```
811
879
  */
812
- async *iterateTickHistory(coin, params, depth) {
880
+ async *iterateTickHistory(symbol, params, depth) {
813
881
  const startTs = typeof params.start === "string" ? new Date(params.start).getTime() : params.start;
814
882
  const endTs = typeof params.end === "string" ? new Date(params.end).getTime() : params.end;
815
883
  let cursor = startTs;
@@ -817,7 +885,7 @@ var OrderBookResource = class {
817
885
  const MAX_DELTAS_PER_PAGE = 1e3;
818
886
  let isFirstPage = true;
819
887
  while (cursor < endTs) {
820
- const tickData = await this.historyTick(coin, {
888
+ const tickData = await this.historyTick(symbol, {
821
889
  start: cursor,
822
890
  end: endTs,
823
891
  depth: params.depth
@@ -855,12 +923,12 @@ var TradesResource = class {
855
923
  this.coinTransform = coinTransform;
856
924
  }
857
925
  /**
858
- * Get trade history for a coin using cursor-based pagination
926
+ * Get trade history for a symbol using cursor-based pagination
859
927
  *
860
928
  * Uses cursor-based pagination by default, which is more efficient for large datasets.
861
929
  * Use the `nextCursor` from the response as the `cursor` parameter to get the next page.
862
930
  *
863
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
931
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
864
932
  * @param params - Time range and cursor pagination parameters (start and end are required)
865
933
  * @returns Object with trades array and nextCursor for pagination
866
934
  *
@@ -884,9 +952,9 @@ var TradesResource = class {
884
952
  * }
885
953
  * ```
886
954
  */
887
- async list(coin, params) {
955
+ async list(symbol, params) {
888
956
  const response = await this.http.get(
889
- `${this.basePath}/trades/${this.coinTransform(coin)}`,
957
+ `${this.basePath}/trades/${this.coinTransform(symbol)}`,
890
958
  params,
891
959
  this.http.validationEnabled ? TradeArrayResponseSchema : void 0
892
960
  );
@@ -896,20 +964,20 @@ var TradesResource = class {
896
964
  };
897
965
  }
898
966
  /**
899
- * Get most recent trades for a coin.
967
+ * Get most recent trades for a symbol.
900
968
  *
901
969
  * Note: This method is available for Lighter (client.lighter.trades.recent())
902
970
  * and HIP-3 (client.hyperliquid.hip3.trades.recent()) which have real-time data
903
971
  * ingestion. Hyperliquid uses hourly backfill so this endpoint is not available
904
972
  * for Hyperliquid.
905
973
  *
906
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
974
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
907
975
  * @param limit - Number of trades to return (default: 100)
908
976
  * @returns Array of recent trades
909
977
  */
910
- async recent(coin, limit) {
978
+ async recent(symbol, limit) {
911
979
  const response = await this.http.get(
912
- `${this.basePath}/trades/${this.coinTransform(coin)}/recent`,
980
+ `${this.basePath}/trades/${this.coinTransform(symbol)}/recent`,
913
981
  { limit },
914
982
  this.http.validationEnabled ? TradeArrayResponseSchema : void 0
915
983
  );
@@ -1021,15 +1089,15 @@ var FundingResource = class {
1021
1089
  this.coinTransform = coinTransform;
1022
1090
  }
1023
1091
  /**
1024
- * Get funding rate history for a coin with cursor-based pagination
1092
+ * Get funding rate history for a symbol with cursor-based pagination
1025
1093
  *
1026
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1094
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1027
1095
  * @param params - Time range and cursor pagination parameters (start and end are required)
1028
1096
  * @returns CursorResponse with funding rate records and nextCursor for pagination
1029
1097
  */
1030
- async history(coin, params) {
1098
+ async history(symbol, params) {
1031
1099
  const response = await this.http.get(
1032
- `${this.basePath}/funding/${this.coinTransform(coin)}`,
1100
+ `${this.basePath}/funding/${this.coinTransform(symbol)}`,
1033
1101
  params,
1034
1102
  this.http.validationEnabled ? FundingRateArrayResponseSchema : void 0
1035
1103
  );
@@ -1039,14 +1107,14 @@ var FundingResource = class {
1039
1107
  };
1040
1108
  }
1041
1109
  /**
1042
- * Get current funding rate for a coin
1110
+ * Get current funding rate for a symbol
1043
1111
  *
1044
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1112
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1045
1113
  * @returns Current funding rate
1046
1114
  */
1047
- async current(coin) {
1115
+ async current(symbol) {
1048
1116
  const response = await this.http.get(
1049
- `${this.basePath}/funding/${this.coinTransform(coin)}/current`,
1117
+ `${this.basePath}/funding/${this.coinTransform(symbol)}/current`,
1050
1118
  void 0,
1051
1119
  this.http.validationEnabled ? FundingRateResponseSchema : void 0
1052
1120
  );
@@ -1062,15 +1130,15 @@ var OpenInterestResource = class {
1062
1130
  this.coinTransform = coinTransform;
1063
1131
  }
1064
1132
  /**
1065
- * Get open interest history for a coin with cursor-based pagination
1133
+ * Get open interest history for a symbol with cursor-based pagination
1066
1134
  *
1067
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1135
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1068
1136
  * @param params - Time range and cursor pagination parameters (start and end are required)
1069
1137
  * @returns CursorResponse with open interest records and nextCursor for pagination
1070
1138
  */
1071
- async history(coin, params) {
1139
+ async history(symbol, params) {
1072
1140
  const response = await this.http.get(
1073
- `${this.basePath}/openinterest/${this.coinTransform(coin)}`,
1141
+ `${this.basePath}/openinterest/${this.coinTransform(symbol)}`,
1074
1142
  params,
1075
1143
  this.http.validationEnabled ? OpenInterestArrayResponseSchema : void 0
1076
1144
  );
@@ -1080,14 +1148,14 @@ var OpenInterestResource = class {
1080
1148
  };
1081
1149
  }
1082
1150
  /**
1083
- * Get current open interest for a coin
1151
+ * Get current open interest for a symbol
1084
1152
  *
1085
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1153
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1086
1154
  * @returns Current open interest
1087
1155
  */
1088
- async current(coin) {
1156
+ async current(symbol) {
1089
1157
  const response = await this.http.get(
1090
- `${this.basePath}/openinterest/${this.coinTransform(coin)}/current`,
1158
+ `${this.basePath}/openinterest/${this.coinTransform(symbol)}/current`,
1091
1159
  void 0,
1092
1160
  this.http.validationEnabled ? OpenInterestResponseSchema : void 0
1093
1161
  );
@@ -1105,13 +1173,13 @@ var CandlesResource = class {
1105
1173
  /**
1106
1174
  * Get historical OHLCV candle data with cursor-based pagination
1107
1175
  *
1108
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1176
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1109
1177
  * @param params - Time range, interval, and cursor pagination parameters (start and end are required)
1110
1178
  * @returns CursorResponse with candle records and nextCursor for pagination
1111
1179
  */
1112
- async history(coin, params) {
1180
+ async history(symbol, params) {
1113
1181
  const response = await this.http.get(
1114
- `${this.basePath}/candles/${this.coinTransform(coin)}`,
1182
+ `${this.basePath}/candles/${this.coinTransform(symbol)}`,
1115
1183
  params,
1116
1184
  this.http.validationEnabled ? CandleArrayResponseSchema : void 0
1117
1185
  );
@@ -1124,20 +1192,21 @@ var CandlesResource = class {
1124
1192
 
1125
1193
  // src/resources/liquidations.ts
1126
1194
  var LiquidationsResource = class {
1127
- constructor(http, basePath = "/v1") {
1195
+ constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
1128
1196
  this.http = http;
1129
1197
  this.basePath = basePath;
1198
+ this.coinTransform = coinTransform;
1130
1199
  }
1131
1200
  /**
1132
- * Get liquidation history for a coin with cursor-based pagination
1201
+ * Get liquidation history for a symbol with cursor-based pagination
1133
1202
  *
1134
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1203
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1135
1204
  * @param params - Time range and cursor pagination parameters (start and end are required)
1136
1205
  * @returns CursorResponse with liquidation records and nextCursor for pagination
1137
1206
  */
1138
- async history(coin, params) {
1207
+ async history(symbol, params) {
1139
1208
  const response = await this.http.get(
1140
- `${this.basePath}/liquidations/${coin.toUpperCase()}`,
1209
+ `${this.basePath}/liquidations/${this.coinTransform(symbol)}`,
1141
1210
  params,
1142
1211
  this.http.validationEnabled ? LiquidationArrayResponseSchema : void 0
1143
1212
  );
@@ -1174,13 +1243,13 @@ var LiquidationsResource = class {
1174
1243
  * Returns pre-aggregated data with total/long/short USD volumes per bucket,
1175
1244
  * reducing data transfer by 100-1000x compared to individual liquidation records.
1176
1245
  *
1177
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1246
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1178
1247
  * @param params - Time range, cursor, and interval parameters
1179
1248
  * @returns CursorResponse with liquidation volume buckets
1180
1249
  */
1181
- async volume(coin, params) {
1250
+ async volume(symbol, params) {
1182
1251
  const response = await this.http.get(
1183
- `${this.basePath}/liquidations/${coin.toUpperCase()}/volume`,
1252
+ `${this.basePath}/liquidations/${this.coinTransform(symbol)}/volume`,
1184
1253
  params,
1185
1254
  this.http.validationEnabled ? LiquidationVolumeArrayResponseSchema : void 0
1186
1255
  );
@@ -1386,6 +1455,286 @@ var DataQualityResource = class {
1386
1455
  }
1387
1456
  };
1388
1457
 
1458
+ // src/resources/web3.ts
1459
+ var Web3Resource = class {
1460
+ constructor(http) {
1461
+ this.http = http;
1462
+ }
1463
+ /**
1464
+ * Get a SIWE challenge message to sign.
1465
+ *
1466
+ * @param address - Ethereum wallet address
1467
+ * @returns SIWE message and nonce. Sign the message with personal_sign (EIP-191).
1468
+ */
1469
+ async challenge(address) {
1470
+ return this.http.post("/v1/auth/web3/challenge", { address });
1471
+ }
1472
+ /**
1473
+ * Create a free-tier account and get an API key.
1474
+ *
1475
+ * @param message - The SIWE message from {@link challenge}
1476
+ * @param signature - Hex-encoded signature from personal_sign
1477
+ * @returns API key, tier, and wallet address
1478
+ */
1479
+ async signup(message, signature) {
1480
+ return this.http.post("/v1/web3/signup", { message, signature });
1481
+ }
1482
+ /**
1483
+ * List all API keys for the authenticated wallet.
1484
+ *
1485
+ * @param message - The SIWE message from {@link challenge}
1486
+ * @param signature - Hex-encoded signature from personal_sign
1487
+ * @returns List of API keys and wallet address
1488
+ */
1489
+ async listKeys(message, signature) {
1490
+ return this.http.post("/v1/web3/keys", { message, signature });
1491
+ }
1492
+ /**
1493
+ * Revoke a specific API key.
1494
+ *
1495
+ * @param message - The SIWE message from {@link challenge}
1496
+ * @param signature - Hex-encoded signature from personal_sign
1497
+ * @param keyId - UUID of the key to revoke
1498
+ * @returns Confirmation message and wallet address
1499
+ */
1500
+ async revokeKey(message, signature, keyId) {
1501
+ return this.http.post("/v1/web3/keys/revoke", {
1502
+ message,
1503
+ signature,
1504
+ key_id: keyId
1505
+ });
1506
+ }
1507
+ /**
1508
+ * Get pricing info for a paid subscription (x402 flow, step 1).
1509
+ *
1510
+ * Returns the payment details needed to sign a USDC transfer on Base.
1511
+ * After signing, pass the payment signature to {@link subscribe}.
1512
+ *
1513
+ * @param tier - Subscription tier: 'build' ($49/mo) or 'pro' ($199/mo)
1514
+ * @returns Payment details (amount, asset, network, pay-to address)
1515
+ */
1516
+ async subscribeQuote(tier) {
1517
+ const url = `${this.http.getBaseUrl()}/v1/web3/subscribe`;
1518
+ const timeout = this.http.getTimeout();
1519
+ const controller = new AbortController();
1520
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
1521
+ try {
1522
+ const response = await fetch(url, {
1523
+ method: "POST",
1524
+ headers: { "Content-Type": "application/json" },
1525
+ body: JSON.stringify({ tier }),
1526
+ signal: controller.signal
1527
+ });
1528
+ clearTimeout(timeoutId);
1529
+ const rawData = await response.json();
1530
+ const data = transformKeys(rawData);
1531
+ if (response.status === 402) {
1532
+ return data.payment;
1533
+ }
1534
+ throw new OxArchiveError(
1535
+ data.error || `Unexpected status ${response.status}`,
1536
+ response.status
1537
+ );
1538
+ } catch (error) {
1539
+ clearTimeout(timeoutId);
1540
+ if (error instanceof OxArchiveError) throw error;
1541
+ if (error instanceof Error && error.name === "AbortError") {
1542
+ throw new OxArchiveError(`Request timeout after ${timeout}ms`, 408);
1543
+ }
1544
+ throw new OxArchiveError(
1545
+ error instanceof Error ? error.message : "Unknown error",
1546
+ 500
1547
+ );
1548
+ }
1549
+ }
1550
+ /**
1551
+ * Complete a paid subscription with a signed x402 payment (step 2).
1552
+ *
1553
+ * Requires a payment signature from signing a USDC transfer (EIP-3009)
1554
+ * for the amount returned by {@link subscribeQuote}.
1555
+ *
1556
+ * @param tier - Subscription tier: 'build' or 'pro'
1557
+ * @param paymentSignature - Signed x402 payment (from EIP-3009 USDC transfer on Base)
1558
+ * @returns API key, tier, expiration, and wallet address
1559
+ */
1560
+ async subscribe(tier, paymentSignature) {
1561
+ const url = `${this.http.getBaseUrl()}/v1/web3/subscribe`;
1562
+ const timeout = this.http.getTimeout();
1563
+ const controller = new AbortController();
1564
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
1565
+ try {
1566
+ const response = await fetch(url, {
1567
+ method: "POST",
1568
+ headers: {
1569
+ "Content-Type": "application/json",
1570
+ "payment-signature": paymentSignature
1571
+ },
1572
+ body: JSON.stringify({ tier }),
1573
+ signal: controller.signal
1574
+ });
1575
+ clearTimeout(timeoutId);
1576
+ const rawData = await response.json();
1577
+ const data = transformKeys(rawData);
1578
+ if (!response.ok) {
1579
+ throw new OxArchiveError(
1580
+ data.error || "Subscribe failed",
1581
+ response.status
1582
+ );
1583
+ }
1584
+ return data;
1585
+ } catch (error) {
1586
+ clearTimeout(timeoutId);
1587
+ if (error instanceof OxArchiveError) throw error;
1588
+ if (error instanceof Error && error.name === "AbortError") {
1589
+ throw new OxArchiveError(`Request timeout after ${timeout}ms`, 408);
1590
+ }
1591
+ throw new OxArchiveError(
1592
+ error instanceof Error ? error.message : "Unknown error",
1593
+ 500
1594
+ );
1595
+ }
1596
+ }
1597
+ };
1598
+
1599
+ // src/resources/orders.ts
1600
+ var OrdersResource = class {
1601
+ constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
1602
+ this.http = http;
1603
+ this.basePath = basePath;
1604
+ this.coinTransform = coinTransform;
1605
+ }
1606
+ /**
1607
+ * Get order history for a symbol with cursor-based pagination
1608
+ *
1609
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1610
+ * @param params - Time range, cursor pagination, and filter parameters
1611
+ * @returns CursorResponse with order records and nextCursor for pagination
1612
+ */
1613
+ async history(symbol, params) {
1614
+ const response = await this.http.get(
1615
+ `${this.basePath}/orders/${this.coinTransform(symbol)}/history`,
1616
+ params
1617
+ );
1618
+ return { data: response.data, nextCursor: response.meta.nextCursor };
1619
+ }
1620
+ /**
1621
+ * Get order flow for a symbol
1622
+ *
1623
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1624
+ * @param params - Time range and interval parameters
1625
+ * @returns CursorResponse with order flow records
1626
+ */
1627
+ async flow(symbol, params) {
1628
+ const response = await this.http.get(
1629
+ `${this.basePath}/orders/${this.coinTransform(symbol)}/flow`,
1630
+ params
1631
+ );
1632
+ return { data: response.data, nextCursor: response.meta.nextCursor };
1633
+ }
1634
+ /**
1635
+ * Get TP/SL orders for a symbol with cursor-based pagination
1636
+ *
1637
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1638
+ * @param params - Time range, cursor pagination, and filter parameters
1639
+ * @returns CursorResponse with TP/SL order records
1640
+ */
1641
+ async tpsl(symbol, params) {
1642
+ const response = await this.http.get(
1643
+ `${this.basePath}/orders/${this.coinTransform(symbol)}/tpsl`,
1644
+ params
1645
+ );
1646
+ return { data: response.data, nextCursor: response.meta.nextCursor };
1647
+ }
1648
+ };
1649
+
1650
+ // src/resources/l4-orderbook.ts
1651
+ var L4OrderBookResource = class {
1652
+ constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
1653
+ this.http = http;
1654
+ this.basePath = basePath;
1655
+ this.coinTransform = coinTransform;
1656
+ }
1657
+ /**
1658
+ * Get L4 order book snapshot for a symbol
1659
+ *
1660
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1661
+ * @param params - Optional parameters (timestamp, depth)
1662
+ * @returns L4 order book snapshot
1663
+ */
1664
+ async get(symbol, params) {
1665
+ const response = await this.http.get(
1666
+ `${this.basePath}/orderbook/${this.coinTransform(symbol)}/l4`,
1667
+ params
1668
+ );
1669
+ return response.data;
1670
+ }
1671
+ /**
1672
+ * Get L4 order book diffs with cursor-based pagination
1673
+ *
1674
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1675
+ * @param params - Time range and cursor pagination parameters
1676
+ * @returns CursorResponse with L4 orderbook diffs and nextCursor for pagination
1677
+ */
1678
+ async diffs(symbol, params) {
1679
+ const response = await this.http.get(
1680
+ `${this.basePath}/orderbook/${this.coinTransform(symbol)}/l4/diffs`,
1681
+ params
1682
+ );
1683
+ return { data: response.data, nextCursor: response.meta.nextCursor };
1684
+ }
1685
+ /**
1686
+ * Get L4 order book history with cursor-based pagination
1687
+ *
1688
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1689
+ * @param params - Time range and cursor pagination parameters
1690
+ * @returns CursorResponse with L4 orderbook snapshots and nextCursor for pagination
1691
+ */
1692
+ async history(symbol, params) {
1693
+ const response = await this.http.get(
1694
+ `${this.basePath}/orderbook/${this.coinTransform(symbol)}/l4/history`,
1695
+ params
1696
+ );
1697
+ return { data: response.data, nextCursor: response.meta.nextCursor };
1698
+ }
1699
+ };
1700
+
1701
+ // src/resources/l3-orderbook.ts
1702
+ var L3OrderBookResource = class {
1703
+ constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
1704
+ this.http = http;
1705
+ this.basePath = basePath;
1706
+ this.coinTransform = coinTransform;
1707
+ }
1708
+ /**
1709
+ * Get L3 order book snapshot for a symbol
1710
+ *
1711
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1712
+ * @param params - Optional parameters (timestamp, depth)
1713
+ * @returns L3 order book snapshot
1714
+ */
1715
+ async get(symbol, params) {
1716
+ const response = await this.http.get(
1717
+ `${this.basePath}/l3orderbook/${this.coinTransform(symbol)}`,
1718
+ params
1719
+ );
1720
+ return response.data;
1721
+ }
1722
+ /**
1723
+ * Get L3 order book history with cursor-based pagination
1724
+ *
1725
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1726
+ * @param params - Time range and cursor pagination parameters
1727
+ * @returns CursorResponse with L3 orderbook snapshots and nextCursor for pagination
1728
+ */
1729
+ async history(symbol, params) {
1730
+ const response = await this.http.get(
1731
+ `${this.basePath}/l3orderbook/${this.coinTransform(symbol)}/history`,
1732
+ params
1733
+ );
1734
+ return { data: response.data, nextCursor: response.meta.nextCursor };
1735
+ }
1736
+ };
1737
+
1389
1738
  // src/exchanges.ts
1390
1739
  var HyperliquidClient = class {
1391
1740
  /**
@@ -1416,6 +1765,14 @@ var HyperliquidClient = class {
1416
1765
  * Liquidation events (May 2025+)
1417
1766
  */
1418
1767
  liquidations;
1768
+ /**
1769
+ * Order history, flow, and TP/SL
1770
+ */
1771
+ orders;
1772
+ /**
1773
+ * L4 order book (snapshots, diffs, history)
1774
+ */
1775
+ l4Orderbook;
1419
1776
  /**
1420
1777
  * HIP-3 builder-deployed perpetuals (February 2026+)
1421
1778
  */
@@ -1431,17 +1788,19 @@ var HyperliquidClient = class {
1431
1788
  this.openInterest = new OpenInterestResource(http, basePath);
1432
1789
  this.candles = new CandlesResource(http, basePath);
1433
1790
  this.liquidations = new LiquidationsResource(http, basePath);
1791
+ this.orders = new OrdersResource(http, basePath);
1792
+ this.l4Orderbook = new L4OrderBookResource(http, basePath);
1434
1793
  this.hip3 = new Hip3Client(http);
1435
1794
  }
1436
1795
  /**
1437
- * Get per-coin data freshness across all data types
1796
+ * Get per-symbol data freshness across all data types
1438
1797
  *
1439
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1440
- * @returns Per-coin freshness with last_updated and lag_ms for each data type
1798
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1799
+ * @returns Per-symbol freshness with last_updated and lag_ms for each data type
1441
1800
  */
1442
- async freshness(coin) {
1801
+ async freshness(symbol) {
1443
1802
  const response = await this.http.get(
1444
- `/v1/hyperliquid/freshness/${coin.toUpperCase()}`,
1803
+ `/v1/hyperliquid/freshness/${symbol.toUpperCase()}`,
1445
1804
  void 0,
1446
1805
  this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
1447
1806
  );
@@ -1450,12 +1809,12 @@ var HyperliquidClient = class {
1450
1809
  /**
1451
1810
  * Get combined market summary (price, funding, OI, volume, liquidations) in one call
1452
1811
  *
1453
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1812
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1454
1813
  * @returns Combined market summary
1455
1814
  */
1456
- async summary(coin) {
1815
+ async summary(symbol) {
1457
1816
  const response = await this.http.get(
1458
- `/v1/hyperliquid/summary/${coin.toUpperCase()}`,
1817
+ `/v1/hyperliquid/summary/${symbol.toUpperCase()}`,
1459
1818
  void 0,
1460
1819
  this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
1461
1820
  );
@@ -1464,13 +1823,13 @@ var HyperliquidClient = class {
1464
1823
  /**
1465
1824
  * Get mark/oracle/mid price history (projected from OI data)
1466
1825
  *
1467
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1826
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1468
1827
  * @param params - Time range, cursor, and interval parameters
1469
1828
  * @returns CursorResponse with price snapshots
1470
1829
  */
1471
- async priceHistory(coin, params) {
1830
+ async priceHistory(symbol, params) {
1472
1831
  const response = await this.http.get(
1473
- `/v1/hyperliquid/prices/${coin.toUpperCase()}`,
1832
+ `/v1/hyperliquid/prices/${symbol.toUpperCase()}`,
1474
1833
  params,
1475
1834
  this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
1476
1835
  );
@@ -1505,6 +1864,18 @@ var Hip3Client = class {
1505
1864
  * OHLCV candle data
1506
1865
  */
1507
1866
  candles;
1867
+ /**
1868
+ * Liquidation events
1869
+ */
1870
+ liquidations;
1871
+ /**
1872
+ * Order history, flow, and TP/SL
1873
+ */
1874
+ orders;
1875
+ /**
1876
+ * L4 order book (snapshots, diffs, history)
1877
+ */
1878
+ l4Orderbook;
1508
1879
  http;
1509
1880
  constructor(http) {
1510
1881
  this.http = http;
@@ -1516,16 +1887,19 @@ var Hip3Client = class {
1516
1887
  this.funding = new FundingResource(http, basePath, coinTransform);
1517
1888
  this.openInterest = new OpenInterestResource(http, basePath, coinTransform);
1518
1889
  this.candles = new CandlesResource(http, basePath, coinTransform);
1890
+ this.liquidations = new LiquidationsResource(http, basePath, coinTransform);
1891
+ this.orders = new OrdersResource(http, basePath, coinTransform);
1892
+ this.l4Orderbook = new L4OrderBookResource(http, basePath, coinTransform);
1519
1893
  }
1520
1894
  /**
1521
- * Get per-coin data freshness across all data types
1895
+ * Get per-symbol data freshness across all data types
1522
1896
  *
1523
- * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
1524
- * @returns Per-coin freshness with last_updated and lag_ms for each data type
1897
+ * @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
1898
+ * @returns Per-symbol freshness with last_updated and lag_ms for each data type
1525
1899
  */
1526
- async freshness(coin) {
1900
+ async freshness(symbol) {
1527
1901
  const response = await this.http.get(
1528
- `/v1/hyperliquid/hip3/freshness/${coin}`,
1902
+ `/v1/hyperliquid/hip3/freshness/${symbol}`,
1529
1903
  void 0,
1530
1904
  this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
1531
1905
  );
@@ -1534,12 +1908,12 @@ var Hip3Client = class {
1534
1908
  /**
1535
1909
  * Get combined market summary (price, funding, OI) in one call
1536
1910
  *
1537
- * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
1911
+ * @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
1538
1912
  * @returns Combined market summary
1539
1913
  */
1540
- async summary(coin) {
1914
+ async summary(symbol) {
1541
1915
  const response = await this.http.get(
1542
- `/v1/hyperliquid/hip3/summary/${coin}`,
1916
+ `/v1/hyperliquid/hip3/summary/${symbol}`,
1543
1917
  void 0,
1544
1918
  this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
1545
1919
  );
@@ -1548,13 +1922,13 @@ var Hip3Client = class {
1548
1922
  /**
1549
1923
  * Get mark/oracle/mid price history (projected from OI data)
1550
1924
  *
1551
- * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
1925
+ * @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
1552
1926
  * @param params - Time range, cursor, and interval parameters
1553
1927
  * @returns CursorResponse with price snapshots
1554
1928
  */
1555
- async priceHistory(coin, params) {
1929
+ async priceHistory(symbol, params) {
1556
1930
  const response = await this.http.get(
1557
- `/v1/hyperliquid/hip3/prices/${coin}`,
1931
+ `/v1/hyperliquid/hip3/prices/${symbol}`,
1558
1932
  params,
1559
1933
  this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
1560
1934
  );
@@ -1589,6 +1963,10 @@ var LighterClient = class {
1589
1963
  * OHLCV candle data
1590
1964
  */
1591
1965
  candles;
1966
+ /**
1967
+ * L3 order book (Lighter only)
1968
+ */
1969
+ l3Orderbook;
1592
1970
  http;
1593
1971
  constructor(http) {
1594
1972
  this.http = http;
@@ -1599,16 +1977,17 @@ var LighterClient = class {
1599
1977
  this.funding = new FundingResource(http, basePath);
1600
1978
  this.openInterest = new OpenInterestResource(http, basePath);
1601
1979
  this.candles = new CandlesResource(http, basePath);
1980
+ this.l3Orderbook = new L3OrderBookResource(http, basePath);
1602
1981
  }
1603
1982
  /**
1604
- * Get per-coin data freshness across all data types
1983
+ * Get per-symbol data freshness across all data types
1605
1984
  *
1606
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1607
- * @returns Per-coin freshness with last_updated and lag_ms for each data type
1985
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1986
+ * @returns Per-symbol freshness with last_updated and lag_ms for each data type
1608
1987
  */
1609
- async freshness(coin) {
1988
+ async freshness(symbol) {
1610
1989
  const response = await this.http.get(
1611
- `/v1/lighter/freshness/${coin.toUpperCase()}`,
1990
+ `/v1/lighter/freshness/${symbol.toUpperCase()}`,
1612
1991
  void 0,
1613
1992
  this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
1614
1993
  );
@@ -1617,12 +1996,12 @@ var LighterClient = class {
1617
1996
  /**
1618
1997
  * Get combined market summary (price, funding, OI) in one call
1619
1998
  *
1620
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1999
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1621
2000
  * @returns Combined market summary
1622
2001
  */
1623
- async summary(coin) {
2002
+ async summary(symbol) {
1624
2003
  const response = await this.http.get(
1625
- `/v1/lighter/summary/${coin.toUpperCase()}`,
2004
+ `/v1/lighter/summary/${symbol.toUpperCase()}`,
1626
2005
  void 0,
1627
2006
  this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
1628
2007
  );
@@ -1631,13 +2010,13 @@ var LighterClient = class {
1631
2010
  /**
1632
2011
  * Get mark/oracle price history (projected from OI data)
1633
2012
  *
1634
- * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2013
+ * @param symbol - The symbol (e.g., 'BTC', 'ETH')
1635
2014
  * @param params - Time range, cursor, and interval parameters
1636
2015
  * @returns CursorResponse with price snapshots
1637
2016
  */
1638
- async priceHistory(coin, params) {
2017
+ async priceHistory(symbol, params) {
1639
2018
  const response = await this.http.get(
1640
- `/v1/lighter/prices/${coin.toUpperCase()}`,
2019
+ `/v1/lighter/prices/${symbol.toUpperCase()}`,
1641
2020
  params,
1642
2021
  this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
1643
2022
  );
@@ -1665,6 +2044,10 @@ var OxArchive = class {
1665
2044
  * Data quality metrics: status, coverage, incidents, latency, SLA
1666
2045
  */
1667
2046
  dataQuality;
2047
+ /**
2048
+ * Wallet-based auth: get API keys via SIWE signature
2049
+ */
2050
+ web3;
1668
2051
  /**
1669
2052
  * @deprecated Use client.hyperliquid.orderbook instead
1670
2053
  */
@@ -1703,6 +2086,7 @@ var OxArchive = class {
1703
2086
  this.hyperliquid = new HyperliquidClient(this.http);
1704
2087
  this.lighter = new LighterClient(this.http);
1705
2088
  this.dataQuality = new DataQualityResource(this.http);
2089
+ this.web3 = new Web3Resource(this.http);
1706
2090
  const legacyBase = "/v1/hyperliquid";
1707
2091
  this.orderbook = new OrderBookResource(this.http, legacyBase);
1708
2092
  this.trades = new TradesResource(this.http, legacyBase);