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

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();
@@ -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 = {}));
@@ -380,6 +380,15 @@ export declare enum Abstraction {
380
380
  PORTFOLIO_MARGIN = "p",
381
381
  DISABLED = "i"
382
382
  }
383
+ export declare enum UserAbstraction {
384
+ UNIFIED_ACCOUNT = "unifiedAccount",
385
+ PORTFOLIO_MARGIN = "portfolioMargin",
386
+ DISABLED = "disabled"
387
+ }
388
+ export interface UserSetAbstractionParams {
389
+ user: string;
390
+ abstraction: UserAbstraction;
391
+ }
383
392
  export declare enum UserAbstractionResp {
384
393
  unifiedAccount = "unifiedAccount",
385
394
  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.2",
4
4
  "description": "Simplified Hyperliquid Perpetuals Trading SDK for Frontend Applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",