@rabby-wallet/hyperliquid-sdk 1.1.7-beta.3 → 1.1.8-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, SendAssetParams, ApproveBuilderFeeParams, PrepareApproveBuilderFeeResult, SendApproveParams, MarketOrderParams, UpdateLeverageParams, BindTpslByOrderIdParams, UpdateIsolatedMarginParams, TwapOrderParams, TwapCancelParams, TwapOrderResponse, PlaceTPSlMarketOrderParams, PlaceTPSlLimitOrderParams, ClearinghouseState, UpdateTpslByOrderIdParams, LimitOrderParams, Abstraction, UserSetAbstractionParams, Tif } from '../types';
2
+ import type { OrderResponse, CancelResponse, ExchangeClientConfig, PlaceOrderParams, MultiOrderParams, CancelOrderParams, ModifyOrderParams, WithdrawParams, SendAssetParams, UsdClassTransferParams, 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
@@ -173,6 +173,15 @@ export declare class ExchangeClient {
173
173
  */
174
174
  prepareSendAsset(params: SendAssetParams): PrepareApproveBuilderFeeResult;
175
175
  sendSendAsset(params: SendApproveParams): Promise<any>;
176
+ /**
177
+ * Move USDC between the spot and perp account on Hyperliquid.
178
+ * Signed by the master wallet.
179
+ *
180
+ * @param params.amount - USDC amount as a decimal string (e.g. "100.5")
181
+ * @param params.toPerp - true: Spot → Perp; false: Perp → Spot
182
+ */
183
+ prepareUsdClassTransfer(params: UsdClassTransferParams): PrepareApproveBuilderFeeResult;
184
+ sendUsdClassTransfer(params: SendApproveParams): Promise<any>;
176
185
  /**
177
186
  * Place a TWAP order
178
187
  * TWAP orders split a large order into smaller slices over time
@@ -1051,6 +1051,50 @@ class ExchangeClient {
1051
1051
  signature: splitSignature,
1052
1052
  });
1053
1053
  }
1054
+ /**
1055
+ * Move USDC between the spot and perp account on Hyperliquid.
1056
+ * Signed by the master wallet.
1057
+ *
1058
+ * @param params.amount - USDC amount as a decimal string (e.g. "100.5")
1059
+ * @param params.toPerp - true: Spot → Perp; false: Perp → Spot
1060
+ */
1061
+ prepareUsdClassTransfer(params) {
1062
+ const nonce = Date.now();
1063
+ const action = {
1064
+ type: constants_1.ExchangeType.USD_CLASS_TRANSFER,
1065
+ hyperliquidChain: this.isTestnet ? 'Testnet' : 'Mainnet',
1066
+ signatureChainId: this.isTestnet ? '0x66eee' : '0xa4b1',
1067
+ amount: params.amount,
1068
+ toPerp: params.toPerp,
1069
+ nonce,
1070
+ };
1071
+ const { domain, types, primaryType, message } = (0, signer_1.prepareMasterSignData)({
1072
+ action,
1073
+ payloadTypes: [
1074
+ { name: 'hyperliquidChain', type: 'string' },
1075
+ { name: 'amount', type: 'string' },
1076
+ { name: 'toPerp', type: 'bool' },
1077
+ { name: 'nonce', type: 'uint64' },
1078
+ ],
1079
+ primaryType: 'HyperliquidTransaction:UsdClassTransfer',
1080
+ isMainnet: !this.isTestnet,
1081
+ });
1082
+ return {
1083
+ domain,
1084
+ types,
1085
+ primaryType,
1086
+ message,
1087
+ nonce,
1088
+ };
1089
+ }
1090
+ sendUsdClassTransfer(params) {
1091
+ const splitSignature = (0, signer_1.splitSig)(params.signature);
1092
+ return this.httpClient.exchange({
1093
+ action: params.action,
1094
+ nonce: params.nonce,
1095
+ signature: splitSignature,
1096
+ });
1097
+ }
1054
1098
  /**
1055
1099
  * Place a TWAP order
1056
1100
  * TWAP orders split a large order into smaller slices over time
@@ -19,6 +19,7 @@ export declare enum ExchangeType {
19
19
  UPDATE_LEVERAGE = "updateLeverage",
20
20
  UPDATE_ISOLATED_MARGIN = "updateIsolatedMargin",
21
21
  USD_SEND = "usdSend",
22
+ USD_CLASS_TRANSFER = "usdClassTransfer",
22
23
  WITHDRAW = "withdraw3",
23
24
  SEND_ASSET = "sendAsset",
24
25
  APPROVE_AGENT = "approveAgent",
@@ -25,6 +25,7 @@ var ExchangeType;
25
25
  ExchangeType["UPDATE_LEVERAGE"] = "updateLeverage";
26
26
  ExchangeType["UPDATE_ISOLATED_MARGIN"] = "updateIsolatedMargin";
27
27
  ExchangeType["USD_SEND"] = "usdSend";
28
+ ExchangeType["USD_CLASS_TRANSFER"] = "usdClassTransfer";
28
29
  ExchangeType["WITHDRAW"] = "withdraw3";
29
30
  ExchangeType["SEND_ASSET"] = "sendAsset";
30
31
  ExchangeType["APPROVE_AGENT"] = "approveAgent";
@@ -226,6 +226,7 @@ export type UserNonFundingLedgerUpdates = {
226
226
  sourceDex?: string;
227
227
  source?: string;
228
228
  fee?: string;
229
+ usdcValue?: string;
229
230
  };
230
231
  };
231
232
  export interface OrderResponse {
@@ -606,6 +607,15 @@ export interface SendAssetParams {
606
607
  destinationDex?: string;
607
608
  fromSubAccount?: string;
608
609
  }
610
+ /**
611
+ * Spot ↔ Perp USDC transfer parameters.
612
+ * `toPerp = true` : Spot → Perp
613
+ * `toPerp = false` : Perp → Spot
614
+ */
615
+ export interface UsdClassTransferParams {
616
+ amount: string;
617
+ toPerp: boolean;
618
+ }
609
619
  export interface DepositParams {
610
620
  amount: string;
611
621
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/hyperliquid-sdk",
3
- "version": "1.1.7-beta.3",
3
+ "version": "1.1.8-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",