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 pub reduce_only: bool,
28}
29
30impl StopOrderTicketDetails {
31 pub fn encrypted_details(&self, salt: Vec<u8>) -> bcs::Result<Vec<u8>> {
33 let mut bytes = bcs::to_bytes(self)?;
34 bytes.extend(salt);
35 Ok(Blake2b256::digest(bytes).to_vec())
36 }
37}