1use serde::{Deserialize, Serialize};
2
3pub struct Config {
6 pub query_key: String,
7 pub base_url: Option<String>,
8 pub verbose: bool,
9}
10
11#[derive(Debug, Clone, Default)]
12pub struct FolioOpts {
13 pub cached: bool,
14}
15
16#[derive(Debug, Clone, Default)]
17pub struct EventsOpts {
18 pub since: Option<u64>,
19 pub poll: bool,
20}
21
22#[derive(Debug, Serialize, Default)]
25pub struct CreateAccountParams {
26 pub signer_type: String,
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub ethereum_signer_address: Option<String>,
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub solana_signer_address: Option<String>,
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub p256_public_key: Option<String>,
33}
34
35#[derive(Debug, Serialize, Deserialize)]
36pub struct Account {
37 pub account_id: String,
38 pub signer_type: Option<String>,
39 pub ethereum_signer_address: Option<String>,
40 pub legend_wallet_address: Option<String>,
41 pub solana_wallet_address: Option<String>,
42 pub turnkey_sub_org_id: Option<String>,
43 pub created_at: String,
44}
45
46#[derive(Debug, Serialize, Deserialize)]
47pub struct AccountList {
48 pub accounts: Vec<Account>,
49}
50
51#[derive(Debug, Serialize, Deserialize)]
52pub struct PrimeAccount {
53 pub id: String,
54 pub name: Option<String>,
55 pub email: Option<String>,
56}
57
58#[derive(Debug, Serialize, Deserialize)]
59pub struct Folio {
60 pub folio: serde_json::Value,
61}
62
63#[derive(Debug, Serialize, Deserialize)]
66pub struct Plan {
67 pub plan_id: String,
68 pub details: serde_json::Value,
69 pub expires_at: String,
70}
71
72impl Plan {
73 pub fn digest(&self) -> Option<&str> {
75 self.details
76 .get("eip712_data")
77 .and_then(|d| d.get("digest"))
78 .and_then(|d| d.as_str())
79 }
80}
81
82#[derive(Debug, Serialize)]
83pub struct ExecuteParams {
84 pub plan_id: String,
85 pub signature: String,
86}
87
88#[derive(Debug, Serialize, Deserialize)]
89pub struct ExecuteResult {
90 pub plan_id: String,
91 pub quark_intent_id: Option<String>,
92 pub activity_id: Option<String>,
93 pub status: String,
94}
95
96#[derive(Debug, Serialize)]
99pub struct EarnParams {
100 pub amount: String,
101 pub asset: String,
102 pub network: String,
103 pub protocol: String,
104 #[serde(skip_serializing_if = "Option::is_none")]
105 pub market: Option<String>,
106}
107
108#[derive(Debug, Serialize)]
109pub struct WithdrawParams {
110 pub amount: String,
111 pub asset: String,
112 pub network: String,
113 pub protocol: String,
114 #[serde(skip_serializing_if = "Option::is_none")]
115 pub market: Option<String>,
116}
117
118#[derive(Debug, Serialize)]
119pub struct TransferParams {
120 pub amount: String,
121 pub asset: String,
122 pub network: String,
123 pub recipient: String,
124}
125
126#[derive(Debug, Serialize)]
127pub struct ClaimRewardsParams {
128 pub asset: String,
129}
130
131#[derive(Debug, Serialize)]
132pub struct BorrowParams {
133 pub amount: String,
134 pub asset: String,
135 pub network: String,
136 pub collateral_amount: String,
137 pub collateral_asset: String,
138 pub protocol: String,
139 #[serde(skip_serializing_if = "Option::is_none")]
140 pub market: Option<String>,
141}
142
143#[derive(Debug, Serialize)]
144pub struct RepayParams {
145 pub amount: String,
146 pub asset: String,
147 pub network: String,
148 pub collateral_amount: String,
149 pub collateral_asset: String,
150 pub protocol: String,
151 #[serde(skip_serializing_if = "Option::is_none")]
152 pub market: Option<String>,
153}
154
155#[derive(Debug, Serialize)]
156pub struct SwapParams {
157 pub sell_asset: String,
158 pub buy_asset: String,
159 pub network: String,
160 #[serde(skip_serializing_if = "Option::is_none")]
161 pub sell_amount: Option<String>,
162 #[serde(skip_serializing_if = "Option::is_none")]
163 pub buy_amount: Option<String>,
164}
165
166#[derive(Debug, Serialize)]
167pub struct LoopLongParams {
168 pub exposure_asset: String,
169 pub backing_asset: String,
170 pub market_id: String,
171 pub is_increase: bool,
172 pub exposure_amount: String,
173 pub max_swap_backing_amount: String,
174 pub max_provided_backing_amount: String,
175 pub pool_fee: u64,
176 pub network: String,
177}
178
179#[derive(Debug, Serialize)]
180pub struct UnloopLongParams {
181 pub exposure_asset: String,
182 pub backing_asset: String,
183 pub market_id: String,
184 pub exposure_amount: String,
185 pub backing_amount_to_exit: String,
186 pub min_swap_backing_amount: String,
187 pub pool_fee: u64,
188 pub network: String,
189}
190
191#[derive(Debug, Serialize)]
192pub struct AddBackingParams {
193 pub exposure_asset: String,
194 pub backing_asset: String,
195 pub market_id: String,
196 pub amount: String,
197 pub is_short: bool,
198 pub network: String,
199}
200
201#[derive(Debug, Serialize)]
202pub struct WithdrawBackingParams {
203 pub exposure_asset: String,
204 pub backing_asset: String,
205 pub market_id: String,
206 pub amount: String,
207 pub is_short: bool,
208 pub network: String,
209}
210
211#[derive(Debug, Serialize)]
212pub struct MigrateParams {
213 pub amount: String,
214 pub asset: String,
215 pub from_protocol: String,
216 pub to_protocol: String,
217 pub network: String,
218 #[serde(skip_serializing_if = "Option::is_none")]
219 pub from_market: Option<String>,
220 #[serde(skip_serializing_if = "Option::is_none")]
221 pub to_market: Option<String>,
222 #[serde(skip_serializing_if = "Option::is_none")]
223 pub migrate_only_supply_balances: Option<bool>,
224}
225
226#[derive(Debug, Serialize)]
227pub struct SwapAndSupplyParams {
228 pub sell_asset: String,
229 pub sell_amount: String,
230 pub buy_asset: String,
231 pub protocol: String,
232 pub network: String,
233 #[serde(skip_serializing_if = "Option::is_none")]
234 pub market: Option<String>,
235}
236
237#[derive(Debug, Serialize)]
238pub struct ReinvestRewardsParams {
239 pub asset: String,
240 pub protocol: String,
241 pub network: String,
242 pub reward_assets: Vec<String>,
243}
244
245#[derive(Debug, Serialize, Deserialize)]
248pub struct ActivityList {
249 pub activities: Vec<Activity>,
250}
251
252#[derive(Debug, Serialize, Deserialize)]
253pub struct Activity {
254 pub id: u64,
255 pub status: Option<String>,
256 pub quark_intent: Option<serde_json::Value>,
257 pub executions: Option<Vec<serde_json::Value>>,
258}
259
260#[derive(Debug, Serialize, Deserialize)]
261pub struct EventList {
262 pub events: Vec<serde_json::Value>,
263 pub cursor: Option<u64>,
264}
265
266#[derive(Debug, Serialize, Deserialize)]
269pub struct NetworkList {
270 pub networks: Vec<Network>,
271}
272
273#[derive(Debug, Serialize, Deserialize)]
274pub struct Network {
275 pub name: String,
276 pub chain_id: u64,
277 pub display_name: String,
278}
279
280#[derive(Debug, Serialize, Deserialize)]
281pub struct AssetMap {
282 pub assets: serde_json::Value,
283}