// file: kb_lib/src/db/entities/orderbook_event.rs

//! Orderbook event entity.

/// Persisted normalized orderbook or limit-order event row.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, sqlx::FromRow)]
pub struct OrderbookEventEntity {
    /// Numeric primary key.
    pub id: i64,
    /// Related transaction id.
    pub transaction_id: i64,
    /// Related decoded DEX event id, when available.
    pub decoded_event_id: std::option::Option<i64>,
    /// Related DEX id, when the DEX row is known.
    pub dex_id: std::option::Option<i64>,
    /// Related pool id, when the pool row is known.
    pub pool_id: std::option::Option<i64>,
    /// Related pair id, when the pair row is known.
    pub pair_id: std::option::Option<i64>,
    /// Transaction signature.
    pub signature: std::string::String,
    /// Optional slot number.
    pub slot: std::option::Option<i64>,
    /// Protocol name that emitted the decoded event.
    pub protocol_name: std::string::String,
    /// Program id that emitted the decoded event.
    pub program_id: std::string::String,
    /// Stable decoded event kind.
    pub event_kind: std::string::String,
    /// Normalized orderbook action.
    pub order_action: std::string::String,
    /// Pool account address, when decoded.
    pub pool_account: std::option::Option<std::string::String>,
    /// Market/orderbook account, when decoded.
    pub market_account: std::option::Option<std::string::String>,
    /// Wallet or authority associated with the event, when decoded.
    pub actor_wallet: std::option::Option<std::string::String>,
    /// Limit/order account, when decoded.
    pub order_account: std::option::Option<std::string::String>,
    /// Base or token A mint, when decoded.
    pub base_token_mint: std::option::Option<std::string::String>,
    /// Quote or token B mint, when decoded.
    pub quote_token_mint: std::option::Option<std::string::String>,
    /// Raw order amount as decimal text, when decoded.
    pub amount_raw: std::option::Option<std::string::String>,
    /// Raw minimum amount as decimal text, when decoded.
    pub amount_min_raw: std::option::Option<std::string::String>,
    /// Optional tick index for CLMM limit orders.
    pub tick_index: std::option::Option<i64>,
    /// Optional zero-for-one side flag, stored as 0/1.
    pub zero_for_one: std::option::Option<i64>,
    /// Source decoded payload JSON.
    pub payload_json: std::string::String,
    /// Execution timestamp encoded as RFC3339 UTC text.
    pub executed_at: std::string::String,
    /// Creation timestamp encoded as RFC3339 UTC text.
    pub created_at: std::string::String,
}
