use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct Usd(pub f64);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Side {
Buy,
Sell,
}
#[derive(Debug, Clone, Serialize)]
pub struct Trade {
pub side: Side,
pub token: String,
pub amount: Usd,
pub signature: Option<String>,
}
impl Trade {
pub fn buy(token: &str, amount: Usd) -> Self {
Self { side: Side::Buy, token: token.to_owned(), amount, signature: None }
}
pub fn sell(token: &str, amount: Usd) -> Self {
Self { side: Side::Sell, token: token.to_owned(), amount, signature: None }
}
pub fn tx(mut self, signature: String) -> Self {
self.signature = Some(signature);
self
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct Receipt {
pub signature: String,
}
#[derive(Debug, Clone)]
pub struct Event<T> {
pub data: T,
}