compass_api_sdk 0.1.4__py3-none-any.whl → 0.1.6__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.
- {compass_api_sdk-0.1.4.dist-info → compass_api_sdk-0.1.6.dist-info}/METADATA +10 -2
- {compass_api_sdk-0.1.4.dist-info → compass_api_sdk-0.1.6.dist-info}/RECORD +42 -35
- compassapisdk/_version.py +2 -2
- compassapisdk/models/__init__.py +46 -0
- compassapisdk/models/aave_liquidity_changeop.py +0 -3
- compassapisdk/models/aave_token_priceop.py +0 -3
- compassapisdk/models/aave_user_position_per_tokenop.py +0 -3
- compassapisdk/models/aave_user_position_summaryop.py +0 -3
- compassapisdk/models/aerodrome_slipstream_liquidity_provision_positionsop.py +0 -3
- compassapisdk/models/aerodrome_slipstream_pool_priceop.py +0 -3
- compassapisdk/models/chain.py +0 -3
- compassapisdk/models/contractname.py +3 -0
- compassapisdk/models/generic_allowanceop.py +3 -3
- compassapisdk/models/generic_ensop.py +0 -3
- compassapisdk/models/generic_portfolioop.py +0 -3
- compassapisdk/models/generic_supported_tokensop.py +0 -3
- compassapisdk/models/generic_visualize_portfolioop.py +0 -3
- compassapisdk/models/increaseallowanceparams.py +3 -0
- compassapisdk/models/increaseallowancerequest.py +3 -0
- compassapisdk/models/morpho_market_positionop.py +0 -3
- compassapisdk/models/morpho_marketsop.py +0 -3
- compassapisdk/models/morpho_vault_positionop.py +0 -3
- compassapisdk/models/morpho_vaultsop.py +0 -3
- compassapisdk/models/multicallactiontype.py +19 -19
- compassapisdk/models/sky_positionop.py +29 -0
- compassapisdk/models/skybuyrequest.py +56 -0
- compassapisdk/models/skycheckpositionresponse.py +18 -0
- compassapisdk/models/skydepositrequest.py +85 -0
- compassapisdk/models/skysellrequest.py +56 -0
- compassapisdk/models/skywithdrawrequest.py +75 -0
- compassapisdk/models/token_addressop.py +0 -3
- compassapisdk/models/token_balanceop.py +0 -3
- compassapisdk/models/token_priceop.py +0 -3
- compassapisdk/models/uniswap_liquidity_provision_in_rangeop.py +0 -3
- compassapisdk/models/uniswap_liquidity_provision_positionsop.py +0 -3
- compassapisdk/models/uniswap_pool_priceop.py +0 -3
- compassapisdk/models/uniswap_quote_buy_exactlyop.py +0 -3
- compassapisdk/models/uniswap_quote_sell_exactlyop.py +0 -3
- compassapisdk/sdk.py +3 -0
- compassapisdk/sdkconfiguration.py +2 -2
- compassapisdk/sky.py +1075 -0
- {compass_api_sdk-0.1.4.dist-info → compass_api_sdk-0.1.6.dist-info}/WHEEL +0 -0
compassapisdk/sky.py
ADDED
|
@@ -0,0 +1,1075 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from compassapisdk import errors, models, utils
|
|
5
|
+
from compassapisdk._hooks import HookContext
|
|
6
|
+
from compassapisdk.types import OptionalNullable, UNSET
|
|
7
|
+
from typing import Any, Mapping, Optional, Union
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Sky(BaseSDK):
|
|
11
|
+
def position(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
user_address: str = "0xa829B388A3DF7f581cE957a95edbe419dd146d1B",
|
|
15
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
16
|
+
server_url: Optional[str] = None,
|
|
17
|
+
timeout_ms: Optional[int] = None,
|
|
18
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
19
|
+
) -> models.SkyCheckPositionResponse:
|
|
20
|
+
r"""Check USDS Position
|
|
21
|
+
|
|
22
|
+
Check the USDS overall position.
|
|
23
|
+
|
|
24
|
+
:param user_address:
|
|
25
|
+
:param retries: Override the default retry configuration for this method
|
|
26
|
+
:param server_url: Override the default server URL for this method
|
|
27
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
28
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
29
|
+
"""
|
|
30
|
+
base_url = None
|
|
31
|
+
url_variables = None
|
|
32
|
+
if timeout_ms is None:
|
|
33
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
34
|
+
|
|
35
|
+
if server_url is not None:
|
|
36
|
+
base_url = server_url
|
|
37
|
+
else:
|
|
38
|
+
base_url = self._get_url(base_url, url_variables)
|
|
39
|
+
|
|
40
|
+
request = models.SkyPositionRequest(
|
|
41
|
+
user_address=user_address,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
req = self._build_request(
|
|
45
|
+
method="GET",
|
|
46
|
+
path="/v0/sky/position",
|
|
47
|
+
base_url=base_url,
|
|
48
|
+
url_variables=url_variables,
|
|
49
|
+
request=request,
|
|
50
|
+
request_body_required=False,
|
|
51
|
+
request_has_path_params=False,
|
|
52
|
+
request_has_query_params=True,
|
|
53
|
+
user_agent_header="user-agent",
|
|
54
|
+
accept_header_value="application/json",
|
|
55
|
+
http_headers=http_headers,
|
|
56
|
+
security=self.sdk_configuration.security,
|
|
57
|
+
timeout_ms=timeout_ms,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if retries == UNSET:
|
|
61
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
62
|
+
retries = self.sdk_configuration.retry_config
|
|
63
|
+
|
|
64
|
+
retry_config = None
|
|
65
|
+
if isinstance(retries, utils.RetryConfig):
|
|
66
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
67
|
+
|
|
68
|
+
http_res = self.do_request(
|
|
69
|
+
hook_ctx=HookContext(
|
|
70
|
+
base_url=base_url or "",
|
|
71
|
+
operation_id="sky_position",
|
|
72
|
+
oauth2_scopes=[],
|
|
73
|
+
security_source=self.sdk_configuration.security,
|
|
74
|
+
),
|
|
75
|
+
request=req,
|
|
76
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
77
|
+
retry_config=retry_config,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
response_data: Any = None
|
|
81
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
82
|
+
return utils.unmarshal_json(http_res.text, models.SkyCheckPositionResponse)
|
|
83
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
84
|
+
response_data = utils.unmarshal_json(
|
|
85
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
86
|
+
)
|
|
87
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
88
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
89
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
90
|
+
raise errors.APIError(
|
|
91
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
92
|
+
)
|
|
93
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
94
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
95
|
+
raise errors.APIError(
|
|
96
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
content_type = http_res.headers.get("Content-Type")
|
|
100
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
101
|
+
raise errors.APIError(
|
|
102
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
103
|
+
http_res.status_code,
|
|
104
|
+
http_res_text,
|
|
105
|
+
http_res,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
async def position_async(
|
|
109
|
+
self,
|
|
110
|
+
*,
|
|
111
|
+
user_address: str = "0xa829B388A3DF7f581cE957a95edbe419dd146d1B",
|
|
112
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
113
|
+
server_url: Optional[str] = None,
|
|
114
|
+
timeout_ms: Optional[int] = None,
|
|
115
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
116
|
+
) -> models.SkyCheckPositionResponse:
|
|
117
|
+
r"""Check USDS Position
|
|
118
|
+
|
|
119
|
+
Check the USDS overall position.
|
|
120
|
+
|
|
121
|
+
:param user_address:
|
|
122
|
+
:param retries: Override the default retry configuration for this method
|
|
123
|
+
:param server_url: Override the default server URL for this method
|
|
124
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
125
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
126
|
+
"""
|
|
127
|
+
base_url = None
|
|
128
|
+
url_variables = None
|
|
129
|
+
if timeout_ms is None:
|
|
130
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
131
|
+
|
|
132
|
+
if server_url is not None:
|
|
133
|
+
base_url = server_url
|
|
134
|
+
else:
|
|
135
|
+
base_url = self._get_url(base_url, url_variables)
|
|
136
|
+
|
|
137
|
+
request = models.SkyPositionRequest(
|
|
138
|
+
user_address=user_address,
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
req = self._build_request_async(
|
|
142
|
+
method="GET",
|
|
143
|
+
path="/v0/sky/position",
|
|
144
|
+
base_url=base_url,
|
|
145
|
+
url_variables=url_variables,
|
|
146
|
+
request=request,
|
|
147
|
+
request_body_required=False,
|
|
148
|
+
request_has_path_params=False,
|
|
149
|
+
request_has_query_params=True,
|
|
150
|
+
user_agent_header="user-agent",
|
|
151
|
+
accept_header_value="application/json",
|
|
152
|
+
http_headers=http_headers,
|
|
153
|
+
security=self.sdk_configuration.security,
|
|
154
|
+
timeout_ms=timeout_ms,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
if retries == UNSET:
|
|
158
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
159
|
+
retries = self.sdk_configuration.retry_config
|
|
160
|
+
|
|
161
|
+
retry_config = None
|
|
162
|
+
if isinstance(retries, utils.RetryConfig):
|
|
163
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
164
|
+
|
|
165
|
+
http_res = await self.do_request_async(
|
|
166
|
+
hook_ctx=HookContext(
|
|
167
|
+
base_url=base_url or "",
|
|
168
|
+
operation_id="sky_position",
|
|
169
|
+
oauth2_scopes=[],
|
|
170
|
+
security_source=self.sdk_configuration.security,
|
|
171
|
+
),
|
|
172
|
+
request=req,
|
|
173
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
174
|
+
retry_config=retry_config,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
response_data: Any = None
|
|
178
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
179
|
+
return utils.unmarshal_json(http_res.text, models.SkyCheckPositionResponse)
|
|
180
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
181
|
+
response_data = utils.unmarshal_json(
|
|
182
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
183
|
+
)
|
|
184
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
185
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
186
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
187
|
+
raise errors.APIError(
|
|
188
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
189
|
+
)
|
|
190
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
191
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
192
|
+
raise errors.APIError(
|
|
193
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
content_type = http_res.headers.get("Content-Type")
|
|
197
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
198
|
+
raise errors.APIError(
|
|
199
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
200
|
+
http_res.status_code,
|
|
201
|
+
http_res_text,
|
|
202
|
+
http_res,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
def buy(
|
|
206
|
+
self,
|
|
207
|
+
*,
|
|
208
|
+
token_in: models.TokenIn,
|
|
209
|
+
amount: Union[models.SkyBuyRequestAmount, models.SkyBuyRequestAmountTypedDict],
|
|
210
|
+
sender: str,
|
|
211
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
212
|
+
server_url: Optional[str] = None,
|
|
213
|
+
timeout_ms: Optional[int] = None,
|
|
214
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
215
|
+
) -> models.UnsignedTransaction:
|
|
216
|
+
r"""Buy USDS
|
|
217
|
+
|
|
218
|
+
Buy USDS with DAI or USDC on a 1:1 basis.
|
|
219
|
+
|
|
220
|
+
There are no fees.
|
|
221
|
+
|
|
222
|
+
:param token_in: The token you would like to swap 1:1 for USDS. Choose from DAI or USDC.
|
|
223
|
+
:param amount: The amount of USDS you would like to buy 1:1 with 'token_in'.
|
|
224
|
+
:param sender: The address of the transaction sender.
|
|
225
|
+
:param retries: Override the default retry configuration for this method
|
|
226
|
+
:param server_url: Override the default server URL for this method
|
|
227
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
228
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
229
|
+
"""
|
|
230
|
+
base_url = None
|
|
231
|
+
url_variables = None
|
|
232
|
+
if timeout_ms is None:
|
|
233
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
234
|
+
|
|
235
|
+
if server_url is not None:
|
|
236
|
+
base_url = server_url
|
|
237
|
+
else:
|
|
238
|
+
base_url = self._get_url(base_url, url_variables)
|
|
239
|
+
|
|
240
|
+
request = models.SkyBuyRequest(
|
|
241
|
+
token_in=token_in,
|
|
242
|
+
amount=amount,
|
|
243
|
+
sender=sender,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
req = self._build_request(
|
|
247
|
+
method="POST",
|
|
248
|
+
path="/v0/sky/buy",
|
|
249
|
+
base_url=base_url,
|
|
250
|
+
url_variables=url_variables,
|
|
251
|
+
request=request,
|
|
252
|
+
request_body_required=True,
|
|
253
|
+
request_has_path_params=False,
|
|
254
|
+
request_has_query_params=True,
|
|
255
|
+
user_agent_header="user-agent",
|
|
256
|
+
accept_header_value="application/json",
|
|
257
|
+
http_headers=http_headers,
|
|
258
|
+
security=self.sdk_configuration.security,
|
|
259
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
260
|
+
request, False, False, "json", models.SkyBuyRequest
|
|
261
|
+
),
|
|
262
|
+
timeout_ms=timeout_ms,
|
|
263
|
+
)
|
|
264
|
+
|
|
265
|
+
if retries == UNSET:
|
|
266
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
267
|
+
retries = self.sdk_configuration.retry_config
|
|
268
|
+
|
|
269
|
+
retry_config = None
|
|
270
|
+
if isinstance(retries, utils.RetryConfig):
|
|
271
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
272
|
+
|
|
273
|
+
http_res = self.do_request(
|
|
274
|
+
hook_ctx=HookContext(
|
|
275
|
+
base_url=base_url or "",
|
|
276
|
+
operation_id="sky_buy",
|
|
277
|
+
oauth2_scopes=[],
|
|
278
|
+
security_source=self.sdk_configuration.security,
|
|
279
|
+
),
|
|
280
|
+
request=req,
|
|
281
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
282
|
+
retry_config=retry_config,
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
response_data: Any = None
|
|
286
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
287
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
288
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
289
|
+
response_data = utils.unmarshal_json(
|
|
290
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
291
|
+
)
|
|
292
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
293
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
294
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
295
|
+
raise errors.APIError(
|
|
296
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
297
|
+
)
|
|
298
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
299
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
300
|
+
raise errors.APIError(
|
|
301
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
content_type = http_res.headers.get("Content-Type")
|
|
305
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
306
|
+
raise errors.APIError(
|
|
307
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
308
|
+
http_res.status_code,
|
|
309
|
+
http_res_text,
|
|
310
|
+
http_res,
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
async def buy_async(
|
|
314
|
+
self,
|
|
315
|
+
*,
|
|
316
|
+
token_in: models.TokenIn,
|
|
317
|
+
amount: Union[models.SkyBuyRequestAmount, models.SkyBuyRequestAmountTypedDict],
|
|
318
|
+
sender: str,
|
|
319
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
320
|
+
server_url: Optional[str] = None,
|
|
321
|
+
timeout_ms: Optional[int] = None,
|
|
322
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
323
|
+
) -> models.UnsignedTransaction:
|
|
324
|
+
r"""Buy USDS
|
|
325
|
+
|
|
326
|
+
Buy USDS with DAI or USDC on a 1:1 basis.
|
|
327
|
+
|
|
328
|
+
There are no fees.
|
|
329
|
+
|
|
330
|
+
:param token_in: The token you would like to swap 1:1 for USDS. Choose from DAI or USDC.
|
|
331
|
+
:param amount: The amount of USDS you would like to buy 1:1 with 'token_in'.
|
|
332
|
+
:param sender: The address of the transaction sender.
|
|
333
|
+
:param retries: Override the default retry configuration for this method
|
|
334
|
+
:param server_url: Override the default server URL for this method
|
|
335
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
336
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
337
|
+
"""
|
|
338
|
+
base_url = None
|
|
339
|
+
url_variables = None
|
|
340
|
+
if timeout_ms is None:
|
|
341
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
342
|
+
|
|
343
|
+
if server_url is not None:
|
|
344
|
+
base_url = server_url
|
|
345
|
+
else:
|
|
346
|
+
base_url = self._get_url(base_url, url_variables)
|
|
347
|
+
|
|
348
|
+
request = models.SkyBuyRequest(
|
|
349
|
+
token_in=token_in,
|
|
350
|
+
amount=amount,
|
|
351
|
+
sender=sender,
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
req = self._build_request_async(
|
|
355
|
+
method="POST",
|
|
356
|
+
path="/v0/sky/buy",
|
|
357
|
+
base_url=base_url,
|
|
358
|
+
url_variables=url_variables,
|
|
359
|
+
request=request,
|
|
360
|
+
request_body_required=True,
|
|
361
|
+
request_has_path_params=False,
|
|
362
|
+
request_has_query_params=True,
|
|
363
|
+
user_agent_header="user-agent",
|
|
364
|
+
accept_header_value="application/json",
|
|
365
|
+
http_headers=http_headers,
|
|
366
|
+
security=self.sdk_configuration.security,
|
|
367
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
368
|
+
request, False, False, "json", models.SkyBuyRequest
|
|
369
|
+
),
|
|
370
|
+
timeout_ms=timeout_ms,
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
if retries == UNSET:
|
|
374
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
375
|
+
retries = self.sdk_configuration.retry_config
|
|
376
|
+
|
|
377
|
+
retry_config = None
|
|
378
|
+
if isinstance(retries, utils.RetryConfig):
|
|
379
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
380
|
+
|
|
381
|
+
http_res = await self.do_request_async(
|
|
382
|
+
hook_ctx=HookContext(
|
|
383
|
+
base_url=base_url or "",
|
|
384
|
+
operation_id="sky_buy",
|
|
385
|
+
oauth2_scopes=[],
|
|
386
|
+
security_source=self.sdk_configuration.security,
|
|
387
|
+
),
|
|
388
|
+
request=req,
|
|
389
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
390
|
+
retry_config=retry_config,
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
response_data: Any = None
|
|
394
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
395
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
396
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
397
|
+
response_data = utils.unmarshal_json(
|
|
398
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
399
|
+
)
|
|
400
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
401
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
402
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
403
|
+
raise errors.APIError(
|
|
404
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
405
|
+
)
|
|
406
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
407
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
408
|
+
raise errors.APIError(
|
|
409
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
content_type = http_res.headers.get("Content-Type")
|
|
413
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
414
|
+
raise errors.APIError(
|
|
415
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
416
|
+
http_res.status_code,
|
|
417
|
+
http_res_text,
|
|
418
|
+
http_res,
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
def sell(
|
|
422
|
+
self,
|
|
423
|
+
*,
|
|
424
|
+
token_out: models.TokenOut,
|
|
425
|
+
amount: Union[
|
|
426
|
+
models.SkySellRequestAmount, models.SkySellRequestAmountTypedDict
|
|
427
|
+
],
|
|
428
|
+
sender: str,
|
|
429
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
430
|
+
server_url: Optional[str] = None,
|
|
431
|
+
timeout_ms: Optional[int] = None,
|
|
432
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
433
|
+
) -> models.UnsignedTransaction:
|
|
434
|
+
r"""Sell USDS
|
|
435
|
+
|
|
436
|
+
Sell USDS for DAI or USDC on a 1:1 basis.
|
|
437
|
+
|
|
438
|
+
There are no fees.
|
|
439
|
+
|
|
440
|
+
:param token_out: The token you would like to swap 1:1 with USDS. Choose from DAI or USDC.
|
|
441
|
+
:param amount: The amount of USDS you would like to sell 1:1 for 'token_out'.
|
|
442
|
+
:param sender: The address of the transaction sender.
|
|
443
|
+
:param retries: Override the default retry configuration for this method
|
|
444
|
+
:param server_url: Override the default server URL for this method
|
|
445
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
446
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
447
|
+
"""
|
|
448
|
+
base_url = None
|
|
449
|
+
url_variables = None
|
|
450
|
+
if timeout_ms is None:
|
|
451
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
452
|
+
|
|
453
|
+
if server_url is not None:
|
|
454
|
+
base_url = server_url
|
|
455
|
+
else:
|
|
456
|
+
base_url = self._get_url(base_url, url_variables)
|
|
457
|
+
|
|
458
|
+
request = models.SkySellRequest(
|
|
459
|
+
token_out=token_out,
|
|
460
|
+
amount=amount,
|
|
461
|
+
sender=sender,
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
req = self._build_request(
|
|
465
|
+
method="POST",
|
|
466
|
+
path="/v0/sky/sell",
|
|
467
|
+
base_url=base_url,
|
|
468
|
+
url_variables=url_variables,
|
|
469
|
+
request=request,
|
|
470
|
+
request_body_required=True,
|
|
471
|
+
request_has_path_params=False,
|
|
472
|
+
request_has_query_params=True,
|
|
473
|
+
user_agent_header="user-agent",
|
|
474
|
+
accept_header_value="application/json",
|
|
475
|
+
http_headers=http_headers,
|
|
476
|
+
security=self.sdk_configuration.security,
|
|
477
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
478
|
+
request, False, False, "json", models.SkySellRequest
|
|
479
|
+
),
|
|
480
|
+
timeout_ms=timeout_ms,
|
|
481
|
+
)
|
|
482
|
+
|
|
483
|
+
if retries == UNSET:
|
|
484
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
485
|
+
retries = self.sdk_configuration.retry_config
|
|
486
|
+
|
|
487
|
+
retry_config = None
|
|
488
|
+
if isinstance(retries, utils.RetryConfig):
|
|
489
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
490
|
+
|
|
491
|
+
http_res = self.do_request(
|
|
492
|
+
hook_ctx=HookContext(
|
|
493
|
+
base_url=base_url or "",
|
|
494
|
+
operation_id="sky_sell",
|
|
495
|
+
oauth2_scopes=[],
|
|
496
|
+
security_source=self.sdk_configuration.security,
|
|
497
|
+
),
|
|
498
|
+
request=req,
|
|
499
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
500
|
+
retry_config=retry_config,
|
|
501
|
+
)
|
|
502
|
+
|
|
503
|
+
response_data: Any = None
|
|
504
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
505
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
506
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
507
|
+
response_data = utils.unmarshal_json(
|
|
508
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
509
|
+
)
|
|
510
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
511
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
512
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
513
|
+
raise errors.APIError(
|
|
514
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
515
|
+
)
|
|
516
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
517
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
518
|
+
raise errors.APIError(
|
|
519
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
content_type = http_res.headers.get("Content-Type")
|
|
523
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
524
|
+
raise errors.APIError(
|
|
525
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
526
|
+
http_res.status_code,
|
|
527
|
+
http_res_text,
|
|
528
|
+
http_res,
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
async def sell_async(
|
|
532
|
+
self,
|
|
533
|
+
*,
|
|
534
|
+
token_out: models.TokenOut,
|
|
535
|
+
amount: Union[
|
|
536
|
+
models.SkySellRequestAmount, models.SkySellRequestAmountTypedDict
|
|
537
|
+
],
|
|
538
|
+
sender: str,
|
|
539
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
540
|
+
server_url: Optional[str] = None,
|
|
541
|
+
timeout_ms: Optional[int] = None,
|
|
542
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
543
|
+
) -> models.UnsignedTransaction:
|
|
544
|
+
r"""Sell USDS
|
|
545
|
+
|
|
546
|
+
Sell USDS for DAI or USDC on a 1:1 basis.
|
|
547
|
+
|
|
548
|
+
There are no fees.
|
|
549
|
+
|
|
550
|
+
:param token_out: The token you would like to swap 1:1 with USDS. Choose from DAI or USDC.
|
|
551
|
+
:param amount: The amount of USDS you would like to sell 1:1 for 'token_out'.
|
|
552
|
+
:param sender: The address of the transaction sender.
|
|
553
|
+
:param retries: Override the default retry configuration for this method
|
|
554
|
+
:param server_url: Override the default server URL for this method
|
|
555
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
556
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
557
|
+
"""
|
|
558
|
+
base_url = None
|
|
559
|
+
url_variables = None
|
|
560
|
+
if timeout_ms is None:
|
|
561
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
562
|
+
|
|
563
|
+
if server_url is not None:
|
|
564
|
+
base_url = server_url
|
|
565
|
+
else:
|
|
566
|
+
base_url = self._get_url(base_url, url_variables)
|
|
567
|
+
|
|
568
|
+
request = models.SkySellRequest(
|
|
569
|
+
token_out=token_out,
|
|
570
|
+
amount=amount,
|
|
571
|
+
sender=sender,
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
req = self._build_request_async(
|
|
575
|
+
method="POST",
|
|
576
|
+
path="/v0/sky/sell",
|
|
577
|
+
base_url=base_url,
|
|
578
|
+
url_variables=url_variables,
|
|
579
|
+
request=request,
|
|
580
|
+
request_body_required=True,
|
|
581
|
+
request_has_path_params=False,
|
|
582
|
+
request_has_query_params=True,
|
|
583
|
+
user_agent_header="user-agent",
|
|
584
|
+
accept_header_value="application/json",
|
|
585
|
+
http_headers=http_headers,
|
|
586
|
+
security=self.sdk_configuration.security,
|
|
587
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
588
|
+
request, False, False, "json", models.SkySellRequest
|
|
589
|
+
),
|
|
590
|
+
timeout_ms=timeout_ms,
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
if retries == UNSET:
|
|
594
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
595
|
+
retries = self.sdk_configuration.retry_config
|
|
596
|
+
|
|
597
|
+
retry_config = None
|
|
598
|
+
if isinstance(retries, utils.RetryConfig):
|
|
599
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
600
|
+
|
|
601
|
+
http_res = await self.do_request_async(
|
|
602
|
+
hook_ctx=HookContext(
|
|
603
|
+
base_url=base_url or "",
|
|
604
|
+
operation_id="sky_sell",
|
|
605
|
+
oauth2_scopes=[],
|
|
606
|
+
security_source=self.sdk_configuration.security,
|
|
607
|
+
),
|
|
608
|
+
request=req,
|
|
609
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
610
|
+
retry_config=retry_config,
|
|
611
|
+
)
|
|
612
|
+
|
|
613
|
+
response_data: Any = None
|
|
614
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
615
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
616
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
617
|
+
response_data = utils.unmarshal_json(
|
|
618
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
619
|
+
)
|
|
620
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
621
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
622
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
623
|
+
raise errors.APIError(
|
|
624
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
625
|
+
)
|
|
626
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
627
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
628
|
+
raise errors.APIError(
|
|
629
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
630
|
+
)
|
|
631
|
+
|
|
632
|
+
content_type = http_res.headers.get("Content-Type")
|
|
633
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
634
|
+
raise errors.APIError(
|
|
635
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
636
|
+
http_res.status_code,
|
|
637
|
+
http_res_text,
|
|
638
|
+
http_res,
|
|
639
|
+
)
|
|
640
|
+
|
|
641
|
+
def deposit(
|
|
642
|
+
self,
|
|
643
|
+
*,
|
|
644
|
+
amount: Union[
|
|
645
|
+
models.SkyDepositRequestAmount, models.SkyDepositRequestAmountTypedDict
|
|
646
|
+
],
|
|
647
|
+
sender: str,
|
|
648
|
+
receiver: OptionalNullable[str] = UNSET,
|
|
649
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
650
|
+
server_url: Optional[str] = None,
|
|
651
|
+
timeout_ms: Optional[int] = None,
|
|
652
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
653
|
+
) -> models.UnsignedTransaction:
|
|
654
|
+
r"""Deposit USDS
|
|
655
|
+
|
|
656
|
+
Deposit USDS for sUSDS to earn yield.
|
|
657
|
+
|
|
658
|
+
There are no fees.
|
|
659
|
+
|
|
660
|
+
:param amount: The amount of USDS you would like to deposit for sUSDS to earn yield.
|
|
661
|
+
:param sender: The address of the transaction sender.
|
|
662
|
+
:param receiver: The address which will receive the sUSDS. Defaults to the sender.
|
|
663
|
+
:param retries: Override the default retry configuration for this method
|
|
664
|
+
:param server_url: Override the default server URL for this method
|
|
665
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
666
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
667
|
+
"""
|
|
668
|
+
base_url = None
|
|
669
|
+
url_variables = None
|
|
670
|
+
if timeout_ms is None:
|
|
671
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
672
|
+
|
|
673
|
+
if server_url is not None:
|
|
674
|
+
base_url = server_url
|
|
675
|
+
else:
|
|
676
|
+
base_url = self._get_url(base_url, url_variables)
|
|
677
|
+
|
|
678
|
+
request = models.SkyDepositRequest(
|
|
679
|
+
amount=amount,
|
|
680
|
+
receiver=receiver,
|
|
681
|
+
sender=sender,
|
|
682
|
+
)
|
|
683
|
+
|
|
684
|
+
req = self._build_request(
|
|
685
|
+
method="POST",
|
|
686
|
+
path="/v0/sky/deposit",
|
|
687
|
+
base_url=base_url,
|
|
688
|
+
url_variables=url_variables,
|
|
689
|
+
request=request,
|
|
690
|
+
request_body_required=True,
|
|
691
|
+
request_has_path_params=False,
|
|
692
|
+
request_has_query_params=True,
|
|
693
|
+
user_agent_header="user-agent",
|
|
694
|
+
accept_header_value="application/json",
|
|
695
|
+
http_headers=http_headers,
|
|
696
|
+
security=self.sdk_configuration.security,
|
|
697
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
698
|
+
request, False, False, "json", models.SkyDepositRequest
|
|
699
|
+
),
|
|
700
|
+
timeout_ms=timeout_ms,
|
|
701
|
+
)
|
|
702
|
+
|
|
703
|
+
if retries == UNSET:
|
|
704
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
705
|
+
retries = self.sdk_configuration.retry_config
|
|
706
|
+
|
|
707
|
+
retry_config = None
|
|
708
|
+
if isinstance(retries, utils.RetryConfig):
|
|
709
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
710
|
+
|
|
711
|
+
http_res = self.do_request(
|
|
712
|
+
hook_ctx=HookContext(
|
|
713
|
+
base_url=base_url or "",
|
|
714
|
+
operation_id="sky_deposit",
|
|
715
|
+
oauth2_scopes=[],
|
|
716
|
+
security_source=self.sdk_configuration.security,
|
|
717
|
+
),
|
|
718
|
+
request=req,
|
|
719
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
720
|
+
retry_config=retry_config,
|
|
721
|
+
)
|
|
722
|
+
|
|
723
|
+
response_data: Any = None
|
|
724
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
725
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
726
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
727
|
+
response_data = utils.unmarshal_json(
|
|
728
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
729
|
+
)
|
|
730
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
731
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
732
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
733
|
+
raise errors.APIError(
|
|
734
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
735
|
+
)
|
|
736
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
737
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
738
|
+
raise errors.APIError(
|
|
739
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
content_type = http_res.headers.get("Content-Type")
|
|
743
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
744
|
+
raise errors.APIError(
|
|
745
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
746
|
+
http_res.status_code,
|
|
747
|
+
http_res_text,
|
|
748
|
+
http_res,
|
|
749
|
+
)
|
|
750
|
+
|
|
751
|
+
async def deposit_async(
|
|
752
|
+
self,
|
|
753
|
+
*,
|
|
754
|
+
amount: Union[
|
|
755
|
+
models.SkyDepositRequestAmount, models.SkyDepositRequestAmountTypedDict
|
|
756
|
+
],
|
|
757
|
+
sender: str,
|
|
758
|
+
receiver: OptionalNullable[str] = UNSET,
|
|
759
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
760
|
+
server_url: Optional[str] = None,
|
|
761
|
+
timeout_ms: Optional[int] = None,
|
|
762
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
763
|
+
) -> models.UnsignedTransaction:
|
|
764
|
+
r"""Deposit USDS
|
|
765
|
+
|
|
766
|
+
Deposit USDS for sUSDS to earn yield.
|
|
767
|
+
|
|
768
|
+
There are no fees.
|
|
769
|
+
|
|
770
|
+
:param amount: The amount of USDS you would like to deposit for sUSDS to earn yield.
|
|
771
|
+
:param sender: The address of the transaction sender.
|
|
772
|
+
:param receiver: The address which will receive the sUSDS. Defaults to the sender.
|
|
773
|
+
:param retries: Override the default retry configuration for this method
|
|
774
|
+
:param server_url: Override the default server URL for this method
|
|
775
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
776
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
777
|
+
"""
|
|
778
|
+
base_url = None
|
|
779
|
+
url_variables = None
|
|
780
|
+
if timeout_ms is None:
|
|
781
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
782
|
+
|
|
783
|
+
if server_url is not None:
|
|
784
|
+
base_url = server_url
|
|
785
|
+
else:
|
|
786
|
+
base_url = self._get_url(base_url, url_variables)
|
|
787
|
+
|
|
788
|
+
request = models.SkyDepositRequest(
|
|
789
|
+
amount=amount,
|
|
790
|
+
receiver=receiver,
|
|
791
|
+
sender=sender,
|
|
792
|
+
)
|
|
793
|
+
|
|
794
|
+
req = self._build_request_async(
|
|
795
|
+
method="POST",
|
|
796
|
+
path="/v0/sky/deposit",
|
|
797
|
+
base_url=base_url,
|
|
798
|
+
url_variables=url_variables,
|
|
799
|
+
request=request,
|
|
800
|
+
request_body_required=True,
|
|
801
|
+
request_has_path_params=False,
|
|
802
|
+
request_has_query_params=True,
|
|
803
|
+
user_agent_header="user-agent",
|
|
804
|
+
accept_header_value="application/json",
|
|
805
|
+
http_headers=http_headers,
|
|
806
|
+
security=self.sdk_configuration.security,
|
|
807
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
808
|
+
request, False, False, "json", models.SkyDepositRequest
|
|
809
|
+
),
|
|
810
|
+
timeout_ms=timeout_ms,
|
|
811
|
+
)
|
|
812
|
+
|
|
813
|
+
if retries == UNSET:
|
|
814
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
815
|
+
retries = self.sdk_configuration.retry_config
|
|
816
|
+
|
|
817
|
+
retry_config = None
|
|
818
|
+
if isinstance(retries, utils.RetryConfig):
|
|
819
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
820
|
+
|
|
821
|
+
http_res = await self.do_request_async(
|
|
822
|
+
hook_ctx=HookContext(
|
|
823
|
+
base_url=base_url or "",
|
|
824
|
+
operation_id="sky_deposit",
|
|
825
|
+
oauth2_scopes=[],
|
|
826
|
+
security_source=self.sdk_configuration.security,
|
|
827
|
+
),
|
|
828
|
+
request=req,
|
|
829
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
830
|
+
retry_config=retry_config,
|
|
831
|
+
)
|
|
832
|
+
|
|
833
|
+
response_data: Any = None
|
|
834
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
835
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
836
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
837
|
+
response_data = utils.unmarshal_json(
|
|
838
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
839
|
+
)
|
|
840
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
841
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
842
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
843
|
+
raise errors.APIError(
|
|
844
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
845
|
+
)
|
|
846
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
847
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
848
|
+
raise errors.APIError(
|
|
849
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
850
|
+
)
|
|
851
|
+
|
|
852
|
+
content_type = http_res.headers.get("Content-Type")
|
|
853
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
854
|
+
raise errors.APIError(
|
|
855
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
856
|
+
http_res.status_code,
|
|
857
|
+
http_res_text,
|
|
858
|
+
http_res,
|
|
859
|
+
)
|
|
860
|
+
|
|
861
|
+
def withdraw(
|
|
862
|
+
self,
|
|
863
|
+
*,
|
|
864
|
+
amount: Any,
|
|
865
|
+
sender: str,
|
|
866
|
+
receiver: OptionalNullable[str] = UNSET,
|
|
867
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
868
|
+
server_url: Optional[str] = None,
|
|
869
|
+
timeout_ms: Optional[int] = None,
|
|
870
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
871
|
+
) -> models.UnsignedTransaction:
|
|
872
|
+
r"""Withdraw USDS
|
|
873
|
+
|
|
874
|
+
Withdraw USDS for sUSDS to stop earning yield.
|
|
875
|
+
|
|
876
|
+
There are no fees.
|
|
877
|
+
|
|
878
|
+
:param amount: The amount of USDS you would like to withdraw. If set to 'ALL', your total deposited USDS amount will be withdrawn.
|
|
879
|
+
:param sender: The address of the transaction sender.
|
|
880
|
+
:param receiver: The address which will receive the withdrawn USDS. Defaults to the sender.
|
|
881
|
+
:param retries: Override the default retry configuration for this method
|
|
882
|
+
:param server_url: Override the default server URL for this method
|
|
883
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
884
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
885
|
+
"""
|
|
886
|
+
base_url = None
|
|
887
|
+
url_variables = None
|
|
888
|
+
if timeout_ms is None:
|
|
889
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
890
|
+
|
|
891
|
+
if server_url is not None:
|
|
892
|
+
base_url = server_url
|
|
893
|
+
else:
|
|
894
|
+
base_url = self._get_url(base_url, url_variables)
|
|
895
|
+
|
|
896
|
+
request = models.SkyWithdrawRequest(
|
|
897
|
+
amount=amount,
|
|
898
|
+
receiver=receiver,
|
|
899
|
+
sender=sender,
|
|
900
|
+
)
|
|
901
|
+
|
|
902
|
+
req = self._build_request(
|
|
903
|
+
method="POST",
|
|
904
|
+
path="/v0/sky/withdraw",
|
|
905
|
+
base_url=base_url,
|
|
906
|
+
url_variables=url_variables,
|
|
907
|
+
request=request,
|
|
908
|
+
request_body_required=True,
|
|
909
|
+
request_has_path_params=False,
|
|
910
|
+
request_has_query_params=True,
|
|
911
|
+
user_agent_header="user-agent",
|
|
912
|
+
accept_header_value="application/json",
|
|
913
|
+
http_headers=http_headers,
|
|
914
|
+
security=self.sdk_configuration.security,
|
|
915
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
916
|
+
request, False, False, "json", models.SkyWithdrawRequest
|
|
917
|
+
),
|
|
918
|
+
timeout_ms=timeout_ms,
|
|
919
|
+
)
|
|
920
|
+
|
|
921
|
+
if retries == UNSET:
|
|
922
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
923
|
+
retries = self.sdk_configuration.retry_config
|
|
924
|
+
|
|
925
|
+
retry_config = None
|
|
926
|
+
if isinstance(retries, utils.RetryConfig):
|
|
927
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
928
|
+
|
|
929
|
+
http_res = self.do_request(
|
|
930
|
+
hook_ctx=HookContext(
|
|
931
|
+
base_url=base_url or "",
|
|
932
|
+
operation_id="sky_withdraw",
|
|
933
|
+
oauth2_scopes=[],
|
|
934
|
+
security_source=self.sdk_configuration.security,
|
|
935
|
+
),
|
|
936
|
+
request=req,
|
|
937
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
938
|
+
retry_config=retry_config,
|
|
939
|
+
)
|
|
940
|
+
|
|
941
|
+
response_data: Any = None
|
|
942
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
943
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
944
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
945
|
+
response_data = utils.unmarshal_json(
|
|
946
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
947
|
+
)
|
|
948
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
949
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
950
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
951
|
+
raise errors.APIError(
|
|
952
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
953
|
+
)
|
|
954
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
955
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
956
|
+
raise errors.APIError(
|
|
957
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
958
|
+
)
|
|
959
|
+
|
|
960
|
+
content_type = http_res.headers.get("Content-Type")
|
|
961
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
962
|
+
raise errors.APIError(
|
|
963
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
964
|
+
http_res.status_code,
|
|
965
|
+
http_res_text,
|
|
966
|
+
http_res,
|
|
967
|
+
)
|
|
968
|
+
|
|
969
|
+
async def withdraw_async(
|
|
970
|
+
self,
|
|
971
|
+
*,
|
|
972
|
+
amount: Any,
|
|
973
|
+
sender: str,
|
|
974
|
+
receiver: OptionalNullable[str] = UNSET,
|
|
975
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
976
|
+
server_url: Optional[str] = None,
|
|
977
|
+
timeout_ms: Optional[int] = None,
|
|
978
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
979
|
+
) -> models.UnsignedTransaction:
|
|
980
|
+
r"""Withdraw USDS
|
|
981
|
+
|
|
982
|
+
Withdraw USDS for sUSDS to stop earning yield.
|
|
983
|
+
|
|
984
|
+
There are no fees.
|
|
985
|
+
|
|
986
|
+
:param amount: The amount of USDS you would like to withdraw. If set to 'ALL', your total deposited USDS amount will be withdrawn.
|
|
987
|
+
:param sender: The address of the transaction sender.
|
|
988
|
+
:param receiver: The address which will receive the withdrawn USDS. Defaults to the sender.
|
|
989
|
+
:param retries: Override the default retry configuration for this method
|
|
990
|
+
:param server_url: Override the default server URL for this method
|
|
991
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
992
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
993
|
+
"""
|
|
994
|
+
base_url = None
|
|
995
|
+
url_variables = None
|
|
996
|
+
if timeout_ms is None:
|
|
997
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
998
|
+
|
|
999
|
+
if server_url is not None:
|
|
1000
|
+
base_url = server_url
|
|
1001
|
+
else:
|
|
1002
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1003
|
+
|
|
1004
|
+
request = models.SkyWithdrawRequest(
|
|
1005
|
+
amount=amount,
|
|
1006
|
+
receiver=receiver,
|
|
1007
|
+
sender=sender,
|
|
1008
|
+
)
|
|
1009
|
+
|
|
1010
|
+
req = self._build_request_async(
|
|
1011
|
+
method="POST",
|
|
1012
|
+
path="/v0/sky/withdraw",
|
|
1013
|
+
base_url=base_url,
|
|
1014
|
+
url_variables=url_variables,
|
|
1015
|
+
request=request,
|
|
1016
|
+
request_body_required=True,
|
|
1017
|
+
request_has_path_params=False,
|
|
1018
|
+
request_has_query_params=True,
|
|
1019
|
+
user_agent_header="user-agent",
|
|
1020
|
+
accept_header_value="application/json",
|
|
1021
|
+
http_headers=http_headers,
|
|
1022
|
+
security=self.sdk_configuration.security,
|
|
1023
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1024
|
+
request, False, False, "json", models.SkyWithdrawRequest
|
|
1025
|
+
),
|
|
1026
|
+
timeout_ms=timeout_ms,
|
|
1027
|
+
)
|
|
1028
|
+
|
|
1029
|
+
if retries == UNSET:
|
|
1030
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1031
|
+
retries = self.sdk_configuration.retry_config
|
|
1032
|
+
|
|
1033
|
+
retry_config = None
|
|
1034
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1035
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1036
|
+
|
|
1037
|
+
http_res = await self.do_request_async(
|
|
1038
|
+
hook_ctx=HookContext(
|
|
1039
|
+
base_url=base_url or "",
|
|
1040
|
+
operation_id="sky_withdraw",
|
|
1041
|
+
oauth2_scopes=[],
|
|
1042
|
+
security_source=self.sdk_configuration.security,
|
|
1043
|
+
),
|
|
1044
|
+
request=req,
|
|
1045
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1046
|
+
retry_config=retry_config,
|
|
1047
|
+
)
|
|
1048
|
+
|
|
1049
|
+
response_data: Any = None
|
|
1050
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1051
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1052
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1053
|
+
response_data = utils.unmarshal_json(
|
|
1054
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1055
|
+
)
|
|
1056
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1057
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1058
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1059
|
+
raise errors.APIError(
|
|
1060
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1061
|
+
)
|
|
1062
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1063
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1064
|
+
raise errors.APIError(
|
|
1065
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1066
|
+
)
|
|
1067
|
+
|
|
1068
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1069
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1070
|
+
raise errors.APIError(
|
|
1071
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1072
|
+
http_res.status_code,
|
|
1073
|
+
http_res_text,
|
|
1074
|
+
http_res,
|
|
1075
|
+
)
|