@0xarchive/sdk 0.5.0 → 0.5.2
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.d.mts +312 -58
- package/dist/index.d.ts +312 -58
- package/dist/index.js +80 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 {
|
|
@@ -688,6 +707,54 @@ var CandlesResource = class {
|
|
|
688
707
|
}
|
|
689
708
|
};
|
|
690
709
|
|
|
710
|
+
// src/resources/liquidations.ts
|
|
711
|
+
var LiquidationsResource = class {
|
|
712
|
+
constructor(http, basePath = "/v1") {
|
|
713
|
+
this.http = http;
|
|
714
|
+
this.basePath = basePath;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Get liquidation history for a coin with cursor-based pagination
|
|
718
|
+
*
|
|
719
|
+
* @param coin - The coin symbol (e.g., 'BTC', 'ETH')
|
|
720
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
721
|
+
* @returns CursorResponse with liquidation records and nextCursor for pagination
|
|
722
|
+
*/
|
|
723
|
+
async history(coin, params) {
|
|
724
|
+
const response = await this.http.get(
|
|
725
|
+
`${this.basePath}/liquidations/${coin.toUpperCase()}`,
|
|
726
|
+
params,
|
|
727
|
+
this.http.validationEnabled ? LiquidationArrayResponseSchema : void 0
|
|
728
|
+
);
|
|
729
|
+
return {
|
|
730
|
+
data: response.data,
|
|
731
|
+
nextCursor: response.meta.nextCursor
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Get liquidation history for a specific user
|
|
736
|
+
*
|
|
737
|
+
* This returns liquidations where the user was either:
|
|
738
|
+
* - The liquidated party (their position was liquidated)
|
|
739
|
+
* - The liquidator (they executed the liquidation)
|
|
740
|
+
*
|
|
741
|
+
* @param userAddress - User's wallet address (e.g., '0x1234...')
|
|
742
|
+
* @param params - Time range and cursor pagination parameters (start and end are required)
|
|
743
|
+
* @returns CursorResponse with liquidation records and nextCursor for pagination
|
|
744
|
+
*/
|
|
745
|
+
async byUser(userAddress, params) {
|
|
746
|
+
const response = await this.http.get(
|
|
747
|
+
`${this.basePath}/liquidations/user/${userAddress}`,
|
|
748
|
+
params,
|
|
749
|
+
this.http.validationEnabled ? LiquidationArrayResponseSchema : void 0
|
|
750
|
+
);
|
|
751
|
+
return {
|
|
752
|
+
data: response.data,
|
|
753
|
+
nextCursor: response.meta.nextCursor
|
|
754
|
+
};
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
|
|
691
758
|
// src/exchanges.ts
|
|
692
759
|
var HyperliquidClient = class {
|
|
693
760
|
/**
|
|
@@ -714,6 +781,10 @@ var HyperliquidClient = class {
|
|
|
714
781
|
* OHLCV candle data
|
|
715
782
|
*/
|
|
716
783
|
candles;
|
|
784
|
+
/**
|
|
785
|
+
* Liquidation events (May 2025+)
|
|
786
|
+
*/
|
|
787
|
+
liquidations;
|
|
717
788
|
constructor(http) {
|
|
718
789
|
const basePath = "/v1/hyperliquid";
|
|
719
790
|
this.orderbook = new OrderBookResource(http, basePath);
|
|
@@ -722,6 +793,7 @@ var HyperliquidClient = class {
|
|
|
722
793
|
this.funding = new FundingResource(http, basePath);
|
|
723
794
|
this.openInterest = new OpenInterestResource(http, basePath);
|
|
724
795
|
this.candles = new CandlesResource(http, basePath);
|
|
796
|
+
this.liquidations = new LiquidationsResource(http, basePath);
|
|
725
797
|
}
|
|
726
798
|
};
|
|
727
799
|
var LighterClient = class {
|
|
@@ -1084,7 +1156,8 @@ var OxArchiveWs = class {
|
|
|
1084
1156
|
start: options.start,
|
|
1085
1157
|
end: options.end,
|
|
1086
1158
|
speed: options.speed ?? 1,
|
|
1087
|
-
granularity: options.granularity
|
|
1159
|
+
granularity: options.granularity,
|
|
1160
|
+
interval: options.interval
|
|
1088
1161
|
});
|
|
1089
1162
|
}
|
|
1090
1163
|
/**
|
|
@@ -1139,7 +1212,8 @@ var OxArchiveWs = class {
|
|
|
1139
1212
|
start: options.start,
|
|
1140
1213
|
end: options.end,
|
|
1141
1214
|
batch_size: options.batchSize ?? 1e3,
|
|
1142
|
-
granularity: options.granularity
|
|
1215
|
+
granularity: options.granularity,
|
|
1216
|
+
interval: options.interval
|
|
1143
1217
|
});
|
|
1144
1218
|
}
|
|
1145
1219
|
/**
|
|
@@ -1376,6 +1450,9 @@ var OxArchiveWs = class {
|
|
|
1376
1450
|
InstrumentSchema,
|
|
1377
1451
|
InstrumentTypeSchema,
|
|
1378
1452
|
LighterClient,
|
|
1453
|
+
LiquidationArrayResponseSchema,
|
|
1454
|
+
LiquidationSchema,
|
|
1455
|
+
LiquidationSideSchema,
|
|
1379
1456
|
OpenInterestArrayResponseSchema,
|
|
1380
1457
|
OpenInterestResponseSchema,
|
|
1381
1458
|
OpenInterestSchema,
|