Cancel one or more open orders.
The examples on this page use Hyperliquid (provider: 'hyperliquid'). Replace the provider value with any supported DEX from getProviders().
USER_AGENT mode
const result = await perps.cancelOrders({
provider: 'hyperliquid',
address: userAddress,
ids: ['12345678'],
});
USER mode (manual signing)
import { createAction, executeAction } from '@lifi/perps-sdk';
// Step 1: Build cancel payloads
const { actions } = await createAction(client, {
provider: 'hyperliquid',
address: userAddress,
action: 'cancelOrder',
params: {
ids: ['12345678', '12345679'],
},
});
// Step 2: Sign and submit
const signedActions = await Promise.all(
actions.map(async (a) => ({
action: a.action,
typedData: a.typedData,
signature: await walletClient.signTypedData({ ...a.typedData }),
}))
);
await executeAction(client, {
provider: 'hyperliquid',
address: userAddress,
action: 'cancelOrder',
actions: signedActions,
});
Use the orderId returned from the submit response to cancel orders.
API Reference: POST /actions