@rabby-wallet/hyperliquid-sdk 1.0.0-beta.2 → 1.0.0-beta.4

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, UserFills, CandleSnapshot, AllMids, ExtraAgent, OpenOrder, FeeResponse } from '../types';
1
+ import type { Meta, AssetCtx, ClearinghouseState, UserFills, CandleSnapshot, AllMids, ExtraAgent, OpenOrder, FeeResponse, UserNonFundingLedgerUpdates } from '../types';
2
2
  export interface InfoClientConfig {
3
3
  isTestnet?: boolean;
4
4
  timeout?: number;
@@ -22,6 +22,7 @@ export declare class InfoClient {
22
22
  metaAndAssetCtxs(): Promise<[Meta, AssetCtx[]]>;
23
23
  getClearingHouseState(address?: string): Promise<ClearinghouseState>;
24
24
  getFrontendOpenOrders(address?: string): Promise<OpenOrder[]>;
25
+ getUserNonFundingLedgerUpdates(address?: string, startTime?: number, endTime?: number): Promise<UserNonFundingLedgerUpdates[]>;
25
26
  /**
26
27
  * Get user's fill history
27
28
  */
@@ -68,6 +68,16 @@ class InfoClient {
68
68
  // user: this.masterAddress,
69
69
  // });
70
70
  // }
71
+ getUserNonFundingLedgerUpdates(address, startTime, endTime) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ return this.httpClient.info({
74
+ type: constants_1.InfoType.USER_NON_FUNDING_LEDGER_UPDATES,
75
+ user: address || this.masterAddress,
76
+ startTime: startTime || 0,
77
+ endTime,
78
+ });
79
+ });
80
+ }
71
81
  /**
72
82
  * Get user's fill history
73
83
  */
@@ -1,4 +1,4 @@
1
- import type { AllMids, L2Book, Candle, WsFill, WsOrder, WebData2 } from '../types';
1
+ import type { AllMids, L2Book, Candle, WsFill, WsOrder, WebData2, WsActiveAssetCtx } from '../types';
2
2
  export interface WebSocketClientConfig {
3
3
  masterAddress: string;
4
4
  isTestnet?: boolean;
@@ -43,6 +43,10 @@ export declare class WebSocketClient {
43
43
  * Subscribe to L2 order book for a specific coin
44
44
  */
45
45
  subscribeToL2Book(coin: string, callback: SubscriptionCallback<L2Book>): Subscription;
46
+ /**
47
+ * Subscribe to active asset ctx
48
+ */
49
+ subscribeToActiveAssetCtx(coin: string, callback: SubscriptionCallback<WsActiveAssetCtx>): Subscription;
46
50
  /**
47
51
  * Subscribe to trades for a specific coin
48
52
  */
@@ -159,6 +159,14 @@ class WebSocketClient {
159
159
  subscription: { type: 'l2Book', coin },
160
160
  }, callback);
161
161
  }
162
+ /**
163
+ * Subscribe to active asset ctx
164
+ */
165
+ subscribeToActiveAssetCtx(coin, callback) {
166
+ return this.subscribe({
167
+ subscription: { type: 'activeAssetCtx', coin },
168
+ }, callback);
169
+ }
162
170
  /**
163
171
  * Subscribe to trades for a specific coin
164
172
  */
@@ -27,6 +27,7 @@ export declare enum ExchangeType {
27
27
  }
28
28
  export declare enum InfoType {
29
29
  ALL_MIDS = "allMids",
30
+ USER_NON_FUNDING_LEDGER_UPDATES = "userNonFundingLedgerUpdates",
30
31
  USER_OPEN_ORDERS = "openOrders",
31
32
  USER_FILLS = "userFills",
32
33
  USER_FILLS_BY_TIME = "userFillsByTime",
@@ -35,7 +36,6 @@ export declare enum InfoType {
35
36
  CANDLES_SNAPSHOT = "candleSnapshot",
36
37
  META_AND_ASSET_CTXS = "metaAndAssetCtxs",
37
38
  USER_FUNDING = "userFunding",
38
- USER_NON_FUNDING_LEDGER_UPDATES = "userNonFundingLedgerUpdates",
39
39
  FUNDING_HISTORY = "fundingHistory",
40
40
  CLEARINGHOUSE_STATE = "clearinghouseState",
41
41
  META = "meta",
@@ -35,6 +35,7 @@ var ExchangeType;
35
35
  var InfoType;
36
36
  (function (InfoType) {
37
37
  InfoType["ALL_MIDS"] = "allMids";
38
+ InfoType["USER_NON_FUNDING_LEDGER_UPDATES"] = "userNonFundingLedgerUpdates";
38
39
  InfoType["USER_OPEN_ORDERS"] = "openOrders";
39
40
  InfoType["USER_FILLS"] = "userFills";
40
41
  InfoType["USER_FILLS_BY_TIME"] = "userFillsByTime";
@@ -43,7 +44,6 @@ var InfoType;
43
44
  InfoType["CANDLES_SNAPSHOT"] = "candleSnapshot";
44
45
  InfoType["META_AND_ASSET_CTXS"] = "metaAndAssetCtxs";
45
46
  InfoType["USER_FUNDING"] = "userFunding";
46
- InfoType["USER_NON_FUNDING_LEDGER_UPDATES"] = "userNonFundingLedgerUpdates";
47
47
  InfoType["FUNDING_HISTORY"] = "fundingHistory";
48
48
  InfoType["CLEARINGHOUSE_STATE"] = "clearinghouseState";
49
49
  InfoType["META"] = "meta";
@@ -121,6 +121,24 @@ export interface UserFill {
121
121
  export type UserFills = {
122
122
  [asset: string]: UserFill[];
123
123
  };
124
+ export type UserNonFundingLedgerUpdates = {
125
+ time: number;
126
+ hash: string;
127
+ delta: {
128
+ type: string;
129
+ usdc?: string;
130
+ vault?: string;
131
+ user?: string;
132
+ token?: string;
133
+ amount?: string;
134
+ requestedUsd?: string;
135
+ commission?: string;
136
+ closingCost?: string;
137
+ basis?: string;
138
+ netWithdrawnUsd?: string;
139
+ toPerp?: boolean;
140
+ };
141
+ };
124
142
  export interface OrderResponse {
125
143
  status: 'ok';
126
144
  response: {
@@ -219,6 +237,18 @@ export interface L2Book {
219
237
  levels: [WsLevel[], WsLevel[]];
220
238
  time: number;
221
239
  }
240
+ export interface WsActiveAssetCtx {
241
+ coin: string;
242
+ ctx: {
243
+ dayNtlVlm: number;
244
+ prevDayPx: number;
245
+ markPx: number;
246
+ midPx?: number;
247
+ funding: number;
248
+ openInterest: number;
249
+ oraclePx: number;
250
+ };
251
+ }
222
252
  export interface Candle {
223
253
  t: number;
224
254
  T: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/hyperliquid-sdk",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "Simplified Hyperliquid Perpetuals Trading SDK for Frontend Applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",