fireblocks_sdk/models/swap_operation.rs
1// Fireblocks API
2//
3// 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)
4//
5// The version of the OpenAPI document: 1.8.0
6// Contact: developers@fireblocks.com
7// Generated by: https://openapi-generator.tech
8
9use {
10 crate::models,
11 serde::{Deserialize, Serialize},
12};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct SwapOperation {
16 /// The id of the swap operation
17 #[serde(rename = "id")]
18 pub id: String,
19 /// The id of the vault account or account id
20 #[serde(rename = "accountId")]
21 pub account_id: String,
22 /// The ID of the provider
23 #[serde(rename = "providerId")]
24 pub provider_id: String,
25 #[serde(rename = "category")]
26 pub category: models::ProviderCategoryEnum,
27 #[serde(rename = "protocol")]
28 pub protocol: models::SwapProviderProtocolsEnum,
29 /// **CREATED** – The swap request has been created but not yet started.
30 /// **PENDING_USER_ACTION** – Awaiting a user action (e.g. signature or
31 /// approval). **PENDING_PROVIDER_ACTION** – Awaiting the provider to
32 /// process the request. **PROCESSING** – The swap is actively being
33 /// executed on‐chain. **COMPLETED** – The swap has finished successfully.
34 /// **CANCELED** – The swap was cancelled by user or provider before
35 /// completion. **FAILED** – The swap attempted but encountered an error.
36 #[serde(rename = "status")]
37 pub status: Status,
38 /// The amount of tokens the swapper will provide
39 #[serde(rename = "inputAmount")]
40 pub input_amount: String,
41 /// The id of the asset the swapper will provide
42 #[serde(rename = "inputAsset")]
43 pub input_asset: String,
44 /// The slippage tolerance is a percentage. The slippage tolerance is the
45 /// maximum amount the price can change between the time the transaction is
46 /// submitted and the time it is executed
47 #[serde(rename = "slippageTolerance")]
48 pub slippage_tolerance: f64,
49 /// The minimum amount of tokens the swapper will receive
50 #[serde(rename = "outputMinAmount")]
51 pub output_min_amount: String,
52 /// Maximum amount of tokens that the swapper will receive
53 #[serde(rename = "outputMaxAmount")]
54 pub output_max_amount: String,
55 /// The id of the asset the swapper will receive
56 #[serde(rename = "outputAsset")]
57 pub output_asset: String,
58 /// Final amount of tokens that the swapper will receive
59 #[serde(
60 rename = "outputFinalAmount",
61 default,
62 with = "::serde_with::rust::double_option",
63 skip_serializing_if = "Option::is_none"
64 )]
65 pub output_final_amount: Option<Option<String>>,
66 /// The required actions for the swap, including the type of action, the
67 /// status of the action, and the transaction id
68 #[serde(rename = "requiredActions")]
69 pub required_actions: Vec<models::SwapRequiredAction>,
70 #[serde(
71 rename = "error",
72 default,
73 with = "::serde_with::rust::double_option",
74 skip_serializing_if = "Option::is_none"
75 )]
76 pub error: Option<Option<models::SwapFlowError>>,
77 /// The creation time of the swap operation (ISO Date time).
78 #[serde(rename = "createdAt")]
79 pub created_at: String,
80 /// The last update time of the swap operation (ISO Date time).
81 #[serde(rename = "updatedAt")]
82 pub updated_at: String,
83 /// Fireblocks user id that issued the swap
84 #[serde(rename = "createdBy")]
85 pub created_by: uuid::Uuid,
86}
87
88impl SwapOperation {
89 pub fn new(
90 id: String,
91 account_id: String,
92 provider_id: String,
93 category: models::ProviderCategoryEnum,
94 protocol: models::SwapProviderProtocolsEnum,
95 status: Status,
96 input_amount: String,
97 input_asset: String,
98 slippage_tolerance: f64,
99 output_min_amount: String,
100 output_max_amount: String,
101 output_asset: String,
102 required_actions: Vec<models::SwapRequiredAction>,
103 created_at: String,
104 updated_at: String,
105 created_by: uuid::Uuid,
106 ) -> SwapOperation {
107 SwapOperation {
108 id,
109 account_id,
110 provider_id,
111 category,
112 protocol,
113 status,
114 input_amount,
115 input_asset,
116 slippage_tolerance,
117 output_min_amount,
118 output_max_amount,
119 output_asset,
120 output_final_amount: None,
121 required_actions,
122 error: None,
123 created_at,
124 updated_at,
125 created_by,
126 }
127 }
128}
129/// **CREATED** – The swap request has been created but not yet started.
130/// **PENDING_USER_ACTION** – Awaiting a user action (e.g. signature or
131/// approval). **PENDING_PROVIDER_ACTION** – Awaiting the provider to process
132/// the request. **PROCESSING** – The swap is actively being executed on‐chain.
133/// **COMPLETED** – The swap has finished successfully. **CANCELED** – The swap
134/// was cancelled by user or provider before completion. **FAILED** – The swap
135/// attempted but encountered an error.
136#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
137pub enum Status {
138 #[serde(rename = "CREATED")]
139 Created,
140 #[serde(rename = "TRANSACTION_IN_PROGRESS")]
141 TransactionInProgress,
142 #[serde(rename = "PENDING_PROVIDER_ACTION")]
143 PendingProviderAction,
144 #[serde(rename = "COMPLETED")]
145 Completed,
146 #[serde(rename = "CANCELED")]
147 Canceled,
148 #[serde(rename = "FAILED")]
149 Failed,
150}
151
152impl Default for Status {
153 fn default() -> Status {
154 Self::Created
155 }
156}