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
// Fireblocks API
//
// Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain. - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
//
// The version of the OpenAPI document: 1.8.0
// Contact: developers@fireblocks.com
// Generated by: https://openapi-generator.tech
use {
crate::models,
serde::{Deserialize, Serialize},
};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct SwapOperation {
/// The id of the swap operation
#[serde(rename = "id")]
pub id: String,
/// The id of the vault account or account id
#[serde(rename = "accountId")]
pub account_id: String,
/// The ID of the provider
#[serde(rename = "providerId")]
pub provider_id: String,
#[serde(rename = "category")]
pub category: models::ProviderCategoryEnum,
#[serde(rename = "protocol")]
pub protocol: models::SwapProviderProtocolsEnum,
/// **CREATED** – The swap request has been created but not yet started.
/// **PENDING_USER_ACTION** – Awaiting a user action (e.g. signature or
/// approval). **PENDING_PROVIDER_ACTION** – Awaiting the provider to
/// process the request. **PROCESSING** – The swap is actively being
/// executed on‐chain. **COMPLETED** – The swap has finished successfully.
/// **CANCELED** – The swap was cancelled by user or provider before
/// completion. **FAILED** – The swap attempted but encountered an error.
#[serde(rename = "status")]
pub status: Status,
/// The amount of tokens the swapper will provide
#[serde(rename = "inputAmount")]
pub input_amount: String,
/// The id of the asset the swapper will provide
#[serde(rename = "inputAsset")]
pub input_asset: String,
/// The slippage tolerance is a percentage. The slippage tolerance is the
/// maximum amount the price can change between the time the transaction is
/// submitted and the time it is executed
#[serde(rename = "slippageTolerance")]
pub slippage_tolerance: f64,
/// The minimum amount of tokens the swapper will receive
#[serde(rename = "outputMinAmount")]
pub output_min_amount: String,
/// Maximum amount of tokens that the swapper will receive
#[serde(rename = "outputMaxAmount")]
pub output_max_amount: String,
/// The id of the asset the swapper will receive
#[serde(rename = "outputAsset")]
pub output_asset: String,
/// Final amount of tokens that the swapper will receive
#[serde(
rename = "outputFinalAmount",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub output_final_amount: Option<Option<String>>,
/// The required actions for the swap, including the type of action, the
/// status of the action, and the transaction id
#[serde(rename = "requiredActions")]
pub required_actions: Vec<models::SwapRequiredAction>,
#[serde(
rename = "error",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub error: Option<Option<models::SwapFlowError>>,
/// The creation time of the swap operation (ISO Date time).
#[serde(rename = "createdAt")]
pub created_at: String,
/// The last update time of the swap operation (ISO Date time).
#[serde(rename = "updatedAt")]
pub updated_at: String,
/// Fireblocks user id that issued the swap
#[serde(rename = "createdBy")]
pub created_by: uuid::Uuid,
}
impl SwapOperation {
pub fn new(
id: String,
account_id: String,
provider_id: String,
category: models::ProviderCategoryEnum,
protocol: models::SwapProviderProtocolsEnum,
status: Status,
input_amount: String,
input_asset: String,
slippage_tolerance: f64,
output_min_amount: String,
output_max_amount: String,
output_asset: String,
required_actions: Vec<models::SwapRequiredAction>,
created_at: String,
updated_at: String,
created_by: uuid::Uuid,
) -> SwapOperation {
SwapOperation {
id,
account_id,
provider_id,
category,
protocol,
status,
input_amount,
input_asset,
slippage_tolerance,
output_min_amount,
output_max_amount,
output_asset,
output_final_amount: None,
required_actions,
error: None,
created_at,
updated_at,
created_by,
}
}
}
/// **CREATED** – The swap request has been created but not yet started.
/// **PENDING_USER_ACTION** – Awaiting a user action (e.g. signature or
/// approval). **PENDING_PROVIDER_ACTION** – Awaiting the provider to process
/// the request. **PROCESSING** – The swap is actively being executed on‐chain.
/// **COMPLETED** – The swap has finished successfully. **CANCELED** – The swap
/// was cancelled by user or provider before completion. **FAILED** – The swap
/// attempted but encountered an error.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "CREATED")]
Created,
#[serde(rename = "TRANSACTION_IN_PROGRESS")]
TransactionInProgress,
#[serde(rename = "PENDING_PROVIDER_ACTION")]
PendingProviderAction,
#[serde(rename = "COMPLETED")]
Completed,
#[serde(rename = "CANCELED")]
Canceled,
#[serde(rename = "FAILED")]
Failed,
}
impl Default for Status {
fn default() -> Status {
Self::Created
}
}