@0xarchive/sdk 1.6.0 → 1.7.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 +103 -1
- package/dist/index.d.mts +294 -78
- package/dist/index.d.ts +294 -78
- package/dist/index.js +124 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -61,6 +61,7 @@ __export(index_exports, {
|
|
|
61
61
|
PriceLevelSchema: () => PriceLevelSchema,
|
|
62
62
|
PriceSnapshotArrayResponseSchema: () => PriceSnapshotArrayResponseSchema,
|
|
63
63
|
PriceSnapshotSchema: () => PriceSnapshotSchema,
|
|
64
|
+
SpotClient: () => SpotClient,
|
|
64
65
|
TimestampedRecordSchema: () => TimestampedRecordSchema,
|
|
65
66
|
TradeArrayResponseSchema: () => TradeArrayResponseSchema,
|
|
66
67
|
TradeDirectionSchema: () => TradeDirectionSchema,
|
|
@@ -107,7 +108,7 @@ var OxArchiveError = class extends Error {
|
|
|
107
108
|
|
|
108
109
|
// src/http.ts
|
|
109
110
|
function snakeToCamel(str) {
|
|
110
|
-
return str.replace(/_([a-
|
|
111
|
+
return str.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
111
112
|
}
|
|
112
113
|
function transformKeys(obj) {
|
|
113
114
|
if (obj === null || obj === void 0) {
|
|
@@ -360,7 +361,7 @@ var OpenInterestSchema = import_zod.z.object({
|
|
|
360
361
|
impactBidPrice: import_zod.z.string().optional(),
|
|
361
362
|
impactAskPrice: import_zod.z.string().optional()
|
|
362
363
|
});
|
|
363
|
-
var LiquidationSideSchema = import_zod.z.enum(["
|
|
364
|
+
var LiquidationSideSchema = import_zod.z.enum(["A", "B"]);
|
|
364
365
|
var LiquidationSchema = import_zod.z.object({
|
|
365
366
|
coin: import_zod.z.string(),
|
|
366
367
|
timestamp: import_zod.z.string(),
|
|
@@ -410,6 +411,11 @@ var WsChannelSchema = import_zod.z.enum([
|
|
|
410
411
|
"hip4_orderbook",
|
|
411
412
|
"hip4_trades",
|
|
412
413
|
"hip4_open_interest",
|
|
414
|
+
"spot_orderbook",
|
|
415
|
+
"spot_trades",
|
|
416
|
+
"spot_l4_diffs",
|
|
417
|
+
"spot_l4_orders",
|
|
418
|
+
"spot_twap",
|
|
413
419
|
"l4_diffs",
|
|
414
420
|
"l4_orders",
|
|
415
421
|
"hip3_l4_diffs",
|
|
@@ -1966,6 +1972,54 @@ var L3OrderBookResource = class {
|
|
|
1966
1972
|
}
|
|
1967
1973
|
};
|
|
1968
1974
|
|
|
1975
|
+
// src/resources/spot.ts
|
|
1976
|
+
var SpotPairsResource = class {
|
|
1977
|
+
constructor(http, basePath = "/v1/hyperliquid/spot", coinTransform = (c) => c.toUpperCase()) {
|
|
1978
|
+
this.http = http;
|
|
1979
|
+
this.basePath = basePath;
|
|
1980
|
+
this.coinTransform = coinTransform;
|
|
1981
|
+
}
|
|
1982
|
+
/** List every active spot pair. */
|
|
1983
|
+
async list() {
|
|
1984
|
+
const response = await this.http.get(
|
|
1985
|
+
`${this.basePath}/pairs`
|
|
1986
|
+
);
|
|
1987
|
+
return response.data;
|
|
1988
|
+
}
|
|
1989
|
+
/**
|
|
1990
|
+
* Get a specific spot pair by dashed symbol (e.g. `HYPE-USDC`).
|
|
1991
|
+
*/
|
|
1992
|
+
async get(symbol) {
|
|
1993
|
+
const response = await this.http.get(
|
|
1994
|
+
`${this.basePath}/pairs/${this.coinTransform(symbol)}`
|
|
1995
|
+
);
|
|
1996
|
+
return response.data;
|
|
1997
|
+
}
|
|
1998
|
+
};
|
|
1999
|
+
var SpotTwapResource = class {
|
|
2000
|
+
constructor(http, basePath = "/v1/hyperliquid/spot", coinTransform = (c) => c.toUpperCase()) {
|
|
2001
|
+
this.http = http;
|
|
2002
|
+
this.basePath = basePath;
|
|
2003
|
+
this.coinTransform = coinTransform;
|
|
2004
|
+
}
|
|
2005
|
+
/** TWAP statuses for a single spot pair. */
|
|
2006
|
+
async bySymbol(symbol, params) {
|
|
2007
|
+
const response = await this.http.get(
|
|
2008
|
+
`${this.basePath}/twap/${this.coinTransform(symbol)}`,
|
|
2009
|
+
params
|
|
2010
|
+
);
|
|
2011
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
2012
|
+
}
|
|
2013
|
+
/** TWAP statuses for a single user wallet across every spot pair. */
|
|
2014
|
+
async byUser(user, params) {
|
|
2015
|
+
const response = await this.http.get(
|
|
2016
|
+
`${this.basePath}/twap/user/${user}`,
|
|
2017
|
+
params
|
|
2018
|
+
);
|
|
2019
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
2020
|
+
}
|
|
2021
|
+
};
|
|
2022
|
+
|
|
1969
2023
|
// src/exchanges.ts
|
|
1970
2024
|
var HyperliquidClient = class {
|
|
1971
2025
|
/**
|
|
@@ -2383,6 +2437,45 @@ var Hip4Client = class {
|
|
|
2383
2437
|
return this.l4Orderbook.history(coin, params);
|
|
2384
2438
|
}
|
|
2385
2439
|
};
|
|
2440
|
+
var SpotClient = class {
|
|
2441
|
+
/** Spot pair metadata (one row per dashed symbol). */
|
|
2442
|
+
pairs;
|
|
2443
|
+
/** L2 order book snapshots (live from 2026-05-05). */
|
|
2444
|
+
orderbook;
|
|
2445
|
+
/** Trade history (S3 backfill from 2025-03-22, live since). */
|
|
2446
|
+
trades;
|
|
2447
|
+
/** Order lifecycle events (Pro+; live from 2026-05-05). */
|
|
2448
|
+
orders;
|
|
2449
|
+
/** L4 order book: snapshots, diffs, and checkpoint history. */
|
|
2450
|
+
l4Orderbook;
|
|
2451
|
+
/** TWAP statuses by symbol or by user wallet (Build+). */
|
|
2452
|
+
twap;
|
|
2453
|
+
http;
|
|
2454
|
+
constructor(http) {
|
|
2455
|
+
this.http = http;
|
|
2456
|
+
const basePath = "/v1/hyperliquid/spot";
|
|
2457
|
+
const coinTransform = (c) => c.toUpperCase();
|
|
2458
|
+
this.pairs = new SpotPairsResource(http, basePath, coinTransform);
|
|
2459
|
+
this.orderbook = new OrderBookResource(http, basePath, coinTransform);
|
|
2460
|
+
this.trades = new TradesResource(http, basePath, coinTransform);
|
|
2461
|
+
this.orders = new OrdersResource(http, basePath, coinTransform);
|
|
2462
|
+
this.l4Orderbook = new L4OrderBookResource(http, basePath, coinTransform);
|
|
2463
|
+
this.twap = new SpotTwapResource(http, basePath, coinTransform);
|
|
2464
|
+
}
|
|
2465
|
+
/**
|
|
2466
|
+
* Get per-symbol data freshness across all spot data types.
|
|
2467
|
+
*
|
|
2468
|
+
* @param symbol Dashed canonical (e.g. `HYPE-USDC`).
|
|
2469
|
+
*/
|
|
2470
|
+
async freshness(symbol) {
|
|
2471
|
+
const response = await this.http.get(
|
|
2472
|
+
`/v1/hyperliquid/spot/freshness/${symbol.toUpperCase()}`,
|
|
2473
|
+
void 0,
|
|
2474
|
+
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
2475
|
+
);
|
|
2476
|
+
return response.data;
|
|
2477
|
+
}
|
|
2478
|
+
};
|
|
2386
2479
|
var LighterClient = class {
|
|
2387
2480
|
/**
|
|
2388
2481
|
* Order book data (L2 snapshots)
|
|
@@ -2485,6 +2578,12 @@ var OxArchive = class {
|
|
|
2485
2578
|
* Lighter.xyz exchange data (August 2025+)
|
|
2486
2579
|
*/
|
|
2487
2580
|
lighter;
|
|
2581
|
+
/**
|
|
2582
|
+
* Hyperliquid Spot exchange data. Trades backfilled from 2025-03-22;
|
|
2583
|
+
* orderbook, L4, and TWAP statuses live from 2026-05-05. Symbols are
|
|
2584
|
+
* dashed canonical (e.g. `HYPE-USDC`).
|
|
2585
|
+
*/
|
|
2586
|
+
spot;
|
|
2488
2587
|
/**
|
|
2489
2588
|
* Data quality metrics: status, coverage, incidents, latency, SLA
|
|
2490
2589
|
*/
|
|
@@ -2530,6 +2629,7 @@ var OxArchive = class {
|
|
|
2530
2629
|
});
|
|
2531
2630
|
this.hyperliquid = new HyperliquidClient(this.http);
|
|
2532
2631
|
this.lighter = new LighterClient(this.http);
|
|
2632
|
+
this.spot = new SpotClient(this.http);
|
|
2533
2633
|
this.dataQuality = new DataQualityResource(this.http);
|
|
2534
2634
|
this.web3 = new Web3Resource(this.http);
|
|
2535
2635
|
const legacyBase = "/v1/hyperliquid";
|
|
@@ -2809,6 +2909,24 @@ var OxArchiveWs = class {
|
|
|
2809
2909
|
unsubscribeHip3Liquidations(coin) {
|
|
2810
2910
|
this.unsubscribe("hip3_liquidations", coin);
|
|
2811
2911
|
}
|
|
2912
|
+
/**
|
|
2913
|
+
* Subscribe to a Hyperliquid Spot channel for a given dashed pair.
|
|
2914
|
+
*
|
|
2915
|
+
* @param channel One of `spot_orderbook`, `spot_trades`, `spot_l4_diffs`,
|
|
2916
|
+
* `spot_l4_orders`, `spot_twap`. The short form (e.g. `'orderbook'`) is
|
|
2917
|
+
* also accepted and the `spot_` prefix is added automatically.
|
|
2918
|
+
* @param coin Spot dashed canonical symbol (e.g. `'HYPE-USDC'`).
|
|
2919
|
+
*/
|
|
2920
|
+
subscribeSpot(channel, coin) {
|
|
2921
|
+
const fullChannel = channel.startsWith("spot_") ? channel : `spot_${channel}`;
|
|
2922
|
+
this.subscribe(fullChannel, coin);
|
|
2923
|
+
}
|
|
2924
|
+
/** Unsubscribe from a Hyperliquid Spot channel for a given dashed pair.
|
|
2925
|
+
* Accepts the short form (`'orderbook'`) or the full form (`'spot_orderbook'`). */
|
|
2926
|
+
unsubscribeSpot(channel, coin) {
|
|
2927
|
+
const fullChannel = channel.startsWith("spot_") ? channel : `spot_${channel}`;
|
|
2928
|
+
this.unsubscribe(fullChannel, coin);
|
|
2929
|
+
}
|
|
2812
2930
|
/**
|
|
2813
2931
|
* Subscribe to a HIP-4 channel for a given outcome coin.
|
|
2814
2932
|
*
|
|
@@ -3182,7 +3300,7 @@ var OxArchiveWs = class {
|
|
|
3182
3300
|
resubscribe() {
|
|
3183
3301
|
for (const key of this.subscriptions) {
|
|
3184
3302
|
const [channel, coin] = key.split(":");
|
|
3185
|
-
this.send({ op: "subscribe", channel, coin });
|
|
3303
|
+
this.send({ op: "subscribe", channel, symbol: coin });
|
|
3186
3304
|
}
|
|
3187
3305
|
}
|
|
3188
3306
|
scheduleReconnect() {
|
|
@@ -3281,12 +3399,12 @@ var OxArchiveWs = class {
|
|
|
3281
3399
|
break;
|
|
3282
3400
|
}
|
|
3283
3401
|
case "data": {
|
|
3284
|
-
if (message.channel === "orderbook" || message.channel === "hip3_orderbook" || message.channel === "hip4_orderbook" || message.channel === "lighter_orderbook") {
|
|
3402
|
+
if (message.channel === "orderbook" || message.channel === "hip3_orderbook" || message.channel === "hip4_orderbook" || message.channel === "lighter_orderbook" || message.channel === "spot_orderbook") {
|
|
3285
3403
|
const orderbook = transformOrderbook(message.coin, message.data);
|
|
3286
3404
|
for (const handler of this.orderbookHandlers) {
|
|
3287
3405
|
handler(message.coin, orderbook);
|
|
3288
3406
|
}
|
|
3289
|
-
} else if (message.channel === "trades" || message.channel === "hip3_trades" || message.channel === "hip4_trades" || message.channel === "lighter_trades") {
|
|
3407
|
+
} else if (message.channel === "trades" || message.channel === "hip3_trades" || message.channel === "hip4_trades" || message.channel === "lighter_trades" || message.channel === "spot_trades") {
|
|
3290
3408
|
const trades = transformTrades(message.coin, message.data);
|
|
3291
3409
|
for (const handler of this.tradesHandlers) {
|
|
3292
3410
|
handler(message.coin, trades);
|
|
@@ -3482,6 +3600,7 @@ var L4OrderBookReconstructor = class {
|
|
|
3482
3600
|
PriceLevelSchema,
|
|
3483
3601
|
PriceSnapshotArrayResponseSchema,
|
|
3484
3602
|
PriceSnapshotSchema,
|
|
3603
|
+
SpotClient,
|
|
3485
3604
|
TimestampedRecordSchema,
|
|
3486
3605
|
TradeArrayResponseSchema,
|
|
3487
3606
|
TradeDirectionSchema,
|