hypercall_db/types/
engine_journal.rs1use rust_decimal::Decimal;
7
8use crate::{DirectiveOutboxAppend, EventType};
9
10#[derive(Debug, Clone)]
11pub struct EngineJournalEventInsert {
12 pub event_topic: String,
13 pub event_key: Option<String>,
14 pub event_data: Vec<u8>,
15 pub l2_sequence: Option<i64>,
16 pub event_type: EventType,
17}
18
19#[derive(Debug, Clone)]
20pub struct EngineJournalFillSideEffect {
21 pub event_idx: i32,
22 pub trade_id: u64,
23 pub taker_ledger_delta: Decimal,
24 pub maker_ledger_delta: Decimal,
25 pub taker_premium_delta: Decimal,
26 pub maker_premium_delta: Decimal,
27 pub underlying_notional: Option<Decimal>,
28}
29
30#[derive(Debug, Clone)]
31pub struct EngineJournalCashWithdrawalSideEffect {
32 pub wallet: hypercall_types::WalletAddress,
33 pub request_id: String,
34 pub amount: Decimal,
35 pub balance_after: Decimal,
36 pub timestamp_ms: u64,
37}
38
39#[derive(Debug, Clone)]
40pub struct EngineJournalBalanceUpdate {
41 pub update: hypercall_types::BalanceUpdate,
42}
43
44#[derive(Debug, Clone)]
45pub struct EngineJournalEntryInsert {
46 pub request_uuid: uuid::Uuid,
47 pub received_ts_ms: u64,
48 pub command_data: Vec<u8>,
49 pub response_data: Option<Vec<u8>>,
50 pub order_id: Option<i64>,
51 pub command_type: Option<String>,
52 pub duration_ms: u64,
53 pub pre_digest_data: Vec<u8>,
54 pub post_digest_data: Vec<u8>,
55 pub events: Vec<EngineJournalEventInsert>,
56 pub outbox_appends: Vec<DirectiveOutboxAppend>,
57 pub fill_side_effects: Vec<EngineJournalFillSideEffect>,
58 pub cash_withdrawal_side_effect: Option<EngineJournalCashWithdrawalSideEffect>,
59 pub balance_updates: Vec<EngineJournalBalanceUpdate>,
60}
61
62#[derive(Debug, Clone, Copy, PartialEq, Eq)]
63pub enum EngineJournalRsmPersistenceMode {
64 Live,
65 Replay,
66}
67
68#[derive(Debug, Clone)]
69pub struct EngineJournalRsmBlockCommandInput {
70 pub rsm_command_seq: u64,
71 pub command_index: u64,
72 pub request_uuid: uuid::Uuid,
73 pub command_type: String,
74 pub command_data: Vec<u8>,
75 pub command_identity_hash: [u8; 32],
76}
77
78#[derive(Debug, Clone)]
79pub struct EngineJournalRsmBlockInput {
80 pub root_summary: crate::NewValidatorRsmRootSummary,
81 pub header: crate::NewRsmBlockHeader,
82 pub commands: Vec<EngineJournalRsmBlockCommandInput>,
83}
84
85#[derive(Debug, Clone)]
86pub struct EngineJournalRsmBlockBatch {
87 pub mode: EngineJournalRsmPersistenceMode,
88 pub blocks: Vec<EngineJournalRsmBlockInput>,
89}
90
91#[derive(Debug, Clone)]
92pub struct EngineJournalBatchInsertResult {
93 pub inserted_count: usize,
94 pub inserted_commands: Vec<(uuid::Uuid, i64)>,
95}