@rabby-wallet/hyperliquid-sdk 1.1.5-beta.1 → 1.1.6-beta.0

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, ApproveBuilderFeeParams, PrepareApproveBuilderFeeResult, SendApproveParams, MarketOrderParams, UpdateLeverageParams, BindTpslByOrderIdParams, UpdateIsolatedMarginParams, TwapOrderParams, TwapCancelParams, TwapOrderResponse, PlaceTPSlMarketOrderParams, PlaceTPSlLimitOrderParams, ClearinghouseState, UpdateTpslByOrderIdParams, LimitOrderParams, Abstraction } 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 } from '../types';
3
3
  /**
4
4
  * Client for executing trades on Hyperliquid (perpetuals only)
5
5
  * Only includes essential trading APIs as specified
@@ -156,6 +156,12 @@ export declare class ExchangeClient {
156
156
  */
157
157
  prepareWithdraw(params: WithdrawParams): PrepareApproveBuilderFeeResult;
158
158
  sendWithdraw(params: SendApproveParams): Promise<any>;
159
+ /**
160
+ * Send asset between dexes or to HyperEVM via system address
161
+ * Need use master wallet
162
+ */
163
+ prepareSendAsset(params: SendAssetParams): PrepareApproveBuilderFeeResult;
164
+ sendSendAsset(params: SendApproveParams): Promise<any>;
159
165
  /**
160
166
  * Place a TWAP order
161
167
  * TWAP orders split a large order into smaller slices over time
@@ -956,6 +956,55 @@ class ExchangeClient {
956
956
  signature: splitSignature,
957
957
  });
958
958
  }
959
+ /**
960
+ * Send asset between dexes or to HyperEVM via system address
961
+ * Need use master wallet
962
+ */
963
+ prepareSendAsset(params) {
964
+ const nonce = Date.now();
965
+ const action = {
966
+ type: constants_1.ExchangeType.SEND_ASSET,
967
+ hyperliquidChain: this.isTestnet ? 'Testnet' : 'Mainnet',
968
+ signatureChainId: this.isTestnet ? '0x66eee' : '0xa4b1',
969
+ destination: params.destination,
970
+ sourceDex: params.sourceDex || '',
971
+ destinationDex: params.destinationDex || '',
972
+ token: params.token,
973
+ amount: params.amount,
974
+ fromSubAccount: params.fromSubAccount || '',
975
+ nonce,
976
+ };
977
+ const { domain, types, primaryType, message } = (0, signer_1.prepareMasterSignData)({
978
+ action,
979
+ payloadTypes: [
980
+ { name: 'hyperliquidChain', type: 'string' },
981
+ { name: 'destination', type: 'string' },
982
+ { name: 'sourceDex', type: 'string' },
983
+ { name: 'destinationDex', type: 'string' },
984
+ { name: 'token', type: 'string' },
985
+ { name: 'amount', type: 'string' },
986
+ { name: 'fromSubAccount', type: 'string' },
987
+ { name: 'nonce', type: 'uint64' },
988
+ ],
989
+ primaryType: 'HyperliquidTransaction:SendAsset',
990
+ isMainnet: !this.isTestnet,
991
+ });
992
+ return {
993
+ domain,
994
+ types,
995
+ primaryType,
996
+ message,
997
+ nonce,
998
+ };
999
+ }
1000
+ sendSendAsset(params) {
1001
+ const splitSignature = (0, signer_1.splitSig)(params.signature);
1002
+ return this.httpClient.exchange({
1003
+ action: params.action,
1004
+ nonce: params.nonce,
1005
+ signature: splitSignature,
1006
+ });
1007
+ }
959
1008
  /**
960
1009
  * Place a TWAP order
961
1010
  * TWAP orders split a large order into smaller slices over time
@@ -20,6 +20,7 @@ export declare enum ExchangeType {
20
20
  UPDATE_ISOLATED_MARGIN = "updateIsolatedMargin",
21
21
  USD_SEND = "usdSend",
22
22
  WITHDRAW = "withdraw3",
23
+ SEND_ASSET = "sendAsset",
23
24
  APPROVE_AGENT = "approveAgent",
24
25
  APPROVE_BUILDER_FEE = "approveBuilderFee",
25
26
  SUB_ACCOUNT_TRANSFER = "subAccountTransfer",
@@ -26,6 +26,7 @@ var ExchangeType;
26
26
  ExchangeType["UPDATE_ISOLATED_MARGIN"] = "updateIsolatedMargin";
27
27
  ExchangeType["USD_SEND"] = "usdSend";
28
28
  ExchangeType["WITHDRAW"] = "withdraw3";
29
+ ExchangeType["SEND_ASSET"] = "sendAsset";
29
30
  ExchangeType["APPROVE_AGENT"] = "approveAgent";
30
31
  ExchangeType["APPROVE_BUILDER_FEE"] = "approveBuilderFee";
31
32
  ExchangeType["SUB_ACCOUNT_TRANSFER"] = "subAccountTransfer";
@@ -578,6 +578,14 @@ export interface WithdrawParams {
578
578
  destination: string;
579
579
  amount: string;
580
580
  }
581
+ export interface SendAssetParams {
582
+ destination: string;
583
+ amount: string;
584
+ token: string;
585
+ sourceDex?: string;
586
+ destinationDex?: string;
587
+ fromSubAccount?: string;
588
+ }
581
589
  export interface DepositParams {
582
590
  amount: string;
583
591
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/hyperliquid-sdk",
3
- "version": "1.1.5-beta.1",
3
+ "version": "1.1.6-beta.0",
4
4
  "description": "Simplified Hyperliquid Perpetuals Trading SDK for Frontend Applications",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",