Exchange Endpoint

The Superstack wallet API provides an endpoint to interact with and trade on the Hyperliquid chain. This is useful for programmatically executing perps & spot trading on Hyperliquid.

Endpoint: POST <https://wallet-service.superstack.xyz/api/exchange>

Headers:

  • Content-Type: application/json

  • Authorization: Bearer <YOUR_API_KEY>

Request Body:

{
  "action": {
    "type": "<action_type>",
	   // action-specific parameters
  },
  "vaultAddress": String, // optional, set it if trading on behalf of a vault or subaccount
  "expiresAfter": Number, // optional, expires timestamp in milliseconds
}

Subaccounts and vaults

If you want to trade on behalf of a subaccount or vault, you can set the vaultAddress field to the address of the subaccount or vault. The format is 42-character hexadecimal address string.

Expires After

Some actions support an optional field expiresAfter which is a timestamp in milliseconds after which the action will be rejected. Users can set it to limit the action to a certain time period.

Action Types

Currently, the following actions are supported:

  • order: Place an order

  • cancel: Cancel an order

  • cancelByCloid: Cancel an order by client order ID

  • scheduleCancel: Schedule automatic order cancellation

  • batchModify: Modify multiple orders

  • updateLeverage: Update leverage

  • updateIsolatedMargin: Update isolated margin

  • usdSend: Transfer USDC within the Hyperliquid ecosystem

  • spotSend: Transfer spot assets

  • usdClassTransfer: Transfer from Spot account to Perp account (and vice versa)

Following are the details of each action.

Action: Place an order

Place one or more orders on the Hyperliquid.

Action Type: order

Required API Key Permissions: TRADING

Request Body:

Action: Cancel order(s)

Cancel one or more orders by order ID on the Hyperliquid.

Action Type: cancel

Required API Key Permissions: TRADING

Request Body:

Action: Cancel order(s) by cloid

Cancel one or more orders by client order ID on the Hyperliquid.

Action Type: cancelByCloid

Required API Key Permissions: TRADING

Request Body:

Action: Schedule cancel

Schedule automatic order cancellation on the Hyperliquid.

Action Type: scheduleCancel

Required API Key Permissions: TRADING

Request Body:

Action: Modify multiple orders

Modify multiple existing orders on the Hyperliquid.

Action Type: batchModify

Required API Key Permissions: TRADING

Request Body:

Action: Update leverage

Update cross or isolated leverage on a coin on the Hyperliquid.

Action Type: updateLeverage

Required API Key Permissions: TRADING

Request Body:

Action: Update isolated margin

Add or remove margin from isolated position on the Hyperliquid.

Action Type: updateIsolatedMargin

Required API Key Permissions: TRADING

Request Body:

Action: Core USDC transfer

Send USD to another address on the Hyperliquid.

Action Type: usdSend

Required API Key Permissions: TRANSFER

Request Body:

Action: Core spot transfer

Send spot assets to another address on the Hyperliquid.

Action Type: spotSend

Required API Key Permissions: TRANSFER

Request Body:

Action: Transfer from Spot account to Perp account (and vice versa)

Transfer funds between spot and perpetual accounts on the Hyperliquid.

Action Type: usdClassTransfer

Required API Key Permissions: TRANSFER

Request Body:

Example Usage

Rust SDK

REST API

First, send the order to the API exchange endpoint to get the response:

Users will get a response like this:

Then, extract the payload field from the response and send it to the Hyperliquid exchange endpoint to execute it:

Last updated