midgard_rs/types/
tvl_interval.rs

1use chrono::{DateTime, Utc};
2use rust_decimal::Decimal;
3use serde::{Deserialize, Serialize};
4use serde_aux::prelude::*;
5use serde_with::formats::Flexible;
6use serde_with::TimestampSeconds;
7
8use crate::TVLPoolDepths;
9
10/*
11
12*** TVL Interval Scheme ***
13{
14		"endTime": "1707782400",
15		"poolsDepth": TVLPoolDepths,
16		"runePriceUSD": "5.417852169697646",
17		"startTime": "1707696000",
18		"totalValuePooled": "6230125879959270"
19}
20
21*/
22
23#[serde_with::serde_as]
24#[derive(Debug, Serialize, Deserialize, Clone)]
25pub struct TVLInterval {
26	#[serde_as(as = "TimestampSeconds<String, Flexible>")]
27	#[serde(rename = "endTime")]
28	end_time: DateTime<Utc>,
29
30	#[serde(rename = "poolsDepth")]
31	pools_depth: TVLPoolDepths,
32
33	#[serde(rename = "runePriceUSD", with = "rust_decimal::serde::str")]
34	rune_price_usd: Decimal,
35
36	#[serde_as(as = "TimestampSeconds<String, Flexible>")]
37	#[serde(rename = "startTime")]
38	start_time: DateTime<Utc>,
39
40	#[serde(rename = "totalValuePooled", deserialize_with = "deserialize_number_from_string")]
41	total_value_pooled: u64,
42}
43
44impl TVLInterval {
45	#[must_use]
46	pub const fn get_end_time(&self) -> &DateTime<Utc> {
47		&self.end_time
48	}
49
50	#[must_use]
51	pub const fn get_pools_depth(&self) -> &TVLPoolDepths {
52		&self.pools_depth
53	}
54
55	#[must_use]
56	pub const fn get_rune_price_usd(&self) -> &Decimal {
57		&self.rune_price_usd
58	}
59
60	#[must_use]
61	pub const fn get_start_time(&self) -> &DateTime<Utc> {
62		&self.start_time
63	}
64
65	#[must_use]
66	pub const fn get_total_value_pooled(&self) -> &u64 {
67		&self.total_value_pooled
68	}
69}