1use af_utilities::types::Fixed;
4use fastcrypto::hash::{Blake2b256, HashFunction};
5use sui_framework_sdk::object::ID;
6
7use crate::order_helpers::{OrderType, Side};
8
9#[derive(Debug, serde::Serialize)]
11pub struct StopOrderTicketDetails {
12 pub clearing_house_id: ID,
13 pub expire_timestamp: u64,
15 pub is_limit_order: bool,
17 pub stop_index_price: Fixed,
18 pub ge_stop_index_price: bool,
21 pub side: Side,
22 pub size: u64,
23 pub price: u64,
25 pub order_type: OrderType,
27}
28
29impl StopOrderTicketDetails {
30 pub fn encrypted_details(&self, salt: Vec<u8>) -> bcs::Result<Vec<u8>> {
32 let mut bytes = bcs::to_bytes(self)?;
33 bytes.extend(salt);
34 Ok(Blake2b256::digest(bytes).to_vec())
35 }
36}