@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.mjs
CHANGED
|
@@ -12,7 +12,7 @@ var OxArchiveError = class extends Error {
|
|
|
12
12
|
|
|
13
13
|
// src/http.ts
|
|
14
14
|
function snakeToCamel(str) {
|
|
15
|
-
return str.replace(/_([a-
|
|
15
|
+
return str.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
16
16
|
}
|
|
17
17
|
function transformKeys(obj) {
|
|
18
18
|
if (obj === null || obj === void 0) {
|
|
@@ -265,7 +265,7 @@ var OpenInterestSchema = z.object({
|
|
|
265
265
|
impactBidPrice: z.string().optional(),
|
|
266
266
|
impactAskPrice: z.string().optional()
|
|
267
267
|
});
|
|
268
|
-
var LiquidationSideSchema = z.enum(["
|
|
268
|
+
var LiquidationSideSchema = z.enum(["A", "B"]);
|
|
269
269
|
var LiquidationSchema = z.object({
|
|
270
270
|
coin: z.string(),
|
|
271
271
|
timestamp: z.string(),
|
|
@@ -315,6 +315,11 @@ var WsChannelSchema = z.enum([
|
|
|
315
315
|
"hip4_orderbook",
|
|
316
316
|
"hip4_trades",
|
|
317
317
|
"hip4_open_interest",
|
|
318
|
+
"spot_orderbook",
|
|
319
|
+
"spot_trades",
|
|
320
|
+
"spot_l4_diffs",
|
|
321
|
+
"spot_l4_orders",
|
|
322
|
+
"spot_twap",
|
|
318
323
|
"l4_diffs",
|
|
319
324
|
"l4_orders",
|
|
320
325
|
"hip3_l4_diffs",
|
|
@@ -1871,6 +1876,54 @@ var L3OrderBookResource = class {
|
|
|
1871
1876
|
}
|
|
1872
1877
|
};
|
|
1873
1878
|
|
|
1879
|
+
// src/resources/spot.ts
|
|
1880
|
+
var SpotPairsResource = class {
|
|
1881
|
+
constructor(http, basePath = "/v1/hyperliquid/spot", coinTransform = (c) => c.toUpperCase()) {
|
|
1882
|
+
this.http = http;
|
|
1883
|
+
this.basePath = basePath;
|
|
1884
|
+
this.coinTransform = coinTransform;
|
|
1885
|
+
}
|
|
1886
|
+
/** List every active spot pair. */
|
|
1887
|
+
async list() {
|
|
1888
|
+
const response = await this.http.get(
|
|
1889
|
+
`${this.basePath}/pairs`
|
|
1890
|
+
);
|
|
1891
|
+
return response.data;
|
|
1892
|
+
}
|
|
1893
|
+
/**
|
|
1894
|
+
* Get a specific spot pair by dashed symbol (e.g. `HYPE-USDC`).
|
|
1895
|
+
*/
|
|
1896
|
+
async get(symbol) {
|
|
1897
|
+
const response = await this.http.get(
|
|
1898
|
+
`${this.basePath}/pairs/${this.coinTransform(symbol)}`
|
|
1899
|
+
);
|
|
1900
|
+
return response.data;
|
|
1901
|
+
}
|
|
1902
|
+
};
|
|
1903
|
+
var SpotTwapResource = class {
|
|
1904
|
+
constructor(http, basePath = "/v1/hyperliquid/spot", coinTransform = (c) => c.toUpperCase()) {
|
|
1905
|
+
this.http = http;
|
|
1906
|
+
this.basePath = basePath;
|
|
1907
|
+
this.coinTransform = coinTransform;
|
|
1908
|
+
}
|
|
1909
|
+
/** TWAP statuses for a single spot pair. */
|
|
1910
|
+
async bySymbol(symbol, params) {
|
|
1911
|
+
const response = await this.http.get(
|
|
1912
|
+
`${this.basePath}/twap/${this.coinTransform(symbol)}`,
|
|
1913
|
+
params
|
|
1914
|
+
);
|
|
1915
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1916
|
+
}
|
|
1917
|
+
/** TWAP statuses for a single user wallet across every spot pair. */
|
|
1918
|
+
async byUser(user, params) {
|
|
1919
|
+
const response = await this.http.get(
|
|
1920
|
+
`${this.basePath}/twap/user/${user}`,
|
|
1921
|
+
params
|
|
1922
|
+
);
|
|
1923
|
+
return { data: response.data, nextCursor: response.meta.nextCursor };
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
|
|
1874
1927
|
// src/exchanges.ts
|
|
1875
1928
|
var HyperliquidClient = class {
|
|
1876
1929
|
/**
|
|
@@ -2288,6 +2341,45 @@ var Hip4Client = class {
|
|
|
2288
2341
|
return this.l4Orderbook.history(coin, params);
|
|
2289
2342
|
}
|
|
2290
2343
|
};
|
|
2344
|
+
var SpotClient = class {
|
|
2345
|
+
/** Spot pair metadata (one row per dashed symbol). */
|
|
2346
|
+
pairs;
|
|
2347
|
+
/** L2 order book snapshots (live from 2026-05-05). */
|
|
2348
|
+
orderbook;
|
|
2349
|
+
/** Trade history (S3 backfill from 2025-03-22, live since). */
|
|
2350
|
+
trades;
|
|
2351
|
+
/** Order lifecycle events (Pro+; live from 2026-05-05). */
|
|
2352
|
+
orders;
|
|
2353
|
+
/** L4 order book: snapshots, diffs, and checkpoint history. */
|
|
2354
|
+
l4Orderbook;
|
|
2355
|
+
/** TWAP statuses by symbol or by user wallet (Build+). */
|
|
2356
|
+
twap;
|
|
2357
|
+
http;
|
|
2358
|
+
constructor(http) {
|
|
2359
|
+
this.http = http;
|
|
2360
|
+
const basePath = "/v1/hyperliquid/spot";
|
|
2361
|
+
const coinTransform = (c) => c.toUpperCase();
|
|
2362
|
+
this.pairs = new SpotPairsResource(http, basePath, coinTransform);
|
|
2363
|
+
this.orderbook = new OrderBookResource(http, basePath, coinTransform);
|
|
2364
|
+
this.trades = new TradesResource(http, basePath, coinTransform);
|
|
2365
|
+
this.orders = new OrdersResource(http, basePath, coinTransform);
|
|
2366
|
+
this.l4Orderbook = new L4OrderBookResource(http, basePath, coinTransform);
|
|
2367
|
+
this.twap = new SpotTwapResource(http, basePath, coinTransform);
|
|
2368
|
+
}
|
|
2369
|
+
/**
|
|
2370
|
+
* Get per-symbol data freshness across all spot data types.
|
|
2371
|
+
*
|
|
2372
|
+
* @param symbol Dashed canonical (e.g. `HYPE-USDC`).
|
|
2373
|
+
*/
|
|
2374
|
+
async freshness(symbol) {
|
|
2375
|
+
const response = await this.http.get(
|
|
2376
|
+
`/v1/hyperliquid/spot/freshness/${symbol.toUpperCase()}`,
|
|
2377
|
+
void 0,
|
|
2378
|
+
this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
|
|
2379
|
+
);
|
|
2380
|
+
return response.data;
|
|
2381
|
+
}
|
|
2382
|
+
};
|
|
2291
2383
|
var LighterClient = class {
|
|
2292
2384
|
/**
|
|
2293
2385
|
* Order book data (L2 snapshots)
|
|
@@ -2390,6 +2482,12 @@ var OxArchive = class {
|
|
|
2390
2482
|
* Lighter.xyz exchange data (August 2025+)
|
|
2391
2483
|
*/
|
|
2392
2484
|
lighter;
|
|
2485
|
+
/**
|
|
2486
|
+
* Hyperliquid Spot exchange data. Trades backfilled from 2025-03-22;
|
|
2487
|
+
* orderbook, L4, and TWAP statuses live from 2026-05-05. Symbols are
|
|
2488
|
+
* dashed canonical (e.g. `HYPE-USDC`).
|
|
2489
|
+
*/
|
|
2490
|
+
spot;
|
|
2393
2491
|
/**
|
|
2394
2492
|
* Data quality metrics: status, coverage, incidents, latency, SLA
|
|
2395
2493
|
*/
|
|
@@ -2435,6 +2533,7 @@ var OxArchive = class {
|
|
|
2435
2533
|
});
|
|
2436
2534
|
this.hyperliquid = new HyperliquidClient(this.http);
|
|
2437
2535
|
this.lighter = new LighterClient(this.http);
|
|
2536
|
+
this.spot = new SpotClient(this.http);
|
|
2438
2537
|
this.dataQuality = new DataQualityResource(this.http);
|
|
2439
2538
|
this.web3 = new Web3Resource(this.http);
|
|
2440
2539
|
const legacyBase = "/v1/hyperliquid";
|
|
@@ -2714,6 +2813,24 @@ var OxArchiveWs = class {
|
|
|
2714
2813
|
unsubscribeHip3Liquidations(coin) {
|
|
2715
2814
|
this.unsubscribe("hip3_liquidations", coin);
|
|
2716
2815
|
}
|
|
2816
|
+
/**
|
|
2817
|
+
* Subscribe to a Hyperliquid Spot channel for a given dashed pair.
|
|
2818
|
+
*
|
|
2819
|
+
* @param channel One of `spot_orderbook`, `spot_trades`, `spot_l4_diffs`,
|
|
2820
|
+
* `spot_l4_orders`, `spot_twap`. The short form (e.g. `'orderbook'`) is
|
|
2821
|
+
* also accepted and the `spot_` prefix is added automatically.
|
|
2822
|
+
* @param coin Spot dashed canonical symbol (e.g. `'HYPE-USDC'`).
|
|
2823
|
+
*/
|
|
2824
|
+
subscribeSpot(channel, coin) {
|
|
2825
|
+
const fullChannel = channel.startsWith("spot_") ? channel : `spot_${channel}`;
|
|
2826
|
+
this.subscribe(fullChannel, coin);
|
|
2827
|
+
}
|
|
2828
|
+
/** Unsubscribe from a Hyperliquid Spot channel for a given dashed pair.
|
|
2829
|
+
* Accepts the short form (`'orderbook'`) or the full form (`'spot_orderbook'`). */
|
|
2830
|
+
unsubscribeSpot(channel, coin) {
|
|
2831
|
+
const fullChannel = channel.startsWith("spot_") ? channel : `spot_${channel}`;
|
|
2832
|
+
this.unsubscribe(fullChannel, coin);
|
|
2833
|
+
}
|
|
2717
2834
|
/**
|
|
2718
2835
|
* Subscribe to a HIP-4 channel for a given outcome coin.
|
|
2719
2836
|
*
|
|
@@ -3087,7 +3204,7 @@ var OxArchiveWs = class {
|
|
|
3087
3204
|
resubscribe() {
|
|
3088
3205
|
for (const key of this.subscriptions) {
|
|
3089
3206
|
const [channel, coin] = key.split(":");
|
|
3090
|
-
this.send({ op: "subscribe", channel, coin });
|
|
3207
|
+
this.send({ op: "subscribe", channel, symbol: coin });
|
|
3091
3208
|
}
|
|
3092
3209
|
}
|
|
3093
3210
|
scheduleReconnect() {
|
|
@@ -3186,12 +3303,12 @@ var OxArchiveWs = class {
|
|
|
3186
3303
|
break;
|
|
3187
3304
|
}
|
|
3188
3305
|
case "data": {
|
|
3189
|
-
if (message.channel === "orderbook" || message.channel === "hip3_orderbook" || message.channel === "hip4_orderbook" || message.channel === "lighter_orderbook") {
|
|
3306
|
+
if (message.channel === "orderbook" || message.channel === "hip3_orderbook" || message.channel === "hip4_orderbook" || message.channel === "lighter_orderbook" || message.channel === "spot_orderbook") {
|
|
3190
3307
|
const orderbook = transformOrderbook(message.coin, message.data);
|
|
3191
3308
|
for (const handler of this.orderbookHandlers) {
|
|
3192
3309
|
handler(message.coin, orderbook);
|
|
3193
3310
|
}
|
|
3194
|
-
} else if (message.channel === "trades" || message.channel === "hip3_trades" || message.channel === "hip4_trades" || message.channel === "lighter_trades") {
|
|
3311
|
+
} else if (message.channel === "trades" || message.channel === "hip3_trades" || message.channel === "hip4_trades" || message.channel === "lighter_trades" || message.channel === "spot_trades") {
|
|
3195
3312
|
const trades = transformTrades(message.coin, message.data);
|
|
3196
3313
|
for (const handler of this.tradesHandlers) {
|
|
3197
3314
|
handler(message.coin, trades);
|
|
@@ -3386,6 +3503,7 @@ export {
|
|
|
3386
3503
|
PriceLevelSchema,
|
|
3387
3504
|
PriceSnapshotArrayResponseSchema,
|
|
3388
3505
|
PriceSnapshotSchema,
|
|
3506
|
+
SpotClient,
|
|
3389
3507
|
TimestampedRecordSchema,
|
|
3390
3508
|
TradeArrayResponseSchema,
|
|
3391
3509
|
TradeDirectionSchema,
|