@@ -19,6 +19,7 @@ type IExchangeAPI interface {
19
19
20
20
// Order management
21
21
CancelOrderByOID (coin string , orderID int ) (any , error )
22
+ CancelOrderByCloid (coin string , clientOID string ) (any , error )
22
23
BulkCancelOrders (cancels []CancelOidWire ) (any , error )
23
24
CancelAllOrdersByCoin (coin string ) (any , error )
24
25
CancelAllOrders () (any , error )
@@ -310,6 +311,33 @@ func (api *ExchangeAPI) CancelOrderByOID(coin string, orderID int64) (*CancelOrd
310
311
return api .BulkCancelOrders ([]CancelOidWire {{Asset : api .meta [coin ].AssetId , Oid : int (orderID )}})
311
312
}
312
313
314
+ // Cancel exact order by Client Order Id
315
+ // https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#cancel-order-s-by-cloid
316
+ func (api * ExchangeAPI ) CancelOrderByCloid (coin string , clientOID string ) (* CancelOrderResponse , error ) {
317
+ timestamp := GetNonce ()
318
+ action := CancelCloidOrderAction {
319
+ Type : "cancelByCloid" ,
320
+ Cancels : []CancelCloidWire {
321
+ {
322
+ Asset : api .meta [coin ].AssetId ,
323
+ Cloid : clientOID ,
324
+ },
325
+ },
326
+ }
327
+ v , r , s , err := api .SignL1Action (action , timestamp )
328
+ if err != nil {
329
+ api .debug ("Error signing L1 action: %s" , err )
330
+ return nil , err
331
+ }
332
+ request := ExchangeRequest {
333
+ Action : action ,
334
+ Nonce : timestamp ,
335
+ Signature : ToTypedSig (r , s , v ),
336
+ VaultAddress : nil ,
337
+ }
338
+ return MakeUniversalRequest [CancelOrderResponse ](api , request )
339
+ }
340
+
313
341
// Cancel all orders for a given coin
314
342
func (api * ExchangeAPI ) CancelAllOrdersByCoin (coin string ) (* CancelOrderResponse , error ) {
315
343
orders , err := api .infoAPI .GetOpenOrders (api .AccountAddress ())
0 commit comments