use crate::{Amount, Chain, Protocol, Provenance, Timestamp};
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EventKind {
Deposit,
Withdraw,
Borrow,
Repay,
Liquidation,
CollectFees,
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HistoryEvent {
pub kind: EventKind,
pub amount: Amount,
pub tx: String,
pub at: Timestamp,
pub block: Option<u64>,
}
impl HistoryEvent {
pub fn new(kind: EventKind, amount: Amount, tx: impl Into<String>, at: Timestamp) -> Self {
HistoryEvent {
kind,
amount,
tx: tx.into(),
at,
block: None,
}
}
#[must_use]
pub fn with_block(mut self, block: Option<u64>) -> Self {
self.block = block;
self
}
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct History {
pub protocol: Protocol,
pub chain: Chain,
pub events: Vec<HistoryEvent>,
pub provenance: Provenance,
}
impl History {
pub fn new(
protocol: Protocol,
chain: Chain,
events: Vec<HistoryEvent>,
provenance: Provenance,
) -> Self {
History {
protocol,
chain,
events,
provenance,
}
}
}