Skip to main content
The cancelAllOrdersForSymbol action enables Vincent Apps to cancel all open orders for a specific symbol on Hyperliquid’s spot or perpetuals market.

Prerequisites

Before executing the cancelAllOrdersForSymbol action, the following conditions must be met:
  • Symbol: You must provide the symbol (trading pair for spot or asset for perp) for which to cancel all orders.
To learn more about executing Vincent Abilities, see the Executing Abilities guide.

Executing the precheck Function

The precheck function validates some prerequisites for executing cancel all orders, without actually performing the operation. For the cancelAllOrdersForSymbol action, the precheck function will validate the following:
  • Open orders for the specified symbol must exist.
The precheck function requires the following parameters:
import { HyperliquidAction } from '@lit-protocol/vincent-ability-hyperliquid';

{
  /**
   * The action to perform (must be HyperliquidAction.CANCEL_ALL_ORDERS_FOR_SYMBOL)
   */
  action: HyperliquidAction.CANCEL_ALL_ORDERS_FOR_SYMBOL;
  /**
   * Whether to use Hyperliquid testnet (optional, defaults to false)
   */
  useTestnet?: boolean;
  /**
   * Cancel all orders parameters
   */
  cancelAllOrdersForSymbol: {
    /**
     * The symbol for which to cancel all orders.
     * For spot: trading pair (e.g., "PURR/USDC")
     * For perp: base asset (e.g., "SOL", "ETH")
     */
    symbol: string;
  };
}

Executing the execute Function

The execute function performs the actual cancel operation, removing all open orders for the specified symbol from Hyperliquid. For the cancelAllOrdersForSymbol action, the execute function will:
  • Cancel all open orders for the specified symbol on Hyperliquid.
  • Return the cancellation result from Hyperliquid.
The execute function requires the following parameters:
import { HyperliquidAction } from '@lit-protocol/vincent-ability-hyperliquid';

{
  /**
   * The action to perform (must be HyperliquidAction.CANCEL_ALL_ORDERS_FOR_SYMBOL)
   */
  action: HyperliquidAction.CANCEL_ALL_ORDERS_FOR_SYMBOL;
  /**
   * Whether to use Hyperliquid testnet (optional, defaults to false)
   */
  useTestnet?: boolean;
  /**
   * Cancel all orders parameters
   */
  cancelAllOrdersForSymbol: {
    /**
     * The symbol for which to cancel all orders.
     * For spot: trading pair (e.g., "PURR/USDC")
     * For perp: base asset (e.g., "SOL", "ETH")
     */
    symbol: string;
  };
}

Important Considerations

This action cancels all open orders for a specific symbol only. Orders for other symbols will remain open.For example:
  • If you cancel all orders for “PURR/USDC”, orders for “ETH/USDC” will not be affected
  • If you cancel all orders for “SOL” (perp), orders for “ETH” (perp) will not be affected
The symbol format differs between spot and perpetual orders:
  • Spot orders: Use trading pair format (e.g., “PURR/USDC”, “ETH/USDC”)
  • Perp orders: Use base asset only (e.g., “SOL”, “ETH”, “BTC”)
Make sure to use the correct format for the type of orders you’re cancelling.
If there are no open orders for the specified symbol, the action will still succeed. The result will indicate that the operation completed successfully, even though no orders were cancelled.
This action cancels all orders for the symbol, including:
  • Buy orders (bids)
  • Sell orders (asks)
  • Limit orders
  • Any other order types for the symbol
All open orders for the symbol will be removed.
After the cancellation is executed, you can verify it was successful by:
  • Checking the open orders list using the Hyperliquid API
  • Confirming the order ID no longer appears in the list
  • Reviewing the cancellation result response

Reference Implementation

For a complete working example showing the full cancel all orders workflow including verification, see the cancel-all-orders.spec.ts end-to-end test in the ability-hyperliquid package.

Next Steps

Explore the rest of the supported Hyperliquid actions: