Skip to content

Commit

Permalink
planned force cancel period oct 4th 2024 (#109)
Browse files Browse the repository at this point in the history
* planned force cancel period oct 4th 2024
* dont modify tree data to keep tests intact
  • Loading branch information
mschneider authored Sep 20, 2024
1 parent f0ce48a commit d1c69f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions programs/manifest/src/state/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 7 additions & 1 deletion programs/manifest/src/state/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -542,6 +542,12 @@ impl<Fixed: DerefOrBorrowMut<MarketFixed>, 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();
Expand Down
8 changes: 6 additions & 2 deletions programs/manifest/src/state/resting_order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d1c69f5

Please sign in to comment.