@rabby-wallet/hyperliquid-sdk 1.1.7-beta.1 → 1.1.7-beta.3

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,5 +1,5 @@
1
1
  import { ExchangeType } from '../types/constants';
2
- import type { OrderResponse, CancelResponse, ExchangeClientConfig, PlaceOrderParams, MultiOrderParams, CancelOrderParams, ModifyOrderParams, WithdrawParams, SendAssetParams, ApproveBuilderFeeParams, PrepareApproveBuilderFeeResult, SendApproveParams, MarketOrderParams, UpdateLeverageParams, BindTpslByOrderIdParams, UpdateIsolatedMarginParams, TwapOrderParams, TwapCancelParams, TwapOrderResponse, PlaceTPSlMarketOrderParams, PlaceTPSlLimitOrderParams, ClearinghouseState, UpdateTpslByOrderIdParams, LimitOrderParams, Abstraction, Tif } from '../types';
2
+ import type { OrderResponse, CancelResponse, ExchangeClientConfig, PlaceOrderParams, MultiOrderParams, CancelOrderParams, ModifyOrderParams, WithdrawParams, SendAssetParams, ApproveBuilderFeeParams, PrepareApproveBuilderFeeResult, SendApproveParams, MarketOrderParams, UpdateLeverageParams, BindTpslByOrderIdParams, UpdateIsolatedMarginParams, TwapOrderParams, TwapCancelParams, TwapOrderResponse, PlaceTPSlMarketOrderParams, PlaceTPSlLimitOrderParams, ClearinghouseState, UpdateTpslByOrderIdParams, LimitOrderParams, Abstraction, UserSetAbstractionParams, Tif } from '../types';
3
3
  /**
4
4
  * Client for executing trades on Hyperliquid (perpetuals only)
5
5
  * Only includes essential trading APIs as specified
@@ -116,6 +116,17 @@ export declare class ExchangeClient {
116
116
  */
117
117
  setReferrer(code: string): Promise<any>;
118
118
  agentEnableDexAbstraction(): Promise<any>;
119
+ /**
120
+ * Prepare userSetAbstraction data for main wallet signing
121
+ * Must be signed by the master wallet (NOT the agent)
122
+ * abstraction values: 'disabled' | 'unifiedAccount' | 'portfolioMargin'
123
+ */
124
+ prepareUserSetAbstraction(params: UserSetAbstractionParams): PrepareApproveBuilderFeeResult;
125
+ /**
126
+ * Send userSetAbstraction request with main wallet signature
127
+ * nonce must be the same as the nonce in prepareUserSetAbstraction
128
+ */
129
+ sendUserSetAbstraction(params: SendApproveParams): Promise<any>;
119
130
  agentSetAbstraction(abstraction: Abstraction): Promise<any>;
