@0xarchive/sdk 0.9.0 → 0.9.1

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 CHANGED
@@ -407,18 +407,26 @@ for (const bucket of volume.data) {
407
407
  Check when each data type was last updated for a specific coin. Useful for verifying data recency before pulling it.
408
408
 
409
409
  ```typescript
410
+ // Hyperliquid
410
411
  const freshness = await client.hyperliquid.freshness('BTC');
411
412
  console.log(`Orderbook last updated: ${freshness.orderbook.lastUpdated}, lag: ${freshness.orderbook.lagMs}ms`);
412
413
  console.log(`Trades last updated: ${freshness.trades.lastUpdated}, lag: ${freshness.trades.lagMs}ms`);
413
414
  console.log(`Funding last updated: ${freshness.funding.lastUpdated}`);
414
415
  console.log(`OI last updated: ${freshness.openInterest.lastUpdated}`);
416
+
417
+ // Lighter.xyz
418
+ const lighterFreshness = await client.lighter.freshness('BTC');
419
+
420
+ // HIP-3 (case-sensitive coins)
421
+ const hip3Freshness = await client.hyperliquid.hip3.freshness('km:US500');
415
422
  ```
416
423
 
417
- ### Summary (Hyperliquid only)
424
+ ### Summary
418
425
 
419
426
  Get a combined market snapshot in a single call -- mark/oracle price, funding rate, open interest, 24h volume, and 24h liquidation volumes.
420
427
 
421
428
  ```typescript
429
+ // Hyperliquid (includes volume + liquidation data)
422
430
  const summary = await client.hyperliquid.summary('BTC');
423
431
  console.log(`Mark price: ${summary.markPrice}`);
424
432
  console.log(`Oracle price: ${summary.oraclePrice}`);
@@ -428,14 +436,21 @@ console.log(`24h volume: ${summary.volume24h}`);
428
436
  console.log(`24h liquidation volume: $${summary.liquidationVolume24h}`);
429
437
  console.log(` Long: $${summary.longLiquidationVolume24h}`);
430
438
  console.log(` Short: $${summary.shortLiquidationVolume24h}`);
439
+
440
+ // Lighter.xyz (price, funding, OI — no volume/liquidation data)
441
+ const lighterSummary = await client.lighter.summary('BTC');
442
+
443
+ // HIP-3 (includes mid_price — case-sensitive coins)
444
+ const hip3Summary = await client.hyperliquid.hip3.summary('km:US500');
445
+ console.log(`Mid price: ${hip3Summary.midPrice}`);
431
446
  ```
432
447
 
433
- ### Price History (Hyperliquid only)
448
+ ### Price History
434
449
 
435
- Get mark, oracle, and mid price history over time. Supports aggregation intervals. Data projected from open interest records (available from May 2023).
450
+ Get mark, oracle, and mid price history over time. Supports aggregation intervals. Data projected from open interest records.
436
451
 
437
452
  ```typescript
438
- // Get hourly price history for the last 24 hours
453
+ // Hyperliquid available from May 2023
439
454
  const prices = await client.hyperliquid.priceHistory('BTC', {
440
455
  start: Date.now() - 86400000,
441
456
  end: Date.now(),
@@ -446,6 +461,20 @@ for (const snapshot of prices.data) {
446
461
  console.log(`${snapshot.timestamp}: mark=${snapshot.markPrice}, oracle=${snapshot.oraclePrice}, mid=${snapshot.midPrice}`);
447
462
  }
448
463
 
464
+ // Lighter.xyz
465
+ const lighterPrices = await client.lighter.priceHistory('BTC', {
466
+ start: Date.now() - 86400000,
467
+ end: Date.now(),
468
+ interval: '1h'
469
+ });
470
+
471
+ // HIP-3 (case-sensitive coins)
472
+ const hip3Prices = await client.hyperliquid.hip3.priceHistory('km:US500', {
473
+ start: Date.now() - 86400000,
474
+ end: Date.now(),
475
+ interval: '1d'
476
+ });
477
+
449
478
  // Paginate for larger ranges
450
479
  let result = await client.hyperliquid.priceHistory('BTC', {
451
480
  start: Date.now() - 86400000 * 30,
package/dist/index.d.mts CHANGED
@@ -363,6 +363,8 @@ interface Candle {
363
363
  interface CandleHistoryParams extends CursorPaginationParams {
364
364
  /** Candle interval (default: 1h) */
365
365
  interval?: CandleInterval;
366
+ /** Maximum number of results to return (default: 100, max: 10000 for candles) */
367
+ limit?: number;
366
368
  }
367
369
  /** Pre-aggregated liquidation volume bucket */
368
370
  interface LiquidationVolume {
@@ -1695,7 +1697,7 @@ declare class OpenInterestResource {
1695
1697
  * start: Date.now() - 86400000,
1696
1698
  * end: Date.now(),
1697
1699
  * interval: '1h',
1698
- * limit: 1000
1700
+ * limit: 10000
1699
1701
  * });
1700
1702
  *
1701
1703
  * // Get all pages
@@ -1706,7 +1708,7 @@ declare class OpenInterestResource {
1706
1708
  * end: Date.now(),
1707
1709
  * interval: '1h',
1708
1710
  * cursor: result.nextCursor,
1709
- * limit: 1000
1711
+ * limit: 10000
1710
1712
  * });
1711
1713
  * allCandles.push(...result.data);
1712
1714
  * }
@@ -2085,7 +2087,30 @@ declare class Hip3Client {
2085
2087
  * OHLCV candle data
2086
2088
  */
2087
2089
  readonly candles: CandlesResource;
2090
+ private http;
2088
2091
  constructor(http: HttpClient);
2092
+ /**
2093
+ * Get per-coin data freshness across all data types
2094
+ *
2095
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2096
+ * @returns Per-coin freshness with last_updated and lag_ms for each data type
2097
+ */
2098
+ freshness(coin: string): Promise<CoinFreshness>;
2099
+ /**
2100
+ * Get combined market summary (price, funding, OI) in one call
2101
+ *
2102
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2103
+ * @returns Combined market summary
2104
+ */
2105
+ summary(coin: string): Promise<CoinSummary>;
2106
+ /**
2107
+ * Get mark/oracle/mid price history (projected from OI data)
2108
+ *
2109
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2110
+ * @param params - Time range, cursor, and interval parameters
2111
+ * @returns CursorResponse with price snapshots
2112
+ */
2113
+ priceHistory(coin: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2089
2114
  }
2090
2115
  /**
2091
2116
  * Lighter.xyz exchange client
@@ -2126,7 +2151,30 @@ declare class LighterClient {
2126
2151
  * OHLCV candle data
2127
2152
  */
2128
2153
  readonly candles: CandlesResource;
2154
+ private http;
2129
2155
  constructor(http: HttpClient);
2156
+ /**
2157
+ * Get per-coin data freshness across all data types
2158
+ *
2159
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2160
+ * @returns Per-coin freshness with last_updated and lag_ms for each data type
2161
+ */
2162
+ freshness(coin: string): Promise<CoinFreshness>;
2163
+ /**
2164
+ * Get combined market summary (price, funding, OI) in one call
2165
+ *
2166
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2167
+ * @returns Combined market summary
2168
+ */
2169
+ summary(coin: string): Promise<CoinSummary>;
2170
+ /**
2171
+ * Get mark/oracle price history (projected from OI data)
2172
+ *
2173
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2174
+ * @param params - Time range, cursor, and interval parameters
2175
+ * @returns CursorResponse with price snapshots
2176
+ */
2177
+ priceHistory(coin: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2130
2178
  }
2131
2179
 
2132
2180
  /**
package/dist/index.d.ts CHANGED
@@ -363,6 +363,8 @@ interface Candle {
363
363
  interface CandleHistoryParams extends CursorPaginationParams {
364
364
  /** Candle interval (default: 1h) */
365
365
  interval?: CandleInterval;
366
+ /** Maximum number of results to return (default: 100, max: 10000 for candles) */
367
+ limit?: number;
366
368
  }
367
369
  /** Pre-aggregated liquidation volume bucket */
368
370
  interface LiquidationVolume {
@@ -1695,7 +1697,7 @@ declare class OpenInterestResource {
1695
1697
  * start: Date.now() - 86400000,
1696
1698
  * end: Date.now(),
1697
1699
  * interval: '1h',
1698
- * limit: 1000
1700
+ * limit: 10000
1699
1701
  * });
1700
1702
  *
1701
1703
  * // Get all pages
@@ -1706,7 +1708,7 @@ declare class OpenInterestResource {
1706
1708
  * end: Date.now(),
1707
1709
  * interval: '1h',
1708
1710
  * cursor: result.nextCursor,
1709
- * limit: 1000
1711
+ * limit: 10000
1710
1712
  * });
1711
1713
  * allCandles.push(...result.data);
1712
1714
  * }
@@ -2085,7 +2087,30 @@ declare class Hip3Client {
2085
2087
  * OHLCV candle data
2086
2088
  */
2087
2089
  readonly candles: CandlesResource;
2090
+ private http;
2088
2091
  constructor(http: HttpClient);
2092
+ /**
2093
+ * Get per-coin data freshness across all data types
2094
+ *
2095
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2096
+ * @returns Per-coin freshness with last_updated and lag_ms for each data type
2097
+ */
2098
+ freshness(coin: string): Promise<CoinFreshness>;
2099
+ /**
2100
+ * Get combined market summary (price, funding, OI) in one call
2101
+ *
2102
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2103
+ * @returns Combined market summary
2104
+ */
2105
+ summary(coin: string): Promise<CoinSummary>;
2106
+ /**
2107
+ * Get mark/oracle/mid price history (projected from OI data)
2108
+ *
2109
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
2110
+ * @param params - Time range, cursor, and interval parameters
2111
+ * @returns CursorResponse with price snapshots
2112
+ */
2113
+ priceHistory(coin: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2089
2114
  }
2090
2115
  /**
2091
2116
  * Lighter.xyz exchange client
@@ -2126,7 +2151,30 @@ declare class LighterClient {
2126
2151
  * OHLCV candle data
2127
2152
  */
2128
2153
  readonly candles: CandlesResource;
2154
+ private http;
2129
2155
  constructor(http: HttpClient);
2156
+ /**
2157
+ * Get per-coin data freshness across all data types
2158
+ *
2159
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2160
+ * @returns Per-coin freshness with last_updated and lag_ms for each data type
2161
+ */
2162
+ freshness(coin: string): Promise<CoinFreshness>;
2163
+ /**
2164
+ * Get combined market summary (price, funding, OI) in one call
2165
+ *
2166
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2167
+ * @returns Combined market summary
2168
+ */
2169
+ summary(coin: string): Promise<CoinSummary>;
2170
+ /**
2171
+ * Get mark/oracle price history (projected from OI data)
2172
+ *
2173
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
2174
+ * @param params - Time range, cursor, and interval parameters
2175
+ * @returns CursorResponse with price snapshots
2176
+ */
2177
+ priceHistory(coin: string, params: PriceHistoryParams): Promise<CursorResponse<PriceSnapshot[]>>;
2130
2178
  }
2131
2179
 
2132
2180
  /**
package/dist/index.js CHANGED
@@ -1596,7 +1596,9 @@ var Hip3Client = class {
1596
1596
  * OHLCV candle data
1597
1597
  */
1598
1598
  candles;
1599
+ http;
1599
1600
  constructor(http) {
1601
+ this.http = http;
1600
1602
  const basePath = "/v1/hyperliquid/hip3";
1601
1603
  const coinTransform = (c) => c;
1602
1604
  this.instruments = new Hip3InstrumentsResource(http, basePath, coinTransform);
@@ -1606,6 +1608,52 @@ var Hip3Client = class {
1606
1608
  this.openInterest = new OpenInterestResource(http, basePath, coinTransform);
1607
1609
  this.candles = new CandlesResource(http, basePath, coinTransform);
1608
1610
  }
1611
+ /**
1612
+ * Get per-coin data freshness across all data types
1613
+ *
1614
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
1615
+ * @returns Per-coin freshness with last_updated and lag_ms for each data type
1616
+ */
1617
+ async freshness(coin) {
1618
+ const response = await this.http.get(
1619
+ `/v1/hyperliquid/hip3/freshness/${coin}`,
1620
+ void 0,
1621
+ this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
1622
+ );
1623
+ return response.data;
1624
+ }
1625
+ /**
1626
+ * Get combined market summary (price, funding, OI) in one call
1627
+ *
1628
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
1629
+ * @returns Combined market summary
1630
+ */
1631
+ async summary(coin) {
1632
+ const response = await this.http.get(
1633
+ `/v1/hyperliquid/hip3/summary/${coin}`,
1634
+ void 0,
1635
+ this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
1636
+ );
1637
+ return response.data;
1638
+ }
1639
+ /**
1640
+ * Get mark/oracle/mid price history (projected from OI data)
1641
+ *
1642
+ * @param coin - The coin symbol (case-sensitive, e.g., 'km:US500')
1643
+ * @param params - Time range, cursor, and interval parameters
1644
+ * @returns CursorResponse with price snapshots
1645
+ */
1646
+ async priceHistory(coin, params) {
1647
+ const response = await this.http.get(
1648
+ `/v1/hyperliquid/hip3/prices/${coin}`,
1649
+ params,
1650
+ this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
1651
+ );
1652
+ return {
1653
+ data: response.data,
1654
+ nextCursor: response.meta.nextCursor
1655
+ };
1656
+ }
1609
1657
  };
1610
1658
  var LighterClient = class {
1611
1659
  /**
@@ -1632,7 +1680,9 @@ var LighterClient = class {
1632
1680
  * OHLCV candle data
1633
1681
  */
1634
1682
  candles;
1683
+ http;
1635
1684
  constructor(http) {
1685
+ this.http = http;
1636
1686
  const basePath = "/v1/lighter";
1637
1687
  this.orderbook = new OrderBookResource(http, basePath);
1638
1688
  this.trades = new TradesResource(http, basePath);
@@ -1641,6 +1691,52 @@ var LighterClient = class {
1641
1691
  this.openInterest = new OpenInterestResource(http, basePath);
1642
1692
  this.candles = new CandlesResource(http, basePath);
1643
1693
  }
1694
+ /**
1695
+ * Get per-coin data freshness across all data types
1696
+ *
1697
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1698
+ * @returns Per-coin freshness with last_updated and lag_ms for each data type
1699
+ */
1700
+ async freshness(coin) {
1701
+ const response = await this.http.get(
1702
+ `/v1/lighter/freshness/${coin.toUpperCase()}`,
1703
+ void 0,
1704
+ this.http.validationEnabled ? CoinFreshnessResponseSchema : void 0
1705
+ );
1706
+ return response.data;
1707
+ }
1708
+ /**
1709
+ * Get combined market summary (price, funding, OI) in one call
1710
+ *
1711
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1712
+ * @returns Combined market summary
1713
+ */
1714
+ async summary(coin) {
1715
+ const response = await this.http.get(
1716
+ `/v1/lighter/summary/${coin.toUpperCase()}`,
1717
+ void 0,
1718
+ this.http.validationEnabled ? CoinSummaryResponseSchema : void 0
1719
+ );
1720
+ return response.data;
1721
+ }
1722
+ /**
1723
+ * Get mark/oracle price history (projected from OI data)
1724
+ *
1725
+ * @param coin - The coin symbol (e.g., 'BTC', 'ETH')
1726
+ * @param params - Time range, cursor, and interval parameters
1727
+ * @returns CursorResponse with price snapshots
1728
+ */
1729
+ async priceHistory(coin, params) {
1730
+ const response = await this.http.get(
1731
+ `/v1/lighter/prices/${coin.toUpperCase()}`,
1732
+ params,
1733
+ this.http.validationEnabled ? PriceSnapshotArrayResponseSchema : void 0
1734
+ );
1735
+ return {
1736
+ data: response.data,
1737
+ nextCursor: response.meta.nextCursor
1738
+ };
1739
+ }
1644
1740
  };
1645
1741
 
1646
1742
  // src/client.ts