From ac7a52aec2c77fe060b99f0b529a5cb8792359fb Mon Sep 17 00:00:00 2001 From: Binye Barwe Date: Thu, 21 Dec 2023 20:20:44 +0100 Subject: [PATCH 1/6] cancel_all_and_place_orders --- ...ders.rs => cancel_all_and_place_orders.rs} | 2 +- programs/openbook-v2/src/accounts_ix/mod.rs | 4 +- ...ders.rs => cancel_all_and_place_orders.rs} | 26 +------ programs/openbook-v2/src/lib.rs | 75 ++++++++++++++----- 4 files changed, 64 insertions(+), 43 deletions(-) rename programs/openbook-v2/src/accounts_ix/{cancel_and_place_orders.rs => cancel_all_and_place_orders.rs} (97%) rename programs/openbook-v2/src/instructions/{cancel_and_place_orders.rs => cancel_all_and_place_orders.rs} (84%) diff --git a/programs/openbook-v2/src/accounts_ix/cancel_and_place_orders.rs b/programs/openbook-v2/src/accounts_ix/cancel_all_and_place_orders.rs similarity index 97% rename from programs/openbook-v2/src/accounts_ix/cancel_and_place_orders.rs rename to programs/openbook-v2/src/accounts_ix/cancel_all_and_place_orders.rs index e23c2b6f3..947f4a167 100644 --- a/programs/openbook-v2/src/accounts_ix/cancel_and_place_orders.rs +++ b/programs/openbook-v2/src/accounts_ix/cancel_all_and_place_orders.rs @@ -5,7 +5,7 @@ use anchor_lang::prelude::*; use anchor_spl::token::{Token, TokenAccount}; #[derive(Accounts)] -pub struct CancelAndPlaceOrders<'info> { +pub struct CancelAllAndPlaceOrders<'info> { pub signer: Signer<'info>, #[account( mut, diff --git a/programs/openbook-v2/src/accounts_ix/mod.rs b/programs/openbook-v2/src/accounts_ix/mod.rs index 6d2ca952a..b8652398f 100644 --- a/programs/openbook-v2/src/accounts_ix/mod.rs +++ b/programs/openbook-v2/src/accounts_ix/mod.rs @@ -1,4 +1,4 @@ -pub use cancel_and_place_orders::*; +pub use cancel_all_and_place_orders::*; pub use cancel_order::*; pub use close_market::*; pub use close_open_orders_account::*; @@ -20,7 +20,7 @@ pub use stub_oracle_create::*; pub use stub_oracle_set::*; pub use sweep_fees::*; -mod cancel_and_place_orders; +mod cancel_all_and_place_orders; mod cancel_order; mod close_market; mod close_open_orders_account; diff --git a/programs/openbook-v2/src/instructions/cancel_and_place_orders.rs b/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs similarity index 84% rename from programs/openbook-v2/src/instructions/cancel_and_place_orders.rs rename to programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs index 2fa401df5..48ec04fb8 100644 --- a/programs/openbook-v2/src/instructions/cancel_and_place_orders.rs +++ b/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs @@ -8,11 +8,11 @@ use crate::state::*; use crate::token_utils::*; #[allow(clippy::too_many_arguments)] -pub fn cancel_and_place_orders( - ctx: Context, +pub fn cancel_all_and_place_orders( + ctx: Context, cancel_client_orders_ids: Vec, mut orders: Vec, - limits: Vec, + limit: u8, ) -> Result>> { let mut open_orders_account = ctx.accounts.open_orders_account.load_mut()?; let open_orders_account_pk = ctx.accounts.open_orders_account.key(); @@ -40,25 +40,7 @@ pub fn cancel_and_place_orders( clock.slot, )?; - for client_order_id in cancel_client_orders_ids { - let oo = open_orders_account.find_order_with_client_order_id(client_order_id); - if let Some(oo) = oo { - let order_id = oo.id; - let order_side_and_tree = oo.side_and_tree(); - - let cancel_result = book.cancel_order( - &mut open_orders_account, - order_id, - order_side_and_tree, - *market, - Some(ctx.accounts.open_orders_account.key()), - ); - // Allow cancel fails due order ID not found. Otherwise propagates error - if !cancel_result.is_anchor_error_with_code(OpenBookError::OrderIdNotFound.into()) { - cancel_result?; - } - }; - } + book.cancel_all_orders(&mut open_orders_account, *market, limit, None)?; let mut base_amount = 0_u64; let mut quote_amount = 0_u64; diff --git a/programs/openbook-v2/src/lib.rs b/programs/openbook-v2/src/lib.rs index 821230dec..02db4377d 100644 --- a/programs/openbook-v2/src/lib.rs +++ b/programs/openbook-v2/src/lib.rs @@ -257,14 +257,50 @@ pub mod openbook_v2 { } /// Cancel orders and place multiple orders. - pub fn cancel_and_place_orders( - ctx: Context, - cancel_client_orders_ids: Vec, - place_orders: Vec, + pub fn cancel_all_and_place_orders( + ctx: Context, + orders_type: PlaceOrderType, + bids: Vec, + asks: Vec, + limit: u8, ) -> Result>> { let mut orders = Vec::new(); let mut limits = Vec::new(); - for place_order in place_orders.iter() { + for (i, place_order) in bids.iter().enumerate() { + require_gte!( + place_order.price_lots, + 1, + OpenBookError::InvalidInputPriceLots + ); + + let time_in_force = match Order::tif_from_expiry(place_order.expiry_timestamp) { + Some(t) => t, + None => { + msg!("Order is already expired"); + continue; + } + }; + orders.push(Order { + side: Side::Bid, + max_base_lots: i64::MAX, + max_quote_lots_including_fees: place_order.max_quote_lots_including_fees, + client_order_id: i as u64, + time_in_force, + self_trade_behavior: SelfTradeBehavior::CancelProvide, + params: match orders_type { + PlaceOrderType::Market => OrderParams::Market, + PlaceOrderType::ImmediateOrCancel => OrderParams::ImmediateOrCancel { + price_lots: place_order.price_lots, + }, + _ => OrderParams::Fixed { + price_lots: place_order.price_lots, + order_type: orders_type.to_post_order_type()?, + }, + }, + }); + limits.push(limit); + } + for (i, place_order) in asks.iter().enumerate() { require_gte!( place_order.price_lots, 1, @@ -279,32 +315,27 @@ pub mod openbook_v2 { } }; orders.push(Order { - side: place_order.side, - max_base_lots: place_order.max_base_lots, + side: Side::Ask, + max_base_lots: i64::MAX, max_quote_lots_including_fees: place_order.max_quote_lots_including_fees, - client_order_id: place_order.client_order_id, + client_order_id: (i + bids.len()) as u64, time_in_force, - self_trade_behavior: place_order.self_trade_behavior, - params: match place_order.order_type { + self_trade_behavior: SelfTradeBehavior::CancelProvide, + params: match orders_type { PlaceOrderType::Market => OrderParams::Market, PlaceOrderType::ImmediateOrCancel => OrderParams::ImmediateOrCancel { price_lots: place_order.price_lots, }, _ => OrderParams::Fixed { price_lots: place_order.price_lots, - order_type: place_order.order_type.to_post_order_type()?, + order_type: orders_type.to_post_order_type()?, }, }, }); - limits.push(place_order.limit); + limits.push(limit); } #[cfg(feature = "enable-gpl")] - return instructions::cancel_and_place_orders( - ctx, - cancel_client_orders_ids, - orders, - limits, - ); + return instructions::cancel_all_and_place_orders(ctx, orders, limits); #[cfg(not(feature = "enable-gpl"))] Ok(vec![]) @@ -573,6 +604,14 @@ pub struct PlaceOrderArgs { pub limit: u8, } +#[derive(AnchorSerialize, AnchorDeserialize, Debug, Copy, Clone)] +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +pub struct PlaceMultipleOrdersArgs { + pub price_lots: i64, + pub max_quote_lots_including_fees: i64, + pub expiry_timestamp: u64, +} + #[derive(AnchorSerialize, AnchorDeserialize, Debug, Copy, Clone)] #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] pub struct PlaceOrderPeggedArgs { From f13d58f278f558c241b1463ab1cb091af70d0599 Mon Sep 17 00:00:00 2001 From: Binye Barwe Date: Tue, 26 Dec 2023 18:30:05 +0100 Subject: [PATCH 2/6] use max_base_lots --- .../openbook-v2/src/instructions/cancel_all_and_place_orders.rs | 2 +- programs/openbook-v2/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs b/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs index 48ec04fb8..d26f933a0 100644 --- a/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs +++ b/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs @@ -46,7 +46,7 @@ pub fn cancel_all_and_place_orders( let mut quote_amount = 0_u64; let mut order_ids = Vec::new(); for (order, limit) in orders.iter_mut().zip(limits) { - require_gte!(order.max_base_lots, 0, OpenBookError::InvalidInputLots); + order.max_base_lots = market.max_base_lots(); require_gte!( order.max_quote_lots_including_fees, 0, diff --git a/programs/openbook-v2/src/lib.rs b/programs/openbook-v2/src/lib.rs index 02db4377d..c4718e551 100644 --- a/programs/openbook-v2/src/lib.rs +++ b/programs/openbook-v2/src/lib.rs @@ -316,7 +316,7 @@ pub mod openbook_v2 { }; orders.push(Order { side: Side::Ask, - max_base_lots: i64::MAX, + max_base_lots: 0, // Setting 0 now. Will be set to max_base_lot later max_quote_lots_including_fees: place_order.max_quote_lots_including_fees, client_order_id: (i + bids.len()) as u64, time_in_force, From cf510a4f2d74d1ce38fd64c16a03df7d292e121f Mon Sep 17 00:00:00 2001 From: skrrb Date: Tue, 26 Dec 2023 19:09:07 +0100 Subject: [PATCH 3/6] fmt --- programs/openbook-v2/src/instructions/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/openbook-v2/src/instructions/mod.rs b/programs/openbook-v2/src/instructions/mod.rs index 698d97755..e8916aa24 100644 --- a/programs/openbook-v2/src/instructions/mod.rs +++ b/programs/openbook-v2/src/instructions/mod.rs @@ -1,5 +1,5 @@ +pub use cancel_all_and_place_orders::*; pub use cancel_all_orders::*; -pub use cancel_and_place_orders::*; pub use cancel_order::*; pub use cancel_order_by_client_order_id::*; pub use close_market::*; @@ -23,8 +23,8 @@ pub use stub_oracle_create::*; pub use stub_oracle_set::*; pub use sweep_fees::*; +mod cancel_all_and_place_orders; mod cancel_all_orders; -mod cancel_and_place_orders; mod cancel_order; mod cancel_order_by_client_order_id; mod close_market; From 462798951a5d7ece58e47dec7a053f3fb648cc78 Mon Sep 17 00:00:00 2001 From: skrrb Date: Tue, 26 Dec 2023 20:30:29 +0100 Subject: [PATCH 4/6] fix args --- .../cancel_all_and_place_orders.rs | 5 +- programs/openbook-v2/src/lib.rs | 65 ++++--------------- 2 files changed, 16 insertions(+), 54 deletions(-) diff --git a/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs b/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs index d26f933a0..ed256a760 100644 --- a/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs +++ b/programs/openbook-v2/src/instructions/cancel_all_and_place_orders.rs @@ -10,7 +10,6 @@ use crate::token_utils::*; #[allow(clippy::too_many_arguments)] pub fn cancel_all_and_place_orders( ctx: Context, - cancel_client_orders_ids: Vec, mut orders: Vec, limit: u8, ) -> Result>> { @@ -40,12 +39,12 @@ pub fn cancel_all_and_place_orders( clock.slot, )?; - book.cancel_all_orders(&mut open_orders_account, *market, limit, None)?; + book.cancel_all_orders(&mut open_orders_account, *market, u8::MAX, None)?; let mut base_amount = 0_u64; let mut quote_amount = 0_u64; let mut order_ids = Vec::new(); - for (order, limit) in orders.iter_mut().zip(limits) { + for order in orders.iter_mut() { order.max_base_lots = market.max_base_lots(); require_gte!( order.max_quote_lots_including_fees, diff --git a/programs/openbook-v2/src/lib.rs b/programs/openbook-v2/src/lib.rs index c4718e551..4268a106c 100644 --- a/programs/openbook-v2/src/lib.rs +++ b/programs/openbook-v2/src/lib.rs @@ -264,16 +264,13 @@ pub mod openbook_v2 { asks: Vec, limit: u8, ) -> Result>> { - let mut orders = Vec::new(); - let mut limits = Vec::new(); - for (i, place_order) in bids.iter().enumerate() { - require_gte!( - place_order.price_lots, - 1, - OpenBookError::InvalidInputPriceLots - ); - - let time_in_force = match Order::tif_from_expiry(place_order.expiry_timestamp) { + let n_bids = bids.len(); + + let mut orders = vec![]; + for (i, order) in bids.into_iter().chain(asks).enumerate() { + require_gte!(order.price_lots, 1, OpenBookError::InvalidInputPriceLots); + + let time_in_force = match Order::tif_from_expiry(order.expiry_timestamp) { Some(t) => t, None => { msg!("Order is already expired"); @@ -281,61 +278,27 @@ pub mod openbook_v2 { } }; orders.push(Order { - side: Side::Bid, - max_base_lots: i64::MAX, - max_quote_lots_including_fees: place_order.max_quote_lots_including_fees, + side: if i < n_bids { Side::Bid } else { Side::Ask }, + max_base_lots: i64::MIN, // this will be overriden to max_base_lots + max_quote_lots_including_fees: order.max_quote_lots_including_fees, client_order_id: i as u64, time_in_force, self_trade_behavior: SelfTradeBehavior::CancelProvide, params: match orders_type { PlaceOrderType::Market => OrderParams::Market, PlaceOrderType::ImmediateOrCancel => OrderParams::ImmediateOrCancel { - price_lots: place_order.price_lots, - }, - _ => OrderParams::Fixed { - price_lots: place_order.price_lots, - order_type: orders_type.to_post_order_type()?, - }, - }, - }); - limits.push(limit); - } - for (i, place_order) in asks.iter().enumerate() { - require_gte!( - place_order.price_lots, - 1, - OpenBookError::InvalidInputPriceLots - ); - - let time_in_force = match Order::tif_from_expiry(place_order.expiry_timestamp) { - Some(t) => t, - None => { - msg!("Order is already expired"); - continue; - } - }; - orders.push(Order { - side: Side::Ask, - max_base_lots: 0, // Setting 0 now. Will be set to max_base_lot later - max_quote_lots_including_fees: place_order.max_quote_lots_including_fees, - client_order_id: (i + bids.len()) as u64, - time_in_force, - self_trade_behavior: SelfTradeBehavior::CancelProvide, - params: match orders_type { - PlaceOrderType::Market => OrderParams::Market, - PlaceOrderType::ImmediateOrCancel => OrderParams::ImmediateOrCancel { - price_lots: place_order.price_lots, + price_lots: order.price_lots, }, _ => OrderParams::Fixed { - price_lots: place_order.price_lots, + price_lots: order.price_lots, order_type: orders_type.to_post_order_type()?, }, }, }); - limits.push(limit); } + #[cfg(feature = "enable-gpl")] - return instructions::cancel_all_and_place_orders(ctx, orders, limits); + return instructions::cancel_all_and_place_orders(ctx, orders, limit); #[cfg(not(feature = "enable-gpl"))] Ok(vec![]) From 37077bc675e2e03cf4259e9ade472dbac64062ec Mon Sep 17 00:00:00 2001 From: skrrb Date: Tue, 26 Dec 2023 21:40:01 +0100 Subject: [PATCH 5/6] test --- .../tests/cases/test_multiple_orders.rs | 60 ++++++------------- .../openbook-v2/tests/program_test/client.rs | 23 ++++--- 2 files changed, 31 insertions(+), 52 deletions(-) diff --git a/programs/openbook-v2/tests/cases/test_multiple_orders.rs b/programs/openbook-v2/tests/cases/test_multiple_orders.rs index fce23141c..93b4edc62 100644 --- a/programs/openbook-v2/tests/cases/test_multiple_orders.rs +++ b/programs/openbook-v2/tests/cases/test_multiple_orders.rs @@ -2,9 +2,6 @@ use super::*; #[tokio::test] async fn insufficient_funds() -> Result<(), TransportError> { - let base_lot_size = 100; - let quote_lot_size = 10; - let TestInitialize { context, owner, @@ -16,15 +13,12 @@ async fn insufficient_funds() -> Result<(), TransportError> { market_base_vault, market_quote_vault, .. - } = TestContext::new_with_market(TestNewMarketInitialize { - base_lot_size, - quote_lot_size, - ..TestNewMarketInitialize::default() - }) - .await?; + } = TestContext::new_with_market(TestNewMarketInitialize::default()).await?; let solana = &context.solana.clone(); + let max_quote_lots_including_fees = 104; + // there's an ask on the book send_tx( solana, @@ -37,8 +31,8 @@ async fn insufficient_funds() -> Result<(), TransportError> { market_vault: market_base_vault, side: Side::Ask, price_lots: 1, - max_base_lots: 10, - max_quote_lots_including_fees: i64::MAX / 1_000_000, + max_base_lots: i64::MAX / 1_000, + max_quote_lots_including_fees, client_order_id: 0, expiry_timestamp: 0, order_type: PlaceOrderType::Limit, @@ -72,47 +66,27 @@ async fn insufficient_funds() -> Result<(), TransportError> { // note that a priori, we only have enough lamports to place 2.5 Ask. But as the bid will be // filled & the taker executed immediately, we will have 10 extra base lots available - let place_orders = (0..5) - .map(|i| { - if i == 1 { - openbook_v2::PlaceOrderArgs { - side: Side::Bid, - price_lots: 1, - max_base_lots: 10, - max_quote_lots_including_fees: i64::MAX / 1_000_000, - client_order_id: 0, - order_type: PlaceOrderType::Limit, - expiry_timestamp: 0, - self_trade_behavior: SelfTradeBehavior::default(), - limit: 10, - } - } else { - openbook_v2::PlaceOrderArgs { - side: Side::Ask, - price_lots: 1, - max_base_lots: 10, - max_quote_lots_including_fees: i64::MAX / 1_000_000, - client_order_id: 0, - order_type: PlaceOrderType::Limit, - expiry_timestamp: 0, - self_trade_behavior: SelfTradeBehavior::default(), - limit: 10, - } - } - }) - .collect::>(); + let order = openbook_v2::PlaceMultipleOrdersArgs { + price_lots: 1, + max_quote_lots_including_fees, + expiry_timestamp: 0, + }; + + let bids = vec![order]; + let asks = vec![order; 4]; send_tx( solana, - CancelAndPlaceOrdersInstruction { + CancelAllAndPlaceOrdersInstruction { open_orders_account: account_1, open_orders_admin: None, market, signer: owner, + orders_type: PlaceOrderType::Limit, user_base_account: owner_token_0, user_quote_account: owner_token_1, - cancel_client_orders_ids: vec![], - place_orders, + bids, + asks, }, ) .await diff --git a/programs/openbook-v2/tests/program_test/client.rs b/programs/openbook-v2/tests/program_test/client.rs index 01ebafe2e..1255ecb6a 100644 --- a/programs/openbook-v2/tests/program_test/client.rs +++ b/programs/openbook-v2/tests/program_test/client.rs @@ -10,7 +10,9 @@ use std::sync::Arc; use super::solana::SolanaCookie; use super::utils::TestKeypair; -use openbook_v2::{state::*, PlaceOrderArgs, PlaceOrderPeggedArgs, PlaceTakeOrderArgs}; +use openbook_v2::{ + state::*, PlaceMultipleOrdersArgs, PlaceOrderArgs, PlaceOrderPeggedArgs, PlaceTakeOrderArgs, +}; #[async_trait::async_trait(?Send)] pub trait ClientAccountLoader { @@ -1327,29 +1329,32 @@ impl ClientInstruction for EditOrderInstruction { } #[derive(Clone)] -pub struct CancelAndPlaceOrdersInstruction { +pub struct CancelAllAndPlaceOrdersInstruction { pub open_orders_account: Pubkey, pub open_orders_admin: Option, pub market: Pubkey, pub signer: TestKeypair, pub user_base_account: Pubkey, pub user_quote_account: Pubkey, - pub cancel_client_orders_ids: Vec, - pub place_orders: Vec, + pub orders_type: PlaceOrderType, + pub bids: Vec, + pub asks: Vec, } #[async_trait::async_trait(?Send)] -impl ClientInstruction for CancelAndPlaceOrdersInstruction { - type Accounts = openbook_v2::accounts::CancelAndPlaceOrders; - type Instruction = openbook_v2::instruction::CancelAndPlaceOrders; +impl ClientInstruction for CancelAllAndPlaceOrdersInstruction { + type Accounts = openbook_v2::accounts::CancelAllAndPlaceOrders; + type Instruction = openbook_v2::instruction::CancelAllAndPlaceOrders; async fn to_instruction( &self, account_loader: impl ClientAccountLoader + 'async_trait, ) -> (Self::Accounts, instruction::Instruction) { let program_id = openbook_v2::id(); let instruction = Self::Instruction { - cancel_client_orders_ids: self.cancel_client_orders_ids.clone(), - place_orders: self.place_orders.clone(), + orders_type: self.orders_type, + bids: self.bids.clone(), + asks: self.asks.clone(), + limit: 10, }; let market: Market = account_loader.load(&self.market).await.unwrap(); From fe6cf44bb95d87ffdefa6b882cfdb2152c768eef Mon Sep 17 00:00:00 2001 From: skrrb Date: Tue, 26 Dec 2023 21:58:09 +0100 Subject: [PATCH 6/6] fuzz --- .../fuzz/fuzz_targets/multiple_orders.rs | 14 +++++++------- programs/openbook-v2/fuzz/src/lib.rs | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs b/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs index 9d9459499..6898a0c4c 100644 --- a/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs +++ b/programs/openbook-v2/fuzz/fuzz_targets/multiple_orders.rs @@ -31,7 +31,7 @@ impl FuzzData { FuzzInstruction::PlaceOrder { .. } | FuzzInstruction::PlaceOrderPegged { .. } | FuzzInstruction::PlaceTakeOrder { .. } - | FuzzInstruction::CancelAndPlaceOrders { .. } + | FuzzInstruction::CancelAllAndPlaceOrders { .. } ) }) } @@ -73,9 +73,9 @@ enum FuzzInstruction { data: openbook_v2::instruction::EditOrderPegged, makers: Option>, }, - CancelAndPlaceOrders { + CancelAllAndPlaceOrders { user_id: UserId, - data: openbook_v2::instruction::CancelAndPlaceOrders, + data: openbook_v2::instruction::CancelAllAndPlaceOrders, makers: Option>, }, CancelOrder { @@ -171,13 +171,13 @@ impl FuzzRunner for FuzzContext { .edit_order_pegged(user_id, data, makers.as_ref()) .map_or_else(error_parser::edit_order_pegged, keep), - FuzzInstruction::CancelAndPlaceOrders { + FuzzInstruction::CancelAllAndPlaceOrders { user_id, data, makers, } => self - .cancel_and_place_orders(user_id, data, makers.as_ref()) - .map_or_else(error_parser::cancel_and_place_orders, keep), + .cancel_all_and_place_orders(user_id, data, makers.as_ref()) + .map_or_else(error_parser::cancel_all_and_place_orders, keep), FuzzInstruction::CancelOrder { user_id, data } => self .cancel_order(user_id, data) @@ -534,7 +534,7 @@ mod error_parser { } } - pub fn cancel_and_place_orders(err: ProgramError) -> Corpus { + pub fn cancel_all_and_place_orders(err: ProgramError) -> Corpus { match err { e if e == OpenBookError::InvalidInputLots.into() => Corpus::Reject, e if e == OpenBookError::InvalidInputLotsSize.into() => Corpus::Reject, diff --git a/programs/openbook-v2/fuzz/src/lib.rs b/programs/openbook-v2/fuzz/src/lib.rs index c2d668ee1..be364ce42 100644 --- a/programs/openbook-v2/fuzz/src/lib.rs +++ b/programs/openbook-v2/fuzz/src/lib.rs @@ -603,15 +603,15 @@ impl FuzzContext { process_instruction(&mut self.state, data, &accounts, &remaining) } - pub fn cancel_and_place_orders( + pub fn cancel_all_and_place_orders( &mut self, user_id: &UserId, - data: &openbook_v2::instruction::CancelAndPlaceOrders, + data: &openbook_v2::instruction::CancelAllAndPlaceOrders, makers: Option<&HashSet>, ) -> ProgramResult { let user = self.get_or_create_new_user(user_id); - let accounts = openbook_v2::accounts::CancelAndPlaceOrders { + let accounts = openbook_v2::accounts::CancelAllAndPlaceOrders { open_orders_account: user.open_orders, signer: user.owner, user_base_account: user.base_vault,