@0xarchive/sdk 0.6.5 → 0.8.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 +31 -1
- package/dist/index.d.mts +91 -16
- package/dist/index.d.ts +91 -16
- package/dist/index.js +76 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -516,9 +516,10 @@ function reconstructFinal(tickData, depth) {
|
|
|
516
516
|
|
|
517
517
|
// src/resources/orderbook.ts
|
|
518
518
|
var OrderBookResource = class {
|
|
519
|
-
constructor(http, basePath = "/v1") {
|
|
519
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
520
520
|
this.http = http;
|
|
521
521
|
this.basePath = basePath;
|
|
522
|
+
this.coinTransform = coinTransform;
|
|
522
523
|
}
|
|
523
524
|
/**
|
|
524
525
|
* Get order book snapshot for a coin
|
|
@@ -529,7 +530,7 @@ var OrderBookResource = class {
|
|
|
529
530
|
*/
|
|
530
531
|
async get(coin, params) {
|
|
531
532
|
const response = await this.http.get(
|
|
532
|
-
`${this.basePath}/orderbook/${
|
|
533
|
+
`${this.basePath}/orderbook/${this.coinTransform(coin)}`,
|
|
533
534
|
params,
|
|
534
535
|
this.http.validationEnabled ? OrderBookResponseSchema : void 0
|
|
535
536
|
);
|
|
@@ -564,7 +565,7 @@ var OrderBookResource = class {
|
|
|
564
565
|
*/
|
|
565
566
|
async history(coin, params) {
|
|
566
567
|
const response = await this.http.get(
|
|
567
|
-
`${this.basePath}/orderbook/${
|
|
568
|
+
`${this.basePath}/orderbook/${this.coinTransform(coin)}/history`,
|
|
568
569
|
params,
|
|
569
570
|
this.http.validationEnabled ? OrderBookArrayResponseSchema : void 0
|
|
570
571
|
);
|
|
@@ -604,7 +605,7 @@ var OrderBookResource = class {
|
|
|
604
605
|
*/
|
|
605
606
|
async historyTick(coin, params) {
|
|
606
607
|
const response = await this.http.get(
|
|
607
|
-
`${this.basePath}/orderbook/${
|
|
608
|
+
`${this.basePath}/orderbook/${this.coinTransform(coin)}/history`,
|
|
608
609
|
{
|
|
609
610
|
...params,
|
|
610
611
|
granularity: "tick"
|
|
@@ -757,9 +758,10 @@ var OrderBookResource = class {
|
|
|
757
758
|
|
|
758
759
|
// src/resources/trades.ts
|
|
759
760
|
var TradesResource = class {
|
|
760
|
-
constructor(http, basePath = "/v1") {
|
|
761
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
761
762
|
this.http = http;
|
|
762
763
|
this.basePath = basePath;
|
|
764
|
+
this.coinTransform = coinTransform;
|
|
763
765
|
}
|
|
764
766
|
/**
|
|
765
767
|
* Get trade history for a coin using cursor-based pagination
|
|
@@ -793,7 +795,7 @@ var TradesResource = class {
|
|
|
793
795
|
*/
|
|
794
796
|
async list(coin, params) {
|
|
795
797
|
const response = await this.http.get(
|
|
796
|
-
`${this.basePath}/trades/${
|
|
798
|
+
`${this.basePath}/trades/${this.coinTransform(coin)}`,
|
|
797
799
|
params,
|
|
798
800
|
this.http.validationEnabled ? TradeArrayResponseSchema : void 0
|
|
799
801
|
);
|
|
@@ -805,9 +807,10 @@ var TradesResource = class {
|
|
|
805
807
|
/**
|
|
806
808
|
* Get most recent trades for a coin.
|
|
807
809
|
*
|
|
808
|
-
* Note: This method is
|
|
809
|
-
* which
|
|
810
|
-
* endpoint is not available
|
|
810
|
+
* Note: This method is available for Lighter (client.lighter.trades.recent())
|
|
811
|
+
* and HIP-3 (client.hyperliquid.hip3.trades.recent()) which have real-time data
|
|
812
|
+
* ingestion. Hyperliquid uses hourly backfill so this endpoint is not available
|
|
813
|
+
* for Hyperliquid.
|
|
811
814
|
*
|
|
812
815
|
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
813
816
|
* @param limit - Number of trades to return (default: 100)
|
|
@@ -815,7 +818,7 @@ var TradesResource = class {
|
|
|
815
818
|
*/
|
|
816
819
|
async recent(coin, limit) {
|
|
817
820
|
const response = await this.http.get(
|
|
818
|
-
`${this.basePath}/trades/${
|
|
821
|
+
`${this.basePath}/trades/${this.coinTransform(coin)}/recent`,
|
|
819
822
|
{ limit },
|
|
820
823
|
this.http.validationEnabled ? TradeArrayResponseSchema : void 0
|
|
821
824
|
);
|
|
@@ -889,9 +892,10 @@ var LighterInstrumentsResource = class {
|
|
|
889
892
|
|
|
890
893
|
// src/resources/funding.ts
|
|
891
894
|
var FundingResource = class {
|
|
892
|
-
constructor(http, basePath = "/v1") {
|
|
895
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
893
896
|
this.http = http;
|
|
894
897
|
this.basePath = basePath;
|
|
898
|
+
this.coinTransform = coinTransform;
|
|
895
899
|
}
|
|
896
900
|
/**
|
|
897
901
|
* Get funding rate history for a coin with cursor-based pagination
|
|
@@ -902,7 +906,7 @@ var FundingResource = class {
|
|
|
902
906
|
*/
|
|
903
907
|
async history(coin, params) {
|
|
904
908
|
const response = await this.http.get(
|
|
905
|
-
`${this.basePath}/funding/${
|
|
909
|
+
`${this.basePath}/funding/${this.coinTransform(coin)}`,
|
|
906
910
|
params,
|
|
907
911
|
this.http.validationEnabled ? FundingRateArrayResponseSchema : void 0
|
|
908
912
|
);
|
|
@@ -919,7 +923,7 @@ var FundingResource = class {
|
|
|
919
923
|
*/
|
|
920
924
|
async current(coin) {
|
|
921
925
|
const response = await this.http.get(
|
|
922
|
-
|
|
926
|
+
`${this.basePath}/funding/${this.coinTransform(coin)}/current`,
|
|
923
927
|
void 0,
|
|
924
928
|
this.http.validationEnabled ? FundingRateResponseSchema : void 0
|
|
925
929
|
);
|
|
@@ -929,9 +933,10 @@ var FundingResource = class {
|
|
|
929
933
|
|
|
930
934
|
// src/resources/openinterest.ts
|
|
931
935
|
var OpenInterestResource = class {
|
|
932
|
-
constructor(http, basePath = "/v1") {
|
|
936
|
+
constructor(http, basePath = "/v1", coinTransform = (c) => c.toUpperCase()) {
|
|
933
937
|
this.http = http;
|
|
934
938
|
this.basePath = basePath;
|
|
939
|
+
this.coinTransform = coinTransform;
|
|
935
940
|
}
|
|
936
941
|
/**
|
|
937
942
|
* Get open interest history for a coin with cursor-based pagination
|
|
@@ -942,7 +947,7 @@ var OpenInterestResource = class {
|
|
|
942
947
|
*/
|
|
943
948
|
async history(coin, params) {
|
|
944
949
|
const response = await this.http.get(
|
|
945
|
-
`${this.basePath}/openinterest/${
|
|
950
|
+
`${this.basePath}/openinterest/${this.coinTransform(coin)}`,
|
|
946
951
|
params,
|
|
947
952
|
this.http.validationEnabled ? OpenInterestArrayResponseSchema : void 0
|
|
948
953
|
);
|
|
@@ -959,7 +964,7 @@ var OpenInterestResource = class {
|
|
|
959
964
|
*/
|
|
960
965
|
async current(coin) {
|
|
961
966
|
const response = await this.http.get(
|
|
962
|
-
|
|
967
|
+
`${this.basePath}/openinterest/${this.coinTransform(coin)}/current`,
|
|
963
968
|
void 0,
|
|
964
969
|
this.http.validationEnabled ? OpenInterestResponseSchema : void 0
|
|
965
970
|
);
|
|
@@ -1093,7 +1098,7 @@ var DataQualityResource = class {
|
|
|
1093
1098
|
/**
|
|
1094
1099
|
* Get data coverage for a specific exchange
|
|
1095
1100
|
*
|
|
1096
|
-
* @param exchange - Exchange name ('hyperliquid' or '
|
|
1101
|
+
* @param exchange - Exchange name ('hyperliquid', 'lighter', or 'hip3')
|
|
1097
1102
|
* @returns ExchangeCoverage with coverage info for all data types on this exchange
|
|
1098
1103
|
*
|
|
1099
1104
|
* @example
|
|
@@ -1110,11 +1115,13 @@ var DataQualityResource = class {
|
|
|
1110
1115
|
/**
|
|
1111
1116
|
* Get data coverage for a specific symbol on an exchange
|
|
1112
1117
|
*
|
|
1113
|
-
* Includes gap detection
|
|
1118
|
+
* Includes gap detection, empirical data cadence, and hour-level historical coverage.
|
|
1119
|
+
* Supports optional time bounds for gap detection (default: last 30 days).
|
|
1114
1120
|
*
|
|
1115
|
-
* @param exchange - Exchange name ('hyperliquid' or '
|
|
1116
|
-
* @param symbol - Symbol name (e.g., 'BTC', 'ETH')
|
|
1117
|
-
* @
|
|
1121
|
+
* @param exchange - Exchange name ('hyperliquid', 'lighter', or 'hip3')
|
|
1122
|
+
* @param symbol - Symbol name (e.g., 'BTC', 'ETH', or HIP3 coins like 'xyz:XYZ100')
|
|
1123
|
+
* @param options - Optional time bounds for gap detection window
|
|
1124
|
+
* @returns SymbolCoverageResponse with per-data-type coverage including gaps, cadence, and historical coverage
|
|
1118
1125
|
*
|
|
1119
1126
|
* @example
|
|
1120
1127
|
* ```typescript
|
|
@@ -1125,11 +1132,24 @@ var DataQualityResource = class {
|
|
|
1125
1132
|
* for (const gap of oi.gaps.slice(0, 3)) {
|
|
1126
1133
|
* console.log(` ${gap.durationMinutes} min gap at ${gap.start}`);
|
|
1127
1134
|
* }
|
|
1135
|
+
*
|
|
1136
|
+
* // Check cadence
|
|
1137
|
+
* if (btc.dataTypes.orderbook.cadence) {
|
|
1138
|
+
* console.log(`Cadence: ~${btc.dataTypes.orderbook.cadence.medianIntervalSeconds}s`);
|
|
1139
|
+
* }
|
|
1140
|
+
*
|
|
1141
|
+
* // Time-bounded (last 7 days)
|
|
1142
|
+
* const weekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;
|
|
1143
|
+
* const btc7d = await client.dataQuality.symbolCoverage('hyperliquid', 'BTC', {
|
|
1144
|
+
* from: weekAgo,
|
|
1145
|
+
* to: Date.now(),
|
|
1146
|
+
* });
|
|
1128
1147
|
* ```
|
|
1129
1148
|
*/
|
|
1130
|
-
async symbolCoverage(exchange, symbol) {
|
|
1149
|
+
async symbolCoverage(exchange, symbol, options) {
|
|
1131
1150
|
return this.http.get(
|
|
1132
|
-
`${this.basePath}/coverage/${exchange.toLowerCase()}/${symbol.toUpperCase()}
|
|
1151
|
+
`${this.basePath}/coverage/${exchange.toLowerCase()}/${symbol.toUpperCase()}`,
|
|
1152
|
+
options
|
|
1133
1153
|
);
|
|
1134
1154
|
}
|
|
1135
1155
|
// ===========================================================================
|
|
@@ -1251,6 +1271,10 @@ var HyperliquidClient = class {
|
|
|
1251
1271
|
* Liquidation events (May 2025+)
|
|
1252
1272
|
*/
|
|
1253
1273
|
liquidations;
|
|
1274
|
+
/**
|
|
1275
|
+
* HIP-3 builder-deployed perpetuals (Pro+ only, February 2026+)
|
|
1276
|
+
*/
|
|
1277
|
+
hip3;
|
|
1254
1278
|
constructor(http) {
|
|
1255
1279
|
const basePath = "/v1/hyperliquid";
|
|
1256
1280
|
this.orderbook = new OrderBookResource(http, basePath);
|
|
@@ -1260,6 +1284,33 @@ var HyperliquidClient = class {
|
|
|
1260
1284
|
this.openInterest = new OpenInterestResource(http, basePath);
|
|
1261
1285
|
this.candles = new CandlesResource(http, basePath);
|
|
1262
1286
|
this.liquidations = new LiquidationsResource(http, basePath);
|
|
1287
|
+
this.hip3 = new Hip3Client(http);
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
var Hip3Client = class {
|
|
1291
|
+
/**
|
|
1292
|
+
* Order book snapshots (February 2026+)
|
|
1293
|
+
*/
|
|
1294
|
+
orderbook;
|
|
1295
|
+
/**
|
|
1296
|
+
* Trade/fill history
|
|
1297
|
+
*/
|
|
1298
|
+
trades;
|
|
1299
|
+
/**
|
|
1300
|
+
* Funding rates
|
|
1301
|
+
*/
|
|
1302
|
+
funding;
|
|
1303
|
+
/**
|
|
1304
|
+
* Open interest
|
|
1305
|
+
*/
|
|
1306
|
+
openInterest;
|
|
1307
|
+
constructor(http) {
|
|
1308
|
+
const basePath = "/v1/hyperliquid/hip3";
|
|
1309
|
+
const coinTransform = (c) => c;
|
|
1310
|
+
this.orderbook = new OrderBookResource(http, basePath, coinTransform);
|
|
1311
|
+
this.trades = new TradesResource(http, basePath, coinTransform);
|
|
1312
|
+
this.funding = new FundingResource(http, basePath, coinTransform);
|
|
1313
|
+
this.openInterest = new OpenInterestResource(http, basePath, coinTransform);
|
|
1263
1314
|
}
|
|
1264
1315
|
};
|
|
1265
1316
|
var LighterClient = class {
|
|
@@ -1941,6 +1992,7 @@ export {
|
|
|
1941
1992
|
FundingRateArrayResponseSchema,
|
|
1942
1993
|
FundingRateResponseSchema,
|
|
1943
1994
|
FundingRateSchema,
|
|
1995
|
+
Hip3Client,
|
|
1944
1996
|
HyperliquidClient,
|
|
1945
1997
|
InstrumentArrayResponseSchema,
|
|
1946
1998
|
InstrumentResponseSchema,
|