@0xarchive/sdk 0.9.2 → 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/README.md +192 -111
- package/dist/index.d.mts +283 -64
- package/dist/index.d.ts +283 -64
- package/dist/index.js +254 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +254 -84
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -772,15 +772,15 @@ var OrderBookResource = class {
|
|
|
772
772
|
this.coinTransform = coinTransform;
|
|
773
773
|
}
|
|
774
774
|
/**
|
|
775
|
-
* Get order book snapshot for a
|
|
775
|
+
* Get order book snapshot for a symbol
|
|
776
776
|
*
|
|
777
|
-
* @param
|
|
777
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
778
778
|
* @param params - Optional parameters
|
|
779
779
|
* @returns Order book snapshot
|
|
780
780
|
*/
|
|
781
|
-
async get(
|
|
781
|
+
async get(symbol, params) {
|
|
782
782
|
const response = await this.http.get(
|
|
783
|
-
`${this.basePath}/orderbook/${this.coinTransform(
|
|
783
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}`,
|
|
784
784
|
params,
|
|
785
785
|
this.http.validationEnabled ? OrderBookResponseSchema : void 0
|
|
786
786
|
);
|
|
@@ -789,7 +789,7 @@ var OrderBookResource = class {
|
|
|
789
789
|
/**
|
|
790
790
|
* Get historical order book snapshots with cursor-based pagination
|
|
791
791
|
*
|
|
792
|
-
* @param
|
|
792
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
793
793
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
794
794
|
* @returns CursorResponse with order book snapshots and nextCursor for pagination
|
|
795
795
|
*
|
|
@@ -813,9 +813,9 @@ var OrderBookResource = class {
|
|
|
813
813
|
* }
|
|
814
814
|
* ```
|
|
815
815
|
*/
|
|
816
|
-
async history(
|
|
816
|
+
async history(symbol, params) {
|
|
817
817
|
const response = await this.http.get(
|
|
818
|
-
`${this.basePath}/orderbook/${this.coinTransform(
|
|
818
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}/history`,
|
|
819
819
|
params,
|
|
820
820
|
this.http.validationEnabled ? OrderBookArrayResponseSchema : void 0
|
|
821
821
|
);
|
|
@@ -833,7 +833,7 @@ var OrderBookResource = class {
|
|
|
833
833
|
*
|
|
834
834
|
* For automatic reconstruction, use `historyReconstructed()` instead.
|
|
835
835
|
*
|
|
836
|
-
* @param
|
|
836
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
837
837
|
* @param params - Time range parameters
|
|
838
838
|
* @returns Tick data with checkpoint and deltas
|
|
839
839
|
*
|
|
@@ -853,9 +853,9 @@ var OrderBookResource = class {
|
|
|
853
853
|
* }
|
|
854
854
|
* ```
|
|
855
855
|
*/
|
|
856
|
-
async historyTick(
|
|
856
|
+
async historyTick(symbol, params) {
|
|
857
857
|
const response = await this.http.get(
|
|
858
|
-
`${this.basePath}/orderbook/${this.coinTransform(
|
|
858
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}/history`,
|
|
859
859
|
{
|
|
860
860
|
...params,
|
|
861
861
|
granularity: "tick"
|
|
@@ -880,7 +880,7 @@ var OrderBookResource = class {
|
|
|
880
880
|
* For large time ranges, consider using `historyTick()` with the
|
|
881
881
|
* `OrderBookReconstructor.iterate()` method for memory efficiency.
|
|
882
882
|
*
|
|
883
|
-
* @param
|
|
883
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
884
884
|
* @param params - Time range parameters
|
|
885
885
|
* @param options - Reconstruction options
|
|
886
886
|
* @returns Array of reconstructed orderbook snapshots
|
|
@@ -904,8 +904,8 @@ var OrderBookResource = class {
|
|
|
904
904
|
* );
|
|
905
905
|
* ```
|
|
906
906
|
*/
|
|
907
|
-
async historyReconstructed(
|
|
908
|
-
const tickData = await this.historyTick(
|
|
907
|
+
async historyReconstructed(symbol, params, options = {}) {
|
|
908
|
+
const tickData = await this.historyTick(symbol, params);
|
|
909
909
|
const reconstructor = new OrderBookReconstructor();
|
|
910
910
|
return reconstructor.reconstructAll(tickData.checkpoint, tickData.deltas, options);
|
|
911
911
|
}
|
|
@@ -945,7 +945,7 @@ var OrderBookResource = class {
|
|
|
945
945
|
* per API request and yielding reconstructed orderbook snapshots one at a time.
|
|
946
946
|
* Memory-efficient for processing large time ranges.
|
|
947
947
|
*
|
|
948
|
-
* @param
|
|
948
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
949
949
|
* @param params - Time range parameters
|
|
950
950
|
* @param depth - Maximum price levels to include in output snapshots
|
|
951
951
|
* @yields Reconstructed orderbook snapshots
|
|
@@ -968,7 +968,7 @@ var OrderBookResource = class {
|
|
|
968
968
|
* }
|
|
969
969
|
* ```
|
|
970
970
|
*/
|
|
971
|
-
async *iterateTickHistory(
|
|
971
|
+
async *iterateTickHistory(symbol, params, depth) {
|
|
972
972
|
const startTs = typeof params.start === "string" ? new Date(params.start).getTime() : params.start;
|
|
973
973
|
const endTs = typeof params.end === "string" ? new Date(params.end).getTime() : params.end;
|
|
974
974
|
let cursor = startTs;
|
|
@@ -976,7 +976,7 @@ var OrderBookResource = class {
|
|
|
976
976
|
const MAX_DELTAS_PER_PAGE = 1e3;
|
|
977
977
|
let isFirstPage = true;
|
|
978
978
|
while (cursor < endTs) {
|
|
979
|
-
const tickData = await this.historyTick(
|
|
979
|
+
const tickData = await this.historyTick(symbol, {
|
|
980
980
|
start: cursor,
|
|
981
981
|
end: endTs,
|
|
982
982
|
depth: params.depth
|
|
@@ -1014,12 +1014,12 @@ var TradesResource = class {
|
|
|
1014
1014
|
this.coinTransform = coinTransform;
|
|
1015
1015
|
}
|
|
1016
1016
|
/**
|
|
1017
|
-
* Get trade history for a
|
|
1017
|
+
* Get trade history for a symbol using cursor-based pagination
|
|
1018
1018
|
*
|
|
1019
1019
|
* Uses cursor-based pagination by default, which is more efficient for large datasets.
|
|
1020
1020
|
* Use the `nextCursor` from the response as the `cursor` parameter to get the next page.
|
|
1021
1021
|
*
|
|
1022
|
-
* @param
|
|
1022
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1023
1023
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
1024
1024
|
* @returns Object with trades array and nextCursor for pagination
|
|
1025
1025
|
*
|
|
@@ -1043,9 +1043,9 @@ var TradesResource = class {
|
|
|
1043
1043
|
* }
|
|
1044
1044
|
* ```
|
|
1045
1045
|
*/
|
|
1046
|
-
async list(
|
|
1046
|
+
async list(symbol, params) {
|
|
1047
1047
|
const response = await this.http.get(
|
|
1048
|
-
`${this.basePath}/trades/${this.coinTransform(
|
|
1048
|
+
`${this.basePath}/trades/${this.coinTransform(symbol)}`,
|
|
1049
1049
|
params,
|
|
1050
1050
|
this.http.validationEnabled ? TradeArrayResponseSchema : void 0
|
|
1051
1051
|
);
|
|
@@ -1055,20 +1055,20 @@ var TradesResource = class {
|
|
|
1055
1055
|
};
|
|
1056
1056
|
}
|
|
1057
1057
|
/**
|
|
1058
|
-
* Get most recent trades for a
|
|
1058
|
+
* Get most recent trades for a symbol.
|
|
1059
1059
|
*
|
|
1060
1060
|
* Note: This method is available for Lighter (client.lighter.trades.recent())
|
|
1061
1061
|
* and HIP-3 (client.hyperliquid.hip3.trades.recent()) which have real-time data
|
|
1062
1062
|
* ingestion. Hyperliquid uses hourly backfill so this endpoint is not available
|
|
1063
1063
|
* for Hyperliquid.
|
|
1064
1064
|
*
|
|
1065
|
-
* @param
|
|
1065
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1066
1066
|
* @param limit - Number of trades to return (default: 100)
|
|
1067
1067
|
* @returns Array of recent trades
|
|
1068
1068
|
*/
|
|
1069
|
-
async recent(
|
|
1069
|
+
async recent(symbol, limit) {
|
|
1070
1070
|
const response = await this.http.get(
|
|
1071
|
-
`${this.basePath}/trades/${this.coinTransform(
|
|
1071
|
+
`${this.basePath}/trades/${this.coinTransform(symbol)}/recent`,
|
|
1072
1072
|
{ limit },
|
|
1073
1073
|
this.http.validationEnabled ? TradeArrayResponseSchema : void 0
|
|
1074
1074
|
);
|
|
@@ -1180,15 +1180,15 @@ var FundingResource = class {
|
|
|
1180
1180
|
this.coinTransform = coinTransform;
|
|
1181
1181
|
}
|
|
1182
1182
|
/**
|
|
1183
|
-
* Get funding rate history for a
|
|
1183
|
+
* Get funding rate history for a symbol with cursor-based pagination
|
|
1184
1184
|
*
|
|
1185
|
-
* @param
|
|
1185
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1186
1186
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
1187
1187
|
* @returns CursorResponse with funding rate records and nextCursor for pagination
|
|
1188
1188
|
*/
|
|
1189
|
-
async history(
|
|
1189
|
+
async history(symbol, params) {
|
|
1190
1190
|
const response = await this.http.get(
|
|
1191
|
-
`${this.basePath}/funding/${this.coinTransform(
|
|
1191
|
+
`${this.basePath}/funding/${this.coinTransform(symbol)}`,
|
|
1192
1192
|
params,
|
|
1193
1193
|
this.http.validationEnabled ? FundingRateArrayResponseSchema : void 0
|
|
1194
1194
|
);
|
|
@@ -1198,14 +1198,14 @@ var FundingResource = class {
|
|
|
1198
1198
|
};
|
|
1199
1199
|
}
|
|
1200
1200
|
/**
|
|
1201
|
-
* Get current funding rate for a
|
|
1201
|
+
* Get current funding rate for a symbol
|
|
1202
1202
|
*
|
|
1203
|
-
* @param
|
|
1203
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1204
1204
|
* @returns Current funding rate
|
|
1205
1205
|
*/
|
|
1206
|
-
async current(
|
|
1206
|
+
async current(symbol) {
|
|
1207
1207
|
const response = await this.http.get(
|
|
1208
|
-
`${this.basePath}/funding/${this.coinTransform(
|
|
1208
|
+
`${this.basePath}/funding/${this.coinTransform(symbol)}/current`,
|
|
1209
1209
|
void 0,
|
|
1210
1210
|
this.http.validationEnabled ? FundingRateResponseSchema : void 0
|
|
1211
1211
|
);
|
|
@@ -1221,15 +1221,15 @@ var OpenInterestResource = class {
|
|
|
1221
1221
|
this.coinTransform = coinTransform;
|
|
1222
1222
|
}
|
|
1223
1223
|
/**
|
|
1224
|
-
* Get open interest history for a
|
|
1224
|
+
* Get open interest history for a symbol with cursor-based pagination
|
|
1225
1225
|
*
|
|
1226
|
-
* @param
|
|
1226
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1227
1227
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
1228
1228
|
* @returns CursorResponse with open interest records and nextCursor for pagination
|
|
1229
1229
|
*/
|
|
1230
|
-
async history(
|
|
1230
|
+
async history(symbol, params) {
|
|
1231
1231
|
const response = await this.http.get(
|
|
1232
|
-
`${this.basePath}/openinterest/${this.coinTransform(
|
|
1232
|
+
`${this.basePath}/openinterest/${this.coinTransform(symbol)}`,
|
|
1233
1233
|
params,
|
|
1234
1234
|
this.http.validationEnabled ? OpenInterestArrayResponseSchema : void 0
|
|
1235
1235
|
);
|
|
@@ -1239,14 +1239,14 @@ var OpenInterestResource = class {
|
|
|
1239
1239
|
};
|
|
1240
1240
|
}
|
|
1241
1241
|
/**
|
|
1242
|
-
* Get current open interest for a
|
|
1242
|
+
* Get current open interest for a symbol
|
|
1243
1243
|
*
|
|
1244
|
-
* @param
|
|
1244
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1245
1245
|
* @returns Current open interest
|
|
1246
1246
|
*/
|
|
1247
|
-
async current(
|
|
1247
|
+
async current(symbol) {
|
|
1248
1248
|
const response = await this.http.get(
|
|
1249
|
-
`${this.basePath}/openinterest/${this.coinTransform(
|
|
1249
|
+
`${this.basePath}/openinterest/${this.coinTransform(symbol)}/current`,
|
|
1250
1250
|
void 0,
|
|
1251
1251
|
this.http.validationEnabled ? OpenInterestResponseSchema : void 0
|
|
1252
1252
|
);
|
|
@@ -1264,13 +1264,13 @@ var CandlesResource = class {
|
|
|
1264
1264
|
/**
|
|
1265
1265
|
* Get historical OHLCV candle data with cursor-based pagination
|
|
1266
1266
|
*
|
|
1267
|
-
* @param
|
|
1267
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1268
1268
|
* @param params - Time range, interval, and cursor pagination parameters (start and end are required)
|
|
1269
1269
|
* @returns CursorResponse with candle records and nextCursor for pagination
|
|
1270
1270
|
*/
|
|
1271
|
-
async history(
|
|
1271
|
+
async history(symbol, params) {
|
|
1272
1272
|
const response = await this.http.get(
|
|
1273
|
-
`${this.basePath}/candles/${this.coinTransform(
|
|
1273
|
+
`${this.basePath}/candles/${this.coinTransform(symbol)}`,
|
|
1274
1274
|
params,
|
|
1275
1275
|
this.http.validationEnabled ? CandleArrayResponseSchema : void 0
|
|
1276
1276
|
);
|
|
@@ -1283,20 +1283,21 @@ var CandlesResource = class {
|
|
|
1283
1283
|
|
|
1284
1284
|
// src/resources/liquidations.ts
|
|
1285
1285
|
var LiquidationsResource = class {
|
|
1286
|
-
constructor(http, basePath = "/v1") {
|
|
1286
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
1287
1287
|
this.http = http;
|
|
1288
1288
|
this.basePath = basePath;
|
|
1289
|
+
this.coinTransform = coinTransform;
|
|
1289
1290
|
}
|
|
1290
1291
|
/**
|
|
1291
|
-
* Get liquidation history for a
|
|
1292
|
+
* Get liquidation history for a symbol with cursor-based pagination
|
|
1292
1293
|
*
|
|
1293
|
-
* @param
|
|
1294
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1294
1295
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
1295
1296
|
* @returns CursorResponse with liquidation records and nextCursor for pagination
|
|
1296
1297
|
*/
|
|
1297
|
-
async history(
|
|
1298
|
+
async history(symbol, params) {
|
|
1298
1299
|
const response = await this.http.get(
|
|
1299
|
-
`${this.basePath}/liquidations/${
|
|
1300
|
+
`${this.basePath}/liquidations/${this.coinTransform(symbol)}`,
|
|
1300
1301
|
params,
|
|
1301
1302
|
this.http.validationEnabled ? LiquidationArrayResponseSchema : void 0
|
|
1302
1303
|
);
|
|
@@ -1333,13 +1334,13 @@ var LiquidationsResource = class {
|
|
|
1333
1334
|
* Returns pre-aggregated data with total/long/short USD volumes per bucket,
|
|
1334
1335
|
* reducing data transfer by 100-1000x compared to individual liquidation records.
|
|
1335
1336
|
*
|
|
1336
|
-
* @param
|
|
1337
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1337
1338
|
* @param params - Time range, cursor, and interval parameters
|
|
1338
1339
|
* @returns CursorResponse with liquidation volume buckets
|
|
1339
1340
|
*/
|
|
1340
|
-
async volume(
|
|
1341
|
+
async volume(symbol, params) {
|
|
1341
1342
|
const response = await this.http.get(
|
|
1342
|
-
`${this.basePath}/liquidations/${
|
|
1343
|
+
`${this.basePath}/liquidations/${this.coinTransform(symbol)}/volume`,
|
|
1343
1344
|
params,
|
|
1344
1345
|
this.http.validationEnabled ? LiquidationVolumeArrayResponseSchema : void 0
|
|
1345
1346
|
);
|
|
@@ -1686,6 +1687,145 @@ var Web3Resource = class {
|
|
|
1686
1687
|
}
|
|
1687
1688
|
};
|
|
1688
1689
|
|
|
1690
|
+
// src/resources/orders.ts
|
|
1691
|
+
var OrdersResource = class {
|
|
1692
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
1693
|
+
this.http = http;
|
|
1694
|
+
this.basePath = basePath;
|
|
1695
|
+
this.coinTransform = coinTransform;
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* Get order history for a symbol with cursor-based pagination
|
|
1699
|
+
*
|
|
1700
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1701
|
+
* @param params - Time range, cursor pagination, and filter parameters
|
|
1702
|
+
* @returns CursorResponse with order records and nextCursor for pagination
|
|
1703
|
+
*/
|
|
1704
|
+
async history(symbol, params) {
|
|
1705
|
+
const response = await this.http.get(
|
|
1706
|
+
`${this.basePath}/orders/${this.coinTransform(symbol)}/history`,
|
|
1707
|
+
params
|
|
1708
|
+
);
|
|
1709
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Get order flow for a symbol
|
|
1713
|
+
*
|
|
1714
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1715
|
+
* @param params - Time range and interval parameters
|
|
1716
|
+
* @returns CursorResponse with order flow records
|
|
1717
|
+
*/
|
|
1718
|
+
async flow(symbol, params) {
|
|
1719
|
+
const response = await this.http.get(
|
|
1720
|
+
`${this.basePath}/orders/${this.coinTransform(symbol)}/flow`,
|
|
1721
|
+
params
|
|
1722
|
+
);
|
|
1723
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1724
|
+
}
|
|
1725
|
+
/**
|
|
1726
|
+
* Get TP/SL orders for a symbol with cursor-based pagination
|
|
1727
|
+
*
|
|
1728
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1729
|
+
* @param params - Time range, cursor pagination, and filter parameters
|
|
1730
|
+
* @returns CursorResponse with TP/SL order records
|
|
1731
|
+
*/
|
|
1732
|
+
async tpsl(symbol, params) {
|
|
1733
|
+
const response = await this.http.get(
|
|
1734
|
+
`${this.basePath}/orders/${this.coinTransform(symbol)}/tpsl`,
|
|
1735
|
+
params
|
|
1736
|
+
);
|
|
1737
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
|
|
1741
|
+
// src/resources/l4-orderbook.ts
|
|
1742
|
+
var L4OrderBookResource = class {
|
|
1743
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
1744
|
+
this.http = http;
|
|
1745
|
+
this.basePath = basePath;
|
|
1746
|
+
this.coinTransform = coinTransform;
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Get L4 order book snapshot for a symbol
|
|
1750
|
+
*
|
|
1751
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1752
|
+
* @param params - Optional parameters (timestamp, depth)
|
|
1753
|
+
* @returns L4 order book snapshot
|
|
1754
|
+
*/
|
|
1755
|
+
async get(symbol, params) {
|
|
1756
|
+
const response = await this.http.get(
|
|
1757
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}/l4`,
|
|
1758
|
+
params
|
|
1759
|
+
);
|
|
1760
|
+
return response.data;
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Get L4 order book diffs with cursor-based pagination
|
|
1764
|
+
*
|
|
1765
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1766
|
+
* @param params - Time range and cursor pagination parameters
|
|
1767
|
+
* @returns CursorResponse with L4 orderbook diffs and nextCursor for pagination
|
|
1768
|
+
*/
|
|
1769
|
+
async diffs(symbol, params) {
|
|
1770
|
+
const response = await this.http.get(
|
|
1771
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}/l4/diffs`,
|
|
1772
|
+
params
|
|
1773
|
+
);
|
|
1774
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Get L4 order book history with cursor-based pagination
|
|
1778
|
+
*
|
|
1779
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1780
|
+
* @param params - Time range and cursor pagination parameters
|
|
1781
|
+
* @returns CursorResponse with L4 orderbook snapshots and nextCursor for pagination
|
|
1782
|
+
*/
|
|
1783
|
+
async history(symbol, params) {
|
|
1784
|
+
const response = await this.http.get(
|
|
1785
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}/l4/history`,
|
|
1786
|
+
params
|
|
1787
|
+
);
|
|
1788
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1792
|
+
// src/resources/l3-orderbook.ts
|
|
1793
|
+
var L3OrderBookResource = class {
|
|
1794
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
1795
|
+
this.http = http;
|
|
1796
|
+
this.basePath = basePath;
|
|
1797
|
+
this.coinTransform = coinTransform;
|
|
1798
|
+
}
|
|
1799
|
+
/**
|
|
1800
|
+
* Get L3 order book snapshot for a symbol
|
|
1801
|
+
*
|
|
1802
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1803
|
+
* @param params - Optional parameters (timestamp, depth)
|
|
1804
|
+
* @returns L3 order book snapshot
|
|
1805
|
+
*/
|
|
1806
|
+
async get(symbol, params) {
|
|
1807
|
+
const response = await this.http.get(
|
|
1808
|
+
`${this.basePath}/l3orderbook/${this.coinTransform(symbol)}`,
|
|
1809
|
+
params
|
|
1810
|
+
);
|
|
1811
|
+
return response.data;
|
|
1812
|
+
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Get L3 order book history with cursor-based pagination
|
|
1815
|
+
*
|
|
1816
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1817
|
+
* @param params - Time range and cursor pagination parameters
|
|
1818
|
+
* @returns CursorResponse with L3 orderbook snapshots and nextCursor for pagination
|
|
1819
|
+
*/
|
|
1820
|
+
async history(symbol, params) {
|
|
1821
|
+
const response = await this.http.get(
|
|
1822
|
+
`${this.basePath}/l3orderbook/${this.coinTransform(symbol)}/history`,
|
|
1823
|
+
params
|
|
1824
|
+
);
|
|
1825
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1689
1829
|
// src/exchanges.ts
|
|
1690
1830
|
var HyperliquidClient = class {
|
|
1691
1831
|
/**
|
|
@@ -1716,6 +1856,14 @@ var HyperliquidClient = class {
|
|
|
1716
1856
|
* Liquidation events (May 2025+)
|
|
1717
1857
|
*/
|
|
1718
1858
|
liquidations;
|
|
1859
|
+
/**
|
|
1860
|
+
* Order history, flow, and TP/SL
|
|
1861
|
+
*/
|
|
1862
|
+
orders;
|
|
1863
|
+
/**
|
|
1864
|
+
* L4 order book (snapshots, diffs, history)
|
|
1865
|
+
*/
|
|
1866
|
+
l4Orderbook;
|
|
1719
1867
|
/**
|
|
1720
1868
|
* HIP-3 builder-deployed perpetuals (February 2026+)
|
|
1721
1869
|
*/
|
|
@@ -1731,17 +1879,19 @@ var HyperliquidClient = class {
|
|
|
1731
1879
|
this.openInterest = new OpenInterestResource(http, basePath);
|
|
1732
1880
|
this.candles = new CandlesResource(http, basePath);
|
|
1733
1881
|
this.liquidations = new LiquidationsResource(http, basePath);
|
|
1882
|
+
this.orders = new OrdersResource(http, basePath);
|
|
1883
|
+
this.l4Orderbook = new L4OrderBookResource(http, basePath);
|
|
1734
1884
|
this.hip3 = new Hip3Client(http);
|
|
1735
1885
|
}
|
|
1736
1886
|
/**
|
|
1737
|
-
* Get per-
|
|
1887
|
+
* Get per-symbol data freshness across all data types
|
|
1738
1888
|
*
|
|
1739
|
-
* @param
|
|
1740
|
-
* @returns Per-
|
|
1889
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1890
|
+
* @returns Per-symbol freshness with last_updated and lag_ms for each data type
|
|
1741
1891
|
*/
|
|
1742
|
-
async freshness(
|
|
1892
|
+
async freshness(symbol) {
|
|
1743
1893
|
const response = await this.http.get(
|
|
1744
|
-
`/v1/hyperliquid/freshness/${
|
|
1894
|
+
`/v1/hyperliquid/freshness/${symbol.toUpperCase()}`,
|
|
1745
1895
|
void 0,
|
|
1746
1896
|
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
1747
1897
|
);
|
|
@@ -1750,12 +1900,12 @@ var HyperliquidClient = class {
|
|
|
1750
1900
|
/**
|
|
1751
1901
|
* Get combined market summary (price, funding, OI, volume, liquidations) in one call
|
|
1752
1902
|
*
|
|
1753
|
-
* @param
|
|
1903
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1754
1904
|
* @returns Combined market summary
|
|
1755
1905
|
*/
|
|
1756
|
-
async summary(
|
|
1906
|
+
async summary(symbol) {
|
|
1757
1907
|
const response = await this.http.get(
|
|
1758
|
-
`/v1/hyperliquid/summary/${
|
|
1908
|
+
`/v1/hyperliquid/summary/${symbol.toUpperCase()}`,
|
|
1759
1909
|
void 0,
|
|
1760
1910
|
this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
|
|
1761
1911
|
);
|
|
@@ -1764,13 +1914,13 @@ var HyperliquidClient = class {
|
|
|
1764
1914
|
/**
|
|
1765
1915
|
* Get mark/oracle/mid price history (projected from OI data)
|
|
1766
1916
|
*
|
|
1767
|
-
* @param
|
|
1917
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1768
1918
|
* @param params - Time range, cursor, and interval parameters
|
|
1769
1919
|
* @returns CursorResponse with price snapshots
|
|
1770
1920
|
*/
|
|
1771
|
-
async priceHistory(
|
|
1921
|
+
async priceHistory(symbol, params) {
|
|
1772
1922
|
const response = await this.http.get(
|
|
1773
|
-
`/v1/hyperliquid/prices/${
|
|
1923
|
+
`/v1/hyperliquid/prices/${symbol.toUpperCase()}`,
|
|
1774
1924
|
params,
|
|
1775
1925
|
this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
|
|
1776
1926
|
);
|
|
@@ -1805,6 +1955,18 @@ var Hip3Client = class {
|
|
|
1805
1955
|
* OHLCV candle data
|
|
1806
1956
|
*/
|
|
1807
1957
|
candles;
|
|
1958
|
+
/**
|
|
1959
|
+
* Liquidation events
|
|
1960
|
+
*/
|
|
1961
|
+
liquidations;
|
|
1962
|
+
/**
|
|
1963
|
+
* Order history, flow, and TP/SL
|
|
1964
|
+
*/
|
|
1965
|
+
orders;
|
|
1966
|
+
/**
|
|
1967
|
+
* L4 order book (snapshots, diffs, history)
|
|
1968
|
+
*/
|
|
1969
|
+
l4Orderbook;
|
|
1808
1970
|
http;
|
|
1809
1971
|
constructor(http) {
|
|
1810
1972
|
this.http = http;
|
|
@@ -1816,16 +1978,19 @@ var Hip3Client = class {
|
|
|
1816
1978
|
this.funding = new FundingResource(http, basePath, coinTransform);
|
|
1817
1979
|
this.openInterest = new OpenInterestResource(http, basePath, coinTransform);
|
|
1818
1980
|
this.candles = new CandlesResource(http, basePath, coinTransform);
|
|
1981
|
+
this.liquidations = new LiquidationsResource(http, basePath, coinTransform);
|
|
1982
|
+
this.orders = new OrdersResource(http, basePath, coinTransform);
|
|
1983
|
+
this.l4Orderbook = new L4OrderBookResource(http, basePath, coinTransform);
|
|
1819
1984
|
}
|
|
1820
1985
|
/**
|
|
1821
|
-
* Get per-
|
|
1986
|
+
* Get per-symbol data freshness across all data types
|
|
1822
1987
|
*
|
|
1823
|
-
* @param
|
|
1824
|
-
* @returns Per-
|
|
1988
|
+
* @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
|
|
1989
|
+
* @returns Per-symbol freshness with last_updated and lag_ms for each data type
|
|
1825
1990
|
*/
|
|
1826
|
-
async freshness(
|
|
1991
|
+
async freshness(symbol) {
|
|
1827
1992
|
const response = await this.http.get(
|
|
1828
|
-
`/v1/hyperliquid/hip3/freshness/${
|
|
1993
|
+
`/v1/hyperliquid/hip3/freshness/${symbol}`,
|
|
1829
1994
|
void 0,
|
|
1830
1995
|
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
1831
1996
|
);
|
|
@@ -1834,12 +1999,12 @@ var Hip3Client = class {
|
|
|
1834
1999
|
/**
|
|
1835
2000
|
* Get combined market summary (price, funding, OI) in one call
|
|
1836
2001
|
*
|
|
1837
|
-
* @param
|
|
2002
|
+
* @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
|
|
1838
2003
|
* @returns Combined market summary
|
|
1839
2004
|
*/
|
|
1840
|
-
async summary(
|
|
2005
|
+
async summary(symbol) {
|
|
1841
2006
|
const response = await this.http.get(
|
|
1842
|
-
`/v1/hyperliquid/hip3/summary/${
|
|
2007
|
+
`/v1/hyperliquid/hip3/summary/${symbol}`,
|
|
1843
2008
|
void 0,
|
|
1844
2009
|
this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
|
|
1845
2010
|
);
|
|
@@ -1848,13 +2013,13 @@ var Hip3Client = class {
|
|
|
1848
2013
|
/**
|
|
1849
2014
|
* Get mark/oracle/mid price history (projected from OI data)
|
|
1850
2015
|
*
|
|
1851
|
-
* @param
|
|
2016
|
+
* @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
|
|
1852
2017
|
* @param params - Time range, cursor, and interval parameters
|
|
1853
2018
|
* @returns CursorResponse with price snapshots
|
|
1854
2019
|
*/
|
|
1855
|
-
async priceHistory(
|
|
2020
|
+
async priceHistory(symbol, params) {
|
|
1856
2021
|
const response = await this.http.get(
|
|
1857
|
-
`/v1/hyperliquid/hip3/prices/${
|
|
2022
|
+
`/v1/hyperliquid/hip3/prices/${symbol}`,
|
|
1858
2023
|
params,
|
|
1859
2024
|
this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
|
|
1860
2025
|
);
|
|
@@ -1889,6 +2054,10 @@ var LighterClient = class {
|
|
|
1889
2054
|
* OHLCV candle data
|
|
1890
2055
|
*/
|
|
1891
2056
|
candles;
|
|
2057
|
+
/**
|
|
2058
|
+
* L3 order book (Lighter only)
|
|
2059
|
+
*/
|
|
2060
|
+
l3Orderbook;
|
|
1892
2061
|
http;
|
|
1893
2062
|
constructor(http) {
|
|
1894
2063
|
this.http = http;
|
|
@@ -1899,16 +2068,17 @@ var LighterClient = class {
|
|
|
1899
2068
|
this.funding = new FundingResource(http, basePath);
|
|
1900
2069
|
this.openInterest = new OpenInterestResource(http, basePath);
|
|
1901
2070
|
this.candles = new CandlesResource(http, basePath);
|
|
2071
|
+
this.l3Orderbook = new L3OrderBookResource(http, basePath);
|
|
1902
2072
|
}
|
|
1903
2073
|
/**
|
|
1904
|
-
* Get per-
|
|
2074
|
+
* Get per-symbol data freshness across all data types
|
|
1905
2075
|
*
|
|
1906
|
-
* @param
|
|
1907
|
-
* @returns Per-
|
|
2076
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
2077
|
+
* @returns Per-symbol freshness with last_updated and lag_ms for each data type
|
|
1908
2078
|
*/
|
|
1909
|
-
async freshness(
|
|
2079
|
+
async freshness(symbol) {
|
|
1910
2080
|
const response = await this.http.get(
|
|
1911
|
-
`/v1/lighter/freshness/${
|
|
2081
|
+
`/v1/lighter/freshness/${symbol.toUpperCase()}`,
|
|
1912
2082
|
void 0,
|
|
1913
2083
|
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
1914
2084
|
);
|
|
@@ -1917,12 +2087,12 @@ var LighterClient = class {
|
|
|
1917
2087
|
/**
|
|
1918
2088
|
* Get combined market summary (price, funding, OI) in one call
|
|
1919
2089
|
*
|
|
1920
|
-
* @param
|
|
2090
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1921
2091
|
* @returns Combined market summary
|
|
1922
2092
|
*/
|
|
1923
|
-
async summary(
|
|
2093
|
+
async summary(symbol) {
|
|
1924
2094
|
const response = await this.http.get(
|
|
1925
|
-
`/v1/lighter/summary/${
|
|
2095
|
+
`/v1/lighter/summary/${symbol.toUpperCase()}`,
|
|
1926
2096
|
void 0,
|
|
1927
2097
|
this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
|
|
1928
2098
|
);
|
|
@@ -1931,13 +2101,13 @@ var LighterClient = class {
|
|
|
1931
2101
|
/**
|
|
1932
2102
|
* Get mark/oracle price history (projected from OI data)
|
|
1933
2103
|
*
|
|
1934
|
-
* @param
|
|
2104
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1935
2105
|
* @param params - Time range, cursor, and interval parameters
|
|
1936
2106
|
* @returns CursorResponse with price snapshots
|
|
1937
2107
|
*/
|
|
1938
|
-
async priceHistory(
|
|
2108
|
+
async priceHistory(symbol, params) {
|
|
1939
2109
|
const response = await this.http.get(
|
|
1940
|
-
`/v1/lighter/prices/${
|
|
2110
|
+
`/v1/lighter/prices/${symbol.toUpperCase()}`,
|
|
1941
2111
|
params,
|
|
1942
2112
|
this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
|
|
1943
2113
|
);
|