@rabby-wallet/hyperliquid-sdk 1.0.0-beta.6 → 1.0.0-beta.8

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
@@ -32,8 +32,10 @@ const sdk = new HyperliquidSDK({
32
32
  // 获取所有中间价
33
33
  const prices = await sdk.info.getAllMids();
34
34
 
35
- // 获取市场元数据与资产上下文
36
- const [meta, assetCtxs] = await sdk.info.metaAndAssetCtxs();
35
+ // 获取市场元数据与资产上下文
36
+ const canUseCache = true; //默认使用缓存,多次请求并发去重 ,需要刷新传false
37
+ const [meta, assetCtxs] = await sdk.info.metaAndAssetCtxs(canUseCache);
38
+
37
39
 
38
40
  // 获取账户综合状态
39
41
  const account = await sdk.info.getClearingHouseState();
@@ -32,7 +32,7 @@ export declare class ExchangeClient {
32
32
  * need to update leverage before place order
33
33
  */
34
34
  marketOrderOpen(params: MarketOrderParams): Promise<OrderResponse>;
35
- marketOrderClose(params: MarketOrderParams): Promise<OrderResponse>;
35
+ marketOrderClose(params: Omit<MarketOrderParams, 'tpTriggerPx' | 'slTriggerPx'>): Promise<OrderResponse>;
36
36
  /**
37
37
  * Place multiple orders at once
38
38
  */
@@ -1,9 +1,11 @@
1
1
  import { HttpClientConfig } from "./http-client";
2
+ import { InfoClient } from "./info-client";
2
3
  export declare class SymbolConversion {
3
4
  private assetToIndexMap;
4
5
  private httpClient;
5
6
  private initialized;
6
- constructor(config: HttpClientConfig);
7
+ private infoClient?;
8
+ constructor(config: HttpClientConfig, infoClient?: InfoClient);
7
9
  initialize(): Promise<void>;
8
10
  private ensureInitialized;
9
11
  private refreshAssetMaps;
@@ -13,9 +13,10 @@ exports.SymbolConversion = void 0;
13
13
  const constants_1 = require("../types/constants");
14
14
  const http_client_1 = require("./http-client");
15
15
  class SymbolConversion {
16
- constructor(config) {
16
+ constructor(config, infoClient) {
17
17
  this.assetToIndexMap = new Map();
18
18
  this.initialized = false;
19
+ this.infoClient = infoClient;
19
20
  this.httpClient = new http_client_1.HttpClient({
20
21
  isTestnet: config.isTestnet,
21
22
  timeout: config.timeout,
@@ -46,9 +47,15 @@ class SymbolConversion {
46
47
  refreshAssetMaps() {
47
48
  return __awaiter(this, void 0, void 0, function* () {
48
49
  try {
49
- const perpMeta = yield this.httpClient.info({
50
- type: constants_1.InfoType.META_AND_ASSET_CTXS,
51
- });
50
+ let perpMeta = null;
51
+ if (!this.infoClient) {
52
+ perpMeta = yield this.httpClient.info({
53
+ type: constants_1.InfoType.META_AND_ASSET_CTXS,
54
+ });
55
+ }
56
+ else {
57
+ perpMeta = yield this.infoClient.metaAndAssetCtxs(false);
58
+ }
52
59
  // Verify responses are valid before proceeding
53
60
  if (!perpMeta ||
54
61
  !perpMeta[0] ||
@@ -21,16 +21,15 @@ const symbolConversion_1 = require("./client/symbolConversion");
21
21
  */
22
22
  class HyperliquidSDK {
23
23
  constructor(config) {
24
- // Initialize info client (always available)
25
- this.symbolConversion = new symbolConversion_1.SymbolConversion({
26
- isTestnet: config.isTestnet,
27
- timeout: config.timeout,
28
- });
29
24
  this.info = new info_client_1.InfoClient({
30
25
  masterAddress: config.masterAddress,
31
26
  isTestnet: config.isTestnet,
32
27
  timeout: config.timeout,
33
28
  });
29
+ this.symbolConversion = new symbolConversion_1.SymbolConversion({
30
+ isTestnet: config.isTestnet,
31
+ timeout: config.timeout,
32
+ }, this.info);
34
33
  this.masterAddress = config.masterAddress;
35
34
  this.configParams = config;
36
35
  // Initialize exchange client only if private key is provided
@@ -226,6 +226,7 @@ export interface WsFill {
226
226
  tid: number;
227
227
  }
228
228
  export interface AssetCtx {
229
+ dayBaseVlm: string;
229
230
  dayNtlVlm: string;
230
231
  funding: string;
231
232
  impactPxs: [string, string];
@@ -247,13 +248,13 @@ export interface L2Book {
247
248
  export interface WsActiveAssetCtx {
248
249
  coin: string;
249
250
  ctx: {
250
- dayNtlVlm: number;
251
- prevDayPx: number;
252
- markPx: number;
253
- midPx?: number;
254
- funding: number;
255
- openInterest: number;
256
- oraclePx: number;
251
+ dayNtlVlm: string;
252
+ prevDayPx: string;
253
+ markPx: string;
254
+ midPx?: string;
255
+ funding: string;
256
+ openInterest: string;
257
+ oraclePx: string;
257
258
  };
258
259
  }
259
260
  export interface Candle {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/hyperliquid-sdk",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.8",
4
4
  "description": "Simplified Hyperliquid Perpetuals Trading SDK for Frontend Applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",