1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
use std::collections::HashMap;

use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};

use crate::QuoteCallData;
use crate::QuoteEvmTransactionDetails;
use crate::QuoteFee;
use crate::QuoteMeta;
use crate::QuoteSwap;
use crate::QuoteTimeEstimates;
use crate::QuoteTransactionEnum;

/*
{
		"path": "ETH.ETH -> BTC.BTC",
		"providers": [
				"THORCHAIN"
		],
		"subProviders": [
				"THORCHAIN"
		],
		"swaps": HashMap<String, Vec<Vec<QuoteSwap>>>,
		"expectedOutput": "0.04505466",
		"expectedOutputMaxSlippage": "0.04460857425742574257",
		"expectedOutputUSD": "2974.330077737888",
		"expectedOutputMaxSlippageUSD": "2944.881265087018",
		"transaction": QuoteTransaction,
		"optimal": true,
		"complete": true,
		"fees": HashMap<String, Vec<QuoteFee>>,
		"meta": QuoteMeta,
		"inboundAddress": "0xcb4c6ae4f20477f96342467df478ae83512a7bd5",
		"targetAddress": "0xD37BbE5744D730a1d98d8DC97c42F0Ca46aD7146",
		"estimatedTime": 678,
		"calldata": QuoteCallData,
		"contract": "0xD37BbE5744D730a1d98d8DC97c42F0Ca46aD7146",
		"contractMethod": "depositWithExpiry",
		"approvalTarget": "0xD37BbE5744D730a1d98d8DC97c42F0Ca46aD7146",
		"approvalToken": null,
		"evmTransactionDetails": QuoteEvmTransactionDetails,
		"timeEstimates": QuoteTimeEstimates,
		"index": 0
}
*/

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct QuoteRoute {
	#[serde(rename = "path")]
	path: String,

	#[serde(rename = "providers")]
	providers: Vec<String>,

	#[serde(rename = "subProviders")]
	sub_providers: Vec<String>,

	#[serde(rename = "swaps")]
	swaps: HashMap<String, Vec<Vec<QuoteSwap>>>,

	#[serde(rename = "expectedOutput", with = "rust_decimal::serde::str")]
	expected_output: Decimal,

	#[serde(rename = "expectedOutputMaxSlippage", with = "rust_decimal::serde::str")]
	expected_output_max_slippage: Decimal,

	#[serde(rename = "expectedOutputUSD", with = "rust_decimal::serde::str")]
	expected_output_usd: Decimal,

	#[serde(rename = "expectedOutputMaxSlippageUSD", with = "rust_decimal::serde::str")]
	expected_output_max_slippage_usd: Decimal,

	#[serde(rename = "transaction")]
	transaction: QuoteTransactionEnum,

	#[serde(rename = "optimal")]
	optimal: bool,

	#[serde(rename = "complete")]
	complete: bool,

	#[serde(rename = "fees")]
	fees: HashMap<String, Vec<QuoteFee>>,

	#[serde(rename = "meta")]
	meta: QuoteMeta,

	#[serde(rename = "inboundAddress")]
	inbound_address: Option<String>,

	#[serde(rename = "targetAddress")]
	target_address: Option<String>,

	#[serde(rename = "estimatedTime", serialize_with = "rust_decimal::serde::str::serialize", deserialize_with = "rust_decimal::serde::float::deserialize")]
	estimated_time: Decimal,

	#[serde(rename = "calldata")]
	calldata: QuoteCallData,

	#[serde(rename = "contract")]
	contract: Option<String>,

	#[serde(rename = "contractMethod")]
	contract_method: Option<String>,

	#[serde(rename = "approvalTarget")]
	approval_target: Option<String>,

	#[serde(rename = "approvalToken")]
	approval_token: Option<String>,

	#[serde(rename = "evmTransactionDetails")]
	evm_transaction_details: QuoteEvmTransactionDetails,

	#[serde(rename = "timeEstimates")]
	time_estimates: QuoteTimeEstimates,

	#[serde(rename = "index", serialize_with = "rust_decimal::serde::str::serialize", deserialize_with = "rust_decimal::serde::float::deserialize")]
	index: Decimal,
}

impl QuoteRoute {
	#[must_use]
	pub const fn get_path(&self) -> &String {
		&self.path
	}

	#[must_use]
	pub const fn get_providers(&self) -> &Vec<String> {
		&self.providers
	}

	#[must_use]
	pub const fn get_sub_providers(&self) -> &Vec<String> {
		&self.sub_providers
	}

	#[must_use]
	pub const fn get_swaps(&self) -> &HashMap<String, Vec<Vec<QuoteSwap>>> {
		&self.swaps
	}

	#[must_use]
	pub const fn get_expected_output(&self) -> Decimal {
		self.expected_output
	}

	#[must_use]
	pub const fn get_expected_output_max_slippage(&self) -> Decimal {
		self.expected_output_max_slippage
	}

	#[must_use]
	pub const fn get_expected_output_usd(&self) -> Decimal {
		self.expected_output_usd
	}

	#[must_use]
	pub const fn get_expected_output_max_slippage_usd(&self) -> Decimal {
		self.expected_output_max_slippage_usd
	}

	#[must_use]
	pub const fn get_transaction(&self) -> &QuoteTransactionEnum {
		&self.transaction
	}

	#[must_use]
	pub const fn get_optimal(&self) -> bool {
		self.optimal
	}

	#[must_use]
	pub const fn get_complete(&self) -> bool {
		self.complete
	}

	#[must_use]
	pub const fn get_fees(&self) -> &HashMap<String, Vec<QuoteFee>> {
		&self.fees
	}

	#[must_use]
	pub const fn get_meta(&self) -> &QuoteMeta {
		&self.meta
	}

	#[must_use]
	pub const fn get_inbound_address(&self) -> &Option<String> {
		&self.inbound_address
	}

	#[must_use]
	pub const fn get_target_address(&self) -> &Option<String> {
		&self.target_address
	}

	#[must_use]
	pub const fn get_estimated_time(&self) -> Decimal {
		self.estimated_time
	}

	#[must_use]
	pub const fn get_calldata(&self) -> &QuoteCallData {
		&self.calldata
	}

	#[must_use]
	pub const fn get_contract(&self) -> &Option<String> {
		&self.contract
	}

	#[must_use]
	pub const fn get_contract_method(&self) -> &Option<String> {
		&self.contract_method
	}

	#[must_use]
	pub const fn get_approval_target(&self) -> &Option<String> {
		&self.approval_target
	}

	#[must_use]
	pub const fn get_approval_token(&self) -> &Option<String> {
		&self.approval_token
	}

	#[must_use]
	pub const fn get_evm_transaction_details(&self) -> &QuoteEvmTransactionDetails {
		&self.evm_transaction_details
	}

	#[must_use]
	pub const fn get_time_estimates(&self) -> &QuoteTimeEstimates {
		&self.time_estimates
	}

	#[must_use]
	pub const fn get_index(&self) -> Decimal {
		self.index
	}
}