diff --git a/lib/client/src/client.rs b/lib/client/src/client.rs index b1eee5adb..0cf3fbc19 100644 --- a/lib/client/src/client.rs +++ b/lib/client/src/client.rs @@ -492,6 +492,64 @@ impl OpenBookClient { self.send_and_confirm_owner_tx(vec![ix]).await } + #[allow(clippy::too_many_arguments)] + pub async fn cancel_order( + &self, + market: Market, + market_address: Pubkey, + order_id: u128, + ) -> anyhow::Result { + let ix = Instruction { + program_id: openbook_v2::id(), + accounts: { + anchor_lang::ToAccountMetas::to_account_metas( + &openbook_v2::accounts::CancelOrder { + open_orders_account: self.open_orders_account, + signer: self.owner(), + market: market_address, + bids: market.bids, + asks: market.asks, + }, + None, + ) + }, + data: anchor_lang::InstructionData::data(&openbook_v2::instruction::CancelOrder { + order_id + }), + }; + self.send_and_confirm_owner_tx(vec![ix]).await + } + + #[allow(clippy::too_many_arguments)] + pub async fn cancel_all_orders( + &self, + market: Market, + market_address: Pubkey, + side_option: Option, + limit: u8, + ) -> anyhow::Result { + let ix = Instruction { + program_id: openbook_v2::id(), + accounts: { + anchor_lang::ToAccountMetas::to_account_metas( + &openbook_v2::accounts::CancelOrder { + open_orders_account: self.open_orders_account, + signer: self.owner(), + market: market_address, + bids: market.bids, + asks: market.asks, + }, + None, + ) + }, + data: anchor_lang::InstructionData::data(&openbook_v2::instruction::CancelAllOrders { + side_option, + limit + }), + }; + self.send_and_confirm_owner_tx(vec![ix]).await + } + #[allow(clippy::too_many_arguments)] pub async fn deposit( &self,