Skip to content

CancelOrderByClientIdV2 API should take NonZeroU64 and not u64. #248

@tommyip

Description

@tommyip

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions