@rabby-wallet/hyperliquid-sdk 1.0.0-beta.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.
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.HyperliquidSDK = void 0;
13
+ const info_client_1 = require("./client/info-client");
14
+ const exchange_client_1 = require("./client/exchange-client");
15
+ const websocket_client_1 = require("./client/websocket-client");
16
+ const symbolConversion_1 = require("./client/symbolConversion");
17
+ /**
18
+ * Main Hyperliquid SDK class for perpetuals trading
19
+ * Simplified version with only essential APIs
20
+ * if use exchange api, must provide agentPrivateKey, agentPublicKey, agentName
21
+ */
22
+ class HyperliquidSDK {
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
+ this.info = new info_client_1.InfoClient({
30
+ masterAddress: config.masterAddress,
31
+ isTestnet: config.isTestnet,
32
+ timeout: config.timeout,
33
+ symbolConversion: this.symbolConversion,
34
+ });
35
+ this.masterAddress = config.masterAddress;
36
+ this.configParams = config;
37
+ // Initialize exchange client only if private key is provided
38
+ if (config.agentPrivateKey) {
39
+ this.exchange = new exchange_client_1.ExchangeClient({
40
+ masterAddress: config.masterAddress,
41
+ agentPrivateKey: config.agentPrivateKey,
42
+ agentPublicKey: config.agentPublicKey,
43
+ agentName: config.agentName,
44
+ isTestnet: config.isTestnet,
45
+ timeout: config.timeout,
46
+ symbolConversion: this.symbolConversion,
47
+ });
48
+ }
49
+ // Initialize WebSocket client (full functionality preserved)
50
+ this.ws = new websocket_client_1.WebSocketClient(Object.assign({ masterAddress: config.masterAddress, isTestnet: config.isTestnet, symbolConversion: this.symbolConversion }, config.wsConfig));
51
+ }
52
+ /**
53
+ * Get wallet address (only available if private key was provided)
54
+ */
55
+ get address() {
56
+ return this.masterAddress;
57
+ }
58
+ updateExchangeAgent(agentPrivateKey, agentPublicKey, agentName) {
59
+ this.exchange = new exchange_client_1.ExchangeClient(Object.assign(Object.assign({}, this.configParams), { symbolConversion: this.symbolConversion, agentPrivateKey,
60
+ agentPublicKey,
61
+ agentName }));
62
+ }
63
+ /**
64
+ * Connect to WebSocket for real-time data
65
+ */
66
+ connectWebSocket() {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ return this.ws.connect();
69
+ });
70
+ }
71
+ /**
72
+ * Disconnect from WebSocket
73
+ */
74
+ disconnectWebSocket() {
75
+ this.ws.disconnect();
76
+ }
77
+ /**
78
+ * Check if WebSocket is connected
79
+ */
80
+ get isWebSocketConnected() {
81
+ return this.ws.isConnected;
82
+ }
83
+ /**
84
+ * Quick helper: Get account summary with essential info
85
+ */
86
+ getAccountSummary() {
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ return this.info.getClearingHouseState();
89
+ });
90
+ }
91
+ /**
92
+ * Quick helper: Get market overview
93
+ */
94
+ getMarketOverview() {
95
+ return __awaiter(this, void 0, void 0, function* () {
96
+ const [meta, assetCtxs] = yield this.info.metaAndAssetCtxs();
97
+ return {
98
+ assets: meta.universe,
99
+ assetContexts: assetCtxs,
100
+ marginTables: meta.marginTables,
101
+ };
102
+ });
103
+ }
104
+ }
105
+ exports.HyperliquidSDK = HyperliquidSDK;
@@ -0,0 +1,9 @@
1
+ export { HyperliquidSDK, HyperliquidSDKConfig } from './hyperliquid-sdk';
2
+ export { InfoClient, InfoClientConfig } from './client/info-client';
3
+ export { ExchangeClient } from './client/exchange-client';
4
+ export { WebSocketClient, WebSocketClientConfig } from './client/websocket-client';
5
+ export { HttpClient, HttpClientConfig } from './client/http-client';
6
+ export * from './types';
7
+ export * from './types/constants';
8
+ export { BASE_URLS, WSS_URLS, ENDPOINTS } from './types/constants';
9
+ export { InfoType, ExchangeType, OrderType, TimeInForce } from './types/constants';
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.TimeInForce = exports.OrderType = exports.ExchangeType = exports.InfoType = exports.ENDPOINTS = exports.WSS_URLS = exports.BASE_URLS = exports.HttpClient = exports.WebSocketClient = exports.ExchangeClient = exports.InfoClient = exports.HyperliquidSDK = void 0;
18
+ // Main SDK
19
+ var hyperliquid_sdk_1 = require("./hyperliquid-sdk");
20
+ Object.defineProperty(exports, "HyperliquidSDK", { enumerable: true, get: function () { return hyperliquid_sdk_1.HyperliquidSDK; } });
21
+ // Individual clients
22
+ var info_client_1 = require("./client/info-client");
23
+ Object.defineProperty(exports, "InfoClient", { enumerable: true, get: function () { return info_client_1.InfoClient; } });
24
+ var exchange_client_1 = require("./client/exchange-client");
25
+ Object.defineProperty(exports, "ExchangeClient", { enumerable: true, get: function () { return exchange_client_1.ExchangeClient; } });
26
+ var websocket_client_1 = require("./client/websocket-client");
27
+ Object.defineProperty(exports, "WebSocketClient", { enumerable: true, get: function () { return websocket_client_1.WebSocketClient; } });
28
+ var http_client_1 = require("./client/http-client");
29
+ Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_client_1.HttpClient; } });
30
+ // Types
31
+ __exportStar(require("./types"), exports);
32
+ __exportStar(require("./types/constants"), exports);
33
+ // Convenience exports for common use cases
34
+ var constants_1 = require("./types/constants");
35
+ Object.defineProperty(exports, "BASE_URLS", { enumerable: true, get: function () { return constants_1.BASE_URLS; } });
36
+ Object.defineProperty(exports, "WSS_URLS", { enumerable: true, get: function () { return constants_1.WSS_URLS; } });
37
+ Object.defineProperty(exports, "ENDPOINTS", { enumerable: true, get: function () { return constants_1.ENDPOINTS; } });
38
+ var constants_2 = require("./types/constants");
39
+ Object.defineProperty(exports, "InfoType", { enumerable: true, get: function () { return constants_2.InfoType; } });
40
+ Object.defineProperty(exports, "ExchangeType", { enumerable: true, get: function () { return constants_2.ExchangeType; } });
41
+ Object.defineProperty(exports, "OrderType", { enumerable: true, get: function () { return constants_2.OrderType; } });
42
+ Object.defineProperty(exports, "TimeInForce", { enumerable: true, get: function () { return constants_2.TimeInForce; } });
@@ -0,0 +1,67 @@
1
+ export declare const BASE_URLS: {
2
+ readonly PRODUCTION: "https://api.hyperliquid.xyz";
3
+ readonly TESTNET: "https://api.hyperliquid-testnet.xyz";
4
+ };
5
+ export declare const WSS_URLS: {
6
+ readonly PRODUCTION: "wss://api.hyperliquid.xyz/ws";
7
+ readonly TESTNET: "wss://api.hyperliquid-testnet.xyz/ws";
8
+ };
9
+ export declare const ENDPOINTS: {
10
+ readonly INFO: "/info";
11
+ readonly EXCHANGE: "/exchange";
12
+ };
13
+ export declare enum ExchangeType {
14
+ ORDER = "order",
15
+ CANCEL = "cancel",
16
+ CANCEL_BY_CLOID = "cancelByCloid",
17
+ MODIFY = "modify",
18
+ BATCH_MODIFY = "batchModify",
19
+ UPDATE_LEVERAGE = "updateLeverage",
20
+ UPDATE_ISOLATED_MARGIN = "updateIsolatedMargin",
21
+ USD_SEND = "usdSend",
22
+ WITHDRAW = "withdraw3",
23
+ APPROVE_AGENT = "approveAgent",
24
+ APPROVE_BUILDER_FEE = "approveBuilderFee",
25
+ SUB_ACCOUNT_TRANSFER = "subAccountTransfer",
26
+ SET_REFERRER = "setReferrer"
27
+ }
28
+ export declare enum InfoType {
29
+ ALL_MIDS = "allMids",
30
+ USER_OPEN_ORDERS = "openOrders",
31
+ USER_FILLS = "userFills",
32
+ USER_FILLS_BY_TIME = "userFillsByTime",
33
+ ORDER_STATUS = "orderStatus",
34
+ L2_BOOK = "l2Book",
35
+ CANDLES_SNAPSHOT = "candleSnapshot",
36
+ META_AND_ASSET_CTXS = "metaAndAssetCtxs",
37
+ USER_FUNDING = "userFunding",
38
+ USER_NON_FUNDING_LEDGER_UPDATES = "userNonFundingLedgerUpdates",
39
+ FUNDING_HISTORY = "fundingHistory",
40
+ CLEARINGHOUSE_STATE = "clearinghouseState",
41
+ META = "meta",
42
+ FRONTEND_OPEN_ORDERS = "frontendOpenOrders",
43
+ PREDICTED_FUNDINGS = "predictedFundings",
44
+ ACTIVE_ASSET_DATA = "activeAssetData",
45
+ CHECK_BUILDER_FEE_APPROVAL = "checkBuilderFeeApproval",
46
+ USER_FEES = "userFees",
47
+ EXTRA_AGENTS = "extraAgents"
48
+ }
49
+ export declare enum OrderType {
50
+ LIMIT = "limit",
51
+ MARKET = "market",
52
+ STOP_MARKET = "stopMarket",
53
+ STOP_LIMIT = "stopLimit",
54
+ TAKE_PROFIT_MARKET = "tpMarket",
55
+ TAKE_PROFIT_LIMIT = "tpLimit"
56
+ }
57
+ export declare enum TimeInForce {
58
+ GTC = "Gtc",// Good Till Cancel
59
+ IOC = "Ioc",// Immediate or Cancel
60
+ ALO = "Alo"
61
+ }
62
+ export declare const CHAIN_IDS: {
63
+ readonly ARBITRUM_MAINNET: 42161;
64
+ readonly ARBITRUM_TESTNET: 421614;
65
+ readonly HYPERLIQUID_MAINNET: 1337;
66
+ };
67
+ export declare const SLIPPAGE = 0.08;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SLIPPAGE = exports.CHAIN_IDS = exports.TimeInForce = exports.OrderType = exports.InfoType = exports.ExchangeType = exports.ENDPOINTS = exports.WSS_URLS = exports.BASE_URLS = void 0;
4
+ // API endpoints
5
+ exports.BASE_URLS = {
6
+ PRODUCTION: 'https://api.hyperliquid.xyz',
7
+ TESTNET: 'https://api.hyperliquid-testnet.xyz',
8
+ };
9
+ exports.WSS_URLS = {
10
+ PRODUCTION: 'wss://api.hyperliquid.xyz/ws',
11
+ TESTNET: 'wss://api.hyperliquid-testnet.xyz/ws',
12
+ };
13
+ exports.ENDPOINTS = {
14
+ INFO: '/info',
15
+ EXCHANGE: '/exchange',
16
+ };
17
+ // Exchange types (perpetuals only)
18
+ var ExchangeType;
19
+ (function (ExchangeType) {
20
+ ExchangeType["ORDER"] = "order";
21
+ ExchangeType["CANCEL"] = "cancel";
22
+ ExchangeType["CANCEL_BY_CLOID"] = "cancelByCloid";
23
+ ExchangeType["MODIFY"] = "modify";
24
+ ExchangeType["BATCH_MODIFY"] = "batchModify";
25
+ ExchangeType["UPDATE_LEVERAGE"] = "updateLeverage";
26
+ ExchangeType["UPDATE_ISOLATED_MARGIN"] = "updateIsolatedMargin";
27
+ ExchangeType["USD_SEND"] = "usdSend";
28
+ ExchangeType["WITHDRAW"] = "withdraw3";
29
+ ExchangeType["APPROVE_AGENT"] = "approveAgent";
30
+ ExchangeType["APPROVE_BUILDER_FEE"] = "approveBuilderFee";
31
+ ExchangeType["SUB_ACCOUNT_TRANSFER"] = "subAccountTransfer";
32
+ ExchangeType["SET_REFERRER"] = "setReferrer";
33
+ })(ExchangeType || (exports.ExchangeType = ExchangeType = {}));
34
+ // Info types for API requests (perpetuals only)
35
+ var InfoType;
36
+ (function (InfoType) {
37
+ InfoType["ALL_MIDS"] = "allMids";
38
+ InfoType["USER_OPEN_ORDERS"] = "openOrders";
39
+ InfoType["USER_FILLS"] = "userFills";
40
+ InfoType["USER_FILLS_BY_TIME"] = "userFillsByTime";
41
+ InfoType["ORDER_STATUS"] = "orderStatus";
42
+ InfoType["L2_BOOK"] = "l2Book";
43
+ InfoType["CANDLES_SNAPSHOT"] = "candleSnapshot";
44
+ InfoType["META_AND_ASSET_CTXS"] = "metaAndAssetCtxs";
45
+ InfoType["USER_FUNDING"] = "userFunding";
46
+ InfoType["USER_NON_FUNDING_LEDGER_UPDATES"] = "userNonFundingLedgerUpdates";
47
+ InfoType["FUNDING_HISTORY"] = "fundingHistory";
48
+ InfoType["CLEARINGHOUSE_STATE"] = "clearinghouseState";
49
+ InfoType["META"] = "meta";
50
+ InfoType["FRONTEND_OPEN_ORDERS"] = "frontendOpenOrders";
51
+ InfoType["PREDICTED_FUNDINGS"] = "predictedFundings";
52
+ InfoType["ACTIVE_ASSET_DATA"] = "activeAssetData";
53
+ InfoType["CHECK_BUILDER_FEE_APPROVAL"] = "checkBuilderFeeApproval";
54
+ InfoType["USER_FEES"] = "userFees";
55
+ InfoType["EXTRA_AGENTS"] = "extraAgents";
56
+ })(InfoType || (exports.InfoType = InfoType = {}));
57
+ // Order types
58
+ var OrderType;
59
+ (function (OrderType) {
60
+ OrderType["LIMIT"] = "limit";
61
+ OrderType["MARKET"] = "market";
62
+ OrderType["STOP_MARKET"] = "stopMarket";
63
+ OrderType["STOP_LIMIT"] = "stopLimit";
64
+ OrderType["TAKE_PROFIT_MARKET"] = "tpMarket";
65
+ OrderType["TAKE_PROFIT_LIMIT"] = "tpLimit";
66
+ })(OrderType || (exports.OrderType = OrderType = {}));
67
+ // Time in force
68
+ var TimeInForce;
69
+ (function (TimeInForce) {
70
+ TimeInForce["GTC"] = "Gtc";
71
+ TimeInForce["IOC"] = "Ioc";
72
+ TimeInForce["ALO"] = "Alo";
73
+ })(TimeInForce || (exports.TimeInForce = TimeInForce = {}));
74
+ // Chain IDs
75
+ exports.CHAIN_IDS = {
76
+ ARBITRUM_MAINNET: 42161,
77
+ ARBITRUM_TESTNET: 421614,
78
+ HYPERLIQUID_MAINNET: 1337,
79
+ };
80
+ exports.SLIPPAGE = 0.08;
@@ -0,0 +1,342 @@
1
+ import { SymbolConversion } from "../client/symbolConversion";
2
+ export type Tif = 'Alo' | 'Ioc' | 'Gtc';
3
+ export type TriggerType = 'tp' | 'sl';
4
+ export type Side = 'A' | 'B';
5
+ export type AssetId = number;
6
+ export type OrderId = number;
7
+ export interface OpenOrder {
8
+ coin: string;
9
+ side: Side;
10
+ limitPx: string;
11
+ sz: string;
12
+ oid: number;
13
+ timestamp: number;
14
+ triggerCondition: string;
15
+ isTrigger: boolean;
16
+ triggerPx: string;
17
+ isPositionTpsl: boolean;
18
+ reduceOnly: boolean;
19
+ orderType: "Take Profit Market" | "Stop Market";
20
+ origSz: "0.0";
21
+ tif: null;
22
+ }
23
+ export interface OrderRequest {
24
+ asset: AssetId;
25
+ isBuy: boolean;
26
+ limitPx: string;
27
+ sz: string;
28
+ reduceOnly: boolean;
29
+ orderType: OrderType;
30
+ }
31
+ export interface LimitOrderType {
32
+ limit: {
33
+ tif: Tif;
34
+ };
35
+ }
36
+ export interface MarketOrderType {
37
+ market: Record<string, never>;
38
+ }
39
+ export interface StopOrderType {
40
+ stopMarket?: {
41
+ triggerPx: string;
42
+ tpsl?: TriggerType;
43
+ };
44
+ stopLimit?: {
45
+ triggerPx: string;
46
+ limitPx: string;
47
+ tif: Tif;
48
+ tpsl?: TriggerType;
49
+ };
50
+ }
51
+ export type OrderType = LimitOrderType | MarketOrderType | StopOrderType;
52
+ export interface AssetInfo {
53
+ name: string;
54
+ szDecimals: number;
55
+ maxLeverage: number;
56
+ onlyIsolated?: boolean;
57
+ isDelisted?: boolean;
58
+ }
59
+ export interface MarginTier {
60
+ lowerBound: string;
61
+ maxLeverage: number;
62
+ }
63
+ export interface MarginTable {
64
+ description: string;
65
+ marginTiers: MarginTier[];
66
+ }
67
+ export type Meta = {
68
+ universe: AssetInfo[];
69
+ marginTables: [number, MarginTable][];
70
+ };
71
+ export interface ClearinghouseState {
72
+ assetPositions: AssetPosition[];
73
+ crossMaintenanceMarginUsed: string;
74
+ crossMarginSummary: MarginSummary;
75
+ marginSummary: MarginSummary;
76
+ time: number;
77
+ withdrawable: string;
78
+ }
79
+ export interface AssetPosition {
80
+ position: {
81
+ coin: string;
82
+ cumFunding: {
83
+ allTime: string;
84
+ sinceChange: string;
85
+ sinceOpen: string;
86
+ };
87
+ entryPx?: string;
88
+ leverage: Leverage;
89
+ liquidationPx?: string;
90
+ marginUsed: string;
91
+ maxLeverage: number;
92
+ positionValue: string;
93
+ returnOnEquity: string;
94
+ szi: string;
95
+ unrealizedPnl: string;
96
+ };
97
+ type: 'oneWay';
98
+ }
99
+ export interface MarginSummary {
100
+ accountValue: string;
101
+ totalMarginUsed: string;
102
+ totalNtlPos: string;
103
+ totalRawUsd: string;
104
+ }
105
+ export interface UserFill {
106
+ coin: string;
107
+ px: string;
108
+ sz: string;
109
+ side: Side;
110
+ time: number;
111
+ startPosition: string;
112
+ dir: string;
113
+ closedPnl: string;
114
+ hash: string;
115
+ oid: number;
116
+ crossed: boolean;
117
+ fee: string;
118
+ liquidationMarkPx?: string;
119
+ tid: number;
120
+ }
121
+ export type UserFills = {
122
+ [asset: string]: UserFill[];
123
+ };
124
+ export interface OrderResponse {
125
+ status: 'ok';
126
+ response: {
127
+ type: 'order';
128
+ data: {
129
+ statuses: Array<{
130
+ resting?: {
131
+ oid: number;
132
+ };
133
+ filled?: {
134
+ totalSz: string;
135
+ avgPx: string;
136
+ };
137
+ error?: string;
138
+ }>;
139
+ };
140
+ };
141
+ }
142
+ export interface MarketOrderParams {
143
+ coin: string;
144
+ isBuy: boolean;
145
+ size: string;
146
+ midPx: string;
147
+ tpTriggerPx?: string;
148
+ slTriggerPx?: string;
149
+ slippage?: number;
150
+ }
151
+ export interface CancelResponse {
152
+ status: 'ok';
153
+ response: {
154
+ type: 'cancel';
155
+ data: {
156
+ statuses: Array<{
157
+ success?: boolean;
158
+ error?: string;
159
+ }>;
160
+ };
161
+ };
162
+ }
163
+ export interface Leverage {
164
+ type: 'cross' | 'isolated';
165
+ value: number;
166
+ rawUsd?: string;
167
+ }
168
+ export interface WsLevel {
169
+ px: string;
170
+ sz: string;
171
+ n: number;
172
+ }
173
+ export interface WsOrder {
174
+ coin: string;
175
+ side: Side;
176
+ limitPx: string;
177
+ sz: string;
178
+ oid: number;
179
+ timestamp: number;
180
+ origSz: string;
181
+ isPositionTpsl: boolean;
182
+ isTrigger: boolean;
183
+ triggerCondition?: string;
184
+ triggerPx?: string;
185
+ children?: WsOrder[];
186
+ user: string;
187
+ }
188
+ export interface WsFill {
189
+ coin: string;
190
+ px: string;
191
+ sz: string;
192
+ side: Side;
193
+ time: number;
194
+ startPosition: string;
195
+ dir: string;
196
+ closedPnl: string;
197
+ hash: string;
198
+ oid: number;
199
+ crossed: boolean;
200
+ fee: string;
201
+ tid: number;
202
+ }
203
+ export interface AssetCtx {
204
+ dayNtlVlm: string;
205
+ funding: string;
206
+ impactPxs: [string, string];
207
+ markPx: string;
208
+ midPx: string;
209
+ openInterest: string;
210
+ oraclePx: string;
211
+ premium: string;
212
+ prevDayPx: string;
213
+ }
214
+ export interface AllMids {
215
+ [coin: string]: string;
216
+ }
217
+ export interface L2Book {
218
+ coin: string;
219
+ levels: [WsLevel[], WsLevel[]];
220
+ time: number;
221
+ }
222
+ export interface Candle {
223
+ t: number;
224
+ T: number;
225
+ s: string;
226
+ i: string;
227
+ o: string;
228
+ c: string;
229
+ h: string;
230
+ l: string;
231
+ v: string;
232
+ n: number;
233
+ }
234
+ export type CandleSnapshot = Candle[];
235
+ export interface FundingHistory {
236
+ coin: string;
237
+ fundingRate: string;
238
+ premium: string;
239
+ time: number;
240
+ }
241
+ export interface Signature {
242
+ r: string;
243
+ s: string;
244
+ v: number;
245
+ }
246
+ export interface ActiveAssetData {
247
+ user: string;
248
+ coin: string;
249
+ leverage: Leverage;
250
+ maxTradeSzs: [string, string];
251
+ availableToTrade: [string, string];
252
+ markPx: string;
253
+ }
254
+ export interface WebData2 {
255
+ assetPositions: AssetPosition[];
256
+ marginSummary: MarginSummary;
257
+ crossMarginSummary: MarginSummary;
258
+ crossMaintenanceMarginUsed: string;
259
+ openOrders: WsOrder[];
260
+ totalNtlPos: string;
261
+ time: number;
262
+ }
263
+ export interface FeeResponse {
264
+ userCrossRate: string;
265
+ userAddRate: string;
266
+ userSpotCrossRate: string;
267
+ userSpotAddRate: string;
268
+ activeReferralDiscount: string;
269
+ }
270
+ export interface ExtraAgent {
271
+ name: string;
272
+ address: string;
273
+ validUntil: number;
274
+ }
275
+ export interface ExchangeClientConfig {
276
+ masterAddress: string;
277
+ agentPrivateKey: string;
278
+ agentPublicKey: string;
279
+ agentName?: string;
280
+ isTestnet?: boolean;
281
+ timeout?: number;
282
+ symbolConversion: SymbolConversion;
283
+ }
284
+ export interface PlaceOrderParams {
285
+ coin: string;
286
+ isBuy: boolean;
287
+ sz: string;
288
+ limitPx: string;
289
+ reduceOnly?: boolean;
290
+ orderType?: any;
291
+ }
292
+ export interface UpdateLeverageParams {
293
+ coin: string;
294
+ leverage: number;
295
+ isCross?: boolean;
296
+ }
297
+ export interface BindTpslByOrderIdParams {
298
+ tpTriggerPx?: string;
299
+ slTriggerPx?: string;
300
+ coin: string;
301
+ isBuy: boolean;
302
+ }
303
+ export interface MultiOrderParams {
304
+ orders: PlaceOrderParams[];
305
+ grouping?: string;
306
+ }
307
+ export interface CancelOrderParams {
308
+ coin: string;
309
+ oid: OrderId;
310
+ }
311
+ export interface ModifyOrderParams {
312
+ oid: OrderId;
313
+ coin: string;
314
+ isBuy: boolean;
315
+ sz: string;
316
+ limitPx: string;
317
+ reduceOnly?: boolean;
318
+ orderType?: any;
319
+ }
320
+ export interface WithdrawParams {
321
+ destination: string;
322
+ amount: string;
323
+ }
324
+ export interface DepositParams {
325
+ amount: string;
326
+ }
327
+ export interface ApproveBuilderFeeParams {
328
+ builder: string;
329
+ maxFee?: string;
330
+ }
331
+ export interface PrepareApproveBuilderFeeResult {
332
+ domain: any;
333
+ types: any;
334
+ primaryType: any;
335
+ message: any;
336
+ nonce: number;
337
+ }
338
+ export interface SendApproveParams {
339
+ action: any;
340
+ nonce: number;
341
+ signature: string;
342
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,35 @@
1
+ import type { TypedMessage, MessageTypes } from '@metamask/eth-sig-util';
2
+ import type { Signature } from '../types';
3
+ export type Eip712Field = {
4
+ name: string;
5
+ type: string;
6
+ };
7
+ export type Eip712Types = Record<string, Eip712Field[]>;
8
+ export declare const EIP712_DOMAIN_TYPES: Array<{
9
+ name: string;
10
+ type: string;
11
+ }>;
12
+ export declare const splitSig: (sig: string) => Signature;
13
+ export declare const signTypedDataV4: ({ privateKey, domain, primaryType, payloadTypes, message, }: {
14
+ privateKey: string;
15
+ domain: {
16
+ name: string;
17
+ version: string;
18
+ chainId: number;
19
+ verifyingContract: string;
20
+ };
21
+ primaryType: string;
22
+ payloadTypes: Eip712Field[];
23
+ message: Record<string, unknown>;
24
+ }) => Signature;
25
+ export declare const signL1AgentAction: (privateKey: string, action: unknown, isTestnet: boolean, nonce: number) => Signature;
26
+ /**
27
+ * Prepare some action sign must by master wallet so we need to prepare the typed data
28
+ * Returns typed data that needs to be signed by the main wallet
29
+ */
30
+ export declare const prepareMasterSignData: ({ action, payloadTypes, primaryType, isMainnet, }: {
31
+ action: Record<string, unknown>;
32
+ payloadTypes: Eip712Field[];
33
+ primaryType: string;
34
+ isMainnet: boolean;
35
+ }) => TypedMessage<MessageTypes>;