@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.mjs
CHANGED
|
@@ -681,15 +681,15 @@ var OrderBookResource = class {
|
|
|
681
681
|
this.coinTransform = coinTransform;
|
|
682
682
|
}
|
|
683
683
|
/**
|
|
684
|
-
* Get order book snapshot for a
|
|
684
|
+
* Get order book snapshot for a symbol
|
|
685
685
|
*
|
|
686
|
-
* @param
|
|
686
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
687
687
|
* @param params - Optional parameters
|
|
688
688
|
* @returns Order book snapshot
|
|
689
689
|
*/
|
|
690
|
-
async get(
|
|
690
|
+
async get(symbol, params) {
|
|
691
691
|
const response = await this.http.get(
|
|
692
|
-
`${this.basePath}/orderbook/${this.coinTransform(
|
|
692
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}`,
|
|
693
693
|
params,
|
|
694
694
|
this.http.validationEnabled ? OrderBookResponseSchema : void 0
|
|
695
695
|
);
|
|
@@ -698,7 +698,7 @@ var OrderBookResource = class {
|
|
|
698
698
|
/**
|
|
699
699
|
* Get historical order book snapshots with cursor-based pagination
|
|
700
700
|
*
|
|
701
|
-
* @param
|
|
701
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
702
702
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
703
703
|
* @returns CursorResponse with order book snapshots and nextCursor for pagination
|
|
704
704
|
*
|
|
@@ -722,9 +722,9 @@ var OrderBookResource = class {
|
|
|
722
722
|
* }
|
|
723
723
|
* ```
|
|
724
724
|
*/
|
|
725
|
-
async history(
|
|
725
|
+
async history(symbol, params) {
|
|
726
726
|
const response = await this.http.get(
|
|
727
|
-
`${this.basePath}/orderbook/${this.coinTransform(
|
|
727
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}/history`,
|
|
728
728
|
params,
|
|
729
729
|
this.http.validationEnabled ? OrderBookArrayResponseSchema : void 0
|
|
730
730
|
);
|
|
@@ -742,7 +742,7 @@ var OrderBookResource = class {
|
|
|
742
742
|
*
|
|
743
743
|
* For automatic reconstruction, use `historyReconstructed()` instead.
|
|
744
744
|
*
|
|
745
|
-
* @param
|
|
745
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
746
746
|
* @param params - Time range parameters
|
|
747
747
|
* @returns Tick data with checkpoint and deltas
|
|
748
748
|
*
|
|
@@ -762,9 +762,9 @@ var OrderBookResource = class {
|
|
|
762
762
|
* }
|
|
763
763
|
* ```
|
|
764
764
|
*/
|
|
765
|
-
async historyTick(
|
|
765
|
+
async historyTick(symbol, params) {
|
|
766
766
|
const response = await this.http.get(
|
|
767
|
-
`${this.basePath}/orderbook/${this.coinTransform(
|
|
767
|
+
`${this.basePath}/orderbook/${this.coinTransform(symbol)}/history`,
|
|
768
768
|
{
|
|
769
769
|
...params,
|
|
770
770
|
granularity: "tick"
|
|
@@ -789,7 +789,7 @@ var OrderBookResource = class {
|
|
|
789
789
|
* For large time ranges, consider using `historyTick()` with the
|
|
790
790
|
* `OrderBookReconstructor.iterate()` method for memory efficiency.
|
|
791
791
|
*
|
|
792
|
-
* @param
|
|
792
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
793
793
|
* @param params - Time range parameters
|
|
794
794
|
* @param options - Reconstruction options
|
|
795
795
|
* @returns Array of reconstructed orderbook snapshots
|
|
@@ -813,8 +813,8 @@ var OrderBookResource = class {
|
|
|
813
813
|
* );
|
|
814
814
|
* ```
|
|
815
815
|
*/
|
|
816
|
-
async historyReconstructed(
|
|
817
|
-
const tickData = await this.historyTick(
|
|
816
|
+
async historyReconstructed(symbol, params, options = {}) {
|
|
817
|
+
const tickData = await this.historyTick(symbol, params);
|
|
818
818
|
const reconstructor = new OrderBookReconstructor();
|
|
819
819
|
return reconstructor.reconstructAll(tickData.checkpoint, tickData.deltas, options);
|
|
820
820
|
}
|
|
@@ -854,7 +854,7 @@ var OrderBookResource = class {
|
|
|
854
854
|
* per API request and yielding reconstructed orderbook snapshots one at a time.
|
|
855
855
|
* Memory-efficient for processing large time ranges.
|
|
856
856
|
*
|
|
857
|
-
* @param
|
|
857
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
858
858
|
* @param params - Time range parameters
|
|
859
859
|
* @param depth - Maximum price levels to include in output snapshots
|
|
860
860
|
* @yields Reconstructed orderbook snapshots
|
|
@@ -877,7 +877,7 @@ var OrderBookResource = class {
|
|
|
877
877
|
* }
|
|
878
878
|
* ```
|
|
879
879
|
*/
|
|
880
|
-
async *iterateTickHistory(
|
|
880
|
+
async *iterateTickHistory(symbol, params, depth) {
|
|
881
881
|
const startTs = typeof params.start === "string" ? new Date(params.start).getTime() : params.start;
|
|
882
882
|
const endTs = typeof params.end === "string" ? new Date(params.end).getTime() : params.end;
|
|
883
883
|
let cursor = startTs;
|
|
@@ -885,7 +885,7 @@ var OrderBookResource = class {
|
|
|
885
885
|
const MAX_DELTAS_PER_PAGE = 1e3;
|
|
886
886
|
let isFirstPage = true;
|
|
887
887
|
while (cursor < endTs) {
|
|
888
|
-
const tickData = await this.historyTick(
|
|
888
|
+
const tickData = await this.historyTick(symbol, {
|
|
889
889
|
start: cursor,
|
|
890
890
|
end: endTs,
|
|
891
891
|
depth: params.depth
|
|
@@ -923,12 +923,12 @@ var TradesResource = class {
|
|
|
923
923
|
this.coinTransform = coinTransform;
|
|
924
924
|
}
|
|
925
925
|
/**
|
|
926
|
-
* Get trade history for a
|
|
926
|
+
* Get trade history for a symbol using cursor-based pagination
|
|
927
927
|
*
|
|
928
928
|
* Uses cursor-based pagination by default, which is more efficient for large datasets.
|
|
929
929
|
* Use the `nextCursor` from the response as the `cursor` parameter to get the next page.
|
|
930
930
|
*
|
|
931
|
-
* @param
|
|
931
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
932
932
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
933
933
|
* @returns Object with trades array and nextCursor for pagination
|
|
934
934
|
*
|
|
@@ -952,9 +952,9 @@ var TradesResource = class {
|
|
|
952
952
|
* }
|
|
953
953
|
* ```
|
|
954
954
|
*/
|
|
955
|
-
async list(
|
|
955
|
+
async list(symbol, params) {
|
|
956
956
|
const response = await this.http.get(
|
|
957
|
-
`${this.basePath}/trades/${this.coinTransform(
|
|
957
|
+
`${this.basePath}/trades/${this.coinTransform(symbol)}`,
|
|
958
958
|
params,
|
|
959
959
|
this.http.validationEnabled ? TradeArrayResponseSchema : void 0
|
|
960
960
|
);
|
|
@@ -964,20 +964,20 @@ var TradesResource = class {
|
|
|
964
964
|
};
|
|
965
965
|
}
|
|
966
966
|
/**
|
|
967
|
-
* Get most recent trades for a
|
|
967
|
+
* Get most recent trades for a symbol.
|
|
968
968
|
*
|
|
969
969
|
* Note: This method is available for Lighter (client.lighter.trades.recent())
|
|
970
970
|
* and HIP-3 (client.hyperliquid.hip3.trades.recent()) which have real-time data
|
|
971
971
|
* ingestion. Hyperliquid uses hourly backfill so this endpoint is not available
|
|
972
972
|
* for Hyperliquid.
|
|
973
973
|
*
|
|
974
|
-
* @param
|
|
974
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
975
975
|
* @param limit - Number of trades to return (default: 100)
|
|
976
976
|
* @returns Array of recent trades
|
|
977
977
|
*/
|
|
978
|
-
async recent(
|
|
978
|
+
async recent(symbol, limit) {
|
|
979
979
|
const response = await this.http.get(
|
|
980
|
-
`${this.basePath}/trades/${this.coinTransform(
|
|
980
|
+
`${this.basePath}/trades/${this.coinTransform(symbol)}/recent`,
|
|
981
981
|
{ limit },
|
|
982
982
|
this.http.validationEnabled ? TradeArrayResponseSchema : void 0
|
|
983
983
|
);
|
|
@@ -1089,15 +1089,15 @@ var FundingResource = class {
|
|
|
1089
1089
|
this.coinTransform = coinTransform;
|
|
1090
1090
|
}
|
|
1091
1091
|
/**
|
|
1092
|
-
* Get funding rate history for a
|
|
1092
|
+
* Get funding rate history for a symbol with cursor-based pagination
|
|
1093
1093
|
*
|
|
1094
|
-
* @param
|
|
1094
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1095
1095
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
1096
1096
|
* @returns CursorResponse with funding rate records and nextCursor for pagination
|
|
1097
1097
|
*/
|
|
1098
|
-
async history(
|
|
1098
|
+
async history(symbol, params) {
|
|
1099
1099
|
const response = await this.http.get(
|
|
1100
|
-
`${this.basePath}/funding/${this.coinTransform(
|
|
1100
|
+
`${this.basePath}/funding/${this.coinTransform(symbol)}`,
|
|
1101
1101
|
params,
|
|
1102
1102
|
this.http.validationEnabled ? FundingRateArrayResponseSchema : void 0
|
|
1103
1103
|
);
|
|
@@ -1107,14 +1107,14 @@ var FundingResource = class {
|
|
|
1107
1107
|
};
|
|
1108
1108
|
}
|
|
1109
1109
|
/**
|
|
1110
|
-
* Get current funding rate for a
|
|
1110
|
+
* Get current funding rate for a symbol
|
|
1111
1111
|
*
|
|
1112
|
-
* @param
|
|
1112
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1113
1113
|
* @returns Current funding rate
|
|
1114
1114
|
*/
|
|
1115
|
-
async current(
|
|
1115
|
+
async current(symbol) {
|
|
1116
1116
|
const response = await this.http.get(
|
|
1117
|
-
`${this.basePath}/funding/${this.coinTransform(
|
|
1117
|
+
`${this.basePath}/funding/${this.coinTransform(symbol)}/current`,
|
|
1118
1118
|
void 0,
|
|
1119
1119
|
this.http.validationEnabled ? FundingRateResponseSchema : void 0
|
|
1120
1120
|
);
|
|
@@ -1130,15 +1130,15 @@ var OpenInterestResource = class {
|
|
|
1130
1130
|
this.coinTransform = coinTransform;
|
|
1131
1131
|
}
|
|
1132
1132
|
/**
|
|
1133
|
-
* Get open interest history for a
|
|
1133
|
+
* Get open interest history for a symbol with cursor-based pagination
|
|
1134
1134
|
*
|
|
1135
|
-
* @param
|
|
1135
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1136
1136
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
1137
1137
|
* @returns CursorResponse with open interest records and nextCursor for pagination
|
|
1138
1138
|
*/
|
|
1139
|
-
async history(
|
|
1139
|
+
async history(symbol, params) {
|
|
1140
1140
|
const response = await this.http.get(
|
|
1141
|
-
`${this.basePath}/openinterest/${this.coinTransform(
|
|
1141
|
+
`${this.basePath}/openinterest/${this.coinTransform(symbol)}`,
|
|
1142
1142
|
params,
|
|
1143
1143
|
this.http.validationEnabled ? OpenInterestArrayResponseSchema : void 0
|
|
1144
1144
|
);
|
|
@@ -1148,14 +1148,14 @@ var OpenInterestResource = class {
|
|
|
1148
1148
|
};
|
|
1149
1149
|
}
|
|
1150
1150
|
/**
|
|
1151
|
-
* Get current open interest for a
|
|
1151
|
+
* Get current open interest for a symbol
|
|
1152
1152
|
*
|
|
1153
|
-
* @param
|
|
1153
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1154
1154
|
* @returns Current open interest
|
|
1155
1155
|
*/
|
|
1156
|
-
async current(
|
|
1156
|
+
async current(symbol) {
|
|
1157
1157
|
const response = await this.http.get(
|
|
1158
|
-
`${this.basePath}/openinterest/${this.coinTransform(
|
|
1158
|
+
`${this.basePath}/openinterest/${this.coinTransform(symbol)}/current`,
|
|
1159
1159
|
void 0,
|
|
1160
1160
|
this.http.validationEnabled ? OpenInterestResponseSchema : void 0
|
|
1161
1161
|
);
|
|
@@ -1173,13 +1173,13 @@ var CandlesResource = class {
|
|
|
1173
1173
|
/**
|
|
1174
1174
|
* Get historical OHLCV candle data with cursor-based pagination
|
|
1175
1175
|
*
|
|
1176
|
-
* @param
|
|
1176
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1177
1177
|
* @param params - Time range, interval, and cursor pagination parameters (start and end are required)
|
|
1178
1178
|
* @returns CursorResponse with candle records and nextCursor for pagination
|
|
1179
1179
|
*/
|
|
1180
|
-
async history(
|
|
1180
|
+
async history(symbol, params) {
|
|
1181
1181
|
const response = await this.http.get(
|
|
1182
|
-
`${this.basePath}/candles/${this.coinTransform(
|
|
1182
|
+
`${this.basePath}/candles/${this.coinTransform(symbol)}`,
|
|
1183
1183
|
params,
|
|
1184
1184
|
this.http.validationEnabled ? CandleArrayResponseSchema : void 0
|
|
1185
1185
|
);
|
|
@@ -1192,20 +1192,21 @@ var CandlesResource = class {
|
|
|
1192
1192
|
|
|
1193
1193
|
// src/resources/liquidations.ts
|
|
1194
1194
|
var LiquidationsResource = class {
|
|
1195
|
-
constructor(http, basePath = "/v1") {
|
|
1195
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
1196
1196
|
this.http = http;
|
|
1197
1197
|
this.basePath = basePath;
|
|
1198
|
+
this.coinTransform = coinTransform;
|
|
1198
1199
|
}
|
|
1199
1200
|
/**
|
|
1200
|
-
* Get liquidation history for a
|
|
1201
|
+
* Get liquidation history for a symbol with cursor-based pagination
|
|
1201
1202
|
*
|
|
1202
|
-
* @param
|
|
1203
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1203
1204
|
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
1204
1205
|
* @returns CursorResponse with liquidation records and nextCursor for pagination
|
|
1205
1206
|
*/
|
|
1206
|
-
async history(
|
|
1207
|
+
async history(symbol, params) {
|
|
1207
1208
|
const response = await this.http.get(
|
|
1208
|
-
`${this.basePath}/liquidations/${
|
|
1209
|
+
`${this.basePath}/liquidations/${this.coinTransform(symbol)}`,
|
|
1209
1210
|
params,
|
|
1210
1211
|
this.http.validationEnabled ? LiquidationArrayResponseSchema : void 0
|
|
1211
1212
|
);
|
|
@@ -1242,13 +1243,13 @@ var LiquidationsResource = class {
|
|
|
1242
1243
|
* Returns pre-aggregated data with total/long/short USD volumes per bucket,
|
|
1243
1244
|
* reducing data transfer by 100-1000x compared to individual liquidation records.
|
|
1244
1245
|
*
|
|
1245
|
-
* @param
|
|
1246
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1246
1247
|
* @param params - Time range, cursor, and interval parameters
|
|
1247
1248
|
* @returns CursorResponse with liquidation volume buckets
|
|
1248
1249
|
*/
|
|
1249
|
-
async volume(
|
|
1250
|
+
async volume(symbol, params) {
|
|
1250
1251
|
const response = await this.http.get(
|
|
1251
|
-
`${this.basePath}/liquidations/${
|
|
1252
|
+
`${this.basePath}/liquidations/${this.coinTransform(symbol)}/volume`,
|
|
1252
1253
|
params,
|
|
1253
1254
|
this.http.validationEnabled ? LiquidationVolumeArrayResponseSchema : void 0
|
|
1254
1255
|
);
|
|
@@ -1595,6 +1596,145 @@ var Web3Resource = class {
|
|
|
1595
1596
|
}
|
|
1596
1597
|
};
|
|
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
|
+
|
|
1598
1738
|
// src/exchanges.ts
|
|
1599
1739
|
var HyperliquidClient = class {
|
|
1600
1740
|
/**
|
|
@@ -1625,6 +1765,14 @@ var HyperliquidClient = class {
|
|
|
1625
1765
|
* Liquidation events (May 2025+)
|
|
1626
1766
|
*/
|
|
1627
1767
|
liquidations;
|
|
1768
|
+
/**
|
|
1769
|
+
* Order history, flow, and TP/SL
|
|
1770
|
+
*/
|
|
1771
|
+
orders;
|
|
1772
|
+
/**
|
|
1773
|
+
* L4 order book (snapshots, diffs, history)
|
|
1774
|
+
*/
|
|
1775
|
+
l4Orderbook;
|
|
1628
1776
|
/**
|
|
1629
1777
|
* HIP-3 builder-deployed perpetuals (February 2026+)
|
|
1630
1778
|
*/
|
|
@@ -1640,17 +1788,19 @@ var HyperliquidClient = class {
|
|
|
1640
1788
|
this.openInterest = new OpenInterestResource(http, basePath);
|
|
1641
1789
|
this.candles = new CandlesResource(http, basePath);
|
|
1642
1790
|
this.liquidations = new LiquidationsResource(http, basePath);
|
|
1791
|
+
this.orders = new OrdersResource(http, basePath);
|
|
1792
|
+
this.l4Orderbook = new L4OrderBookResource(http, basePath);
|
|
1643
1793
|
this.hip3 = new Hip3Client(http);
|
|
1644
1794
|
}
|
|
1645
1795
|
/**
|
|
1646
|
-
* Get per-
|
|
1796
|
+
* Get per-symbol data freshness across all data types
|
|
1647
1797
|
*
|
|
1648
|
-
* @param
|
|
1649
|
-
* @returns Per-
|
|
1798
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1799
|
+
* @returns Per-symbol freshness with last_updated and lag_ms for each data type
|
|
1650
1800
|
*/
|
|
1651
|
-
async freshness(
|
|
1801
|
+
async freshness(symbol) {
|
|
1652
1802
|
const response = await this.http.get(
|
|
1653
|
-
`/v1/hyperliquid/freshness/${
|
|
1803
|
+
`/v1/hyperliquid/freshness/${symbol.toUpperCase()}`,
|
|
1654
1804
|
void 0,
|
|
1655
1805
|
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
1656
1806
|
);
|
|
@@ -1659,12 +1809,12 @@ var HyperliquidClient = class {
|
|
|
1659
1809
|
/**
|
|
1660
1810
|
* Get combined market summary (price, funding, OI, volume, liquidations) in one call
|
|
1661
1811
|
*
|
|
1662
|
-
* @param
|
|
1812
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1663
1813
|
* @returns Combined market summary
|
|
1664
1814
|
*/
|
|
1665
|
-
async summary(
|
|
1815
|
+
async summary(symbol) {
|
|
1666
1816
|
const response = await this.http.get(
|
|
1667
|
-
`/v1/hyperliquid/summary/${
|
|
1817
|
+
`/v1/hyperliquid/summary/${symbol.toUpperCase()}`,
|
|
1668
1818
|
void 0,
|
|
1669
1819
|
this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
|
|
1670
1820
|
);
|
|
@@ -1673,13 +1823,13 @@ var HyperliquidClient = class {
|
|
|
1673
1823
|
/**
|
|
1674
1824
|
* Get mark/oracle/mid price history (projected from OI data)
|
|
1675
1825
|
*
|
|
1676
|
-
* @param
|
|
1826
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1677
1827
|
* @param params - Time range, cursor, and interval parameters
|
|
1678
1828
|
* @returns CursorResponse with price snapshots
|
|
1679
1829
|
*/
|
|
1680
|
-
async priceHistory(
|
|
1830
|
+
async priceHistory(symbol, params) {
|
|
1681
1831
|
const response = await this.http.get(
|
|
1682
|
-
`/v1/hyperliquid/prices/${
|
|
1832
|
+
`/v1/hyperliquid/prices/${symbol.toUpperCase()}`,
|
|
1683
1833
|
params,
|
|
1684
1834
|
this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
|
|
1685
1835
|
);
|
|
@@ -1714,6 +1864,18 @@ var Hip3Client = class {
|
|
|
1714
1864
|
* OHLCV candle data
|
|
1715
1865
|
*/
|
|
1716
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;
|
|
1717
1879
|
http;
|
|
1718
1880
|
constructor(http) {
|
|
1719
1881
|
this.http = http;
|
|
@@ -1725,16 +1887,19 @@ var Hip3Client = class {
|
|
|
1725
1887
|
this.funding = new FundingResource(http, basePath, coinTransform);
|
|
1726
1888
|
this.openInterest = new OpenInterestResource(http, basePath, coinTransform);
|
|
1727
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);
|
|
1728
1893
|
}
|
|
1729
1894
|
/**
|
|
1730
|
-
* Get per-
|
|
1895
|
+
* Get per-symbol data freshness across all data types
|
|
1731
1896
|
*
|
|
1732
|
-
* @param
|
|
1733
|
-
* @returns Per-
|
|
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
|
|
1734
1899
|
*/
|
|
1735
|
-
async freshness(
|
|
1900
|
+
async freshness(symbol) {
|
|
1736
1901
|
const response = await this.http.get(
|
|
1737
|
-
`/v1/hyperliquid/hip3/freshness/${
|
|
1902
|
+
`/v1/hyperliquid/hip3/freshness/${symbol}`,
|
|
1738
1903
|
void 0,
|
|
1739
1904
|
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
1740
1905
|
);
|
|
@@ -1743,12 +1908,12 @@ var Hip3Client = class {
|
|
|
1743
1908
|
/**
|
|
1744
1909
|
* Get combined market summary (price, funding, OI) in one call
|
|
1745
1910
|
*
|
|
1746
|
-
* @param
|
|
1911
|
+
* @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
|
|
1747
1912
|
* @returns Combined market summary
|
|
1748
1913
|
*/
|
|
1749
|
-
async summary(
|
|
1914
|
+
async summary(symbol) {
|
|
1750
1915
|
const response = await this.http.get(
|
|
1751
|
-
`/v1/hyperliquid/hip3/summary/${
|
|
1916
|
+
`/v1/hyperliquid/hip3/summary/${symbol}`,
|
|
1752
1917
|
void 0,
|
|
1753
1918
|
this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
|
|
1754
1919
|
);
|
|
@@ -1757,13 +1922,13 @@ var Hip3Client = class {
|
|
|
1757
1922
|
/**
|
|
1758
1923
|
* Get mark/oracle/mid price history (projected from OI data)
|
|
1759
1924
|
*
|
|
1760
|
-
* @param
|
|
1925
|
+
* @param symbol - The symbol (case-sensitive, e.g., 'km:US500')
|
|
1761
1926
|
* @param params - Time range, cursor, and interval parameters
|
|
1762
1927
|
* @returns CursorResponse with price snapshots
|
|
1763
1928
|
*/
|
|
1764
|
-
async priceHistory(
|
|
1929
|
+
async priceHistory(symbol, params) {
|
|
1765
1930
|
const response = await this.http.get(
|
|
1766
|
-
`/v1/hyperliquid/hip3/prices/${
|
|
1931
|
+
`/v1/hyperliquid/hip3/prices/${symbol}`,
|
|
1767
1932
|
params,
|
|
1768
1933
|
this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
|
|
1769
1934
|
);
|
|
@@ -1798,6 +1963,10 @@ var LighterClient = class {
|
|
|
1798
1963
|
* OHLCV candle data
|
|
1799
1964
|
*/
|
|
1800
1965
|
candles;
|
|
1966
|
+
/**
|
|
1967
|
+
* L3 order book (Lighter only)
|
|
1968
|
+
*/
|
|
1969
|
+
l3Orderbook;
|
|
1801
1970
|
http;
|
|
1802
1971
|
constructor(http) {
|
|
1803
1972
|
this.http = http;
|
|
@@ -1808,16 +1977,17 @@ var LighterClient = class {
|
|
|
1808
1977
|
this.funding = new FundingResource(http, basePath);
|
|
1809
1978
|
this.openInterest = new OpenInterestResource(http, basePath);
|
|
1810
1979
|
this.candles = new CandlesResource(http, basePath);
|
|
1980
|
+
this.l3Orderbook = new L3OrderBookResource(http, basePath);
|
|
1811
1981
|
}
|
|
1812
1982
|
/**
|
|
1813
|
-
* Get per-
|
|
1983
|
+
* Get per-symbol data freshness across all data types
|
|
1814
1984
|
*
|
|
1815
|
-
* @param
|
|
1816
|
-
* @returns Per-
|
|
1985
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1986
|
+
* @returns Per-symbol freshness with last_updated and lag_ms for each data type
|
|
1817
1987
|
*/
|
|
1818
|
-
async freshness(
|
|
1988
|
+
async freshness(symbol) {
|
|
1819
1989
|
const response = await this.http.get(
|
|
1820
|
-
`/v1/lighter/freshness/${
|
|
1990
|
+
`/v1/lighter/freshness/${symbol.toUpperCase()}`,
|
|
1821
1991
|
void 0,
|
|
1822
1992
|
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
1823
1993
|
);
|
|
@@ -1826,12 +1996,12 @@ var LighterClient = class {
|
|
|
1826
1996
|
/**
|
|
1827
1997
|
* Get combined market summary (price, funding, OI) in one call
|
|
1828
1998
|
*
|
|
1829
|
-
* @param
|
|
1999
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1830
2000
|
* @returns Combined market summary
|
|
1831
2001
|
*/
|
|
1832
|
-
async summary(
|
|
2002
|
+
async summary(symbol) {
|
|
1833
2003
|
const response = await this.http.get(
|
|
1834
|
-
`/v1/lighter/summary/${
|
|
2004
|
+
`/v1/lighter/summary/${symbol.toUpperCase()}`,
|
|
1835
2005
|
void 0,
|
|
1836
2006
|
this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
|
|
1837
2007
|
);
|
|
@@ -1840,13 +2010,13 @@ var LighterClient = class {
|
|
|
1840
2010
|
/**
|
|
1841
2011
|
* Get mark/oracle price history (projected from OI data)
|
|
1842
2012
|
*
|
|
1843
|
-
* @param
|
|
2013
|
+
* @param symbol - The symbol (e.g., 'BTC', 'ETH')
|
|
1844
2014
|
* @param params - Time range, cursor, and interval parameters
|
|
1845
2015
|
* @returns CursorResponse with price snapshots
|
|
1846
2016
|
*/
|
|
1847
|
-
async priceHistory(
|
|
2017
|
+
async priceHistory(symbol, params) {
|
|
1848
2018
|
const response = await this.http.get(
|
|
1849
|
-
`/v1/lighter/prices/${
|
|
2019
|
+
`/v1/lighter/prices/${symbol.toUpperCase()}`,
|
|
1850
2020
|
params,
|
|
1851
2021
|
this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
|
|
1852
2022
|
);
|