@rabby-wallet/hyperliquid-sdk 1.1.4 → 1.1.5

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.
@@ -1,4 +1,4 @@
1
- import type { Meta, AssetCtx, ClearinghouseState, CandleSnapshot, AllMids, ExtraAgent, OpenOrder, FeeResponse, UserNonFundingLedgerUpdates, UserHistoricalOrders, ReferralResponse, L2BookSnapshot, UserTwapSliceFill, FundingHistoryItem, UserFunding, WsFill, PerpDexsResponse } from '../types';
1
+ import type { Meta, AssetCtx, ClearinghouseState, CandleSnapshot, AllMids, ExtraAgent, OpenOrder, FeeResponse, UserNonFundingLedgerUpdates, UserHistoricalOrders, ReferralResponse, L2BookSnapshot, UserTwapSliceFill, FundingHistoryItem, UserFunding, WsFill, PerpDexsResponse, UserAbstractionResp, SpotClearinghouseState } from '../types';
2
2
  export interface InfoClientConfig {
3
3
  isTestnet?: boolean;
4
4
  timeout?: number;
@@ -19,6 +19,8 @@ export declare class InfoClient {
19
19
  * dex: undefined means hyper; and 'xyz' means xyz dex
20
20
  */
21
21
  getAllMids(dex?: string): Promise<AllMids>;
22
+ getDexAbstraction(address?: string): Promise<boolean>;
23
+ getUserAbstraction(address?: string): Promise<UserAbstractionResp>;
22
24
  initMasterAddress(masterAddress: string): void;
23
25
  /**
24
26
  * Get metadata and asset contexts
@@ -32,6 +34,10 @@ export declare class InfoClient {
32
34
  * dex: undefined means hyper; and 'xyz' means xyz dex
33
35
  */
34
36
  getClearingHouseState(address?: string, dex?: string): Promise<ClearinghouseState>;
37
+ /**
38
+ * Get Spot clearing house state
39
+ */
40
+ getSpotClearingHouseState(address?: string): Promise<SpotClearinghouseState>;
35
41
  getFrontendOpenOrders(address?: string, dex?: string): Promise<OpenOrder[]>;
36
42
  getUserNonFundingLedgerUpdates(address?: string, startTime?: number, endTime?: number): Promise<UserNonFundingLedgerUpdates[]>;
37
43
  /**
@@ -38,6 +38,30 @@ class InfoClient {
38
38
  });
39
39
  });
40
40
  }
41
+ getDexAbstraction(address) {
42
+ return __awaiter(this, void 0, void 0, function* () {
43
+ const user = address || this.masterAddress;
44
+ if (!user) {
45
+ throw new Error('user address is empty');
46
+ }
47
+ return this.httpClient.info({
48
+ type: constants_1.InfoType.USER_DEX_ABSTRACTION,
49
+ user,
50
+ });
51
+ });
52
+ }
53
+ getUserAbstraction(address) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const user = address || this.masterAddress;
56
+ if (!user) {
57
+ throw new Error('user address is empty');
58
+ }
59
+ return this.httpClient.info({
60
+ type: constants_1.InfoType.USER_ABSTRACTION,
61
+ user,
62
+ });
63
+ });
64
+ }
41
65
  initMasterAddress(masterAddress) {
42
66
  this.masterAddress = masterAddress;
43
67
  }
@@ -94,6 +118,21 @@ class InfoClient {
94
118
  });
95
119
  });
96
120
  }
121
+ /**
122
+ * Get Spot clearing house state
123
+ */
124
+ getSpotClearingHouseState(address) {
125
+ return __awaiter(this, void 0, void 0, function* () {
126
+ const user = address || this.masterAddress;
127
+ if (!user) {
128
+ throw new Error('user address is empty');
129
+ }
130
+ return this.httpClient.info({
131
+ type: constants_1.InfoType.SPOT_CLEARINGHOUSE_STATE,
132
+ user,
133
+ });
134
+ });
135
+ }
97
136
  // frontendOpenOrders
98
137
  getFrontendOpenOrders(address, dex) {
99
138
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,4 @@
1
- import type { L2Book, Candle, WsOrder, WebData2, WsActiveAssetCtx, WsUserFills, WsClearinghouseState, Notification, WsTwapStates, WsOpenOrders, WsUserTwapSliceFills, WsUserTwapHistory, wsUserNonFundingLedgerUpdates, WsAllMids, WsTrade, WsActiveAssetData, WsUserHistoricalOrders, WsUserFunding, WsAllDexsAssetCtxs, WsAllClearinghouseStates } from '../types';
1
+ import type { L2Book, Candle, WsOrder, WebData2, WsActiveAssetCtx, WsUserFills, WsClearinghouseState, Notification, WsTwapStates, WsOpenOrders, WsUserTwapSliceFills, WsUserTwapHistory, wsUserNonFundingLedgerUpdates, WsAllMids, WsTrade, WsActiveAssetData, WsUserHistoricalOrders, WsUserFunding, WsAllDexsAssetCtxs, WsAllClearinghouseStates, WsSpotClearinghouseState } from '../types';
2
2
  export interface WebSocketClientConfig {
3
3
  masterAddress?: string;
4
4
  isTestnet?: boolean;
@@ -121,6 +121,7 @@ export declare class WebSocketClient {
121
121
  */
122
122
  subscribeToAllDexsAssetCtxs(callback: SubscriptionCallback<WsAllDexsAssetCtxs>): Subscription;
123
123
  subscribeToClearinghouseState(user: string | string[], callback: SubscriptionCallback<WsClearinghouseState>): Subscription;
124
+ subscribeToSpotState(callback: SubscriptionCallback<WsSpotClearinghouseState>): Subscription;
124
125
  subscribeToAllDexsClearinghouseState(user: string | string[], callback: SubscriptionCallback<WsAllClearinghouseStates>): Subscription;
125
126
  /**
126
127
  * Check if WebSocket is connected
@@ -433,6 +433,14 @@ class WebSocketClient {
433
433
  }
434
434
  };
435
435
  }
436
+ subscribeToSpotState(callback) {
437
+ if (!this.config.masterAddress) {
438
+ throw new Error('masterAddress is empty');
439
+ }
440
+ return this.subscribe({
441
+ subscription: { type: constants_1.WsSubscriptionType.SPOT_STATE, user: this.config.masterAddress },
442
+ }, callback);
443
+ }
436
444
  subscribeToAllDexsClearinghouseState(user, callback) {
437
445
  const users = Array.isArray(user) ? user : [user];
438
446
  if (users.length === 0) {
@@ -48,6 +48,7 @@ export declare enum InfoType {
48
48
  USER_FUNDING = "userFunding",
49
49
  FUNDING_HISTORY = "fundingHistory",
50
50
  CLEARINGHOUSE_STATE = "clearinghouseState",
51
+ SPOT_CLEARINGHOUSE_STATE = "spotClearinghouseState",
51
52
  META = "meta",
52
53
  FRONTEND_OPEN_ORDERS = "frontendOpenOrders",
53
54
  PREDICTED_FUNDINGS = "predictedFundings",
@@ -56,6 +57,8 @@ export declare enum InfoType {
56
57
  USER_FEES = "userFees",
57
58
  USER_ROLE = "userRole",
58
59
  EXTRA_AGENTS = "extraAgents",
60
+ USER_DEX_ABSTRACTION = "userDexAbstraction",
61
+ USER_ABSTRACTION = "userAbstraction",
59
62
  REFERRAL = "referral"
60
63
  }
61
64
  export declare enum OrderType {
@@ -92,6 +95,7 @@ export declare enum WsSubscriptionType {
92
95
  CLEARINGHOUSE_STATE = "clearinghouseState",
93
96
  ALL_DEXS_CLEARINGHOUSE_STATES = "allDexsClearinghouseState",
94
97
  NOTIFICATION = "notification",
98
+ SPOT_STATE = "spotState",
95
99
  TWAP_STATES = "twapStates",
96
100
  OPEN_ORDERS = "openOrders",
97
101
  USER_NON_FUNDING_LEDGER_UPDATES = "userNonFundingLedgerUpdates",
@@ -56,6 +56,7 @@ var InfoType;
56
56
  InfoType["USER_FUNDING"] = "userFunding";
57
57
  InfoType["FUNDING_HISTORY"] = "fundingHistory";
58
58
  InfoType["CLEARINGHOUSE_STATE"] = "clearinghouseState";
59
+ InfoType["SPOT_CLEARINGHOUSE_STATE"] = "spotClearinghouseState";
59
60
  InfoType["META"] = "meta";
60
61
  InfoType["FRONTEND_OPEN_ORDERS"] = "frontendOpenOrders";
61
62
  InfoType["PREDICTED_FUNDINGS"] = "predictedFundings";
@@ -64,6 +65,8 @@ var InfoType;
64
65
  InfoType["USER_FEES"] = "userFees";
65
66
  InfoType["USER_ROLE"] = "userRole";
66
67
  InfoType["EXTRA_AGENTS"] = "extraAgents";
68
+ InfoType["USER_DEX_ABSTRACTION"] = "userDexAbstraction";
69
+ InfoType["USER_ABSTRACTION"] = "userAbstraction";
67
70
  InfoType["REFERRAL"] = "referral";
68
71
  })(InfoType || (exports.InfoType = InfoType = {}));
69
72
  // Order types
@@ -107,6 +110,7 @@ var WsSubscriptionType;
107
110
  WsSubscriptionType["CLEARINGHOUSE_STATE"] = "clearinghouseState";
108
111
  WsSubscriptionType["ALL_DEXS_CLEARINGHOUSE_STATES"] = "allDexsClearinghouseState";
109
112
  WsSubscriptionType["NOTIFICATION"] = "notification";
113
+ WsSubscriptionType["SPOT_STATE"] = "spotState";
110
114
  WsSubscriptionType["TWAP_STATES"] = "twapStates";
111
115
  WsSubscriptionType["OPEN_ORDERS"] = "openOrders";
112
116
  WsSubscriptionType["USER_NON_FUNDING_LEDGER_UPDATES"] = "userNonFundingLedgerUpdates";
@@ -374,9 +374,31 @@ export declare enum Abstraction {
374
374
  PORTFOLIO_MARGIN = "p",
375
375
  DISABLED = "i"
376
376
  }
377
+ export declare enum UserAbstractionResp {
378
+ unifiedAccount = "unifiedAccount",
379
+ portfolioMargin = "portfolioMargin",
380
+ disabled = "disabled",
381
+ default = "default",
382
+ dexAbstraction = "dexAbstraction"
383
+ }
377
384
  export interface WsAllDexsAssetCtxs {
378
385
  ctxs: [string, AssetCtx[]][];
379
386
  }
387
+ export declare const USDC_TOKEN_ID = 0;
388
+ export interface SpotClearinghouseState {
389
+ balances: {
390
+ coin: string;
391
+ token: number;
392
+ total: string;
393
+ hold: string;
394
+ entryNtl: string;
395
+ }[];
396
+ tokenToAvailableAfterMaintenance?: [number, string][];
397
+ }
398
+ export interface WsSpotClearinghouseState {
399
+ user: string;
400
+ spotState: SpotClearinghouseState;
401
+ }
380
402
  export interface WsAllClearinghouseStates {
381
403
  clearinghouseStates: [string, ClearinghouseState][];
382
404
  }
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Abstraction = void 0;
3
+ exports.USDC_TOKEN_ID = exports.UserAbstractionResp = exports.Abstraction = void 0;
4
4
  var Abstraction;
5
5
  (function (Abstraction) {
6
6
  Abstraction["UNIFIED_ACCOUNT"] = "u";
7
7
  Abstraction["PORTFOLIO_MARGIN"] = "p";
8
8
  Abstraction["DISABLED"] = "i";
9
9
  })(Abstraction || (exports.Abstraction = Abstraction = {}));
10
+ var UserAbstractionResp;
11
+ (function (UserAbstractionResp) {
12
+ UserAbstractionResp["unifiedAccount"] = "unifiedAccount";
13
+ UserAbstractionResp["portfolioMargin"] = "portfolioMargin";
14
+ UserAbstractionResp["disabled"] = "disabled";
15
+ UserAbstractionResp["default"] = "default";
16
+ UserAbstractionResp["dexAbstraction"] = "dexAbstraction";
17
+ })(UserAbstractionResp || (exports.UserAbstractionResp = UserAbstractionResp = {}));
18
+ exports.USDC_TOKEN_ID = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/hyperliquid-sdk",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Simplified Hyperliquid Perpetuals Trading SDK for Frontend Applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",