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