fts_core/models/
outcome.rs

1use serde::{Deserialize, Serialize};
2use time::OffsetDateTime;
3use utoipa::ToSchema;
4
5/// An outcome represents the result of an auction for a particular auth or product.
6///
7/// An outcome contains:
8/// - A `price` at which the asset was cleared in the auction
9/// - A `trade` amount representing the quantity that was traded
10/// - Optional implementation-dependent `data` for additional context
11///
12/// The sign convention for trades follows the flow trading standard:
13/// - Positive values indicate buying
14/// - Negative values indicate selling
15#[derive(Serialize, Deserialize, Debug, ToSchema)]
16pub struct Outcome<T> {
17    /// The clearing price determined by the auction solver
18    pub price: f64,
19    /// The trade amount (positive for buying, negative for selling)
20    pub trade: f64,
21    /// Optional implementation-specific data related to the outcome
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub data: Option<T>,
24}
25
26/// Provides temporal context for an outcome by associating it with
27/// a specific auction time interval.
28///
29/// This structure embeds an `Outcome` with the time range (`from` and `thru`)
30/// of the auction that produced it, allowing for tracking outcomes across
31/// multiple consecutive auctions.
32#[derive(Serialize, Deserialize, Debug, ToSchema)]
33pub struct AuctionOutcome<T> {
34    /// The starting time of the auction interval
35    #[serde(with = "time::serde::rfc3339")]
36    pub from: OffsetDateTime,
37    /// The ending time of the auction interval
38    #[serde(with = "time::serde::rfc3339")]
39    pub thru: OffsetDateTime,
40    /// The actual outcome (price and trade) from the auction
41    #[serde(flatten)]
42    pub outcome: Outcome<T>,
43}