compass_api_sdk 0.9.13__py3-none-any.whl → 0.9.15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of compass_api_sdk might be problematic. Click here for more details.

Files changed (28) hide show
  1. compass_api_sdk/_version.py +3 -3
  2. compass_api_sdk/models/__init__.py +56 -0
  3. compass_api_sdk/models/aavelooprequest.py +113 -0
  4. compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_market_marketstate.py +33 -13
  5. compass_api_sdk/models/metadata.py +1 -7
  6. compass_api_sdk/models/multicallauthorizationrequest.py +39 -0
  7. compass_api_sdk/models/multicallauthorizationresponse.py +30 -0
  8. compass_api_sdk/models/multicallexecuterequest.py +36 -0
  9. compass_api_sdk/models/pendleaddliquidityparams.py +5 -0
  10. compass_api_sdk/models/pendleaddliquidityrequest.py +5 -0
  11. compass_api_sdk/models/pendlebuyptparams.py +5 -0
  12. compass_api_sdk/models/pendlebuyptrequest.py +5 -0
  13. compass_api_sdk/models/pendlebuyytparams.py +5 -0
  14. compass_api_sdk/models/pendlebuyytrequest.py +5 -0
  15. compass_api_sdk/models/pendleremoveliquidityparams.py +5 -0
  16. compass_api_sdk/models/pendleremoveliquidityrequest.py +5 -0
  17. compass_api_sdk/models/pendlesellptparams.py +5 -0
  18. compass_api_sdk/models/pendlesellptrequest.py +5 -0
  19. compass_api_sdk/models/pendlesellytparams.py +5 -0
  20. compass_api_sdk/models/pendlesellytrequest.py +5 -0
  21. compass_api_sdk/models/useroperation.py +18 -18
  22. compass_api_sdk/pendle.py +36 -0
  23. compass_api_sdk/sdk.py +6 -0
  24. compass_api_sdk/transaction_batching.py +765 -0
  25. compass_api_sdk/utils/forms.py +49 -28
  26. {compass_api_sdk-0.9.13.dist-info → compass_api_sdk-0.9.15.dist-info}/METADATA +7 -1
  27. {compass_api_sdk-0.9.13.dist-info → compass_api_sdk-0.9.15.dist-info}/RECORD +28 -23
  28. {compass_api_sdk-0.9.13.dist-info → compass_api_sdk-0.9.15.dist-info}/WHEEL +0 -0
