Skip to main content
Learn how to use Hyperliquid subaccounts to isolate balances, positions, and PnL per strategy or user while maintaining consolidated fee tiers.
Before continuing with this guide, make sure you have initialized your Hyperliquid client as shown in the Getting Started guide. This guide assumes you have client and other basic setup completed.

Overview

Subaccounts let you isolate balances, positions, and PnL per strategy or user while still rolling up trading volume to the master account for fee tier benefits. You can create up to 10 subaccounts per master account. Key Benefits:
  • Risk Isolation: Separate balances and positions for different strategies
  • Consolidated Fees: All trading volume rolls up to the master account
  • Organization: Manage multiple strategies or users under one master account
  • Flexibility: Each subaccount can have its own risk parameters
Subaccounts are only available for master accounts with at least $100,000 in total trading volume.

Creating a Subaccount

// Create a new subaccount
await masterClient.createSubAccount({
  name: "Strategy Alpha",
});

// List all subaccounts
const subAccounts = await infoClient.subAccounts({
  user: masterWallet.address as `0x${string}`,
});

console.log("Subaccounts:", subAccounts);

Trading with a Subaccount

To execute trades for a specific subaccount, create a client with the defaultVaultAddress parameter:
// Get the first subaccount
const subAccount = subAccounts[0];

// Create a client for the subaccount
const subAccountClient = new hl.ExchangeClient({
  transport,
  wallet: masterAccount, // Use the master account signer
  defaultVaultAddress: subAccount.subAccountUser
});

// Place an order using the subaccount
const subAccountOrder = await subAccountClient.order({
  orders: [
    {
      a: 0, // BTC
      b: true, // Buy
      s: '0.01', // Size
      r: false,
      p: '50000',
      t: {limit: {tif: 'Gtc'}}
    }
  ],
  grouping: 'na'
});

Transferring Funds Between Accounts

Transfer funds between the master account and subaccounts using the sendAsset method:
// Transfer from master to subaccount
await masterClient.sendAsset({
  destination: subAccount.subAccountUser,
  sourceDex: "",
  token: "USDC",
  amount: "1000",
  fromSubAccount: "",        // Empty string = from master account
  destinationDex: ""
});

// Transfer from subaccount back to master
await masterClient.sendAsset({
  destination: masterWallet.address as `0x${string}`,
  sourceDex: "",
  token: "USDC",
  amount: "500",
  fromSubAccount: subAccount.subAccountUser,  // Specify source subaccount
  destinationDex: ""
});
The fromSubAccount parameter determines the source: an empty string "" transfers from the master account, while specifying a subaccount address transfers from that subaccount.

Combining Agents and Subaccounts

You can use agent wallets to trade on behalf of subaccounts, creating a flexible multi-account trading architecture:
// Agent wallet can trade for any subaccount of the master
const agentForSubAccountClient = new hl.ExchangeClient({
  transport,
  wallet: agentAccount, // Agent wallet
  defaultVaultAddress: subAccount.subAccountUser // Subaccount
});

// Place order using agent for the subaccount
await agentForSubAccountClient.order({
  orders: [
    {
      a: 0,
      b: true,
      s: '0.01',
      r: false,
      p: '50000',
      t: {limit: {tif: 'Gtc'}}
    }
  ],
  grouping: 'na'
});
This pattern is ideal for managing multiple strategies or user accounts - each subaccount gets isolated risk, while a single agent wallet can manage trading operations across all of them.

Best Practices

Create separate subaccounts for different risk profiles. For example, maintain one subaccount for conservative strategies with tight stop losses, and another for high-risk, high-reward strategies.
Regularly check subaccount balances and positions to ensure proper risk allocation across your strategies.
Remember that all subaccount trading volume rolls up to the master account, so you maintain your fee tier benefits across all strategies.

Next Steps