@0xarchive/sdk 0.5.1 → 0.5.3

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/dist/index.js CHANGED
@@ -34,6 +34,9 @@ __export(index_exports, {
34
34
  InstrumentSchema: () => InstrumentSchema,
35
35
  InstrumentTypeSchema: () => InstrumentTypeSchema,
36
36
  LighterClient: () => LighterClient,
37
+ LiquidationArrayResponseSchema: () => LiquidationArrayResponseSchema,
38
+ LiquidationSchema: () => LiquidationSchema,
39
+ LiquidationSideSchema: () => LiquidationSideSchema,
37
40
  OpenInterestArrayResponseSchema: () => OpenInterestArrayResponseSchema,
38
41
  OpenInterestResponseSchema: () => OpenInterestResponseSchema,
39
42
  OpenInterestSchema: () => OpenInterestSchema,
@@ -265,6 +268,21 @@ var OpenInterestSchema = import_zod.z.object({
265
268
  impactBidPrice: import_zod.z.string().optional(),
266
269
  impactAskPrice: import_zod.z.string().optional()
267
270
  });
271
+ var LiquidationSideSchema = import_zod.z.enum(["B", "S"]);
272
+ var LiquidationSchema = import_zod.z.object({
273
+ coin: import_zod.z.string(),
274
+ timestamp: import_zod.z.string(),
275
+ liquidatedUser: import_zod.z.string(),
276
+ liquidatorUser: import_zod.z.string(),
277
+ price: import_zod.z.string(),
278
+ size: import_zod.z.string(),
279
+ side: LiquidationSideSchema,
280
+ markPrice: import_zod.z.string().optional(),
281
+ closedPnl: import_zod.z.string().optional(),
282
+ direction: import_zod.z.string().optional(),
283
+ tradeId: import_zod.z.number().optional(),
284
+ txHash: import_zod.z.string().optional()
285
+ });
268
286
  var CandleIntervalSchema = import_zod.z.enum(["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w"]);
269
287
  var CandleSchema = import_zod.z.object({
270
288
  timestamp: import_zod.z.string(),
@@ -276,7 +294,7 @@ var CandleSchema = import_zod.z.object({
276
294
  quoteVolume: import_zod.z.number().optional(),
277
295
  tradeCount: import_zod.z.number().optional()
278
296
  });
279
- var WsChannelSchema = import_zod.z.enum(["orderbook", "trades", "candles", "ticker", "all_tickers"]);
297
+ var WsChannelSchema = import_zod.z.enum(["orderbook", "trades", "candles", "liquidations", "ticker", "all_tickers"]);
280
298
  var WsConnectionStateSchema = import_zod.z.enum(["connecting", "connected", "disconnected", "reconnecting"]);
281
299
  var WsSubscribedSchema = import_zod.z.object({
282
300
  type: import_zod.z.literal("subscribed"),
@@ -392,6 +410,7 @@ var FundingRateArrayResponseSchema = ApiResponseSchema(import_zod.z.array(Fundin
392
410
  var OpenInterestResponseSchema = ApiResponseSchema(OpenInterestSchema);
393
411
  var OpenInterestArrayResponseSchema = ApiResponseSchema(import_zod.z.array(OpenInterestSchema));
394
412
  var CandleArrayResponseSchema = ApiResponseSchema(import_zod.z.array(CandleSchema));
413
+ var LiquidationArrayResponseSchema = ApiResponseSchema(import_zod.z.array(LiquidationSchema));
395
414
 
396
415
  // src/resources/orderbook.ts
397
416
  var OrderBookResource = class {
@@ -502,7 +521,11 @@ var TradesResource = class {
502
521
  };
503
522
  }
504
523
  /**
505
- * Get most recent trades for a coin
524
+ * Get most recent trades for a coin.
525
+ *
526
+ * Note: This method is only available for Lighter (client.lighter.trades.recent())
527
+ * which has real-time data ingestion. Hyperliquid uses hourly backfill so this
528
+ * endpoint is not available for Hyperliquid.
506
529
  *
507
530
  * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
508
531
  * @param limit - Number of trades to return (default: 100)
@@ -688,6 +711,54 @@ var CandlesResource = class {
688
711
  }
689
712
  };
690
713
 
714
+ // src/resources/liquidations.ts
715
+ var LiquidationsResource = class {
716
+ constructor(http, basePath = "/v1") {
717
+ this.http = http;
718
+ this.basePath = basePath;
719
+ }
720
+ /**
721
+ * Get liquidation history for a coin with cursor-based pagination
722
+ *
723
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
724
+ * @param params - Time range and cursor pagination parameters (start and end are required)
725
+ * @returns CursorResponse with liquidation records and nextCursor for pagination
726
+ */
727
+ async history(coin, params) {
728
+ const response = await this.http.get(
729
+ `${this.basePath}/liquidations/${coin.toUpperCase()}`,
730
+ params,
731
+ this.http.validationEnabled ? LiquidationArrayResponseSchema : void 0
732
+ );
733
+ return {
734
+ data: response.data,
735
+ nextCursor: response.meta.nextCursor
736
+ };
737
+ }
738
+ /**
739
+ * Get liquidation history for a specific user
740
+ *
741
+ * This returns liquidations where the user was either:
742
+ * - The liquidated party (their position was liquidated)
743
+ * - The liquidator (they executed the liquidation)
744
+ *
745
+ * @param userAddress - User's wallet address (e.g., '0x1234...')
746
+ * @param params - Time range and cursor pagination parameters (start and end are required)
747
+ * @returns CursorResponse with liquidation records and nextCursor for pagination
748
+ */
749
+ async byUser(userAddress, params) {
750
+ const response = await this.http.get(
751
+ `${this.basePath}/liquidations/user/${userAddress}`,
752
+ params,
753
+ this.http.validationEnabled ? LiquidationArrayResponseSchema : void 0
754
+ );
755
+ return {
756
+ data: response.data,
757
+ nextCursor: response.meta.nextCursor
758
+ };
759
+ }
760
+ };
761
+
691
762
  // src/exchanges.ts
692
763
  var HyperliquidClient = class {
693
764
  /**
@@ -714,6 +785,10 @@ var HyperliquidClient = class {
714
785
  * OHLCV candle data
715
786
  */
716
787
  candles;
788
+ /**
789
+ * Liquidation events (May 2025+)
790
+ */
791
+ liquidations;
717
792
  constructor(http) {
718
793
  const basePath = "/v1/hyperliquid";
719
794
  this.orderbook = new OrderBookResource(http, basePath);
@@ -722,6 +797,7 @@ var HyperliquidClient = class {
722
797
  this.funding = new FundingResource(http, basePath);
723
798
  this.openInterest = new OpenInterestResource(http, basePath);
724
799
  this.candles = new CandlesResource(http, basePath);
800
+ this.liquidations = new LiquidationsResource(http, basePath);
725
801
  }
726
802
  };
727
803
  var LighterClient = class {
@@ -1378,6 +1454,9 @@ var OxArchiveWs = class {
1378
1454
  InstrumentSchema,
1379
1455
  InstrumentTypeSchema,
1380
1456
  LighterClient,
1457
+ LiquidationArrayResponseSchema,
1458
+ LiquidationSchema,
1459
+ LiquidationSideSchema,
1381
1460
  OpenInterestArrayResponseSchema,
1382
1461
  OpenInterestResponseSchema,
1383
1462
  OpenInterestSchema,