diff --git a/crates/database/src/orders.rs b/crates/database/src/orders.rs index af0b8fe442..68cfba2316 100644 --- a/crates/database/src/orders.rs +++ b/crates/database/src/orders.rs @@ -378,6 +378,17 @@ pub struct FullOrder { pub surplus_fee_timestamp: Option>, } +impl FullOrder { + pub fn valid_to(&self) -> i64 { + if let Some((_, valid_to)) = self.ethflow_data { + // For ethflow orders, we always return the user valid_to, + // as the Eip1271 valid to is u32::max + return valid_to; + } + self.valid_to + } +} + // When querying orders we have several specialized use cases working with their own filtering, // ordering, indexes. The parts that are shared between all queries are defined here so they can be // reused. diff --git a/crates/orderbook/src/database/orders.rs b/crates/orderbook/src/database/orders.rs index 29efadf8f0..819ecb952d 100644 --- a/crates/orderbook/src/database/orders.rs +++ b/crates/orderbook/src/database/orders.rs @@ -315,7 +315,7 @@ fn calculate_status(order: &FullOrder) -> OrderStatus { if order.invalidated { return OrderStatus::Cancelled; } - if order.valid_to < Utc::now().timestamp() { + if order.valid_to() < Utc::now().timestamp() { return OrderStatus::Expired; } if order.presignature_pending { @@ -629,6 +629,16 @@ mod tests { }), OrderStatus::Expired ); + + // Expired - for ethflow orders + assert_eq!( + calculate_status(&FullOrder { + invalidated: false, + ethflow_data: Some((false, valid_to_yesterday.timestamp())), + ..order_row() + }), + OrderStatus::Expired + ); } #[tokio::test]