diff --git a/programs/manifest/src/state/constants.rs b/programs/manifest/src/state/constants.rs index c307ca984..c7dd1cc6f 100644 --- a/programs/manifest/src/state/constants.rs +++ b/programs/manifest/src/state/constants.rs @@ -18,6 +18,7 @@ pub const MARKET_FREE_LIST_BLOCK_SIZE: usize = MARKET_BLOCK_SIZE - FREE_LIST_OVE pub const GLOBAL_FREE_LIST_BLOCK_SIZE: usize = GLOBAL_BLOCK_SIZE - FREE_LIST_OVERHEAD; pub const NO_EXPIRATION_LAST_VALID_SLOT: u32 = 0; +pub const NEXT_PLANNED_MAINTENANCE_SLOT: u32 = 293522000; // ~Fri Oct 04 2024 midnight GMT pub const MARKET_FIXED_DISCRIMINANT: u64 = 4859840929024028656; pub const GLOBAL_FIXED_DISCRIMINANT: u64 = 10787423733276977665; diff --git a/programs/manifest/src/state/market.rs b/programs/manifest/src/state/market.rs index 5d4bc6d18..9e2c036b1 100644 --- a/programs/manifest/src/state/market.rs +++ b/programs/manifest/src/state/market.rs @@ -30,7 +30,7 @@ use super::{ assert_already_has_seat, assert_not_already_expired, get_now_slot, try_to_add_to_global, }, DerefOrBorrow, DerefOrBorrowMut, DynamicAccount, RestingOrder, MARKET_FIXED_DISCRIMINANT, - MARKET_FREE_LIST_BLOCK_SIZE, + MARKET_FREE_LIST_BLOCK_SIZE, NEXT_PLANNED_MAINTENANCE_SLOT, }; pub struct AddOrderToMarketArgs<'a, 'info> { @@ -542,6 +542,12 @@ impl, Dynamic: DerefOrBorrowMut<[u8]>> } = args; assert_already_has_seat(trader_index)?; let now_slot: u32 = current_slot.unwrap_or_else(|| get_now_slot()); + + require!( + now_slot < NEXT_PLANNED_MAINTENANCE_SLOT, + ManifestError::AlreadyExpired, + "manifest is under planned maintenance" + )?; assert_not_already_expired(last_valid_slot, now_slot)?; let DynamicAccount { fixed, dynamic } = self.borrow_mut(); diff --git a/programs/manifest/src/state/resting_order.rs b/programs/manifest/src/state/resting_order.rs index dac9f0147..d889729bf 100644 --- a/programs/manifest/src/state/resting_order.rs +++ b/programs/manifest/src/state/resting_order.rs @@ -10,7 +10,9 @@ use solana_program::{entrypoint::ProgramResult, program_error::ProgramError}; use static_assertions::const_assert_eq; use std::cmp::Ordering; -use super::{constants::NO_EXPIRATION_LAST_VALID_SLOT, RESTING_ORDER_SIZE}; +use super::{ + constants::NO_EXPIRATION_LAST_VALID_SLOT, NEXT_PLANNED_MAINTENANCE_SLOT, RESTING_ORDER_SIZE, +}; #[derive( Debug, @@ -139,7 +141,9 @@ impl RestingOrder { } pub fn is_expired(&self, current_slot: u32) -> bool { - self.last_valid_slot != NO_EXPIRATION_LAST_VALID_SLOT && self.last_valid_slot < current_slot + current_slot >= NEXT_PLANNED_MAINTENANCE_SLOT + || (self.last_valid_slot != NO_EXPIRATION_LAST_VALID_SLOT + && self.last_valid_slot < current_slot) } pub fn get_is_bid(&self) -> bool {