midgard_rs/types/
swap_meta.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
8/*
9
10*** Swap Meta Scheme ***
11
12{
13		"averageSlip": "0.7043212107695739",
14		"endTime": "1710288000",
15		"runePriceUSD": "9.849104010393853",
16		"startTime": "1707696000",
17		"synthMintAverageSlip": "0.660790711470825",
18		"synthMintCount": "141594",
19		"synthMintFees": "2738318966140",
20		"synthMintVolume": "12721267621939614",
21		"synthRedeemAverageSlip": "0.7406643757159221",
22		"synthRedeemCount": "126585",
23		"synthRedeemFees": "4513847204931",
24		"synthRedeemVolume": "12838360056854707",
25		"toAssetAverageSlip": "1.1981717544448172",
26		"toAssetCount": "35772",
27		"toAssetFees": "4346538184030",
28		"toAssetVolume": "5245279208252100",
29		"toRuneAverageSlip": "0.5174002878766774",
30		"toRuneCount": "86148",
31		"toRuneFees": "1231526856953",
32		"toRuneVolume": "5323649320824332",
33		"totalCount": "390099",
34		"totalFees": "12830231212054",
35		"totalVolume": "36128556207870753"
36}
37
38*/
39
40#[serde_with::serde_as]
41#[derive(Debug, Serialize, Deserialize, Clone, Default)]
42pub struct SwapMeta {
43	#[serde(rename = "averageSlip", with = "rust_decimal::serde::str")]
44	average_slip: Decimal,
45
46	#[serde_as(as = "TimestampSeconds<String, Flexible>")]
47	#[serde(rename = "endTime")]
48	end_time: DateTime<Utc>,
49
50	#[serde(rename = "runePriceUSD", with = "rust_decimal::serde::str")]
51	rune_price_usd: Decimal,
52
53	#[serde_as(as = "TimestampSeconds<String, Flexible>")]
54	#[serde(rename = "startTime")]
55	start_time: DateTime<Utc>,
56
57	#[serde(rename = "synthMintAverageSlip", with = "rust_decimal::serde::str")]
58	synth_mint_average_slip: Decimal,
59
60	#[serde(rename = "synthMintCount", deserialize_with = "deserialize_number_from_string")]
61	synth_mint_count: u64,
62
63	#[serde(rename = "synthMintFees", deserialize_with = "deserialize_number_from_string")]
64	synth_mint_fees: u64,
65
66	#[serde(rename = "synthMintVolume", deserialize_with = "deserialize_number_from_string")]
67	synth_mint_volume: u64,
68
69	#[serde(rename = "synthMintVolumeUSD", deserialize_with = "deserialize_option_number_from_string")]
70	synth_mint_volume_usd: Option<u64>,
71
72	#[serde(rename = "synthRedeemAverageSlip", with = "rust_decimal::serde::str")]
73	synth_redeem_average_slip: Decimal,
74
75	#[serde(rename = "synthRedeemCount", deserialize_with = "deserialize_number_from_string")]
76	synth_redeem_count: u64,
77
78	#[serde(rename = "synthRedeemFees", deserialize_with = "deserialize_number_from_string")]
79	synth_redeem_fees: u64,
80
81	#[serde(rename = "synthRedeemVolume", deserialize_with = "deserialize_number_from_string")]
82	synth_redeem_volume: u64,
83
84	#[serde(rename = "synthRedeemVolumeUSD", deserialize_with = "deserialize_option_number_from_string")]
85	synth_redeem_volume_usd: Option<u64>,
86
87	#[serde(rename = "toAssetAverageSlip", with = "rust_decimal::serde::str")]
88	to_asset_average_slip: Decimal,
89
90	#[serde(rename = "toAssetCount", deserialize_with = "deserialize_number_from_string")]
91	to_asset_count: u64,
92
93	#[serde(rename = "toAssetFees", deserialize_with = "deserialize_number_from_string")]
94	to_asset_fees: u64,
95
96	#[serde(rename = "toAssetVolume", deserialize_with = "deserialize_number_from_string")]
97	to_asset_volume: u64,
98
99	#[serde(rename = "toAssetVolumeUSD", deserialize_with = "deserialize_option_number_from_string")]
100	to_asset_volume_usd: Option<u64>,
101
102	#[serde(rename = "toRuneAverageSlip", with = "rust_decimal::serde::str")]
103	to_rune_average_slip: Decimal,
104
105	#[serde(rename = "toRuneCount", deserialize_with = "deserialize_number_from_string")]
106	to_rune_count: u64,
107
108	#[serde(rename = "toRuneFees", deserialize_with = "deserialize_number_from_string")]
109	to_rune_fees: u64,
110
111	#[serde(rename = "toRuneVolume", deserialize_with = "deserialize_number_from_string")]
112	to_rune_volume: u64,
113
114	#[serde(rename = "toRuneVolumeUSD", deserialize_with = "deserialize_option_number_from_string")]
115	to_rune_volume_usd: Option<u64>,
116
117	#[serde(rename = "totalCount", deserialize_with = "deserialize_number_from_string")]
118	total_count: u64,
119
120	#[serde(rename = "totalFees", deserialize_with = "deserialize_number_from_string")]
121	total_fees: u64,
122
123	#[serde(rename = "totalVolume", deserialize_with = "deserialize_number_from_string")]
124	total_volume: u64,
125
126	#[serde(rename = "totalVolumeUSD", deserialize_with = "deserialize_option_number_from_string")]
127	total_volume_usd: Option<u64>,
128}
129
130impl SwapMeta {
131	#[must_use]
132	pub const fn get_average_slip(&self) -> &Decimal {
133		&self.average_slip
134	}
135
136	#[must_use]
137	pub const fn get_end_time(&self) -> &DateTime<Utc> {
138		&self.end_time
139	}
140
141	#[must_use]
142	pub const fn get_rune_price_usd(&self) -> &Decimal {
143		&self.rune_price_usd
144	}
145
146	#[must_use]
147	pub const fn get_start_time(&self) -> &DateTime<Utc> {
148		&self.start_time
149	}
150
151	#[must_use]
152	pub const fn get_synth_mint_average_slip(&self) -> &Decimal {
153		&self.synth_mint_average_slip
154	}
155
156	#[must_use]
157	pub const fn get_synth_mint_count(&self) -> &u64 {
158		&self.synth_mint_count
159	}
160
161	#[must_use]
162	pub const fn get_synth_mint_fees(&self) -> &u64 {
163		&self.synth_mint_fees
164	}
165
166	#[must_use]
167	pub const fn get_synth_mint_volume(&self) -> &u64 {
168		&self.synth_mint_volume
169	}
170
171	#[must_use]
172	pub const fn get_synth_mint_volume_usd(&self) -> &Option<u64> {
173		&self.synth_mint_volume_usd
174	}
175
176	#[must_use]
177	pub const fn get_synth_redeem_average_slip(&self) -> &Decimal {
178		&self.synth_redeem_average_slip
179	}
180
181	#[must_use]
182	pub const fn get_synth_redeem_count(&self) -> &u64 {
183		&self.synth_redeem_count
184	}
185
186	#[must_use]
187	pub const fn get_synth_redeem_fees(&self) -> &u64 {
188		&self.synth_redeem_fees
189	}
190
191	#[must_use]
192	pub const fn get_synth_redeem_volume(&self) -> &u64 {
193		&self.synth_redeem_volume
194	}
195
196	#[must_use]
197	pub const fn get_synth_redeem_volume_usd(&self) -> &Option<u64> {
198		&self.synth_redeem_volume_usd
199	}
200
201	#[must_use]
202	pub const fn get_to_asset_average_slip(&self) -> &Decimal {
203		&self.to_asset_average_slip
204	}
205
206	#[must_use]
207	pub const fn get_to_asset_count(&self) -> &u64 {
208		&self.to_asset_count
209	}
210
211	#[must_use]
212	pub const fn get_to_asset_fees(&self) -> &u64 {
213		&self.to_asset_fees
214	}
215
216	#[must_use]
217	pub const fn get_to_asset_volume(&self) -> &u64 {
218		&self.to_asset_volume
219	}
220
221	#[must_use]
222	pub const fn get_to_asset_volume_usd(&self) -> &Option<u64> {
223		&self.to_asset_volume_usd
224	}
225
226	#[must_use]
227	pub const fn get_to_rune_average_slip(&self) -> &Decimal {
228		&self.to_rune_average_slip
229	}
230
231	#[must_use]
232	pub const fn get_to_rune_count(&self) -> &u64 {
233		&self.to_rune_count
234	}
235
236	#[must_use]
237	pub const fn get_to_rune_fees(&self) -> &u64 {
238		&self.to_rune_fees
239	}
240
241	#[must_use]
242	pub const fn get_to_rune_volume(&self) -> &u64 {
243		&self.to_rune_volume
244	}
245
246	#[must_use]
247	pub const fn get_to_rune_volume_usd(&self) -> &Option<u64> {
248		&self.to_rune_volume_usd
249	}
250
251	#[must_use]
252	pub const fn get_total_count(&self) -> &u64 {
253		&self.total_count
254	}
255
256	#[must_use]
257	pub const fn get_total_fees(&self) -> &u64 {
258		&self.total_fees
259	}
260
261	#[must_use]
262	pub const fn get_total_volume(&self) -> &u64 {
263		&self.total_volume
264	}
265
266	#[must_use]
267	pub const fn get_total_volume_usd(&self) -> &Option<u64> {
268		&self.total_volume_usd
269	}
270}