@@ -0,0 +1,765 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from .basesdk import BaseSDK
4
+ from compass_api_sdk import errors, models, utils
5
+ from compass_api_sdk._hooks import HookContext
6
+ from compass_api_sdk.types import OptionalNullable, UNSET
7
+ from typing import Any, List, Mapping, Optional, Union
8
+
9
+
10
+ class TransactionBatching(BaseSDK):
11
+ def authorization(
12
+ self,
13
+ *,
14
+ chain: models.Chain,
15
+ sender: str,
16
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
17
+ server_url: Optional[str] = None,
18
+ timeout_ms: Optional[int] = None,
19
+ http_headers: Optional[Mapping[str, str]] = None,
20
+ ) -> models.MulticallAuthorizationResponse:
21
+ r"""Enable transaction bundling.
22
+
23
+ Get authorization for bundling transactions.
24
+
25
+ Currently this is required for every transaction bundle to prevent replay attacks
26
+ and ensure transaction ordering when batching multiple actions into a single
27
+ transaction. The authorization includes a nonce and chain ID to guarantee
28
+ transaction uniqueness and proper network targeting.
29
+
30
+ :param chain: The chain to use.
31
+ :param sender: The Ethereum address to use for authorization
32
+ :param retries: Override the default retry configuration for this method
33
+ :param server_url: Override the default server URL for this method
34
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
35
+ :param http_headers: Additional headers to set or replace on requests.
36
+ """
37
+ base_url = None
38
+ url_variables = None
39
+ if timeout_ms is None:
40
+ timeout_ms = self.sdk_configuration.timeout_ms
41
+
42
+ if server_url is not None:
43
+ base_url = server_url
44
+ else:
45
+ base_url = self._get_url(base_url, url_variables)
46
+
47
+ request = models.MulticallAuthorizationRequest(
48
+ chain=chain,
49
+ sender=sender,
50
+ )
51
+
52
+ req = self._build_request(
53
+ method="POST",
54
+ path="/v0/multicall/authorization",
55
+ base_url=base_url,
56
+ url_variables=url_variables,
57
+ request=request,
58
+ request_body_required=True,
59
+ request_has_path_params=False,
60
+ request_has_query_params=True,
61
+ user_agent_header="user-agent",
62
+ accept_header_value="application/json",
63
+ http_headers=http_headers,
64
+ security=self.sdk_configuration.security,
65
+ get_serialized_body=lambda: utils.serialize_request_body(
66
+ request, False, False, "json", models.MulticallAuthorizationRequest
67
+ ),
68
+ timeout_ms=timeout_ms,
69
+ )
70
+
71
+ if retries == UNSET:
72
+ if self.sdk_configuration.retry_config is not UNSET:
73
+ retries = self.sdk_configuration.retry_config
74
+
75
+ retry_config = None
76
+ if isinstance(retries, utils.RetryConfig):
77
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
78
+
79
+ http_res = self.do_request(
80
+ hook_ctx=HookContext(
81
+ config=self.sdk_configuration,
82
+ base_url=base_url or "",
83
+ operation_id="multicall_authorization",
84
+ oauth2_scopes=[],
85
+ security_source=self.sdk_configuration.security,
86
+ ),
87
+ request=req,
88
+ error_status_codes=["422", "4XX", "5XX"],
89
+ retry_config=retry_config,
90
+ )
91
+
92
+ response_data: Any = None
93
+ if utils.match_response(http_res, "200", "application/json"):
94
+ return utils.unmarshal_json(
95
+ http_res.text, models.MulticallAuthorizationResponse
96
+ )
97
+ if utils.match_response(http_res, "422", "application/json"):
98
+ response_data = utils.unmarshal_json(
99
+ http_res.text, errors.HTTPValidationErrorData
100
+ )
101
+ raise errors.HTTPValidationError(data=response_data)
102
+ if utils.match_response(http_res, "4XX", "*"):
103
+ http_res_text = utils.stream_to_text(http_res)
104
+ raise errors.APIError(
105
+ "API error occurred", http_res.status_code, http_res_text, http_res
106
+ )
107
+ if utils.match_response(http_res, "5XX", "*"):
108
+ http_res_text = utils.stream_to_text(http_res)
109
+ raise errors.APIError(
110
+ "API error occurred", http_res.status_code, http_res_text, http_res
111
+ )
112
+
113
+ content_type = http_res.headers.get("Content-Type")
114
+ http_res_text = utils.stream_to_text(http_res)
115
+ raise errors.APIError(
116
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
117
+ http_res.status_code,
118
+ http_res_text,
119
+ http_res,
120
+ )
121
+
122
+ async def authorization_async(
123
+ self,
124
+ *,
125
+ chain: models.Chain,
126
+ sender: str,
127
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
128
+ server_url: Optional[str] = None,
129
+ timeout_ms: Optional[int] = None,
130
+ http_headers: Optional[Mapping[str, str]] = None,
131
+ ) -> models.MulticallAuthorizationResponse:
132
+ r"""Enable transaction bundling.
133
+
134
+ Get authorization for bundling transactions.
135
+
136
+ Currently this is required for every transaction bundle to prevent replay attacks
137
+ and ensure transaction ordering when batching multiple actions into a single
138
+ transaction. The authorization includes a nonce and chain ID to guarantee
139
+ transaction uniqueness and proper network targeting.
140
+
141
+ :param chain: The chain to use.
142
+ :param sender: The Ethereum address to use for authorization
143
+ :param retries: Override the default retry configuration for this method
144
+ :param server_url: Override the default server URL for this method
145
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
146
+ :param http_headers: Additional headers to set or replace on requests.
147
+ """
148
+ base_url = None
149
+ url_variables = None
150
+ if timeout_ms is None:
151
+ timeout_ms = self.sdk_configuration.timeout_ms
152
+
153
+ if server_url is not None:
154
+ base_url = server_url
155
+ else:
156
+ base_url = self._get_url(base_url, url_variables)
157
+
158
+ request = models.MulticallAuthorizationRequest(
159
+ chain=chain,
160
+ sender=sender,
161
+ )
162
+
163
+ req = self._build_request_async(
164
+ method="POST",
165
+ path="/v0/multicall/authorization",
166
+ base_url=base_url,
167
+ url_variables=url_variables,
168
+ request=request,
169
+ request_body_required=True,
170
+ request_has_path_params=False,
171
+ request_has_query_params=True,
172
+ user_agent_header="user-agent",
173
+ accept_header_value="application/json",
174
+ http_headers=http_headers,
175
+ security=self.sdk_configuration.security,
176
+ get_serialized_body=lambda: utils.serialize_request_body(
177
+ request, False, False, "json", models.MulticallAuthorizationRequest
178
+ ),
179
+ timeout_ms=timeout_ms,
180
+ )
181
+
182
+ if retries == UNSET:
183
+ if self.sdk_configuration.retry_config is not UNSET:
184
+ retries = self.sdk_configuration.retry_config
185
+
186
+ retry_config = None
187
+ if isinstance(retries, utils.RetryConfig):
188
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
189
+
190
+ http_res = await self.do_request_async(
191
+ hook_ctx=HookContext(
192
+ config=self.sdk_configuration,
193
+ base_url=base_url or "",
194
+ operation_id="multicall_authorization",
195
+ oauth2_scopes=[],
196
+ security_source=self.sdk_configuration.security,
197
+ ),
198
+ request=req,
199
+ error_status_codes=["422", "4XX", "5XX"],
200
+ retry_config=retry_config,
201
+ )
202
+
203
+ response_data: Any = None
204
+ if utils.match_response(http_res, "200", "application/json"):
205
+ return utils.unmarshal_json(
206
+ http_res.text, models.MulticallAuthorizationResponse
207
+ )
208
+ if utils.match_response(http_res, "422", "application/json"):
209
+ response_data = utils.unmarshal_json(
210
+ http_res.text, errors.HTTPValidationErrorData
211
+ )
212
+ raise errors.HTTPValidationError(data=response_data)
213
+ if utils.match_response(http_res, "4XX", "*"):
214
+ http_res_text = await utils.stream_to_text_async(http_res)
215
+ raise errors.APIError(
216
+ "API error occurred", http_res.status_code, http_res_text, http_res
217
+ )
218
+ if utils.match_response(http_res, "5XX", "*"):
219
+ http_res_text = await utils.stream_to_text_async(http_res)
220
+ raise errors.APIError(
221
+ "API error occurred", http_res.status_code, http_res_text, http_res
222
+ )
223
+
224
+ content_type = http_res.headers.get("Content-Type")
225
+ http_res_text = await utils.stream_to_text_async(http_res)
226
+ raise errors.APIError(
227
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
228
+ http_res.status_code,
229
+ http_res_text,
230
+ http_res,
231
+ )
232
+
233
+ def execute(
234
+ self,
235
+ *,
236
+ chain: models.Chain,
237
+ sender: str,
238
+ signed_authorization: Union[
239
+ models.SignedAuthorization, models.SignedAuthorizationTypedDict
240
+ ],
241
+ actions: Union[List[models.UserOperation], List[models.UserOperationTypedDict]],
242
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
243
+ server_url: Optional[str] = None,
244
+ timeout_ms: Optional[int] = None,
245
+ http_headers: Optional[Mapping[str, str]] = None,
246
+ ) -> models.UnsignedMulticallTransaction:
247
+ r"""Construct Bundled Transaction
248
+
249
+ Bundle arbitrary transactions together into a single multicall transaction using
250
+ EIP-7702.
251
+
252
+ This endpoint allows bundling multiple contract calls into a single atomic
253
+ transaction, reducing gas costs and ensuring all operations succeed or fail
254
+ together. The transaction must be authorized using the /authorization endpoint to
255
+ prevent replay attacks.
256
+
257
+ :param chain: The chain to use.
258
+ :param sender: The address of the transaction sender.
259
+ :param signed_authorization:
260
+ :param actions: List of possible actions for multicall
261
+ :param retries: Override the default retry configuration for this method
262
+ :param server_url: Override the default server URL for this method
263
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
264
+ :param http_headers: Additional headers to set or replace on requests.
265
+ """
266
+ base_url = None
267
+ url_variables = None
268
+ if timeout_ms is None:
269
+ timeout_ms = self.sdk_configuration.timeout_ms
270
+
271
+ if server_url is not None:
272
+ base_url = server_url
273
+ else:
274
+ base_url = self._get_url(base_url, url_variables)
275
+
276
+ request = models.MulticallExecuteRequest(
277
+ chain=chain,
278
+ sender=sender,
279
+ signed_authorization=utils.get_pydantic_model(
280
+ signed_authorization, models.SignedAuthorization
281
+ ),
282
+ actions=utils.get_pydantic_model(actions, List[models.UserOperation]),
283
+ )
284
+
285
+ req = self._build_request(
286
+ method="POST",
287
+ path="/v0/multicall/execute",
288
+ base_url=base_url,
289
+ url_variables=url_variables,
290
+ request=request,
291
+ request_body_required=True,
292
+ request_has_path_params=False,
293
+ request_has_query_params=True,
294
+ user_agent_header="user-agent",
295
+ accept_header_value="application/json",
296
+ http_headers=http_headers,
297
+ security=self.sdk_configuration.security,
298
+ get_serialized_body=lambda: utils.serialize_request_body(
299
+ request, False, False, "json", models.MulticallExecuteRequest
300
+ ),
301
+ timeout_ms=timeout_ms,
302
+ )
303
+
304
+ if retries == UNSET:
305
+ if self.sdk_configuration.retry_config is not UNSET:
306
+ retries = self.sdk_configuration.retry_config
307
+
308
+ retry_config = None
309
+ if isinstance(retries, utils.RetryConfig):
310
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
311
+
312
+ http_res = self.do_request(
313
+ hook_ctx=HookContext(
314
+ config=self.sdk_configuration,
315
+ base_url=base_url or "",
316
+ operation_id="multicall_execute",
317
+ oauth2_scopes=[],
318
+ security_source=self.sdk_configuration.security,
319
+ ),
320
+ request=req,
321
+ error_status_codes=["422", "4XX", "5XX"],
322
+ retry_config=retry_config,
323
+ )
324
+
325
+ response_data: Any = None
326
+ if utils.match_response(http_res, "200", "application/json"):
327
+ return utils.unmarshal_json(
328
+ http_res.text, models.UnsignedMulticallTransaction
329
+ )
330
+ if utils.match_response(http_res, "422", "application/json"):
331
+ response_data = utils.unmarshal_json(
332
+ http_res.text, errors.HTTPValidationErrorData
333
+ )
334
+ raise errors.HTTPValidationError(data=response_data)
335
+ if utils.match_response(http_res, "4XX", "*"):
336
+ http_res_text = utils.stream_to_text(http_res)
337
+ raise errors.APIError(
338
+ "API error occurred", http_res.status_code, http_res_text, http_res
339
+ )
340
+ if utils.match_response(http_res, "5XX", "*"):
341
+ http_res_text = utils.stream_to_text(http_res)
342
+ raise errors.APIError(
343
+ "API error occurred", http_res.status_code, http_res_text, http_res
344
+ )
345
+
346
+ content_type = http_res.headers.get("Content-Type")
347
+ http_res_text = utils.stream_to_text(http_res)
348
+ raise errors.APIError(
349
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
350
+ http_res.status_code,
351
+ http_res_text,
352
+ http_res,
353
+ )
354
+
355
+ async def execute_async(
356
+ self,
357
+ *,
358
+ chain: models.Chain,
359
+ sender: str,
360
+ signed_authorization: Union[
361
+ models.SignedAuthorization, models.SignedAuthorizationTypedDict
362
+ ],
363
+ actions: Union[List[models.UserOperation], List[models.UserOperationTypedDict]],
364
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
365
+ server_url: Optional[str] = None,
366
+ timeout_ms: Optional[int] = None,
367
+ http_headers: Optional[Mapping[str, str]] = None,
368
+ ) -> models.UnsignedMulticallTransaction:
369
+ r"""Construct Bundled Transaction
370
+
371
+ Bundle arbitrary transactions together into a single multicall transaction using
372
+ EIP-7702.
373
+
374
+ This endpoint allows bundling multiple contract calls into a single atomic
375
+ transaction, reducing gas costs and ensuring all operations succeed or fail
376
+ together. The transaction must be authorized using the /authorization endpoint to
377
+ prevent replay attacks.
378
+
379
+ :param chain: The chain to use.
380
+ :param sender: The address of the transaction sender.
381
+ :param signed_authorization:
382
+ :param actions: List of possible actions for multicall
383
+ :param retries: Override the default retry configuration for this method
384
+ :param server_url: Override the default server URL for this method
385
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
386
+ :param http_headers: Additional headers to set or replace on requests.
387
+ """
388
+ base_url = None
389
+ url_variables = None
390
+ if timeout_ms is None:
391
+ timeout_ms = self.sdk_configuration.timeout_ms
392
+
393
+ if server_url is not None:
394
+ base_url = server_url
395
+ else:
396
+ base_url = self._get_url(base_url, url_variables)
397
+
398
+ request = models.MulticallExecuteRequest(
399
+ chain=chain,
400
+ sender=sender,
401
+ signed_authorization=utils.get_pydantic_model(
402
+ signed_authorization, models.SignedAuthorization
403
+ ),
404
+ actions=utils.get_pydantic_model(actions, List[models.UserOperation]),
405
+ )
406
+
407
+ req = self._build_request_async(
408
+ method="POST",
409
+ path="/v0/multicall/execute",
410
+ base_url=base_url,
411
+ url_variables=url_variables,
412
+ request=request,
413
+ request_body_required=True,
414
+ request_has_path_params=False,
415
+ request_has_query_params=True,
416
+ user_agent_header="user-agent",
417
+ accept_header_value="application/json",
418
+ http_headers=http_headers,
419
+ security=self.sdk_configuration.security,
420
+ get_serialized_body=lambda: utils.serialize_request_body(
421
+ request, False, False, "json", models.MulticallExecuteRequest
422
+ ),
423
+ timeout_ms=timeout_ms,
424
+ )
425
+
426
+ if retries == UNSET:
427
+ if self.sdk_configuration.retry_config is not UNSET:
428
+ retries = self.sdk_configuration.retry_config
429
+
430
+ retry_config = None
431
+ if isinstance(retries, utils.RetryConfig):
432
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
433
+
434
+ http_res = await self.do_request_async(
435
+ hook_ctx=HookContext(
436
+ config=self.sdk_configuration,
437
+ base_url=base_url or "",
438
+ operation_id="multicall_execute",
439
+ oauth2_scopes=[],
440
+ security_source=self.sdk_configuration.security,
441
+ ),
442
+ request=req,
443
+ error_status_codes=["422", "4XX", "5XX"],
444
+ retry_config=retry_config,
445
+ )
446
+
447
+ response_data: Any = None
448
+ if utils.match_response(http_res, "200", "application/json"):
449
+ return utils.unmarshal_json(
450
+ http_res.text, models.UnsignedMulticallTransaction
451
+ )
452
+ if utils.match_response(http_res, "422", "application/json"):
453
+ response_data = utils.unmarshal_json(
454
+ http_res.text, errors.HTTPValidationErrorData
455
+ )
456
+ raise errors.HTTPValidationError(data=response_data)
457
+ if utils.match_response(http_res, "4XX", "*"):
458
+ http_res_text = await utils.stream_to_text_async(http_res)
459
+ raise errors.APIError(
460
+ "API error occurred", http_res.status_code, http_res_text, http_res
461
+ )
462
+ if utils.match_response(http_res, "5XX", "*"):
463
+ http_res_text = await utils.stream_to_text_async(http_res)
464
+ raise errors.APIError(
465
+ "API error occurred", http_res.status_code, http_res_text, http_res
466
+ )
467
+
468
+ content_type = http_res.headers.get("Content-Type")
469
+ http_res_text = await utils.stream_to_text_async(http_res)
470
+ raise errors.APIError(
471
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
472
+ http_res.status_code,
473
+ http_res_text,
474
+ http_res,
475
+ )
476
+
477
+ def aave_loop(
478
+ self,
479
+ *,
480
+ chain: models.Chain,
481
+ sender: str,
482
+ signed_authorization: Union[
483
+ models.SignedAuthorization, models.SignedAuthorizationTypedDict
484
+ ],
485
+ collateral_token: models.TokenEnum,
486
+ borrow_token: models.TokenEnum,
487
+ initial_collateral_amount: Union[
488
+ models.InitialCollateralAmount, models.InitialCollateralAmountTypedDict
489
+ ],
490
+ multiplier: Union[models.Multiplier, models.MultiplierTypedDict],
491
+ max_slippage_percent: Union[
492
+ models.MaxSlippagePercent, models.MaxSlippagePercentTypedDict
493
+ ],
494
+ loan_to_value: Union[models.LoanToValue, models.LoanToValueTypedDict],
495
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
496
+ server_url: Optional[str] = None,
497
+ timeout_ms: Optional[int] = None,
498
+ http_headers: Optional[Mapping[str, str]] = None,
499
+ ) -> models.UnsignedMulticallTransaction:
500
+ r"""AAVE leverage long/short
501
+
502
+ Execute an Aave looping strategy that involves repeated supply and borrow
503
+ operations.
504
+
505
+ This endpoint creates a multicall transaction that performs a series of operations:
506
+ 1. Approves and supplies initial token
507
+ 2. For each loop:
508
+ - Borrows another token
509
+ - Swaps borrowed token back to supply token
510
+ - Supplies the swapped tokens
511
+
512
+ The transaction must be authorized using the /authorization endpoint to prevent replay attacks.
513
+
514
+ :param chain: The chain to use.
515
+ :param sender: The address of the transaction sender.
516
+ :param signed_authorization:
517
+ :param collateral_token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
518
+ :param borrow_token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
519
+ :param initial_collateral_amount: Amount of collateral token to supply to Aave
520
+ :param multiplier: Total loop collateral will be calculated as `multiplier` x `initial_collateral_amount`
521
+ :param max_slippage_percent: Maximum allowed slippage for token swaps in percentage
522
+ :param loan_to_value: Loan To Value percentage of the loop
523
+ :param retries: Override the default retry configuration for this method
524
+ :param server_url: Override the default server URL for this method
525
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
526
+ :param http_headers: Additional headers to set or replace on requests.
527
+ """
528
+ base_url = None
529
+ url_variables = None
530
+ if timeout_ms is None:
531
+ timeout_ms = self.sdk_configuration.timeout_ms
532
+
533
+ if server_url is not None:
534
+ base_url = server_url
535
+ else:
536
+ base_url = self._get_url(base_url, url_variables)
537
+
538
+ request = models.AaveLoopRequest(
539
+ chain=chain,
540
+ sender=sender,
541
+ signed_authorization=utils.get_pydantic_model(
542
+ signed_authorization, models.SignedAuthorization
543
+ ),
544
+ collateral_token=collateral_token,
545
+ borrow_token=borrow_token,
546
+ initial_collateral_amount=initial_collateral_amount,
547
+ multiplier=multiplier,
548
+ max_slippage_percent=max_slippage_percent,
549
+ loan_to_value=loan_to_value,
550
+ )
551
+
552
+ req = self._build_request(
553
+ method="POST",
554
+ path="/v0/multicall/aave/loop",
555
+ base_url=base_url,
556
+ url_variables=url_variables,
557
+ request=request,
558
+ request_body_required=True,
559
+ request_has_path_params=False,
560
+ request_has_query_params=True,
561
+ user_agent_header="user-agent",
562
+ accept_header_value="application/json",
563
+ http_headers=http_headers,
564
+ security=self.sdk_configuration.security,
565
+ get_serialized_body=lambda: utils.serialize_request_body(
566
+ request, False, False, "json", models.AaveLoopRequest
567
+ ),
568
+ timeout_ms=timeout_ms,
569
+ )
570
+
571
+ if retries == UNSET:
572
+ if self.sdk_configuration.retry_config is not UNSET:
573
+ retries = self.sdk_configuration.retry_config
574
+
575
+ retry_config = None
576
+ if isinstance(retries, utils.RetryConfig):
577
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
578
+
579
+ http_res = self.do_request(
580
+ hook_ctx=HookContext(
581
+ config=self.sdk_configuration,
582
+ base_url=base_url or "",
583
+ operation_id="multicall_aave_loop",
584
+ oauth2_scopes=[],
585
+ security_source=self.sdk_configuration.security,
586
+ ),
587
+ request=req,
588
+ error_status_codes=["422", "4XX", "5XX"],
589
+ retry_config=retry_config,
590
+ )
591
+
592
+ response_data: Any = None
593
+ if utils.match_response(http_res, "200", "application/json"):
594
+ return utils.unmarshal_json(
595
+ http_res.text, models.UnsignedMulticallTransaction
596
+ )
597
+ if utils.match_response(http_res, "422", "application/json"):
598
+ response_data = utils.unmarshal_json(
599
+ http_res.text, errors.HTTPValidationErrorData
600
+ )
601
+ raise errors.HTTPValidationError(data=response_data)
602
+ if utils.match_response(http_res, "4XX", "*"):
603
+ http_res_text = utils.stream_to_text(http_res)
604
+ raise errors.APIError(
605
+ "API error occurred", http_res.status_code, http_res_text, http_res
606
+ )
607
+ if utils.match_response(http_res, "5XX", "*"):
608
+ http_res_text = utils.stream_to_text(http_res)
609
+ raise errors.APIError(
610
+ "API error occurred", http_res.status_code, http_res_text, http_res
611
+ )
612
+
613
+ content_type = http_res.headers.get("Content-Type")
614
+ http_res_text = utils.stream_to_text(http_res)
615
+ raise errors.APIError(
616
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
617
+ http_res.status_code,
618
+ http_res_text,
619
+ http_res,
620
+ )
621
+
622
+ async def aave_loop_async(
623
+ self,
624
+ *,
625
+ chain: models.Chain,
626
+ sender: str,
627
+ signed_authorization: Union[
628
+ models.SignedAuthorization, models.SignedAuthorizationTypedDict
629
+ ],
630
+ collateral_token: models.TokenEnum,
631
+ borrow_token: models.TokenEnum,
632
+ initial_collateral_amount: Union[
633
+ models.InitialCollateralAmount, models.InitialCollateralAmountTypedDict
634
+ ],
635
+ multiplier: Union[models.Multiplier, models.MultiplierTypedDict],
636
+ max_slippage_percent: Union[
637
+ models.MaxSlippagePercent, models.MaxSlippagePercentTypedDict
638
+ ],
639
+ loan_to_value: Union[models.LoanToValue, models.LoanToValueTypedDict],
640
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
641
+ server_url: Optional[str] = None,
642
+ timeout_ms: Optional[int] = None,
643
+ http_headers: Optional[Mapping[str, str]] = None,
644
+ ) -> models.UnsignedMulticallTransaction:
645
+ r"""AAVE leverage long/short
646
+
647
+ Execute an Aave looping strategy that involves repeated supply and borrow
648
+ operations.
649
+
650
+ This endpoint creates a multicall transaction that performs a series of operations:
651
+ 1. Approves and supplies initial token
652
+ 2. For each loop:
653
+ - Borrows another token
654
+ - Swaps borrowed token back to supply token
655
+ - Supplies the swapped tokens
656
+
657
+ The transaction must be authorized using the /authorization endpoint to prevent replay attacks.
658
+
659
+ :param chain: The chain to use.
660
+ :param sender: The address of the transaction sender.
661
+ :param signed_authorization:
662
+ :param collateral_token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
663
+ :param borrow_token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
664
+ :param initial_collateral_amount: Amount of collateral token to supply to Aave
665
+ :param multiplier: Total loop collateral will be calculated as `multiplier` x `initial_collateral_amount`
666
+ :param max_slippage_percent: Maximum allowed slippage for token swaps in percentage
667
+ :param loan_to_value: Loan To Value percentage of the loop
668
+ :param retries: Override the default retry configuration for this method
669
+ :param server_url: Override the default server URL for this method
670
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
671
+ :param http_headers: Additional headers to set or replace on requests.
672
+ """
673
+ base_url = None
674
+ url_variables = None
675
+ if timeout_ms is None:
676
+ timeout_ms = self.sdk_configuration.timeout_ms
677
+
678
+ if server_url is not None:
679
+ base_url = server_url
680
+ else:
681
+ base_url = self._get_url(base_url, url_variables)
682
+
683
+ request = models.AaveLoopRequest(
684
+ chain=chain,
685
+ sender=sender,
686
+ signed_authorization=utils.get_pydantic_model(
687
+ signed_authorization, models.SignedAuthorization
688
+ ),
689
+ collateral_token=collateral_token,
690
+ borrow_token=borrow_token,
691
+ initial_collateral_amount=initial_collateral_amount,
692
+ multiplier=multiplier,
693
+ max_slippage_percent=max_slippage_percent,
694
+ loan_to_value=loan_to_value,
695
+ )
696
+
697
+ req = self._build_request_async(
698
+ method="POST",
699
+ path="/v0/multicall/aave/loop",
700
+ base_url=base_url,
701
+ url_variables=url_variables,
702
+ request=request,
703
+ request_body_required=True,
704
+ request_has_path_params=False,
705
+ request_has_query_params=True,
706
+ user_agent_header="user-agent",
707
+ accept_header_value="application/json",
708
+ http_headers=http_headers,
709
+ security=self.sdk_configuration.security,
710
+ get_serialized_body=lambda: utils.serialize_request_body(
711
+ request, False, False, "json", models.AaveLoopRequest
712
+ ),
713
+ timeout_ms=timeout_ms,
714
+ )
715
+
716
+ if retries == UNSET:
717
+ if self.sdk_configuration.retry_config is not UNSET:
718
+ retries = self.sdk_configuration.retry_config
719
+
720
+ retry_config = None
721
+ if isinstance(retries, utils.RetryConfig):
722
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
723
+
724
+ http_res = await self.do_request_async(
725
+ hook_ctx=HookContext(
726
+ config=self.sdk_configuration,
727
+ base_url=base_url or "",
728
+ operation_id="multicall_aave_loop",
729
+ oauth2_scopes=[],
730
+ security_source=self.sdk_configuration.security,
731
+ ),
732
+ request=req,
733
+ error_status_codes=["422", "4XX", "5XX"],
734
+ retry_config=retry_config,
735
+ )
736
+
737
+ response_data: Any = None
738
+ if utils.match_response(http_res, "200", "application/json"):
739
+ return utils.unmarshal_json(
740
+ http_res.text, models.UnsignedMulticallTransaction
741
+ )
742
+ if utils.match_response(http_res, "422", "application/json"):
743
+ response_data = utils.unmarshal_json(
744
+ http_res.text, errors.HTTPValidationErrorData
745
+ )
746
+ raise errors.HTTPValidationError(data=response_data)
747
+ if utils.match_response(http_res, "4XX", "*"):
748
+ http_res_text = await utils.stream_to_text_async(http_res)
749
+ raise errors.APIError(
750
+ "API error occurred", http_res.status_code, http_res_text, http_res
751
+ )
752
+ if utils.match_response(http_res, "5XX", "*"):
753
+ http_res_text = await utils.stream_to_text_async(http_res)
754
+ raise errors.APIError(
755
+ "API error occurred", http_res.status_code, http_res_text, http_res
756
+ )
757
+
758
+ content_type = http_res.headers.get("Content-Type")
759
+ http_res_text = await utils.stream_to_text_async(http_res)
760
+ raise errors.APIError(
761
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
762
+ http_res.status_code,
763
+ http_res_text,
764
+ http_res,
765
+ )