project-serum/serum-dex

`CancelOrderByClientIdV2` API should take `NonZeroU64` and not `u64`.

tommyip opened this issue · 0 comments

The instruction accepts an u64:

CancelOrderByClientIdV2(u64),

despite it being casted to a NonZeroU64 internally:
let client_order_id = NonZeroU64::new(client_order_id).ok_or(assertion_error!())?;

which means that an order with client id of 0 can not be cancelled (raising an assertion error).

This is also an issue for the CancelOrdersByClientIds instruction, worst yet it silently filters away the 0 id order:

serum-dex/dex/src/state.rs

Lines 2190 to 2194 in 0c23a51

let client_order_ids = client_order_ids
.iter()
.cloned()
.filter_map(NonZeroU64::new)
.collect::<Vec<NonZeroU64>>();

Causing confusing errors like insufficient funds.