The cancelOrder function allows users to cancel an existing order.
cancelOrder
cancelOrder( orderCapId: string, collateralToken: string, indexToken: string, long: boolean, type: string ): Promise<TransactionBlock>
orderCapId: The ID of the order to cancel
orderCapId
collateralToken: The token used as collateral (e.g., "USDC")
collateralToken
indexToken: The token used as the market index (e.g., "BTC")
indexToken
long: Boolean indicating if this is a long (true) or short (false) position
long
type: The type of order ("OPEN_POSITION" or "DECREASE_POSITION")
type
Returns a Promise that resolves to a TransactionBlock object.
Promise
TransactionBlock
const tx = await sudoAPI.cancelOrder( '0x123...', // orderCapId 'USDC', // collateralToken 'BTC', // indexToken true, // long position 'OPEN_POSITION' // order type );