compass_api_sdk 0.0.1__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 (137) hide show
  1. compass_api_sdk/__init__.py +17 -0
  2. compass_api_sdk/_hooks/__init__.py +5 -0
  3. compass_api_sdk/_hooks/registration.py +13 -0
  4. compass_api_sdk/_hooks/sdkhooks.py +76 -0
  5. compass_api_sdk/_hooks/types.py +106 -0
  6. compass_api_sdk/_version.py +15 -0
  7. compass_api_sdk/aave_v3.py +1903 -0
  8. compass_api_sdk/aerodrome_slipstream.py +1875 -0
  9. compass_api_sdk/basesdk.py +362 -0
  10. compass_api_sdk/errors/__init__.py +7 -0
  11. compass_api_sdk/errors/apierror.py +22 -0
  12. compass_api_sdk/errors/httpvalidationerror.py +21 -0
  13. compass_api_sdk/httpclient.py +136 -0
  14. compass_api_sdk/models/__init__.py +777 -0
  15. compass_api_sdk/models/aave_liquidity_changeop.py +108 -0
  16. compass_api_sdk/models/aave_token_priceop.py +98 -0
  17. compass_api_sdk/models/aave_user_position_per_tokenop.py +104 -0
  18. compass_api_sdk/models/aave_user_position_summaryop.py +35 -0
  19. compass_api_sdk/models/aaveborrowrequest.py +105 -0
  20. compass_api_sdk/models/aaveliquiditychangeresponse.py +26 -0
  21. compass_api_sdk/models/aaverepayrequest.py +105 -0
  22. compass_api_sdk/models/aavesupplyrequest.py +93 -0
  23. compass_api_sdk/models/aavetokenpriceresponse.py +15 -0
  24. compass_api_sdk/models/aaveuserpositionpertokenresponse.py +73 -0
  25. compass_api_sdk/models/aaveuserpositionsummaryresponse.py +50 -0
  26. compass_api_sdk/models/aavewithdrawrequest.py +58 -0
  27. compass_api_sdk/models/aerodrome_slipstream_liquidity_provision_positionsop.py +35 -0
  28. compass_api_sdk/models/aerodrome_slipstream_pool_priceop.py +173 -0
  29. compass_api_sdk/models/aerodromelppositionsresponse.py +21 -0
  30. compass_api_sdk/models/aerodromeposition.py +70 -0
  31. compass_api_sdk/models/aerodromeslipstreambuyexactlyrequest.py +92 -0
  32. compass_api_sdk/models/aerodromeslipstreamincreaseliquidityprovisionrequest.py +109 -0
  33. compass_api_sdk/models/aerodromeslipstreammintliquidityprovisionrequest.py +186 -0
  34. compass_api_sdk/models/aerodromeslipstreampoolpriceresponse.py +57 -0
  35. compass_api_sdk/models/aerodromeslipstreamsellexactlyrequest.py +96 -0
  36. compass_api_sdk/models/aerodromeslipstreamwithdrawliquidityprovisionrequest.py +50 -0
  37. compass_api_sdk/models/allowanceinforesponse.py +48 -0
  38. compass_api_sdk/models/balanceinforesponse.py +43 -0
  39. compass_api_sdk/models/chain.py +12 -0
  40. compass_api_sdk/models/chaininfo.py +53 -0
  41. compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_markets_asset.py +22 -0
  42. compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_vaults_asset.py +23 -0
  43. compass_api_sdk/models/ensnameinforesponse.py +24 -0
  44. compass_api_sdk/models/feeenum.py +16 -0
  45. compass_api_sdk/models/generic_allowanceop.py +121 -0
  46. compass_api_sdk/models/generic_balanceop.py +104 -0
  47. compass_api_sdk/models/generic_ensop.py +35 -0
  48. compass_api_sdk/models/generic_portfolioop.py +35 -0
  49. compass_api_sdk/models/generic_price_usdop.py +98 -0
  50. compass_api_sdk/models/generic_supported_tokensop.py +29 -0
  51. compass_api_sdk/models/generic_visualize_portfolioop.py +35 -0
  52. compass_api_sdk/models/image.py +15 -0
  53. compass_api_sdk/models/increaseallowancerequest.py +77 -0
  54. compass_api_sdk/models/interestratemode.py +14 -0
  55. compass_api_sdk/models/marketstate.py +35 -0
  56. compass_api_sdk/models/morpho_market_positionop.py +39 -0
  57. compass_api_sdk/models/morpho_marketsop.py +78 -0
  58. compass_api_sdk/models/morpho_vault_positionop.py +39 -0
  59. compass_api_sdk/models/morpho_vaultsop.py +72 -0
  60. compass_api_sdk/models/morphoborrowrequest.py +91 -0
  61. compass_api_sdk/models/morphocheckmarketpositionresponse.py +23 -0
  62. compass_api_sdk/models/morphocheckvaultpositionresponse.py +20 -0
  63. compass_api_sdk/models/morphodepositrequest.py +86 -0
  64. compass_api_sdk/models/morphogetmarketsresponse.py +17 -0
  65. compass_api_sdk/models/morphogetvaultsresponse.py +17 -0
  66. compass_api_sdk/models/morphomarket.py +80 -0
  67. compass_api_sdk/models/morphorepayrequest.py +79 -0
  68. compass_api_sdk/models/morphosetvaultallowancerequest.py +44 -0
  69. compass_api_sdk/models/morphosupplycollateralrequest.py +91 -0
  70. compass_api_sdk/models/morphovault.py +47 -0
  71. compass_api_sdk/models/morphowithdrawcollateralrequest.py +91 -0
  72. compass_api_sdk/models/morphowithdrawrequest.py +74 -0
  73. compass_api_sdk/models/portfolio.py +22 -0
  74. compass_api_sdk/models/priceresponse.py +15 -0
  75. compass_api_sdk/models/security.py +24 -0
  76. compass_api_sdk/models/token_addressop.py +98 -0
  77. compass_api_sdk/models/token_balanceop.py +49 -0
  78. compass_api_sdk/models/token_enum.py +57 -0
  79. compass_api_sdk/models/token_priceop.py +97 -0
  80. compass_api_sdk/models/tokenaddressresponse.py +15 -0
  81. compass_api_sdk/models/tokenbalance.py +49 -0
  82. compass_api_sdk/models/tokenbalanceresponse.py +44 -0
  83. compass_api_sdk/models/tokeninfo.py +17 -0
  84. compass_api_sdk/models/tokenpriceresponse.py +15 -0
  85. compass_api_sdk/models/tokentransferrequest.py +66 -0
  86. compass_api_sdk/models/transfererc20request.py +62 -0
  87. compass_api_sdk/models/transferethrequest.py +46 -0
  88. compass_api_sdk/models/uniswap_liquidity_provision_in_rangeop.py +34 -0
  89. compass_api_sdk/models/uniswap_liquidity_provision_positionsop.py +35 -0
  90. compass_api_sdk/models/uniswap_pool_priceop.py +193 -0
  91. compass_api_sdk/models/uniswap_quote_buy_exactlyop.py +209 -0
  92. compass_api_sdk/models/uniswap_quote_sell_exactlyop.py +209 -0
  93. compass_api_sdk/models/uniswapbuyexactlyrequest.py +104 -0
  94. compass_api_sdk/models/uniswapbuyquoteinforesponse.py +20 -0
  95. compass_api_sdk/models/uniswapcheckinrangeresponse.py +15 -0
  96. compass_api_sdk/models/uniswapincreaseliquidityprovisionrequest.py +99 -0
  97. compass_api_sdk/models/uniswaplppositionsinforesponse.py +24 -0
  98. compass_api_sdk/models/uniswapmintliquidityprovisionrequest.py +185 -0
  99. compass_api_sdk/models/uniswappoolpriceresponse.py +47 -0
  100. compass_api_sdk/models/uniswappositionssolidityresponse.py +46 -0
  101. compass_api_sdk/models/uniswapsellexactlyrequest.py +104 -0
  102. compass_api_sdk/models/uniswapsellquoteinforesponse.py +20 -0
  103. compass_api_sdk/models/uniswapwithdrawliquidityprovisionrequest.py +51 -0
  104. compass_api_sdk/models/unsignedtransaction.py +58 -0
  105. compass_api_sdk/models/unwrapwethrequest.py +41 -0
  106. compass_api_sdk/models/validationerror.py +26 -0
  107. compass_api_sdk/models/vaultstate.py +32 -0
  108. compass_api_sdk/models/weeklyapys.py +23 -0
  109. compass_api_sdk/models/wrapethrequest.py +41 -0
  110. compass_api_sdk/morpho.py +2577 -0
  111. compass_api_sdk/py.typed +1 -0
  112. compass_api_sdk/sdk.py +155 -0
  113. compass_api_sdk/sdkconfiguration.py +56 -0
  114. compass_api_sdk/token_sdk.py +861 -0
  115. compass_api_sdk/types/__init__.py +21 -0
  116. compass_api_sdk/types/basemodel.py +39 -0
  117. compass_api_sdk/uniswap_v3.py +2551 -0
  118. compass_api_sdk/universal.py +2625 -0
  119. compass_api_sdk/utils/__init__.py +100 -0
  120. compass_api_sdk/utils/annotations.py +55 -0
  121. compass_api_sdk/utils/datetimes.py +23 -0
  122. compass_api_sdk/utils/enums.py +74 -0
  123. compass_api_sdk/utils/eventstreaming.py +238 -0
  124. compass_api_sdk/utils/forms.py +202 -0
  125. compass_api_sdk/utils/headers.py +136 -0
  126. compass_api_sdk/utils/logger.py +22 -0
  127. compass_api_sdk/utils/metadata.py +118 -0
  128. compass_api_sdk/utils/queryparams.py +205 -0
  129. compass_api_sdk/utils/requestbodies.py +66 -0
  130. compass_api_sdk/utils/retries.py +217 -0
  131. compass_api_sdk/utils/security.py +174 -0
  132. compass_api_sdk/utils/serializers.py +248 -0
  133. compass_api_sdk/utils/url.py +155 -0
  134. compass_api_sdk/utils/values.py +137 -0
  135. compass_api_sdk-0.0.1.dist-info/METADATA +534 -0
  136. compass_api_sdk-0.0.1.dist-info/RECORD +137 -0
  137. compass_api_sdk-0.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,861 @@
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, Mapping, Optional, Union
8
+
9
+
10
+ class TokenSDK(BaseSDK):
11
+ def address(
12
+ self,
13
+ *,
14
+ chain: Optional[
15
+ models.TokenAddressChain
16
+ ] = models.TokenAddressChain.ARBITRUM_MAINNET,
17
+ token: Optional[models.TokenAddressToken] = models.TokenAddressToken.WETH,
18
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
19
+ server_url: Optional[str] = None,
20
+ timeout_ms: Optional[int] = None,
21
+ http_headers: Optional[Mapping[str, str]] = None,
22
+ ) -> models.TokenAddressResponse:
23
+ r"""Token Address
24
+
25
+ This endpoint retrieves the address for a token supported by us.
26
+
27
+ :param chain: The chain to use.
28
+ :param 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.
29
+ :param retries: Override the default retry configuration for this method
30
+ :param server_url: Override the default server URL for this method
31
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
32
+ :param http_headers: Additional headers to set or replace on requests.
33
+ """
34
+ base_url = None
35
+ url_variables = None
36
+ if timeout_ms is None:
37
+ timeout_ms = self.sdk_configuration.timeout_ms
38
+
39
+ if server_url is not None:
40
+ base_url = server_url
41
+ else:
42
+ base_url = self._get_url(base_url, url_variables)
43
+
44
+ request = models.TokenAddressRequest(
45
+ chain=chain,
46
+ token=token,
47
+ )
48
+
49
+ req = self._build_request(
50
+ method="GET",
51
+ path="/v0/token/address/get",
52
+ base_url=base_url,
53
+ url_variables=url_variables,
54
+ request=request,
55
+ request_body_required=False,
56
+ request_has_path_params=False,
57
+ request_has_query_params=True,
58
+ user_agent_header="user-agent",
59
+ accept_header_value="application/json",
60
+ http_headers=http_headers,
61
+ security=self.sdk_configuration.security,
62
+ timeout_ms=timeout_ms,
63
+ )
64
+
65
+ if retries == UNSET:
66
+ if self.sdk_configuration.retry_config is not UNSET:
67
+ retries = self.sdk_configuration.retry_config
68
+
69
+ retry_config = None
70
+ if isinstance(retries, utils.RetryConfig):
71
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
72
+
73
+ http_res = self.do_request(
74
+ hook_ctx=HookContext(
75
+ base_url=base_url or "",
76
+ operation_id="token_address",
77
+ oauth2_scopes=[],
78
+ security_source=self.sdk_configuration.security,
79
+ ),
80
+ request=req,
81
+ error_status_codes=["422", "4XX", "5XX"],
82
+ retry_config=retry_config,
83
+ )
84
+
85
+ response_data: Any = None
86
+ if utils.match_response(http_res, "200", "application/json"):
87
+ return utils.unmarshal_json(http_res.text, models.TokenAddressResponse)
88
+ if utils.match_response(http_res, "422", "application/json"):
89
+ response_data = utils.unmarshal_json(
90
+ http_res.text, errors.HTTPValidationErrorData
91
+ )
92
+ raise errors.HTTPValidationError(data=response_data)
93
+ if utils.match_response(http_res, "4XX", "*"):
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
+ if utils.match_response(http_res, "5XX", "*"):
99
+ http_res_text = utils.stream_to_text(http_res)
100
+ raise errors.APIError(
101
+ "API error occurred", http_res.status_code, http_res_text, http_res
102
+ )
103
+
104
+ content_type = http_res.headers.get("Content-Type")
105
+ http_res_text = utils.stream_to_text(http_res)
106
+ raise errors.APIError(
107
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
108
+ http_res.status_code,
109
+ http_res_text,
110
+ http_res,
111
+ )
112
+
113
+ async def address_async(
114
+ self,
115
+ *,
116
+ chain: Optional[
117
+ models.TokenAddressChain
118
+ ] = models.TokenAddressChain.ARBITRUM_MAINNET,
119
+ token: Optional[models.TokenAddressToken] = models.TokenAddressToken.WETH,
120
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
121
+ server_url: Optional[str] = None,
122
+ timeout_ms: Optional[int] = None,
123
+ http_headers: Optional[Mapping[str, str]] = None,
124
+ ) -> models.TokenAddressResponse:
125
+ r"""Token Address
126
+
127
+ This endpoint retrieves the address for a token supported by us.
128
+
129
+ :param chain: The chain to use.
130
+ :param 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.
131
+ :param retries: Override the default retry configuration for this method
132
+ :param server_url: Override the default server URL for this method
133
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
134
+ :param http_headers: Additional headers to set or replace on requests.
135
+ """
136
+ base_url = None
137
+ url_variables = None
138
+ if timeout_ms is None:
139
+ timeout_ms = self.sdk_configuration.timeout_ms
140
+
141
+ if server_url is not None:
142
+ base_url = server_url
143
+ else:
144
+ base_url = self._get_url(base_url, url_variables)
145
+
146
+ request = models.TokenAddressRequest(
147
+ chain=chain,
148
+ token=token,
149
+ )
150
+
151
+ req = self._build_request_async(
152
+ method="GET",
153
+ path="/v0/token/address/get",
154
+ base_url=base_url,
155
+ url_variables=url_variables,
156
+ request=request,
157
+ request_body_required=False,
158
+ request_has_path_params=False,
159
+ request_has_query_params=True,
160
+ user_agent_header="user-agent",
161
+ accept_header_value="application/json",
162
+ http_headers=http_headers,
163
+ security=self.sdk_configuration.security,
164
+ timeout_ms=timeout_ms,
165
+ )
166
+
167
+ if retries == UNSET:
168
+ if self.sdk_configuration.retry_config is not UNSET:
169
+ retries = self.sdk_configuration.retry_config
170
+
171
+ retry_config = None
172
+ if isinstance(retries, utils.RetryConfig):
173
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
174
+
175
+ http_res = await self.do_request_async(
176
+ hook_ctx=HookContext(
177
+ base_url=base_url or "",
178
+ operation_id="token_address",
179
+ oauth2_scopes=[],
180
+ security_source=self.sdk_configuration.security,
181
+ ),
182
+ request=req,
183
+ error_status_codes=["422", "4XX", "5XX"],
184
+ retry_config=retry_config,
185
+ )
186
+
187
+ response_data: Any = None
188
+ if utils.match_response(http_res, "200", "application/json"):
189
+ return utils.unmarshal_json(http_res.text, models.TokenAddressResponse)
190
+ if utils.match_response(http_res, "422", "application/json"):
191
+ response_data = utils.unmarshal_json(
192
+ http_res.text, errors.HTTPValidationErrorData
193
+ )
194
+ raise errors.HTTPValidationError(data=response_data)
195
+ if utils.match_response(http_res, "4XX", "*"):
196
+ http_res_text = await utils.stream_to_text_async(http_res)
197
+ raise errors.APIError(
198
+ "API error occurred", http_res.status_code, http_res_text, http_res
199
+ )
200
+ if utils.match_response(http_res, "5XX", "*"):
201
+ http_res_text = await utils.stream_to_text_async(http_res)
202
+ raise errors.APIError(
203
+ "API error occurred", http_res.status_code, http_res_text, http_res
204
+ )
205
+
206
+ content_type = http_res.headers.get("Content-Type")
207
+ http_res_text = await utils.stream_to_text_async(http_res)
208
+ raise errors.APIError(
209
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
210
+ http_res.status_code,
211
+ http_res_text,
212
+ http_res,
213
+ )
214
+
215
+ def price(
216
+ self,
217
+ *,
218
+ chain: models.TokenPriceChain = models.TokenPriceChain.ARBITRUM_MAINNET,
219
+ token: models.TokenPriceToken = models.TokenPriceToken.WBTC,
220
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
221
+ server_url: Optional[str] = None,
222
+ timeout_ms: Optional[int] = None,
223
+ http_headers: Optional[Mapping[str, str]] = None,
224
+ ) -> models.TokenPriceResponse:
225
+ r"""Token Price
226
+
227
+ Retrieves the price of a token in USD using Chainlink's on-chain price feeds.
228
+
229
+ Chainlink is a decentralized oracle that aggregates price data from off-chain
230
+ sources. This ensures the price is tamper-resistant but the price might be stale
231
+ with the update frequency of the oracle.
232
+
233
+ :param chain: The chain to use.
234
+ :param 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.
235
+ :param retries: Override the default retry configuration for this method
236
+ :param server_url: Override the default server URL for this method
237
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
238
+ :param http_headers: Additional headers to set or replace on requests.
239
+ """
240
+ base_url = None
241
+ url_variables = None
242
+ if timeout_ms is None:
243
+ timeout_ms = self.sdk_configuration.timeout_ms
244
+
245
+ if server_url is not None:
246
+ base_url = server_url
247
+ else:
248
+ base_url = self._get_url(base_url, url_variables)
249
+
250
+ request = models.TokenPriceRequest(
251
+ chain=chain,
252
+ token=token,
253
+ )
254
+
255
+ req = self._build_request(
256
+ method="GET",
257
+ path="/v0/token/price/get",
258
+ base_url=base_url,
259
+ url_variables=url_variables,
260
+ request=request,
261
+ request_body_required=False,
262
+ request_has_path_params=False,
263
+ request_has_query_params=True,
264
+ user_agent_header="user-agent",
265
+ accept_header_value="application/json",
266
+ http_headers=http_headers,
267
+ security=self.sdk_configuration.security,
268
+ timeout_ms=timeout_ms,
269
+ )
270
+
271
+ if retries == UNSET:
272
+ if self.sdk_configuration.retry_config is not UNSET:
273
+ retries = self.sdk_configuration.retry_config
274
+
275
+ retry_config = None
276
+ if isinstance(retries, utils.RetryConfig):
277
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
278
+
279
+ http_res = self.do_request(
280
+ hook_ctx=HookContext(
281
+ base_url=base_url or "",
282
+ operation_id="token_price",
283
+ oauth2_scopes=[],
284
+ security_source=self.sdk_configuration.security,
285
+ ),
286
+ request=req,
287
+ error_status_codes=["422", "4XX", "5XX"],
288
+ retry_config=retry_config,
289
+ )
290
+
291
+ response_data: Any = None
292
+ if utils.match_response(http_res, "200", "application/json"):
293
+ return utils.unmarshal_json(http_res.text, models.TokenPriceResponse)
294
+ if utils.match_response(http_res, "422", "application/json"):
295
+ response_data = utils.unmarshal_json(
296
+ http_res.text, errors.HTTPValidationErrorData
297
+ )
298
+ raise errors.HTTPValidationError(data=response_data)
299
+ if utils.match_response(http_res, "4XX", "*"):
300
+ http_res_text = utils.stream_to_text(http_res)
301
+ raise errors.APIError(
302
+ "API error occurred", http_res.status_code, http_res_text, http_res
303
+ )
304
+ if utils.match_response(http_res, "5XX", "*"):
305
+ http_res_text = utils.stream_to_text(http_res)
306
+ raise errors.APIError(
307
+ "API error occurred", http_res.status_code, http_res_text, http_res
308
+ )
309
+
310
+ content_type = http_res.headers.get("Content-Type")
311
+ http_res_text = utils.stream_to_text(http_res)
312
+ raise errors.APIError(
313
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
314
+ http_res.status_code,
315
+ http_res_text,
316
+ http_res,
317
+ )
318
+
319
+ async def price_async(
320
+ self,
321
+ *,
322
+ chain: models.TokenPriceChain = models.TokenPriceChain.ARBITRUM_MAINNET,
323
+ token: models.TokenPriceToken = models.TokenPriceToken.WBTC,
324
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
325
+ server_url: Optional[str] = None,
326
+ timeout_ms: Optional[int] = None,
327
+ http_headers: Optional[Mapping[str, str]] = None,
328
+ ) -> models.TokenPriceResponse:
329
+ r"""Token Price
330
+
331
+ Retrieves the price of a token in USD using Chainlink's on-chain price feeds.
332
+
333
+ Chainlink is a decentralized oracle that aggregates price data from off-chain
334
+ sources. This ensures the price is tamper-resistant but the price might be stale
335
+ with the update frequency of the oracle.
336
+
337
+ :param chain: The chain to use.
338
+ :param 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.
339
+ :param retries: Override the default retry configuration for this method
340
+ :param server_url: Override the default server URL for this method
341
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
342
+ :param http_headers: Additional headers to set or replace on requests.
343
+ """
344
+ base_url = None
345
+ url_variables = None
346
+ if timeout_ms is None:
347
+ timeout_ms = self.sdk_configuration.timeout_ms
348
+
349
+ if server_url is not None:
350
+ base_url = server_url
351
+ else:
352
+ base_url = self._get_url(base_url, url_variables)
353
+
354
+ request = models.TokenPriceRequest(
355
+ chain=chain,
356
+ token=token,
357
+ )
358
+
359
+ req = self._build_request_async(
360
+ method="GET",
361
+ path="/v0/token/price/get",
362
+ base_url=base_url,
363
+ url_variables=url_variables,
364
+ request=request,
365
+ request_body_required=False,
366
+ request_has_path_params=False,
367
+ request_has_query_params=True,
368
+ user_agent_header="user-agent",
369
+ accept_header_value="application/json",
370
+ http_headers=http_headers,
371
+ security=self.sdk_configuration.security,
372
+ timeout_ms=timeout_ms,
373
+ )
374
+
375
+ if retries == UNSET:
376
+ if self.sdk_configuration.retry_config is not UNSET:
377
+ retries = self.sdk_configuration.retry_config
378
+
379
+ retry_config = None
380
+ if isinstance(retries, utils.RetryConfig):
381
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
382
+
383
+ http_res = await self.do_request_async(
384
+ hook_ctx=HookContext(
385
+ base_url=base_url or "",
386
+ operation_id="token_price",
387
+ oauth2_scopes=[],
388
+ security_source=self.sdk_configuration.security,
389
+ ),
390
+ request=req,
391
+ error_status_codes=["422", "4XX", "5XX"],
392
+ retry_config=retry_config,
393
+ )
394
+
395
+ response_data: Any = None
396
+ if utils.match_response(http_res, "200", "application/json"):
397
+ return utils.unmarshal_json(http_res.text, models.TokenPriceResponse)
398
+ if utils.match_response(http_res, "422", "application/json"):
399
+ response_data = utils.unmarshal_json(
400
+ http_res.text, errors.HTTPValidationErrorData
401
+ )
402
+ raise errors.HTTPValidationError(data=response_data)
403
+ if utils.match_response(http_res, "4XX", "*"):
404
+ http_res_text = await utils.stream_to_text_async(http_res)
405
+ raise errors.APIError(
406
+ "API error occurred", http_res.status_code, http_res_text, http_res
407
+ )
408
+ if utils.match_response(http_res, "5XX", "*"):
409
+ http_res_text = await utils.stream_to_text_async(http_res)
410
+ raise errors.APIError(
411
+ "API error occurred", http_res.status_code, http_res_text, http_res
412
+ )
413
+
414
+ content_type = http_res.headers.get("Content-Type")
415
+ http_res_text = await utils.stream_to_text_async(http_res)
416
+ raise errors.APIError(
417
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
418
+ http_res.status_code,
419
+ http_res_text,
420
+ http_res,
421
+ )
422
+
423
+ def balance(
424
+ self,
425
+ *,
426
+ chain: models.TokenBalanceChain = models.TokenBalanceChain.ARBITRUM_MAINNET,
427
+ user: str = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
428
+ token: Union[models.TokenBalanceToken, models.TokenBalanceTokenTypedDict],
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.TokenBalanceResponse:
434
+ r"""Token Balance
435
+
436
+ Returns the balance of a specific ERC20 token for a given user address.
437
+
438
+ :param chain: The chain to use.
439
+ :param user:
440
+ :param token:
441
+ :param retries: Override the default retry configuration for this method
442
+ :param server_url: Override the default server URL for this method
443
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
444
+ :param http_headers: Additional headers to set or replace on requests.
445
+ """
446
+ base_url = None
447
+ url_variables = None
448
+ if timeout_ms is None:
449
+ timeout_ms = self.sdk_configuration.timeout_ms
450
+
451
+ if server_url is not None:
452
+ base_url = server_url
453
+ else:
454
+ base_url = self._get_url(base_url, url_variables)
455
+
456
+ request = models.TokenBalanceRequest(
457
+ chain=chain,
458
+ user=user,
459
+ token=token,
460
+ )
461
+
462
+ req = self._build_request(
463
+ method="GET",
464
+ path="/v0/token/balance/get",
465
+ base_url=base_url,
466
+ url_variables=url_variables,
467
+ request=request,
468
+ request_body_required=False,
469
+ request_has_path_params=False,
470
+ request_has_query_params=True,
471
+ user_agent_header="user-agent",
472
+ accept_header_value="application/json",
473
+ http_headers=http_headers,
474
+ security=self.sdk_configuration.security,
475
+ timeout_ms=timeout_ms,
476
+ )
477
+
478
+ if retries == UNSET:
479
+ if self.sdk_configuration.retry_config is not UNSET:
480
+ retries = self.sdk_configuration.retry_config
481
+
482
+ retry_config = None
483
+ if isinstance(retries, utils.RetryConfig):
484
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
485
+
486
+ http_res = self.do_request(
487
+ hook_ctx=HookContext(
488
+ base_url=base_url or "",
489
+ operation_id="token_balance",
490
+ oauth2_scopes=[],
491
+ security_source=self.sdk_configuration.security,
492
+ ),
493
+ request=req,
494
+ error_status_codes=["422", "4XX", "5XX"],
495
+ retry_config=retry_config,
496
+ )
497
+
498
+ response_data: Any = None
499
+ if utils.match_response(http_res, "200", "application/json"):
500
+ return utils.unmarshal_json(http_res.text, models.TokenBalanceResponse)
501
+ if utils.match_response(http_res, "422", "application/json"):
502
+ response_data = utils.unmarshal_json(
503
+ http_res.text, errors.HTTPValidationErrorData
504
+ )
505
+ raise errors.HTTPValidationError(data=response_data)
506
+ if utils.match_response(http_res, "4XX", "*"):
507
+ http_res_text = utils.stream_to_text(http_res)
508
+ raise errors.APIError(
509
+ "API error occurred", http_res.status_code, http_res_text, http_res
510
+ )
511
+ if utils.match_response(http_res, "5XX", "*"):
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
+
517
+ content_type = http_res.headers.get("Content-Type")
518
+ http_res_text = utils.stream_to_text(http_res)
519
+ raise errors.APIError(
520
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
521
+ http_res.status_code,
522
+ http_res_text,
523
+ http_res,
524
+ )
525
+
526
+ async def balance_async(
527
+ self,
528
+ *,
529
+ chain: models.TokenBalanceChain = models.TokenBalanceChain.ARBITRUM_MAINNET,
530
+ user: str = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
531
+ token: Union[models.TokenBalanceToken, models.TokenBalanceTokenTypedDict],
532
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
533
+ server_url: Optional[str] = None,
534
+ timeout_ms: Optional[int] = None,
535
+ http_headers: Optional[Mapping[str, str]] = None,
536
+ ) -> models.TokenBalanceResponse:
537
+ r"""Token Balance
538
+
539
+ Returns the balance of a specific ERC20 token for a given user address.
540
+
541
+ :param chain: The chain to use.
542
+ :param user:
543
+ :param token:
544
+ :param retries: Override the default retry configuration for this method
545
+ :param server_url: Override the default server URL for this method
546
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
547
+ :param http_headers: Additional headers to set or replace on requests.
548
+ """
549
+ base_url = None
550
+ url_variables = None
551
+ if timeout_ms is None:
552
+ timeout_ms = self.sdk_configuration.timeout_ms
553
+
554
+ if server_url is not None:
555
+ base_url = server_url
556
+ else:
557
+ base_url = self._get_url(base_url, url_variables)
558
+
559
+ request = models.TokenBalanceRequest(
560
+ chain=chain,
561
+ user=user,
562
+ token=token,
563
+ )
564
+
565
+ req = self._build_request_async(
566
+ method="GET",
567
+ path="/v0/token/balance/get",
568
+ base_url=base_url,
569
+ url_variables=url_variables,
570
+ request=request,
571
+ request_body_required=False,
572
+ request_has_path_params=False,
573
+ request_has_query_params=True,
574
+ user_agent_header="user-agent",
575
+ accept_header_value="application/json",
576
+ http_headers=http_headers,
577
+ security=self.sdk_configuration.security,
578
+ timeout_ms=timeout_ms,
579
+ )
580
+
581
+ if retries == UNSET:
582
+ if self.sdk_configuration.retry_config is not UNSET:
583
+ retries = self.sdk_configuration.retry_config
584
+
585
+ retry_config = None
586
+ if isinstance(retries, utils.RetryConfig):
587
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
588
+
589
+ http_res = await self.do_request_async(
590
+ hook_ctx=HookContext(
591
+ base_url=base_url or "",
592
+ operation_id="token_balance",
593
+ oauth2_scopes=[],
594
+ security_source=self.sdk_configuration.security,
595
+ ),
596
+ request=req,
597
+ error_status_codes=["422", "4XX", "5XX"],
598
+ retry_config=retry_config,
599
+ )
600
+
601
+ response_data: Any = None
602
+ if utils.match_response(http_res, "200", "application/json"):
603
+ return utils.unmarshal_json(http_res.text, models.TokenBalanceResponse)
604
+ if utils.match_response(http_res, "422", "application/json"):
605
+ response_data = utils.unmarshal_json(
606
+ http_res.text, errors.HTTPValidationErrorData
607
+ )
608
+ raise errors.HTTPValidationError(data=response_data)
609
+ if utils.match_response(http_res, "4XX", "*"):
610
+ http_res_text = await utils.stream_to_text_async(http_res)
611
+ raise errors.APIError(
612
+ "API error occurred", http_res.status_code, http_res_text, http_res
613
+ )
614
+ if utils.match_response(http_res, "5XX", "*"):
615
+ http_res_text = await utils.stream_to_text_async(http_res)
616
+ raise errors.APIError(
617
+ "API error occurred", http_res.status_code, http_res_text, http_res
618
+ )
619
+
620
+ content_type = http_res.headers.get("Content-Type")
621
+ http_res_text = await utils.stream_to_text_async(http_res)
622
+ raise errors.APIError(
623
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
624
+ http_res.status_code,
625
+ http_res_text,
626
+ http_res,
627
+ )
628
+
629
+ def transfer(
630
+ self,
631
+ *,
632
+ amount: Union[
633
+ models.TokenTransferRequestAmount,
634
+ models.TokenTransferRequestAmountTypedDict,
635
+ ],
636
+ token: Union[
637
+ models.TokenTransferRequestToken, models.TokenTransferRequestTokenTypedDict
638
+ ],
639
+ to: str,
640
+ chain: models.Chain,
641
+ sender: str,
642
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
643
+ server_url: Optional[str] = None,
644
+ timeout_ms: Optional[int] = None,
645
+ http_headers: Optional[Mapping[str, str]] = None,
646
+ ) -> models.UnsignedTransaction:
647
+ r"""Transfer ETH or ERC20 Tokens
648
+
649
+ Sends native ETH or ERC20 tokens from the sender's address to another address.
650
+
651
+ :param amount: Amount of token to transfer
652
+ :param token: The symbol of the token to transfer..
653
+ :param to: The recipient of the tokens.
654
+ :param chain: The chain to use.
655
+ :param sender: The address of the transaction sender.
656
+ :param retries: Override the default retry configuration for this method
657
+ :param server_url: Override the default server URL for this method
658
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
659
+ :param http_headers: Additional headers to set or replace on requests.
660
+ """
661
+ base_url = None
662
+ url_variables = None
663
+ if timeout_ms is None:
664
+ timeout_ms = self.sdk_configuration.timeout_ms
665
+
666
+ if server_url is not None:
667
+ base_url = server_url
668
+ else:
669
+ base_url = self._get_url(base_url, url_variables)
670
+
671
+ request = models.TokenTransferRequest(
672
+ amount=amount,
673
+ token=token,
674
+ to=to,
675
+ chain=chain,
676
+ sender=sender,
677
+ )
678
+
679
+ req = self._build_request(
680
+ method="POST",
681
+ path="/v0/token/transfer",
682
+ base_url=base_url,
683
+ url_variables=url_variables,
684
+ request=request,
685
+ request_body_required=True,
686
+ request_has_path_params=False,
687
+ request_has_query_params=True,
688
+ user_agent_header="user-agent",
689
+ accept_header_value="application/json",
690
+ http_headers=http_headers,
691
+ security=self.sdk_configuration.security,
692
+ get_serialized_body=lambda: utils.serialize_request_body(
693
+ request, False, False, "json", models.TokenTransferRequest
694
+ ),
695
+ timeout_ms=timeout_ms,
696
+ )
697
+
698
+ if retries == UNSET:
699
+ if self.sdk_configuration.retry_config is not UNSET:
700
+ retries = self.sdk_configuration.retry_config
701
+
702
+ retry_config = None
703
+ if isinstance(retries, utils.RetryConfig):
704
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
705
+
706
+ http_res = self.do_request(
707
+ hook_ctx=HookContext(
708
+ base_url=base_url or "",
709
+ operation_id="token_transfer",
710
+ oauth2_scopes=[],
711
+ security_source=self.sdk_configuration.security,
712
+ ),
713
+ request=req,
714
+ error_status_codes=["422", "4XX", "5XX"],
715
+ retry_config=retry_config,
716
+ )
717
+
718
+ response_data: Any = None
719
+ if utils.match_response(http_res, "200", "application/json"):
720
+ return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
721
+ if utils.match_response(http_res, "422", "application/json"):
722
+ response_data = utils.unmarshal_json(
723
+ http_res.text, errors.HTTPValidationErrorData
724
+ )
725
+ raise errors.HTTPValidationError(data=response_data)
726
+ if utils.match_response(http_res, "4XX", "*"):
727
+ http_res_text = utils.stream_to_text(http_res)
728
+ raise errors.APIError(
729
+ "API error occurred", http_res.status_code, http_res_text, http_res
730
+ )
731
+ if utils.match_response(http_res, "5XX", "*"):
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
+
737
+ content_type = http_res.headers.get("Content-Type")
738
+ http_res_text = utils.stream_to_text(http_res)
739
+ raise errors.APIError(
740
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
741
+ http_res.status_code,
742
+ http_res_text,
743
+ http_res,
744
+ )
745
+
746
+ async def transfer_async(
747
+ self,
748
+ *,
749
+ amount: Union[
750
+ models.TokenTransferRequestAmount,
751
+ models.TokenTransferRequestAmountTypedDict,
752
+ ],
753
+ token: Union[
754
+ models.TokenTransferRequestToken, models.TokenTransferRequestTokenTypedDict
755
+ ],
756
+ to: str,
757
+ chain: models.Chain,
758
+ sender: str,
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"""Transfer ETH or ERC20 Tokens
765
+
766
+ Sends native ETH or ERC20 tokens from the sender's address to another address.
767
+
768
+ :param amount: Amount of token to transfer
769
+ :param token: The symbol of the token to transfer..
770
+ :param to: The recipient of the tokens.
771
+ :param chain: The chain to use.
772
+ :param sender: The address of the transaction 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.TokenTransferRequest(
789
+ amount=amount,
790
+ token=token,
791
+ to=to,
792
+ chain=chain,
793
+ sender=sender,
794
+ )
795
+
796
+ req = self._build_request_async(
797
+ method="POST",
798
+ path="/v0/token/transfer",
799
+ base_url=base_url,
800
+ url_variables=url_variables,
801
+ request=request,
802
+ request_body_required=True,
803
+ request_has_path_params=False,
804
+ request_has_query_params=True,
805
+ user_agent_header="user-agent",
806
+ accept_header_value="application/json",
807
+ http_headers=http_headers,
808
+ security=self.sdk_configuration.security,
809
+ get_serialized_body=lambda: utils.serialize_request_body(
810
+ request, False, False, "json", models.TokenTransferRequest
811
+ ),
812
+ timeout_ms=timeout_ms,
813
+ )
814
+
815
+ if retries == UNSET:
816
+ if self.sdk_configuration.retry_config is not UNSET:
817
+ retries = self.sdk_configuration.retry_config
818
+
819
+ retry_config = None
820
+ if isinstance(retries, utils.RetryConfig):
821
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
822
+
823
+ http_res = await self.do_request_async(
824
+ hook_ctx=HookContext(
825
+ base_url=base_url or "",
826
+ operation_id="token_transfer",
827
+ oauth2_scopes=[],
828
+ security_source=self.sdk_configuration.security,
829
+ ),
830
+ request=req,
831
+ error_status_codes=["422", "4XX", "5XX"],
832
+ retry_config=retry_config,
833
+ )
834
+
835
+ response_data: Any = None
836
+ if utils.match_response(http_res, "200", "application/json"):
837
+ return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
838
+ if utils.match_response(http_res, "422", "application/json"):
839
+ response_data = utils.unmarshal_json(
840
+ http_res.text, errors.HTTPValidationErrorData
841
+ )
842
+ raise errors.HTTPValidationError(data=response_data)
843
+ if utils.match_response(http_res, "4XX", "*"):
844
+ http_res_text = await utils.stream_to_text_async(http_res)
845
+ raise errors.APIError(
846
+ "API error occurred", http_res.status_code, http_res_text, http_res
847
+ )
848
+ if utils.match_response(http_res, "5XX", "*"):
849
+ http_res_text = await utils.stream_to_text_async(http_res)
850
+ raise errors.APIError(
851
+ "API error occurred", http_res.status_code, http_res_text, http_res
852
+ )
853
+
854
+ content_type = http_res.headers.get("Content-Type")
855
+ http_res_text = await utils.stream_to_text_async(http_res)
856
+ raise errors.APIError(
857
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
858
+ http_res.status_code,
859
+ http_res_text,
860
+ http_res,
861
+ )