120
131
  /**
121
132
  * Prepare approve agent data for main wallet signing
@@ -797,6 +797,52 @@ class ExchangeClient {
797
797
  }
798
798
  });
799
799
  }
800
+ /**
801
+ * Prepare userSetAbstraction data for main wallet signing
802
+ * Must be signed by the master wallet (NOT the agent)
803
+ * abstraction values: 'disabled' | 'unifiedAccount' | 'portfolioMargin'
804
+ */
805
+ prepareUserSetAbstraction(params) {
806
+ const nonce = Date.now();
807
+ const action = {
808
+ type: constants_1.ExchangeType.USER_SET_ABSTRACTION,
809
+ hyperliquidChain: this.isTestnet ? 'Testnet' : 'Mainnet',
810
+ signatureChainId: this.isTestnet ? '0x66eee' : '0xa4b1',
811
+ user: params.user,
812
+ abstraction: params.abstraction,
813
+ nonce,
814
+ };
815
+ const { domain, types, primaryType, message } = (0, signer_1.prepareMasterSignData)({
816
+ action,
817
+ payloadTypes: [
818
+ { name: 'hyperliquidChain', type: 'string' },
819
+ { name: 'user', type: 'address' },
820
+ { name: 'abstraction', type: 'string' },
821
+ { name: 'nonce', type: 'uint64' },
822
+ ],
823
+ primaryType: 'HyperliquidTransaction:UserSetAbstraction',
824
+ isMainnet: !this.isTestnet,
825
+ });
826
+ return {
827
+ domain,
828
+ types,
829
+ primaryType,
830
+ message,
831
+ nonce,
832
+ };
833
+ }
834
+ /**
835
+ * Send userSetAbstraction request with main wallet signature
836
+ * nonce must be the same as the nonce in prepareUserSetAbstraction
837
+ */
838
+ sendUserSetAbstraction(params) {
839
+ const splitSignature = (0, signer_1.splitSig)(params.signature);
840
+ return this.httpClient.exchange({
841
+ action: params.action,
842
+ nonce: params.nonce,
843
+ signature: splitSignature,
844
+ });
845
+ }
800
846
  agentSetAbstraction(abstraction) {
801
847
  return __awaiter(this, void 0, void 0, function* () {
802
848
  const nonce = Date.now();
@@ -1080,8 +1126,8 @@ class ExchangeClient {
1080
1126
  const orderRequest = {
1081
1127
  a: assetIndex,
1082
1128
  b: isBuy,
1083
- p: limitPx,
1084
- s: size,
1129
+ p: (0, number_1.removeTrailingZeros)(limitPx),
1130
+ s: (0, number_1.removeTrailingZeros)(size),
1085
1131
  r: false,
1086
1132
  t: {
1087
1133
  limit: { tif },
@@ -27,6 +27,7 @@ export declare enum ExchangeType {
27
27
  SET_REFERRER = "setReferrer",
28
28
  AGENT_ENABLE_DEX_ABSTRACTION = "agentEnableDexAbstraction",
29
29
  AGENT_SET_ABSTRACTION = "agentSetAbstraction",
30
+ USER_SET_ABSTRACTION = "userSetAbstraction",
30
31
  TWAP_ORDER = "twapOrder",
31
32
  TWAP_CANCEL = "twapCancel"
32
33
  }
@@ -33,6 +33,7 @@ var ExchangeType;
33
33
  ExchangeType["SET_REFERRER"] = "setReferrer";
34
34
  ExchangeType["AGENT_ENABLE_DEX_ABSTRACTION"] = "agentEnableDexAbstraction";
35
35
  ExchangeType["AGENT_SET_ABSTRACTION"] = "agentSetAbstraction";
36
+ ExchangeType["USER_SET_ABSTRACTION"] = "userSetAbstraction";
36
37
  ExchangeType["TWAP_ORDER"] = "twapOrder";
37
38
  ExchangeType["TWAP_CANCEL"] = "twapCancel";
38
39
  })(ExchangeType || (exports.ExchangeType = ExchangeType = {}));
@@ -221,6 +221,11 @@ export type UserNonFundingLedgerUpdates = {
221
221
  basis?: string;
222
222
  netWithdrawnUsd?: string;
223
223
  toPerp?: boolean;
224
+ destination?: string;
225
+ destinationDex?: string;
226
+ sourceDex?: string;
227
+ source?: string;
228
+ fee?: string;
224
229
  };
225
230
  };
226
231
  export interface OrderResponse {
@@ -380,6 +385,15 @@ export declare enum Abstraction {
380
385
  PORTFOLIO_MARGIN = "p",
381
386
  DISABLED = "i"
382
387
  }
388
+ export declare enum UserAbstraction {
389
+ UNIFIED_ACCOUNT = "unifiedAccount",
390
+ PORTFOLIO_MARGIN = "portfolioMargin",
391
+ DISABLED = "disabled"
392
+ }
393
+ export interface UserSetAbstractionParams {
394
+ user: string;
395
+ abstraction: UserAbstraction;
396
+ }
383
397
  export declare enum UserAbstractionResp {
384
398
  unifiedAccount = "unifiedAccount",
385
399
  portfolioMargin = "portfolioMargin",
@@ -1,12 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.USDC_TOKEN_ID = exports.UserAbstractionResp = exports.Abstraction = void 0;
3
+ exports.USDC_TOKEN_ID = exports.UserAbstractionResp = exports.UserAbstraction = 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 UserAbstraction;
11
+ (function (UserAbstraction) {
12
+ UserAbstraction["UNIFIED_ACCOUNT"] = "unifiedAccount";
13
+ UserAbstraction["PORTFOLIO_MARGIN"] = "portfolioMargin";
14
+ UserAbstraction["DISABLED"] = "disabled";
15
+ })(UserAbstraction || (exports.UserAbstraction = UserAbstraction = {}));
10
16
  var UserAbstractionResp;
11
17
  (function (UserAbstractionResp) {
12
18
  UserAbstractionResp["unifiedAccount"] = "unifiedAccount";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/hyperliquid-sdk",
3
- "version": "1.1.7-beta.1",
3
+ "version": "1.1.7-beta.3",
4
4
  "description": "Simplified Hyperliquid Perpetuals Trading SDK for Frontend Applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",