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.
- compass_api_sdk/__init__.py +17 -0
- compass_api_sdk/_hooks/__init__.py +5 -0
- compass_api_sdk/_hooks/registration.py +13 -0
- compass_api_sdk/_hooks/sdkhooks.py +76 -0
- compass_api_sdk/_hooks/types.py +106 -0
- compass_api_sdk/_version.py +15 -0
- compass_api_sdk/aave_v3.py +1903 -0
- compass_api_sdk/aerodrome_slipstream.py +1875 -0
- compass_api_sdk/basesdk.py +362 -0
- compass_api_sdk/errors/__init__.py +7 -0
- compass_api_sdk/errors/apierror.py +22 -0
- compass_api_sdk/errors/httpvalidationerror.py +21 -0
- compass_api_sdk/httpclient.py +136 -0
- compass_api_sdk/models/__init__.py +777 -0
- compass_api_sdk/models/aave_liquidity_changeop.py +108 -0
- compass_api_sdk/models/aave_token_priceop.py +98 -0
- compass_api_sdk/models/aave_user_position_per_tokenop.py +104 -0
- compass_api_sdk/models/aave_user_position_summaryop.py +35 -0
- compass_api_sdk/models/aaveborrowrequest.py +105 -0
- compass_api_sdk/models/aaveliquiditychangeresponse.py +26 -0
- compass_api_sdk/models/aaverepayrequest.py +105 -0
- compass_api_sdk/models/aavesupplyrequest.py +93 -0
- compass_api_sdk/models/aavetokenpriceresponse.py +15 -0
- compass_api_sdk/models/aaveuserpositionpertokenresponse.py +73 -0
- compass_api_sdk/models/aaveuserpositionsummaryresponse.py +50 -0
- compass_api_sdk/models/aavewithdrawrequest.py +58 -0
- compass_api_sdk/models/aerodrome_slipstream_liquidity_provision_positionsop.py +35 -0
- compass_api_sdk/models/aerodrome_slipstream_pool_priceop.py +173 -0
- compass_api_sdk/models/aerodromelppositionsresponse.py +21 -0
- compass_api_sdk/models/aerodromeposition.py +70 -0
- compass_api_sdk/models/aerodromeslipstreambuyexactlyrequest.py +92 -0
- compass_api_sdk/models/aerodromeslipstreamincreaseliquidityprovisionrequest.py +109 -0
- compass_api_sdk/models/aerodromeslipstreammintliquidityprovisionrequest.py +186 -0
- compass_api_sdk/models/aerodromeslipstreampoolpriceresponse.py +57 -0
- compass_api_sdk/models/aerodromeslipstreamsellexactlyrequest.py +96 -0
- compass_api_sdk/models/aerodromeslipstreamwithdrawliquidityprovisionrequest.py +50 -0
- compass_api_sdk/models/allowanceinforesponse.py +48 -0
- compass_api_sdk/models/balanceinforesponse.py +43 -0
- compass_api_sdk/models/chain.py +12 -0
- compass_api_sdk/models/chaininfo.py +53 -0
- compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_markets_asset.py +22 -0
- compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_vaults_asset.py +23 -0
- compass_api_sdk/models/ensnameinforesponse.py +24 -0
- compass_api_sdk/models/feeenum.py +16 -0
- compass_api_sdk/models/generic_allowanceop.py +121 -0
- compass_api_sdk/models/generic_balanceop.py +104 -0
- compass_api_sdk/models/generic_ensop.py +35 -0
- compass_api_sdk/models/generic_portfolioop.py +35 -0
- compass_api_sdk/models/generic_price_usdop.py +98 -0
- compass_api_sdk/models/generic_supported_tokensop.py +29 -0
- compass_api_sdk/models/generic_visualize_portfolioop.py +35 -0
- compass_api_sdk/models/image.py +15 -0
- compass_api_sdk/models/increaseallowancerequest.py +77 -0
- compass_api_sdk/models/interestratemode.py +14 -0
- compass_api_sdk/models/marketstate.py +35 -0
- compass_api_sdk/models/morpho_market_positionop.py +39 -0
- compass_api_sdk/models/morpho_marketsop.py +78 -0
- compass_api_sdk/models/morpho_vault_positionop.py +39 -0
- compass_api_sdk/models/morpho_vaultsop.py +72 -0
- compass_api_sdk/models/morphoborrowrequest.py +91 -0
- compass_api_sdk/models/morphocheckmarketpositionresponse.py +23 -0
- compass_api_sdk/models/morphocheckvaultpositionresponse.py +20 -0
- compass_api_sdk/models/morphodepositrequest.py +86 -0
- compass_api_sdk/models/morphogetmarketsresponse.py +17 -0
- compass_api_sdk/models/morphogetvaultsresponse.py +17 -0
- compass_api_sdk/models/morphomarket.py +80 -0
- compass_api_sdk/models/morphorepayrequest.py +79 -0
- compass_api_sdk/models/morphosetvaultallowancerequest.py +44 -0
- compass_api_sdk/models/morphosupplycollateralrequest.py +91 -0
- compass_api_sdk/models/morphovault.py +47 -0
- compass_api_sdk/models/morphowithdrawcollateralrequest.py +91 -0
- compass_api_sdk/models/morphowithdrawrequest.py +74 -0
- compass_api_sdk/models/portfolio.py +22 -0
- compass_api_sdk/models/priceresponse.py +15 -0
- compass_api_sdk/models/security.py +24 -0
- compass_api_sdk/models/token_addressop.py +98 -0
- compass_api_sdk/models/token_balanceop.py +49 -0
- compass_api_sdk/models/token_enum.py +57 -0
- compass_api_sdk/models/token_priceop.py +97 -0
- compass_api_sdk/models/tokenaddressresponse.py +15 -0
- compass_api_sdk/models/tokenbalance.py +49 -0
- compass_api_sdk/models/tokenbalanceresponse.py +44 -0
- compass_api_sdk/models/tokeninfo.py +17 -0
- compass_api_sdk/models/tokenpriceresponse.py +15 -0
- compass_api_sdk/models/tokentransferrequest.py +66 -0
- compass_api_sdk/models/transfererc20request.py +62 -0
- compass_api_sdk/models/transferethrequest.py +46 -0
- compass_api_sdk/models/uniswap_liquidity_provision_in_rangeop.py +34 -0
- compass_api_sdk/models/uniswap_liquidity_provision_positionsop.py +35 -0
- compass_api_sdk/models/uniswap_pool_priceop.py +193 -0
- compass_api_sdk/models/uniswap_quote_buy_exactlyop.py +209 -0
- compass_api_sdk/models/uniswap_quote_sell_exactlyop.py +209 -0
- compass_api_sdk/models/uniswapbuyexactlyrequest.py +104 -0
- compass_api_sdk/models/uniswapbuyquoteinforesponse.py +20 -0
- compass_api_sdk/models/uniswapcheckinrangeresponse.py +15 -0
- compass_api_sdk/models/uniswapincreaseliquidityprovisionrequest.py +99 -0
- compass_api_sdk/models/uniswaplppositionsinforesponse.py +24 -0
- compass_api_sdk/models/uniswapmintliquidityprovisionrequest.py +185 -0
- compass_api_sdk/models/uniswappoolpriceresponse.py +47 -0
- compass_api_sdk/models/uniswappositionssolidityresponse.py +46 -0
- compass_api_sdk/models/uniswapsellexactlyrequest.py +104 -0
- compass_api_sdk/models/uniswapsellquoteinforesponse.py +20 -0
- compass_api_sdk/models/uniswapwithdrawliquidityprovisionrequest.py +51 -0
- compass_api_sdk/models/unsignedtransaction.py +58 -0
- compass_api_sdk/models/unwrapwethrequest.py +41 -0
- compass_api_sdk/models/validationerror.py +26 -0
- compass_api_sdk/models/vaultstate.py +32 -0
- compass_api_sdk/models/weeklyapys.py +23 -0
- compass_api_sdk/models/wrapethrequest.py +41 -0
- compass_api_sdk/morpho.py +2577 -0
- compass_api_sdk/py.typed +1 -0
- compass_api_sdk/sdk.py +155 -0
- compass_api_sdk/sdkconfiguration.py +56 -0
- compass_api_sdk/token_sdk.py +861 -0
- compass_api_sdk/types/__init__.py +21 -0
- compass_api_sdk/types/basemodel.py +39 -0
- compass_api_sdk/uniswap_v3.py +2551 -0
- compass_api_sdk/universal.py +2625 -0
- compass_api_sdk/utils/__init__.py +100 -0
- compass_api_sdk/utils/annotations.py +55 -0
- compass_api_sdk/utils/datetimes.py +23 -0
- compass_api_sdk/utils/enums.py +74 -0
- compass_api_sdk/utils/eventstreaming.py +238 -0
- compass_api_sdk/utils/forms.py +202 -0
- compass_api_sdk/utils/headers.py +136 -0
- compass_api_sdk/utils/logger.py +22 -0
- compass_api_sdk/utils/metadata.py +118 -0
- compass_api_sdk/utils/queryparams.py +205 -0
- compass_api_sdk/utils/requestbodies.py +66 -0
- compass_api_sdk/utils/retries.py +217 -0
- compass_api_sdk/utils/security.py +174 -0
- compass_api_sdk/utils/serializers.py +248 -0
- compass_api_sdk/utils/url.py +155 -0
- compass_api_sdk/utils/values.py +137 -0
- compass_api_sdk-0.0.1.dist-info/METADATA +534 -0
- compass_api_sdk-0.0.1.dist-info/RECORD +137 -0
- compass_api_sdk-0.0.1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,2625 @@
|
|
|
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 Universal(BaseSDK):
|
|
11
|
+
def portfolio(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
chain: Optional[
|
|
15
|
+
models.GenericPortfolioChain
|
|
16
|
+
] = models.GenericPortfolioChain.ARBITRUM_MAINNET,
|
|
17
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
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.Portfolio:
|
|
23
|
+
r"""List user portfolio
|
|
24
|
+
|
|
25
|
+
Fetch the detailed portfolio of a specific wallet address on a given blockchain.
|
|
26
|
+
|
|
27
|
+
This includes the total value of the portfolio in USD and a breakdown of token
|
|
28
|
+
balances, including their respective values and quantities.
|
|
29
|
+
|
|
30
|
+
:param chain: The chain to use.
|
|
31
|
+
:param user:
|
|
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.GenericPortfolioRequest(
|
|
48
|
+
chain=chain,
|
|
49
|
+
user=user,
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
req = self._build_request(
|
|
53
|
+
method="GET",
|
|
54
|
+
path="/v0/generic/portfolio/get",
|
|
55
|
+
base_url=base_url,
|
|
56
|
+
url_variables=url_variables,
|
|
57
|
+
request=request,
|
|
58
|
+
request_body_required=False,
|
|
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
|
+
timeout_ms=timeout_ms,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if retries == UNSET:
|
|
69
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
70
|
+
retries = self.sdk_configuration.retry_config
|
|
71
|
+
|
|
72
|
+
retry_config = None
|
|
73
|
+
if isinstance(retries, utils.RetryConfig):
|
|
74
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
75
|
+
|
|
76
|
+
http_res = self.do_request(
|
|
77
|
+
hook_ctx=HookContext(
|
|
78
|
+
base_url=base_url or "",
|
|
79
|
+
operation_id="generic_portfolio",
|
|
80
|
+
oauth2_scopes=[],
|
|
81
|
+
security_source=self.sdk_configuration.security,
|
|
82
|
+
),
|
|
83
|
+
request=req,
|
|
84
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
85
|
+
retry_config=retry_config,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
response_data: Any = None
|
|
89
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
90
|
+
return utils.unmarshal_json(http_res.text, models.Portfolio)
|
|
91
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
92
|
+
response_data = utils.unmarshal_json(
|
|
93
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
94
|
+
)
|
|
95
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
96
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
97
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
98
|
+
raise errors.APIError(
|
|
99
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
100
|
+
)
|
|
101
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
102
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
103
|
+
raise errors.APIError(
|
|
104
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
content_type = http_res.headers.get("Content-Type")
|
|
108
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
109
|
+
raise errors.APIError(
|
|
110
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
111
|
+
http_res.status_code,
|
|
112
|
+
http_res_text,
|
|
113
|
+
http_res,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
async def portfolio_async(
|
|
117
|
+
self,
|
|
118
|
+
*,
|
|
119
|
+
chain: Optional[
|
|
120
|
+
models.GenericPortfolioChain
|
|
121
|
+
] = models.GenericPortfolioChain.ARBITRUM_MAINNET,
|
|
122
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
123
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
124
|
+
server_url: Optional[str] = None,
|
|
125
|
+
timeout_ms: Optional[int] = None,
|
|
126
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
127
|
+
) -> models.Portfolio:
|
|
128
|
+
r"""List user portfolio
|
|
129
|
+
|
|
130
|
+
Fetch the detailed portfolio of a specific wallet address on a given blockchain.
|
|
131
|
+
|
|
132
|
+
This includes the total value of the portfolio in USD and a breakdown of token
|
|
133
|
+
balances, including their respective values and quantities.
|
|
134
|
+
|
|
135
|
+
:param chain: The chain to use.
|
|
136
|
+
:param user:
|
|
137
|
+
:param retries: Override the default retry configuration for this method
|
|
138
|
+
:param server_url: Override the default server URL for this method
|
|
139
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
140
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
141
|
+
"""
|
|
142
|
+
base_url = None
|
|
143
|
+
url_variables = None
|
|
144
|
+
if timeout_ms is None:
|
|
145
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
146
|
+
|
|
147
|
+
if server_url is not None:
|
|
148
|
+
base_url = server_url
|
|
149
|
+
else:
|
|
150
|
+
base_url = self._get_url(base_url, url_variables)
|
|
151
|
+
|
|
152
|
+
request = models.GenericPortfolioRequest(
|
|
153
|
+
chain=chain,
|
|
154
|
+
user=user,
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
req = self._build_request_async(
|
|
158
|
+
method="GET",
|
|
159
|
+
path="/v0/generic/portfolio/get",
|
|
160
|
+
base_url=base_url,
|
|
161
|
+
url_variables=url_variables,
|
|
162
|
+
request=request,
|
|
163
|
+
request_body_required=False,
|
|
164
|
+
request_has_path_params=False,
|
|
165
|
+
request_has_query_params=True,
|
|
166
|
+
user_agent_header="user-agent",
|
|
167
|
+
accept_header_value="application/json",
|
|
168
|
+
http_headers=http_headers,
|
|
169
|
+
security=self.sdk_configuration.security,
|
|
170
|
+
timeout_ms=timeout_ms,
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
if retries == UNSET:
|
|
174
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
175
|
+
retries = self.sdk_configuration.retry_config
|
|
176
|
+
|
|
177
|
+
retry_config = None
|
|
178
|
+
if isinstance(retries, utils.RetryConfig):
|
|
179
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
180
|
+
|
|
181
|
+
http_res = await self.do_request_async(
|
|
182
|
+
hook_ctx=HookContext(
|
|
183
|
+
base_url=base_url or "",
|
|
184
|
+
operation_id="generic_portfolio",
|
|
185
|
+
oauth2_scopes=[],
|
|
186
|
+
security_source=self.sdk_configuration.security,
|
|
187
|
+
),
|
|
188
|
+
request=req,
|
|
189
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
190
|
+
retry_config=retry_config,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
response_data: Any = None
|
|
194
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
195
|
+
return utils.unmarshal_json(http_res.text, models.Portfolio)
|
|
196
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
197
|
+
response_data = utils.unmarshal_json(
|
|
198
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
199
|
+
)
|
|
200
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
201
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
202
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
203
|
+
raise errors.APIError(
|
|
204
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
205
|
+
)
|
|
206
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
207
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
208
|
+
raise errors.APIError(
|
|
209
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
content_type = http_res.headers.get("Content-Type")
|
|
213
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
214
|
+
raise errors.APIError(
|
|
215
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
216
|
+
http_res.status_code,
|
|
217
|
+
http_res_text,
|
|
218
|
+
http_res,
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
def visualize_portfolio(
|
|
222
|
+
self,
|
|
223
|
+
*,
|
|
224
|
+
chain: Optional[
|
|
225
|
+
models.GenericVisualizePortfolioChain
|
|
226
|
+
] = models.GenericVisualizePortfolioChain.ARBITRUM_MAINNET,
|
|
227
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
228
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
229
|
+
server_url: Optional[str] = None,
|
|
230
|
+
timeout_ms: Optional[int] = None,
|
|
231
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
232
|
+
) -> models.Image:
|
|
233
|
+
r"""Visualize user portfolio
|
|
234
|
+
|
|
235
|
+
Generate a visual representation of the token portfolio for a wallet address.
|
|
236
|
+
|
|
237
|
+
The response is an SVG image of a pie chart depicting the relative distribution of
|
|
238
|
+
tokens held, colored and labeled with token symbols, percentages and token values in
|
|
239
|
+
USD.
|
|
240
|
+
|
|
241
|
+
:param chain: The chain to use.
|
|
242
|
+
:param user:
|
|
243
|
+
:param retries: Override the default retry configuration for this method
|
|
244
|
+
:param server_url: Override the default server URL for this method
|
|
245
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
246
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
247
|
+
"""
|
|
248
|
+
base_url = None
|
|
249
|
+
url_variables = None
|
|
250
|
+
if timeout_ms is None:
|
|
251
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
252
|
+
|
|
253
|
+
if server_url is not None:
|
|
254
|
+
base_url = server_url
|
|
255
|
+
else:
|
|
256
|
+
base_url = self._get_url(base_url, url_variables)
|
|
257
|
+
|
|
258
|
+
request = models.GenericVisualizePortfolioRequest(
|
|
259
|
+
chain=chain,
|
|
260
|
+
user=user,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
req = self._build_request(
|
|
264
|
+
method="GET",
|
|
265
|
+
path="/v0/generic/visualize_portfolio/get",
|
|
266
|
+
base_url=base_url,
|
|
267
|
+
url_variables=url_variables,
|
|
268
|
+
request=request,
|
|
269
|
+
request_body_required=False,
|
|
270
|
+
request_has_path_params=False,
|
|
271
|
+
request_has_query_params=True,
|
|
272
|
+
user_agent_header="user-agent",
|
|
273
|
+
accept_header_value="application/json",
|
|
274
|
+
http_headers=http_headers,
|
|
275
|
+
security=self.sdk_configuration.security,
|
|
276
|
+
timeout_ms=timeout_ms,
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
if retries == UNSET:
|
|
280
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
281
|
+
retries = self.sdk_configuration.retry_config
|
|
282
|
+
|
|
283
|
+
retry_config = None
|
|
284
|
+
if isinstance(retries, utils.RetryConfig):
|
|
285
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
286
|
+
|
|
287
|
+
http_res = self.do_request(
|
|
288
|
+
hook_ctx=HookContext(
|
|
289
|
+
base_url=base_url or "",
|
|
290
|
+
operation_id="generic_visualize_portfolio",
|
|
291
|
+
oauth2_scopes=[],
|
|
292
|
+
security_source=self.sdk_configuration.security,
|
|
293
|
+
),
|
|
294
|
+
request=req,
|
|
295
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
296
|
+
retry_config=retry_config,
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
response_data: Any = None
|
|
300
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
301
|
+
return utils.unmarshal_json(http_res.text, models.Image)
|
|
302
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
303
|
+
response_data = utils.unmarshal_json(
|
|
304
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
305
|
+
)
|
|
306
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
307
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
308
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
309
|
+
raise errors.APIError(
|
|
310
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
311
|
+
)
|
|
312
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
313
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
314
|
+
raise errors.APIError(
|
|
315
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
content_type = http_res.headers.get("Content-Type")
|
|
319
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
320
|
+
raise errors.APIError(
|
|
321
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
322
|
+
http_res.status_code,
|
|
323
|
+
http_res_text,
|
|
324
|
+
http_res,
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
async def visualize_portfolio_async(
|
|
328
|
+
self,
|
|
329
|
+
*,
|
|
330
|
+
chain: Optional[
|
|
331
|
+
models.GenericVisualizePortfolioChain
|
|
332
|
+
] = models.GenericVisualizePortfolioChain.ARBITRUM_MAINNET,
|
|
333
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
334
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
335
|
+
server_url: Optional[str] = None,
|
|
336
|
+
timeout_ms: Optional[int] = None,
|
|
337
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
338
|
+
) -> models.Image:
|
|
339
|
+
r"""Visualize user portfolio
|
|
340
|
+
|
|
341
|
+
Generate a visual representation of the token portfolio for a wallet address.
|
|
342
|
+
|
|
343
|
+
The response is an SVG image of a pie chart depicting the relative distribution of
|
|
344
|
+
tokens held, colored and labeled with token symbols, percentages and token values in
|
|
345
|
+
USD.
|
|
346
|
+
|
|
347
|
+
:param chain: The chain to use.
|
|
348
|
+
:param user:
|
|
349
|
+
:param retries: Override the default retry configuration for this method
|
|
350
|
+
:param server_url: Override the default server URL for this method
|
|
351
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
352
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
353
|
+
"""
|
|
354
|
+
base_url = None
|
|
355
|
+
url_variables = None
|
|
356
|
+
if timeout_ms is None:
|
|
357
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
358
|
+
|
|
359
|
+
if server_url is not None:
|
|
360
|
+
base_url = server_url
|
|
361
|
+
else:
|
|
362
|
+
base_url = self._get_url(base_url, url_variables)
|
|
363
|
+
|
|
364
|
+
request = models.GenericVisualizePortfolioRequest(
|
|
365
|
+
chain=chain,
|
|
366
|
+
user=user,
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
req = self._build_request_async(
|
|
370
|
+
method="GET",
|
|
371
|
+
path="/v0/generic/visualize_portfolio/get",
|
|
372
|
+
base_url=base_url,
|
|
373
|
+
url_variables=url_variables,
|
|
374
|
+
request=request,
|
|
375
|
+
request_body_required=False,
|
|
376
|
+
request_has_path_params=False,
|
|
377
|
+
request_has_query_params=True,
|
|
378
|
+
user_agent_header="user-agent",
|
|
379
|
+
accept_header_value="application/json",
|
|
380
|
+
http_headers=http_headers,
|
|
381
|
+
security=self.sdk_configuration.security,
|
|
382
|
+
timeout_ms=timeout_ms,
|
|
383
|
+
)
|
|
384
|
+
|
|
385
|
+
if retries == UNSET:
|
|
386
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
387
|
+
retries = self.sdk_configuration.retry_config
|
|
388
|
+
|
|
389
|
+
retry_config = None
|
|
390
|
+
if isinstance(retries, utils.RetryConfig):
|
|
391
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
392
|
+
|
|
393
|
+
http_res = await self.do_request_async(
|
|
394
|
+
hook_ctx=HookContext(
|
|
395
|
+
base_url=base_url or "",
|
|
396
|
+
operation_id="generic_visualize_portfolio",
|
|
397
|
+
oauth2_scopes=[],
|
|
398
|
+
security_source=self.sdk_configuration.security,
|
|
399
|
+
),
|
|
400
|
+
request=req,
|
|
401
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
402
|
+
retry_config=retry_config,
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
response_data: Any = None
|
|
406
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
407
|
+
return utils.unmarshal_json(http_res.text, models.Image)
|
|
408
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
409
|
+
response_data = utils.unmarshal_json(
|
|
410
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
411
|
+
)
|
|
412
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
413
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
414
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
415
|
+
raise errors.APIError(
|
|
416
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
417
|
+
)
|
|
418
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
419
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
420
|
+
raise errors.APIError(
|
|
421
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
content_type = http_res.headers.get("Content-Type")
|
|
425
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
426
|
+
raise errors.APIError(
|
|
427
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
428
|
+
http_res.status_code,
|
|
429
|
+
http_res_text,
|
|
430
|
+
http_res,
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
def price_usd(
|
|
434
|
+
self,
|
|
435
|
+
*,
|
|
436
|
+
chain: Optional[
|
|
437
|
+
models.GenericPriceUsdChain
|
|
438
|
+
] = models.GenericPriceUsdChain.ARBITRUM_MAINNET,
|
|
439
|
+
token: Optional[models.GenericPriceUsdToken] = models.GenericPriceUsdToken.WBTC,
|
|
440
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
441
|
+
server_url: Optional[str] = None,
|
|
442
|
+
timeout_ms: Optional[int] = None,
|
|
443
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
444
|
+
) -> models.PriceResponse:
|
|
445
|
+
r"""Token price
|
|
446
|
+
|
|
447
|
+
Retrieves the price of the specified token relative to USD using Chainlink's on-
|
|
448
|
+
chain price feeds.
|
|
449
|
+
|
|
450
|
+
Chainlink is a decentralized oracle that aggregates price data from off-chain
|
|
451
|
+
sources. This ensures the price is tamper-resistant but the price might be stale
|
|
452
|
+
with the update frequency of the oracle.
|
|
453
|
+
|
|
454
|
+
:param chain: The chain to use.
|
|
455
|
+
: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.
|
|
456
|
+
:param retries: Override the default retry configuration for this method
|
|
457
|
+
:param server_url: Override the default server URL for this method
|
|
458
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
459
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
460
|
+
"""
|
|
461
|
+
base_url = None
|
|
462
|
+
url_variables = None
|
|
463
|
+
if timeout_ms is None:
|
|
464
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
465
|
+
|
|
466
|
+
if server_url is not None:
|
|
467
|
+
base_url = server_url
|
|
468
|
+
else:
|
|
469
|
+
base_url = self._get_url(base_url, url_variables)
|
|
470
|
+
|
|
471
|
+
request = models.GenericPriceUsdRequest(
|
|
472
|
+
chain=chain,
|
|
473
|
+
token=token,
|
|
474
|
+
)
|
|
475
|
+
|
|
476
|
+
req = self._build_request(
|
|
477
|
+
method="GET",
|
|
478
|
+
path="/v0/generic/price/usd/get",
|
|
479
|
+
base_url=base_url,
|
|
480
|
+
url_variables=url_variables,
|
|
481
|
+
request=request,
|
|
482
|
+
request_body_required=False,
|
|
483
|
+
request_has_path_params=False,
|
|
484
|
+
request_has_query_params=True,
|
|
485
|
+
user_agent_header="user-agent",
|
|
486
|
+
accept_header_value="application/json",
|
|
487
|
+
http_headers=http_headers,
|
|
488
|
+
security=self.sdk_configuration.security,
|
|
489
|
+
timeout_ms=timeout_ms,
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
if retries == UNSET:
|
|
493
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
494
|
+
retries = self.sdk_configuration.retry_config
|
|
495
|
+
|
|
496
|
+
retry_config = None
|
|
497
|
+
if isinstance(retries, utils.RetryConfig):
|
|
498
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
499
|
+
|
|
500
|
+
http_res = self.do_request(
|
|
501
|
+
hook_ctx=HookContext(
|
|
502
|
+
base_url=base_url or "",
|
|
503
|
+
operation_id="generic_price_usd",
|
|
504
|
+
oauth2_scopes=[],
|
|
505
|
+
security_source=self.sdk_configuration.security,
|
|
506
|
+
),
|
|
507
|
+
request=req,
|
|
508
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
509
|
+
retry_config=retry_config,
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
response_data: Any = None
|
|
513
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
514
|
+
return utils.unmarshal_json(http_res.text, models.PriceResponse)
|
|
515
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
516
|
+
response_data = utils.unmarshal_json(
|
|
517
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
518
|
+
)
|
|
519
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
520
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
521
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
522
|
+
raise errors.APIError(
|
|
523
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
524
|
+
)
|
|
525
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
526
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
527
|
+
raise errors.APIError(
|
|
528
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
529
|
+
)
|
|
530
|
+
|
|
531
|
+
content_type = http_res.headers.get("Content-Type")
|
|
532
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
533
|
+
raise errors.APIError(
|
|
534
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
535
|
+
http_res.status_code,
|
|
536
|
+
http_res_text,
|
|
537
|
+
http_res,
|
|
538
|
+
)
|
|
539
|
+
|
|
540
|
+
async def price_usd_async(
|
|
541
|
+
self,
|
|
542
|
+
*,
|
|
543
|
+
chain: Optional[
|
|
544
|
+
models.GenericPriceUsdChain
|
|
545
|
+
] = models.GenericPriceUsdChain.ARBITRUM_MAINNET,
|
|
546
|
+
token: Optional[models.GenericPriceUsdToken] = models.GenericPriceUsdToken.WBTC,
|
|
547
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
548
|
+
server_url: Optional[str] = None,
|
|
549
|
+
timeout_ms: Optional[int] = None,
|
|
550
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
551
|
+
) -> models.PriceResponse:
|
|
552
|
+
r"""Token price
|
|
553
|
+
|
|
554
|
+
Retrieves the price of the specified token relative to USD using Chainlink's on-
|
|
555
|
+
chain price feeds.
|
|
556
|
+
|
|
557
|
+
Chainlink is a decentralized oracle that aggregates price data from off-chain
|
|
558
|
+
sources. This ensures the price is tamper-resistant but the price might be stale
|
|
559
|
+
with the update frequency of the oracle.
|
|
560
|
+
|
|
561
|
+
:param chain: The chain to use.
|
|
562
|
+
: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.
|
|
563
|
+
:param retries: Override the default retry configuration for this method
|
|
564
|
+
:param server_url: Override the default server URL for this method
|
|
565
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
566
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
567
|
+
"""
|
|
568
|
+
base_url = None
|
|
569
|
+
url_variables = None
|
|
570
|
+
if timeout_ms is None:
|
|
571
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
572
|
+
|
|
573
|
+
if server_url is not None:
|
|
574
|
+
base_url = server_url
|
|
575
|
+
else:
|
|
576
|
+
base_url = self._get_url(base_url, url_variables)
|
|
577
|
+
|
|
578
|
+
request = models.GenericPriceUsdRequest(
|
|
579
|
+
chain=chain,
|
|
580
|
+
token=token,
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
req = self._build_request_async(
|
|
584
|
+
method="GET",
|
|
585
|
+
path="/v0/generic/price/usd/get",
|
|
586
|
+
base_url=base_url,
|
|
587
|
+
url_variables=url_variables,
|
|
588
|
+
request=request,
|
|
589
|
+
request_body_required=False,
|
|
590
|
+
request_has_path_params=False,
|
|
591
|
+
request_has_query_params=True,
|
|
592
|
+
user_agent_header="user-agent",
|
|
593
|
+
accept_header_value="application/json",
|
|
594
|
+
http_headers=http_headers,
|
|
595
|
+
security=self.sdk_configuration.security,
|
|
596
|
+
timeout_ms=timeout_ms,
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
if retries == UNSET:
|
|
600
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
601
|
+
retries = self.sdk_configuration.retry_config
|
|
602
|
+
|
|
603
|
+
retry_config = None
|
|
604
|
+
if isinstance(retries, utils.RetryConfig):
|
|
605
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
606
|
+
|
|
607
|
+
http_res = await self.do_request_async(
|
|
608
|
+
hook_ctx=HookContext(
|
|
609
|
+
base_url=base_url or "",
|
|
610
|
+
operation_id="generic_price_usd",
|
|
611
|
+
oauth2_scopes=[],
|
|
612
|
+
security_source=self.sdk_configuration.security,
|
|
613
|
+
),
|
|
614
|
+
request=req,
|
|
615
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
616
|
+
retry_config=retry_config,
|
|
617
|
+
)
|
|
618
|
+
|
|
619
|
+
response_data: Any = None
|
|
620
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
621
|
+
return utils.unmarshal_json(http_res.text, models.PriceResponse)
|
|
622
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
623
|
+
response_data = utils.unmarshal_json(
|
|
624
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
625
|
+
)
|
|
626
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
627
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
628
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
629
|
+
raise errors.APIError(
|
|
630
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
631
|
+
)
|
|
632
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
633
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
634
|
+
raise errors.APIError(
|
|
635
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
636
|
+
)
|
|
637
|
+
|
|
638
|
+
content_type = http_res.headers.get("Content-Type")
|
|
639
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
640
|
+
raise errors.APIError(
|
|
641
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
642
|
+
http_res.status_code,
|
|
643
|
+
http_res_text,
|
|
644
|
+
http_res,
|
|
645
|
+
)
|
|
646
|
+
|
|
647
|
+
def supported_tokens(
|
|
648
|
+
self,
|
|
649
|
+
*,
|
|
650
|
+
chain: Optional[
|
|
651
|
+
models.GenericSupportedTokensChain
|
|
652
|
+
] = models.GenericSupportedTokensChain.ARBITRUM_MAINNET,
|
|
653
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
654
|
+
server_url: Optional[str] = None,
|
|
655
|
+
timeout_ms: Optional[int] = None,
|
|
656
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
657
|
+
) -> models.TokenInfo:
|
|
658
|
+
r"""List supported tokens
|
|
659
|
+
|
|
660
|
+
Get the list of supported tokens on a chain by the Compass API.
|
|
661
|
+
|
|
662
|
+
:param chain: The chain to use.
|
|
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.GenericSupportedTokensRequest(
|
|
679
|
+
chain=chain,
|
|
680
|
+
)
|
|
681
|
+
|
|
682
|
+
req = self._build_request(
|
|
683
|
+
method="GET",
|
|
684
|
+
path="/v0/generic/supported_tokens/get",
|
|
685
|
+
base_url=base_url,
|
|
686
|
+
url_variables=url_variables,
|
|
687
|
+
request=request,
|
|
688
|
+
request_body_required=False,
|
|
689
|
+
request_has_path_params=False,
|
|
690
|
+
request_has_query_params=True,
|
|
691
|
+
user_agent_header="user-agent",
|
|
692
|
+
accept_header_value="application/json",
|
|
693
|
+
http_headers=http_headers,
|
|
694
|
+
security=self.sdk_configuration.security,
|
|
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="generic_supported_tokens",
|
|
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.TokenInfo)
|
|
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 supported_tokens_async(
|
|
747
|
+
self,
|
|
748
|
+
*,
|
|
749
|
+
chain: Optional[
|
|
750
|
+
models.GenericSupportedTokensChain
|
|
751
|
+
] = models.GenericSupportedTokensChain.ARBITRUM_MAINNET,
|
|
752
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
753
|
+
server_url: Optional[str] = None,
|
|
754
|
+
timeout_ms: Optional[int] = None,
|
|
755
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
756
|
+
) -> models.TokenInfo:
|
|
757
|
+
r"""List supported tokens
|
|
758
|
+
|
|
759
|
+
Get the list of supported tokens on a chain by the Compass API.
|
|
760
|
+
|
|
761
|
+
:param chain: The chain to use.
|
|
762
|
+
:param retries: Override the default retry configuration for this method
|
|
763
|
+
:param server_url: Override the default server URL for this method
|
|
764
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
765
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
766
|
+
"""
|
|
767
|
+
base_url = None
|
|
768
|
+
url_variables = None
|
|
769
|
+
if timeout_ms is None:
|
|
770
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
771
|
+
|
|
772
|
+
if server_url is not None:
|
|
773
|
+
base_url = server_url
|
|
774
|
+
else:
|
|
775
|
+
base_url = self._get_url(base_url, url_variables)
|
|
776
|
+
|
|
777
|
+
request = models.GenericSupportedTokensRequest(
|
|
778
|
+
chain=chain,
|
|
779
|
+
)
|
|
780
|
+
|
|
781
|
+
req = self._build_request_async(
|
|
782
|
+
method="GET",
|
|
783
|
+
path="/v0/generic/supported_tokens/get",
|
|
784
|
+
base_url=base_url,
|
|
785
|
+
url_variables=url_variables,
|
|
786
|
+
request=request,
|
|
787
|
+
request_body_required=False,
|
|
788
|
+
request_has_path_params=False,
|
|
789
|
+
request_has_query_params=True,
|
|
790
|
+
user_agent_header="user-agent",
|
|
791
|
+
accept_header_value="application/json",
|
|
792
|
+
http_headers=http_headers,
|
|
793
|
+
security=self.sdk_configuration.security,
|
|
794
|
+
timeout_ms=timeout_ms,
|
|
795
|
+
)
|
|
796
|
+
|
|
797
|
+
if retries == UNSET:
|
|
798
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
799
|
+
retries = self.sdk_configuration.retry_config
|
|
800
|
+
|
|
801
|
+
retry_config = None
|
|
802
|
+
if isinstance(retries, utils.RetryConfig):
|
|
803
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
804
|
+
|
|
805
|
+
http_res = await self.do_request_async(
|
|
806
|
+
hook_ctx=HookContext(
|
|
807
|
+
base_url=base_url or "",
|
|
808
|
+
operation_id="generic_supported_tokens",
|
|
809
|
+
oauth2_scopes=[],
|
|
810
|
+
security_source=self.sdk_configuration.security,
|
|
811
|
+
),
|
|
812
|
+
request=req,
|
|
813
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
814
|
+
retry_config=retry_config,
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
response_data: Any = None
|
|
818
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
819
|
+
return utils.unmarshal_json(http_res.text, models.TokenInfo)
|
|
820
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
821
|
+
response_data = utils.unmarshal_json(
|
|
822
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
823
|
+
)
|
|
824
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
825
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
826
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
827
|
+
raise errors.APIError(
|
|
828
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
829
|
+
)
|
|
830
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
831
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
832
|
+
raise errors.APIError(
|
|
833
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
834
|
+
)
|
|
835
|
+
|
|
836
|
+
content_type = http_res.headers.get("Content-Type")
|
|
837
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
838
|
+
raise errors.APIError(
|
|
839
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
840
|
+
http_res.status_code,
|
|
841
|
+
http_res_text,
|
|
842
|
+
http_res,
|
|
843
|
+
)
|
|
844
|
+
|
|
845
|
+
def balance(
|
|
846
|
+
self,
|
|
847
|
+
*,
|
|
848
|
+
chain: Optional[
|
|
849
|
+
models.GenericBalanceChain
|
|
850
|
+
] = models.GenericBalanceChain.ARBITRUM_MAINNET,
|
|
851
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
852
|
+
token: Optional[models.GenericBalanceToken] = models.GenericBalanceToken.USDC,
|
|
853
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
854
|
+
server_url: Optional[str] = None,
|
|
855
|
+
timeout_ms: Optional[int] = None,
|
|
856
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
857
|
+
) -> models.BalanceInfoResponse:
|
|
858
|
+
r"""User Token Balance
|
|
859
|
+
|
|
860
|
+
Returns the balance of a specific ERC20 token for a given user address.
|
|
861
|
+
|
|
862
|
+
:param chain: The chain to use.
|
|
863
|
+
:param user:
|
|
864
|
+
: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.
|
|
865
|
+
:param retries: Override the default retry configuration for this method
|
|
866
|
+
:param server_url: Override the default server URL for this method
|
|
867
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
868
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
869
|
+
"""
|
|
870
|
+
base_url = None
|
|
871
|
+
url_variables = None
|
|
872
|
+
if timeout_ms is None:
|
|
873
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
874
|
+
|
|
875
|
+
if server_url is not None:
|
|
876
|
+
base_url = server_url
|
|
877
|
+
else:
|
|
878
|
+
base_url = self._get_url(base_url, url_variables)
|
|
879
|
+
|
|
880
|
+
request = models.GenericBalanceRequest(
|
|
881
|
+
chain=chain,
|
|
882
|
+
user=user,
|
|
883
|
+
token=token,
|
|
884
|
+
)
|
|
885
|
+
|
|
886
|
+
req = self._build_request(
|
|
887
|
+
method="GET",
|
|
888
|
+
path="/v0/generic/balance/get",
|
|
889
|
+
base_url=base_url,
|
|
890
|
+
url_variables=url_variables,
|
|
891
|
+
request=request,
|
|
892
|
+
request_body_required=False,
|
|
893
|
+
request_has_path_params=False,
|
|
894
|
+
request_has_query_params=True,
|
|
895
|
+
user_agent_header="user-agent",
|
|
896
|
+
accept_header_value="application/json",
|
|
897
|
+
http_headers=http_headers,
|
|
898
|
+
security=self.sdk_configuration.security,
|
|
899
|
+
timeout_ms=timeout_ms,
|
|
900
|
+
)
|
|
901
|
+
|
|
902
|
+
if retries == UNSET:
|
|
903
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
904
|
+
retries = self.sdk_configuration.retry_config
|
|
905
|
+
|
|
906
|
+
retry_config = None
|
|
907
|
+
if isinstance(retries, utils.RetryConfig):
|
|
908
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
909
|
+
|
|
910
|
+
http_res = self.do_request(
|
|
911
|
+
hook_ctx=HookContext(
|
|
912
|
+
base_url=base_url or "",
|
|
913
|
+
operation_id="generic_balance",
|
|
914
|
+
oauth2_scopes=[],
|
|
915
|
+
security_source=self.sdk_configuration.security,
|
|
916
|
+
),
|
|
917
|
+
request=req,
|
|
918
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
919
|
+
retry_config=retry_config,
|
|
920
|
+
)
|
|
921
|
+
|
|
922
|
+
response_data: Any = None
|
|
923
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
924
|
+
return utils.unmarshal_json(http_res.text, models.BalanceInfoResponse)
|
|
925
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
926
|
+
response_data = utils.unmarshal_json(
|
|
927
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
928
|
+
)
|
|
929
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
930
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
931
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
932
|
+
raise errors.APIError(
|
|
933
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
934
|
+
)
|
|
935
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
936
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
937
|
+
raise errors.APIError(
|
|
938
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
939
|
+
)
|
|
940
|
+
|
|
941
|
+
content_type = http_res.headers.get("Content-Type")
|
|
942
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
943
|
+
raise errors.APIError(
|
|
944
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
945
|
+
http_res.status_code,
|
|
946
|
+
http_res_text,
|
|
947
|
+
http_res,
|
|
948
|
+
)
|
|
949
|
+
|
|
950
|
+
async def balance_async(
|
|
951
|
+
self,
|
|
952
|
+
*,
|
|
953
|
+
chain: Optional[
|
|
954
|
+
models.GenericBalanceChain
|
|
955
|
+
] = models.GenericBalanceChain.ARBITRUM_MAINNET,
|
|
956
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
957
|
+
token: Optional[models.GenericBalanceToken] = models.GenericBalanceToken.USDC,
|
|
958
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
959
|
+
server_url: Optional[str] = None,
|
|
960
|
+
timeout_ms: Optional[int] = None,
|
|
961
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
962
|
+
) -> models.BalanceInfoResponse:
|
|
963
|
+
r"""User Token Balance
|
|
964
|
+
|
|
965
|
+
Returns the balance of a specific ERC20 token for a given user address.
|
|
966
|
+
|
|
967
|
+
:param chain: The chain to use.
|
|
968
|
+
:param user:
|
|
969
|
+
: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.
|
|
970
|
+
:param retries: Override the default retry configuration for this method
|
|
971
|
+
:param server_url: Override the default server URL for this method
|
|
972
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
973
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
974
|
+
"""
|
|
975
|
+
base_url = None
|
|
976
|
+
url_variables = None
|
|
977
|
+
if timeout_ms is None:
|
|
978
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
979
|
+
|
|
980
|
+
if server_url is not None:
|
|
981
|
+
base_url = server_url
|
|
982
|
+
else:
|
|
983
|
+
base_url = self._get_url(base_url, url_variables)
|
|
984
|
+
|
|
985
|
+
request = models.GenericBalanceRequest(
|
|
986
|
+
chain=chain,
|
|
987
|
+
user=user,
|
|
988
|
+
token=token,
|
|
989
|
+
)
|
|
990
|
+
|
|
991
|
+
req = self._build_request_async(
|
|
992
|
+
method="GET",
|
|
993
|
+
path="/v0/generic/balance/get",
|
|
994
|
+
base_url=base_url,
|
|
995
|
+
url_variables=url_variables,
|
|
996
|
+
request=request,
|
|
997
|
+
request_body_required=False,
|
|
998
|
+
request_has_path_params=False,
|
|
999
|
+
request_has_query_params=True,
|
|
1000
|
+
user_agent_header="user-agent",
|
|
1001
|
+
accept_header_value="application/json",
|
|
1002
|
+
http_headers=http_headers,
|
|
1003
|
+
security=self.sdk_configuration.security,
|
|
1004
|
+
timeout_ms=timeout_ms,
|
|
1005
|
+
)
|
|
1006
|
+
|
|
1007
|
+
if retries == UNSET:
|
|
1008
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1009
|
+
retries = self.sdk_configuration.retry_config
|
|
1010
|
+
|
|
1011
|
+
retry_config = None
|
|
1012
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1013
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1014
|
+
|
|
1015
|
+
http_res = await self.do_request_async(
|
|
1016
|
+
hook_ctx=HookContext(
|
|
1017
|
+
base_url=base_url or "",
|
|
1018
|
+
operation_id="generic_balance",
|
|
1019
|
+
oauth2_scopes=[],
|
|
1020
|
+
security_source=self.sdk_configuration.security,
|
|
1021
|
+
),
|
|
1022
|
+
request=req,
|
|
1023
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1024
|
+
retry_config=retry_config,
|
|
1025
|
+
)
|
|
1026
|
+
|
|
1027
|
+
response_data: Any = None
|
|
1028
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1029
|
+
return utils.unmarshal_json(http_res.text, models.BalanceInfoResponse)
|
|
1030
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1031
|
+
response_data = utils.unmarshal_json(
|
|
1032
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1033
|
+
)
|
|
1034
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1035
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1036
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1037
|
+
raise errors.APIError(
|
|
1038
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1039
|
+
)
|
|
1040
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1041
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1042
|
+
raise errors.APIError(
|
|
1043
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1044
|
+
)
|
|
1045
|
+
|
|
1046
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1047
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1048
|
+
raise errors.APIError(
|
|
1049
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1050
|
+
http_res.status_code,
|
|
1051
|
+
http_res_text,
|
|
1052
|
+
http_res,
|
|
1053
|
+
)
|
|
1054
|
+
|
|
1055
|
+
def allowance(
|
|
1056
|
+
self,
|
|
1057
|
+
*,
|
|
1058
|
+
contract_name: models.GenericAllowanceContractName = models.GenericAllowanceContractName.AAVE_V3_POOL,
|
|
1059
|
+
chain: Optional[
|
|
1060
|
+
models.GenericAllowanceChain
|
|
1061
|
+
] = models.GenericAllowanceChain.ARBITRUM_MAINNET,
|
|
1062
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
1063
|
+
token: Optional[
|
|
1064
|
+
models.GenericAllowanceToken
|
|
1065
|
+
] = models.GenericAllowanceToken.USDC,
|
|
1066
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1067
|
+
server_url: Optional[str] = None,
|
|
1068
|
+
timeout_ms: Optional[int] = None,
|
|
1069
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1070
|
+
) -> models.AllowanceInfoResponse:
|
|
1071
|
+
r"""Get allowance - Protocol
|
|
1072
|
+
|
|
1073
|
+
In decentralized finance (DeFi) protocols such as Uniswap or AAVE, users must set
|
|
1074
|
+
a token allowance to authorize the protocol to spend a specified amount of their
|
|
1075
|
+
tokens on their behalf.
|
|
1076
|
+
|
|
1077
|
+
This is a crucial step before engaging in any transactions or operations within
|
|
1078
|
+
these protocols, ensuring that the protocol has the necessary permissions to manage
|
|
1079
|
+
the user's tokens securely and efficiently.
|
|
1080
|
+
|
|
1081
|
+
:param contract_name:
|
|
1082
|
+
:param chain: The chain to use.
|
|
1083
|
+
:param user:
|
|
1084
|
+
: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.
|
|
1085
|
+
:param retries: Override the default retry configuration for this method
|
|
1086
|
+
:param server_url: Override the default server URL for this method
|
|
1087
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1088
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1089
|
+
"""
|
|
1090
|
+
base_url = None
|
|
1091
|
+
url_variables = None
|
|
1092
|
+
if timeout_ms is None:
|
|
1093
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1094
|
+
|
|
1095
|
+
if server_url is not None:
|
|
1096
|
+
base_url = server_url
|
|
1097
|
+
else:
|
|
1098
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1099
|
+
|
|
1100
|
+
request = models.GenericAllowanceRequest(
|
|
1101
|
+
chain=chain,
|
|
1102
|
+
user=user,
|
|
1103
|
+
token=token,
|
|
1104
|
+
contract_name=contract_name,
|
|
1105
|
+
)
|
|
1106
|
+
|
|
1107
|
+
req = self._build_request(
|
|
1108
|
+
method="GET",
|
|
1109
|
+
path="/v0/generic/allowance/get",
|
|
1110
|
+
base_url=base_url,
|
|
1111
|
+
url_variables=url_variables,
|
|
1112
|
+
request=request,
|
|
1113
|
+
request_body_required=False,
|
|
1114
|
+
request_has_path_params=False,
|
|
1115
|
+
request_has_query_params=True,
|
|
1116
|
+
user_agent_header="user-agent",
|
|
1117
|
+
accept_header_value="application/json",
|
|
1118
|
+
http_headers=http_headers,
|
|
1119
|
+
security=self.sdk_configuration.security,
|
|
1120
|
+
timeout_ms=timeout_ms,
|
|
1121
|
+
)
|
|
1122
|
+
|
|
1123
|
+
if retries == UNSET:
|
|
1124
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1125
|
+
retries = self.sdk_configuration.retry_config
|
|
1126
|
+
|
|
1127
|
+
retry_config = None
|
|
1128
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1129
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1130
|
+
|
|
1131
|
+
http_res = self.do_request(
|
|
1132
|
+
hook_ctx=HookContext(
|
|
1133
|
+
base_url=base_url or "",
|
|
1134
|
+
operation_id="generic_allowance",
|
|
1135
|
+
oauth2_scopes=[],
|
|
1136
|
+
security_source=self.sdk_configuration.security,
|
|
1137
|
+
),
|
|
1138
|
+
request=req,
|
|
1139
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1140
|
+
retry_config=retry_config,
|
|
1141
|
+
)
|
|
1142
|
+
|
|
1143
|
+
response_data: Any = None
|
|
1144
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1145
|
+
return utils.unmarshal_json(http_res.text, models.AllowanceInfoResponse)
|
|
1146
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1147
|
+
response_data = utils.unmarshal_json(
|
|
1148
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1149
|
+
)
|
|
1150
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1151
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1152
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1153
|
+
raise errors.APIError(
|
|
1154
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1155
|
+
)
|
|
1156
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1157
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1158
|
+
raise errors.APIError(
|
|
1159
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1160
|
+
)
|
|
1161
|
+
|
|
1162
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1163
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1164
|
+
raise errors.APIError(
|
|
1165
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1166
|
+
http_res.status_code,
|
|
1167
|
+
http_res_text,
|
|
1168
|
+
http_res,
|
|
1169
|
+
)
|
|
1170
|
+
|
|
1171
|
+
async def allowance_async(
|
|
1172
|
+
self,
|
|
1173
|
+
*,
|
|
1174
|
+
contract_name: models.GenericAllowanceContractName = models.GenericAllowanceContractName.AAVE_V3_POOL,
|
|
1175
|
+
chain: Optional[
|
|
1176
|
+
models.GenericAllowanceChain
|
|
1177
|
+
] = models.GenericAllowanceChain.ARBITRUM_MAINNET,
|
|
1178
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
1179
|
+
token: Optional[
|
|
1180
|
+
models.GenericAllowanceToken
|
|
1181
|
+
] = models.GenericAllowanceToken.USDC,
|
|
1182
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1183
|
+
server_url: Optional[str] = None,
|
|
1184
|
+
timeout_ms: Optional[int] = None,
|
|
1185
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1186
|
+
) -> models.AllowanceInfoResponse:
|
|
1187
|
+
r"""Get allowance - Protocol
|
|
1188
|
+
|
|
1189
|
+
In decentralized finance (DeFi) protocols such as Uniswap or AAVE, users must set
|
|
1190
|
+
a token allowance to authorize the protocol to spend a specified amount of their
|
|
1191
|
+
tokens on their behalf.
|
|
1192
|
+
|
|
1193
|
+
This is a crucial step before engaging in any transactions or operations within
|
|
1194
|
+
these protocols, ensuring that the protocol has the necessary permissions to manage
|
|
1195
|
+
the user's tokens securely and efficiently.
|
|
1196
|
+
|
|
1197
|
+
:param contract_name:
|
|
1198
|
+
:param chain: The chain to use.
|
|
1199
|
+
:param user:
|
|
1200
|
+
: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.
|
|
1201
|
+
:param retries: Override the default retry configuration for this method
|
|
1202
|
+
:param server_url: Override the default server URL for this method
|
|
1203
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1204
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1205
|
+
"""
|
|
1206
|
+
base_url = None
|
|
1207
|
+
url_variables = None
|
|
1208
|
+
if timeout_ms is None:
|
|
1209
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1210
|
+
|
|
1211
|
+
if server_url is not None:
|
|
1212
|
+
base_url = server_url
|
|
1213
|
+
else:
|
|
1214
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1215
|
+
|
|
1216
|
+
request = models.GenericAllowanceRequest(
|
|
1217
|
+
chain=chain,
|
|
1218
|
+
user=user,
|
|
1219
|
+
token=token,
|
|
1220
|
+
contract_name=contract_name,
|
|
1221
|
+
)
|
|
1222
|
+
|
|
1223
|
+
req = self._build_request_async(
|
|
1224
|
+
method="GET",
|
|
1225
|
+
path="/v0/generic/allowance/get",
|
|
1226
|
+
base_url=base_url,
|
|
1227
|
+
url_variables=url_variables,
|
|
1228
|
+
request=request,
|
|
1229
|
+
request_body_required=False,
|
|
1230
|
+
request_has_path_params=False,
|
|
1231
|
+
request_has_query_params=True,
|
|
1232
|
+
user_agent_header="user-agent",
|
|
1233
|
+
accept_header_value="application/json",
|
|
1234
|
+
http_headers=http_headers,
|
|
1235
|
+
security=self.sdk_configuration.security,
|
|
1236
|
+
timeout_ms=timeout_ms,
|
|
1237
|
+
)
|
|
1238
|
+
|
|
1239
|
+
if retries == UNSET:
|
|
1240
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1241
|
+
retries = self.sdk_configuration.retry_config
|
|
1242
|
+
|
|
1243
|
+
retry_config = None
|
|
1244
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1245
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1246
|
+
|
|
1247
|
+
http_res = await self.do_request_async(
|
|
1248
|
+
hook_ctx=HookContext(
|
|
1249
|
+
base_url=base_url or "",
|
|
1250
|
+
operation_id="generic_allowance",
|
|
1251
|
+
oauth2_scopes=[],
|
|
1252
|
+
security_source=self.sdk_configuration.security,
|
|
1253
|
+
),
|
|
1254
|
+
request=req,
|
|
1255
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1256
|
+
retry_config=retry_config,
|
|
1257
|
+
)
|
|
1258
|
+
|
|
1259
|
+
response_data: Any = None
|
|
1260
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1261
|
+
return utils.unmarshal_json(http_res.text, models.AllowanceInfoResponse)
|
|
1262
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1263
|
+
response_data = utils.unmarshal_json(
|
|
1264
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1265
|
+
)
|
|
1266
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1267
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1268
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1269
|
+
raise errors.APIError(
|
|
1270
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1271
|
+
)
|
|
1272
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1273
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1274
|
+
raise errors.APIError(
|
|
1275
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1276
|
+
)
|
|
1277
|
+
|
|
1278
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1279
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1280
|
+
raise errors.APIError(
|
|
1281
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1282
|
+
http_res.status_code,
|
|
1283
|
+
http_res_text,
|
|
1284
|
+
http_res,
|
|
1285
|
+
)
|
|
1286
|
+
|
|
1287
|
+
def ens(
|
|
1288
|
+
self,
|
|
1289
|
+
*,
|
|
1290
|
+
chain: Optional[
|
|
1291
|
+
models.GenericEnsChain
|
|
1292
|
+
] = models.GenericEnsChain.ETHEREUM_MAINNET,
|
|
1293
|
+
ens_name: Optional[str] = "vitalik.eth",
|
|
1294
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1295
|
+
server_url: Optional[str] = None,
|
|
1296
|
+
timeout_ms: Optional[int] = None,
|
|
1297
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1298
|
+
) -> models.EnsNameInfoResponse:
|
|
1299
|
+
r"""Resolve ENS
|
|
1300
|
+
|
|
1301
|
+
An ENS name is a string ending in `.eth`.
|
|
1302
|
+
|
|
1303
|
+
E.g. `vitalik.eth`. This endpoint can be used to
|
|
1304
|
+
query the actual ethereum wallet address behind the ENS name.
|
|
1305
|
+
|
|
1306
|
+
:param chain: The chain to use.
|
|
1307
|
+
:param ens_name:
|
|
1308
|
+
:param retries: Override the default retry configuration for this method
|
|
1309
|
+
:param server_url: Override the default server URL for this method
|
|
1310
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1311
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1312
|
+
"""
|
|
1313
|
+
base_url = None
|
|
1314
|
+
url_variables = None
|
|
1315
|
+
if timeout_ms is None:
|
|
1316
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1317
|
+
|
|
1318
|
+
if server_url is not None:
|
|
1319
|
+
base_url = server_url
|
|
1320
|
+
else:
|
|
1321
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1322
|
+
|
|
1323
|
+
request = models.GenericEnsRequest(
|
|
1324
|
+
chain=chain,
|
|
1325
|
+
ens_name=ens_name,
|
|
1326
|
+
)
|
|
1327
|
+
|
|
1328
|
+
req = self._build_request(
|
|
1329
|
+
method="GET",
|
|
1330
|
+
path="/v0/generic/ens/get",
|
|
1331
|
+
base_url=base_url,
|
|
1332
|
+
url_variables=url_variables,
|
|
1333
|
+
request=request,
|
|
1334
|
+
request_body_required=False,
|
|
1335
|
+
request_has_path_params=False,
|
|
1336
|
+
request_has_query_params=True,
|
|
1337
|
+
user_agent_header="user-agent",
|
|
1338
|
+
accept_header_value="application/json",
|
|
1339
|
+
http_headers=http_headers,
|
|
1340
|
+
security=self.sdk_configuration.security,
|
|
1341
|
+
timeout_ms=timeout_ms,
|
|
1342
|
+
)
|
|
1343
|
+
|
|
1344
|
+
if retries == UNSET:
|
|
1345
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1346
|
+
retries = self.sdk_configuration.retry_config
|
|
1347
|
+
|
|
1348
|
+
retry_config = None
|
|
1349
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1350
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1351
|
+
|
|
1352
|
+
http_res = self.do_request(
|
|
1353
|
+
hook_ctx=HookContext(
|
|
1354
|
+
base_url=base_url or "",
|
|
1355
|
+
operation_id="generic_ens",
|
|
1356
|
+
oauth2_scopes=[],
|
|
1357
|
+
security_source=self.sdk_configuration.security,
|
|
1358
|
+
),
|
|
1359
|
+
request=req,
|
|
1360
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1361
|
+
retry_config=retry_config,
|
|
1362
|
+
)
|
|
1363
|
+
|
|
1364
|
+
response_data: Any = None
|
|
1365
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1366
|
+
return utils.unmarshal_json(http_res.text, models.EnsNameInfoResponse)
|
|
1367
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1368
|
+
response_data = utils.unmarshal_json(
|
|
1369
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1370
|
+
)
|
|
1371
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1372
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1373
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1374
|
+
raise errors.APIError(
|
|
1375
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1376
|
+
)
|
|
1377
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1378
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1379
|
+
raise errors.APIError(
|
|
1380
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1381
|
+
)
|
|
1382
|
+
|
|
1383
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1384
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1385
|
+
raise errors.APIError(
|
|
1386
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1387
|
+
http_res.status_code,
|
|
1388
|
+
http_res_text,
|
|
1389
|
+
http_res,
|
|
1390
|
+
)
|
|
1391
|
+
|
|
1392
|
+
async def ens_async(
|
|
1393
|
+
self,
|
|
1394
|
+
*,
|
|
1395
|
+
chain: Optional[
|
|
1396
|
+
models.GenericEnsChain
|
|
1397
|
+
] = models.GenericEnsChain.ETHEREUM_MAINNET,
|
|
1398
|
+
ens_name: Optional[str] = "vitalik.eth",
|
|
1399
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1400
|
+
server_url: Optional[str] = None,
|
|
1401
|
+
timeout_ms: Optional[int] = None,
|
|
1402
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1403
|
+
) -> models.EnsNameInfoResponse:
|
|
1404
|
+
r"""Resolve ENS
|
|
1405
|
+
|
|
1406
|
+
An ENS name is a string ending in `.eth`.
|
|
1407
|
+
|
|
1408
|
+
E.g. `vitalik.eth`. This endpoint can be used to
|
|
1409
|
+
query the actual ethereum wallet address behind the ENS name.
|
|
1410
|
+
|
|
1411
|
+
:param chain: The chain to use.
|
|
1412
|
+
:param ens_name:
|
|
1413
|
+
:param retries: Override the default retry configuration for this method
|
|
1414
|
+
:param server_url: Override the default server URL for this method
|
|
1415
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1416
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1417
|
+
"""
|
|
1418
|
+
base_url = None
|
|
1419
|
+
url_variables = None
|
|
1420
|
+
if timeout_ms is None:
|
|
1421
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1422
|
+
|
|
1423
|
+
if server_url is not None:
|
|
1424
|
+
base_url = server_url
|
|
1425
|
+
else:
|
|
1426
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1427
|
+
|
|
1428
|
+
request = models.GenericEnsRequest(
|
|
1429
|
+
chain=chain,
|
|
1430
|
+
ens_name=ens_name,
|
|
1431
|
+
)
|
|
1432
|
+
|
|
1433
|
+
req = self._build_request_async(
|
|
1434
|
+
method="GET",
|
|
1435
|
+
path="/v0/generic/ens/get",
|
|
1436
|
+
base_url=base_url,
|
|
1437
|
+
url_variables=url_variables,
|
|
1438
|
+
request=request,
|
|
1439
|
+
request_body_required=False,
|
|
1440
|
+
request_has_path_params=False,
|
|
1441
|
+
request_has_query_params=True,
|
|
1442
|
+
user_agent_header="user-agent",
|
|
1443
|
+
accept_header_value="application/json",
|
|
1444
|
+
http_headers=http_headers,
|
|
1445
|
+
security=self.sdk_configuration.security,
|
|
1446
|
+
timeout_ms=timeout_ms,
|
|
1447
|
+
)
|
|
1448
|
+
|
|
1449
|
+
if retries == UNSET:
|
|
1450
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1451
|
+
retries = self.sdk_configuration.retry_config
|
|
1452
|
+
|
|
1453
|
+
retry_config = None
|
|
1454
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1455
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1456
|
+
|
|
1457
|
+
http_res = await self.do_request_async(
|
|
1458
|
+
hook_ctx=HookContext(
|
|
1459
|
+
base_url=base_url or "",
|
|
1460
|
+
operation_id="generic_ens",
|
|
1461
|
+
oauth2_scopes=[],
|
|
1462
|
+
security_source=self.sdk_configuration.security,
|
|
1463
|
+
),
|
|
1464
|
+
request=req,
|
|
1465
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1466
|
+
retry_config=retry_config,
|
|
1467
|
+
)
|
|
1468
|
+
|
|
1469
|
+
response_data: Any = None
|
|
1470
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1471
|
+
return utils.unmarshal_json(http_res.text, models.EnsNameInfoResponse)
|
|
1472
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1473
|
+
response_data = utils.unmarshal_json(
|
|
1474
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1475
|
+
)
|
|
1476
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1477
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1478
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1479
|
+
raise errors.APIError(
|
|
1480
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1481
|
+
)
|
|
1482
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1483
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1484
|
+
raise errors.APIError(
|
|
1485
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1486
|
+
)
|
|
1487
|
+
|
|
1488
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1489
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1490
|
+
raise errors.APIError(
|
|
1491
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1492
|
+
http_res.status_code,
|
|
1493
|
+
http_res_text,
|
|
1494
|
+
http_res,
|
|
1495
|
+
)
|
|
1496
|
+
|
|
1497
|
+
def wrap_eth(
|
|
1498
|
+
self,
|
|
1499
|
+
*,
|
|
1500
|
+
amount: Union[
|
|
1501
|
+
models.WrapEthRequestAmount, models.WrapEthRequestAmountTypedDict
|
|
1502
|
+
],
|
|
1503
|
+
chain: models.Chain,
|
|
1504
|
+
sender: str,
|
|
1505
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1506
|
+
server_url: Optional[str] = None,
|
|
1507
|
+
timeout_ms: Optional[int] = None,
|
|
1508
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1509
|
+
) -> models.UnsignedTransaction:
|
|
1510
|
+
r"""Wrap ETH
|
|
1511
|
+
|
|
1512
|
+
Wrapping ETH creates an ERC-20 compliant form of ETH that is typically needed for
|
|
1513
|
+
it to be traded on DeFi protocols.
|
|
1514
|
+
|
|
1515
|
+
:param amount: The amount of ETH to wrap.
|
|
1516
|
+
:param chain: The chain to use.
|
|
1517
|
+
:param sender: The address of the transaction sender.
|
|
1518
|
+
:param retries: Override the default retry configuration for this method
|
|
1519
|
+
:param server_url: Override the default server URL for this method
|
|
1520
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1521
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1522
|
+
"""
|
|
1523
|
+
base_url = None
|
|
1524
|
+
url_variables = None
|
|
1525
|
+
if timeout_ms is None:
|
|
1526
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1527
|
+
|
|
1528
|
+
if server_url is not None:
|
|
1529
|
+
base_url = server_url
|
|
1530
|
+
else:
|
|
1531
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1532
|
+
|
|
1533
|
+
request = models.WrapEthRequest(
|
|
1534
|
+
amount=amount,
|
|
1535
|
+
chain=chain,
|
|
1536
|
+
sender=sender,
|
|
1537
|
+
)
|
|
1538
|
+
|
|
1539
|
+
req = self._build_request(
|
|
1540
|
+
method="POST",
|
|
1541
|
+
path="/v0/generic/wrap_eth",
|
|
1542
|
+
base_url=base_url,
|
|
1543
|
+
url_variables=url_variables,
|
|
1544
|
+
request=request,
|
|
1545
|
+
request_body_required=True,
|
|
1546
|
+
request_has_path_params=False,
|
|
1547
|
+
request_has_query_params=True,
|
|
1548
|
+
user_agent_header="user-agent",
|
|
1549
|
+
accept_header_value="application/json",
|
|
1550
|
+
http_headers=http_headers,
|
|
1551
|
+
security=self.sdk_configuration.security,
|
|
1552
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1553
|
+
request, False, False, "json", models.WrapEthRequest
|
|
1554
|
+
),
|
|
1555
|
+
timeout_ms=timeout_ms,
|
|
1556
|
+
)
|
|
1557
|
+
|
|
1558
|
+
if retries == UNSET:
|
|
1559
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1560
|
+
retries = self.sdk_configuration.retry_config
|
|
1561
|
+
|
|
1562
|
+
retry_config = None
|
|
1563
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1564
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1565
|
+
|
|
1566
|
+
http_res = self.do_request(
|
|
1567
|
+
hook_ctx=HookContext(
|
|
1568
|
+
base_url=base_url or "",
|
|
1569
|
+
operation_id="generic_wrap_eth",
|
|
1570
|
+
oauth2_scopes=[],
|
|
1571
|
+
security_source=self.sdk_configuration.security,
|
|
1572
|
+
),
|
|
1573
|
+
request=req,
|
|
1574
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1575
|
+
retry_config=retry_config,
|
|
1576
|
+
)
|
|
1577
|
+
|
|
1578
|
+
response_data: Any = None
|
|
1579
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1580
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1581
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1582
|
+
response_data = utils.unmarshal_json(
|
|
1583
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1584
|
+
)
|
|
1585
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1586
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1587
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1588
|
+
raise errors.APIError(
|
|
1589
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1590
|
+
)
|
|
1591
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1592
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1593
|
+
raise errors.APIError(
|
|
1594
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1595
|
+
)
|
|
1596
|
+
|
|
1597
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1598
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1599
|
+
raise errors.APIError(
|
|
1600
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1601
|
+
http_res.status_code,
|
|
1602
|
+
http_res_text,
|
|
1603
|
+
http_res,
|
|
1604
|
+
)
|
|
1605
|
+
|
|
1606
|
+
async def wrap_eth_async(
|
|
1607
|
+
self,
|
|
1608
|
+
*,
|
|
1609
|
+
amount: Union[
|
|
1610
|
+
models.WrapEthRequestAmount, models.WrapEthRequestAmountTypedDict
|
|
1611
|
+
],
|
|
1612
|
+
chain: models.Chain,
|
|
1613
|
+
sender: str,
|
|
1614
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1615
|
+
server_url: Optional[str] = None,
|
|
1616
|
+
timeout_ms: Optional[int] = None,
|
|
1617
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1618
|
+
) -> models.UnsignedTransaction:
|
|
1619
|
+
r"""Wrap ETH
|
|
1620
|
+
|
|
1621
|
+
Wrapping ETH creates an ERC-20 compliant form of ETH that is typically needed for
|
|
1622
|
+
it to be traded on DeFi protocols.
|
|
1623
|
+
|
|
1624
|
+
:param amount: The amount of ETH to wrap.
|
|
1625
|
+
:param chain: The chain to use.
|
|
1626
|
+
:param sender: The address of the transaction sender.
|
|
1627
|
+
:param retries: Override the default retry configuration for this method
|
|
1628
|
+
:param server_url: Override the default server URL for this method
|
|
1629
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1630
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1631
|
+
"""
|
|
1632
|
+
base_url = None
|
|
1633
|
+
url_variables = None
|
|
1634
|
+
if timeout_ms is None:
|
|
1635
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1636
|
+
|
|
1637
|
+
if server_url is not None:
|
|
1638
|
+
base_url = server_url
|
|
1639
|
+
else:
|
|
1640
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1641
|
+
|
|
1642
|
+
request = models.WrapEthRequest(
|
|
1643
|
+
amount=amount,
|
|
1644
|
+
chain=chain,
|
|
1645
|
+
sender=sender,
|
|
1646
|
+
)
|
|
1647
|
+
|
|
1648
|
+
req = self._build_request_async(
|
|
1649
|
+
method="POST",
|
|
1650
|
+
path="/v0/generic/wrap_eth",
|
|
1651
|
+
base_url=base_url,
|
|
1652
|
+
url_variables=url_variables,
|
|
1653
|
+
request=request,
|
|
1654
|
+
request_body_required=True,
|
|
1655
|
+
request_has_path_params=False,
|
|
1656
|
+
request_has_query_params=True,
|
|
1657
|
+
user_agent_header="user-agent",
|
|
1658
|
+
accept_header_value="application/json",
|
|
1659
|
+
http_headers=http_headers,
|
|
1660
|
+
security=self.sdk_configuration.security,
|
|
1661
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1662
|
+
request, False, False, "json", models.WrapEthRequest
|
|
1663
|
+
),
|
|
1664
|
+
timeout_ms=timeout_ms,
|
|
1665
|
+
)
|
|
1666
|
+
|
|
1667
|
+
if retries == UNSET:
|
|
1668
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1669
|
+
retries = self.sdk_configuration.retry_config
|
|
1670
|
+
|
|
1671
|
+
retry_config = None
|
|
1672
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1673
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1674
|
+
|
|
1675
|
+
http_res = await self.do_request_async(
|
|
1676
|
+
hook_ctx=HookContext(
|
|
1677
|
+
base_url=base_url or "",
|
|
1678
|
+
operation_id="generic_wrap_eth",
|
|
1679
|
+
oauth2_scopes=[],
|
|
1680
|
+
security_source=self.sdk_configuration.security,
|
|
1681
|
+
),
|
|
1682
|
+
request=req,
|
|
1683
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1684
|
+
retry_config=retry_config,
|
|
1685
|
+
)
|
|
1686
|
+
|
|
1687
|
+
response_data: Any = None
|
|
1688
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1689
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1690
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1691
|
+
response_data = utils.unmarshal_json(
|
|
1692
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1693
|
+
)
|
|
1694
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1695
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1696
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1697
|
+
raise errors.APIError(
|
|
1698
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1699
|
+
)
|
|
1700
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1701
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1702
|
+
raise errors.APIError(
|
|
1703
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1704
|
+
)
|
|
1705
|
+
|
|
1706
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1707
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1708
|
+
raise errors.APIError(
|
|
1709
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1710
|
+
http_res.status_code,
|
|
1711
|
+
http_res_text,
|
|
1712
|
+
http_res,
|
|
1713
|
+
)
|
|
1714
|
+
|
|
1715
|
+
def unwrap_weth(
|
|
1716
|
+
self,
|
|
1717
|
+
*,
|
|
1718
|
+
amount: Union[
|
|
1719
|
+
models.UnwrapWethRequestAmount, models.UnwrapWethRequestAmountTypedDict
|
|
1720
|
+
],
|
|
1721
|
+
chain: models.Chain,
|
|
1722
|
+
sender: str,
|
|
1723
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1724
|
+
server_url: Optional[str] = None,
|
|
1725
|
+
timeout_ms: Optional[int] = None,
|
|
1726
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1727
|
+
) -> models.UnsignedTransaction:
|
|
1728
|
+
r"""Unwrap WETH
|
|
1729
|
+
|
|
1730
|
+
Unwrapping WETH converts the ERC-20 compliant form of ETH back to native ETH that
|
|
1731
|
+
can be used for gas and other native purposes.
|
|
1732
|
+
|
|
1733
|
+
:param amount: The amount of WETH to unwrap.
|
|
1734
|
+
:param chain: The chain to use.
|
|
1735
|
+
:param sender: The address of the transaction sender.
|
|
1736
|
+
:param retries: Override the default retry configuration for this method
|
|
1737
|
+
:param server_url: Override the default server URL for this method
|
|
1738
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1739
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1740
|
+
"""
|
|
1741
|
+
base_url = None
|
|
1742
|
+
url_variables = None
|
|
1743
|
+
if timeout_ms is None:
|
|
1744
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1745
|
+
|
|
1746
|
+
if server_url is not None:
|
|
1747
|
+
base_url = server_url
|
|
1748
|
+
else:
|
|
1749
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1750
|
+
|
|
1751
|
+
request = models.UnwrapWethRequest(
|
|
1752
|
+
amount=amount,
|
|
1753
|
+
chain=chain,
|
|
1754
|
+
sender=sender,
|
|
1755
|
+
)
|
|
1756
|
+
|
|
1757
|
+
req = self._build_request(
|
|
1758
|
+
method="POST",
|
|
1759
|
+
path="/v0/generic/unwrap_weth",
|
|
1760
|
+
base_url=base_url,
|
|
1761
|
+
url_variables=url_variables,
|
|
1762
|
+
request=request,
|
|
1763
|
+
request_body_required=True,
|
|
1764
|
+
request_has_path_params=False,
|
|
1765
|
+
request_has_query_params=True,
|
|
1766
|
+
user_agent_header="user-agent",
|
|
1767
|
+
accept_header_value="application/json",
|
|
1768
|
+
http_headers=http_headers,
|
|
1769
|
+
security=self.sdk_configuration.security,
|
|
1770
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1771
|
+
request, False, False, "json", models.UnwrapWethRequest
|
|
1772
|
+
),
|
|
1773
|
+
timeout_ms=timeout_ms,
|
|
1774
|
+
)
|
|
1775
|
+
|
|
1776
|
+
if retries == UNSET:
|
|
1777
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1778
|
+
retries = self.sdk_configuration.retry_config
|
|
1779
|
+
|
|
1780
|
+
retry_config = None
|
|
1781
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1782
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1783
|
+
|
|
1784
|
+
http_res = self.do_request(
|
|
1785
|
+
hook_ctx=HookContext(
|
|
1786
|
+
base_url=base_url or "",
|
|
1787
|
+
operation_id="generic_unwrap_weth",
|
|
1788
|
+
oauth2_scopes=[],
|
|
1789
|
+
security_source=self.sdk_configuration.security,
|
|
1790
|
+
),
|
|
1791
|
+
request=req,
|
|
1792
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1793
|
+
retry_config=retry_config,
|
|
1794
|
+
)
|
|
1795
|
+
|
|
1796
|
+
response_data: Any = None
|
|
1797
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1798
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1799
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1800
|
+
response_data = utils.unmarshal_json(
|
|
1801
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1802
|
+
)
|
|
1803
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1804
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1805
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1806
|
+
raise errors.APIError(
|
|
1807
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1808
|
+
)
|
|
1809
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1810
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1811
|
+
raise errors.APIError(
|
|
1812
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1813
|
+
)
|
|
1814
|
+
|
|
1815
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1816
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1817
|
+
raise errors.APIError(
|
|
1818
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1819
|
+
http_res.status_code,
|
|
1820
|
+
http_res_text,
|
|
1821
|
+
http_res,
|
|
1822
|
+
)
|
|
1823
|
+
|
|
1824
|
+
async def unwrap_weth_async(
|
|
1825
|
+
self,
|
|
1826
|
+
*,
|
|
1827
|
+
amount: Union[
|
|
1828
|
+
models.UnwrapWethRequestAmount, models.UnwrapWethRequestAmountTypedDict
|
|
1829
|
+
],
|
|
1830
|
+
chain: models.Chain,
|
|
1831
|
+
sender: str,
|
|
1832
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1833
|
+
server_url: Optional[str] = None,
|
|
1834
|
+
timeout_ms: Optional[int] = None,
|
|
1835
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1836
|
+
) -> models.UnsignedTransaction:
|
|
1837
|
+
r"""Unwrap WETH
|
|
1838
|
+
|
|
1839
|
+
Unwrapping WETH converts the ERC-20 compliant form of ETH back to native ETH that
|
|
1840
|
+
can be used for gas and other native purposes.
|
|
1841
|
+
|
|
1842
|
+
:param amount: The amount of WETH to unwrap.
|
|
1843
|
+
:param chain: The chain to use.
|
|
1844
|
+
:param sender: The address of the transaction sender.
|
|
1845
|
+
:param retries: Override the default retry configuration for this method
|
|
1846
|
+
:param server_url: Override the default server URL for this method
|
|
1847
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1848
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1849
|
+
"""
|
|
1850
|
+
base_url = None
|
|
1851
|
+
url_variables = None
|
|
1852
|
+
if timeout_ms is None:
|
|
1853
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1854
|
+
|
|
1855
|
+
if server_url is not None:
|
|
1856
|
+
base_url = server_url
|
|
1857
|
+
else:
|
|
1858
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1859
|
+
|
|
1860
|
+
request = models.UnwrapWethRequest(
|
|
1861
|
+
amount=amount,
|
|
1862
|
+
chain=chain,
|
|
1863
|
+
sender=sender,
|
|
1864
|
+
)
|
|
1865
|
+
|
|
1866
|
+
req = self._build_request_async(
|
|
1867
|
+
method="POST",
|
|
1868
|
+
path="/v0/generic/unwrap_weth",
|
|
1869
|
+
base_url=base_url,
|
|
1870
|
+
url_variables=url_variables,
|
|
1871
|
+
request=request,
|
|
1872
|
+
request_body_required=True,
|
|
1873
|
+
request_has_path_params=False,
|
|
1874
|
+
request_has_query_params=True,
|
|
1875
|
+
user_agent_header="user-agent",
|
|
1876
|
+
accept_header_value="application/json",
|
|
1877
|
+
http_headers=http_headers,
|
|
1878
|
+
security=self.sdk_configuration.security,
|
|
1879
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1880
|
+
request, False, False, "json", models.UnwrapWethRequest
|
|
1881
|
+
),
|
|
1882
|
+
timeout_ms=timeout_ms,
|
|
1883
|
+
)
|
|
1884
|
+
|
|
1885
|
+
if retries == UNSET:
|
|
1886
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1887
|
+
retries = self.sdk_configuration.retry_config
|
|
1888
|
+
|
|
1889
|
+
retry_config = None
|
|
1890
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1891
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1892
|
+
|
|
1893
|
+
http_res = await self.do_request_async(
|
|
1894
|
+
hook_ctx=HookContext(
|
|
1895
|
+
base_url=base_url or "",
|
|
1896
|
+
operation_id="generic_unwrap_weth",
|
|
1897
|
+
oauth2_scopes=[],
|
|
1898
|
+
security_source=self.sdk_configuration.security,
|
|
1899
|
+
),
|
|
1900
|
+
request=req,
|
|
1901
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1902
|
+
retry_config=retry_config,
|
|
1903
|
+
)
|
|
1904
|
+
|
|
1905
|
+
response_data: Any = None
|
|
1906
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1907
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1908
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1909
|
+
response_data = utils.unmarshal_json(
|
|
1910
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1911
|
+
)
|
|
1912
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1913
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1914
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1915
|
+
raise errors.APIError(
|
|
1916
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1917
|
+
)
|
|
1918
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1919
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1920
|
+
raise errors.APIError(
|
|
1921
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1922
|
+
)
|
|
1923
|
+
|
|
1924
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1925
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1926
|
+
raise errors.APIError(
|
|
1927
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1928
|
+
http_res.status_code,
|
|
1929
|
+
http_res_text,
|
|
1930
|
+
http_res,
|
|
1931
|
+
)
|
|
1932
|
+
|
|
1933
|
+
def transfer_erc20(
|
|
1934
|
+
self,
|
|
1935
|
+
*,
|
|
1936
|
+
amount: Union[
|
|
1937
|
+
models.TransferErc20RequestAmount,
|
|
1938
|
+
models.TransferErc20RequestAmountTypedDict,
|
|
1939
|
+
],
|
|
1940
|
+
token: models.TokenEnum,
|
|
1941
|
+
to: str,
|
|
1942
|
+
chain: models.Chain,
|
|
1943
|
+
sender: str,
|
|
1944
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1945
|
+
server_url: Optional[str] = None,
|
|
1946
|
+
timeout_ms: Optional[int] = None,
|
|
1947
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1948
|
+
) -> models.UnsignedTransaction:
|
|
1949
|
+
r"""Transfer Token
|
|
1950
|
+
|
|
1951
|
+
Sends ERC20 tokens from the sender's address to the specified recipient.
|
|
1952
|
+
|
|
1953
|
+
:param amount: Amount of token to transfer
|
|
1954
|
+
: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.
|
|
1955
|
+
:param to: The recipient of the tokens.
|
|
1956
|
+
:param chain: The chain to use.
|
|
1957
|
+
:param sender: The address of the transaction sender.
|
|
1958
|
+
:param retries: Override the default retry configuration for this method
|
|
1959
|
+
:param server_url: Override the default server URL for this method
|
|
1960
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1961
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1962
|
+
"""
|
|
1963
|
+
base_url = None
|
|
1964
|
+
url_variables = None
|
|
1965
|
+
if timeout_ms is None:
|
|
1966
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1967
|
+
|
|
1968
|
+
if server_url is not None:
|
|
1969
|
+
base_url = server_url
|
|
1970
|
+
else:
|
|
1971
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1972
|
+
|
|
1973
|
+
request = models.TransferErc20Request(
|
|
1974
|
+
amount=amount,
|
|
1975
|
+
token=token,
|
|
1976
|
+
to=to,
|
|
1977
|
+
chain=chain,
|
|
1978
|
+
sender=sender,
|
|
1979
|
+
)
|
|
1980
|
+
|
|
1981
|
+
req = self._build_request(
|
|
1982
|
+
method="POST",
|
|
1983
|
+
path="/v0/generic/transfer/erc20",
|
|
1984
|
+
base_url=base_url,
|
|
1985
|
+
url_variables=url_variables,
|
|
1986
|
+
request=request,
|
|
1987
|
+
request_body_required=True,
|
|
1988
|
+
request_has_path_params=False,
|
|
1989
|
+
request_has_query_params=True,
|
|
1990
|
+
user_agent_header="user-agent",
|
|
1991
|
+
accept_header_value="application/json",
|
|
1992
|
+
http_headers=http_headers,
|
|
1993
|
+
security=self.sdk_configuration.security,
|
|
1994
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1995
|
+
request, False, False, "json", models.TransferErc20Request
|
|
1996
|
+
),
|
|
1997
|
+
timeout_ms=timeout_ms,
|
|
1998
|
+
)
|
|
1999
|
+
|
|
2000
|
+
if retries == UNSET:
|
|
2001
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2002
|
+
retries = self.sdk_configuration.retry_config
|
|
2003
|
+
|
|
2004
|
+
retry_config = None
|
|
2005
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2006
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2007
|
+
|
|
2008
|
+
http_res = self.do_request(
|
|
2009
|
+
hook_ctx=HookContext(
|
|
2010
|
+
base_url=base_url or "",
|
|
2011
|
+
operation_id="generic_transfer_erc20",
|
|
2012
|
+
oauth2_scopes=[],
|
|
2013
|
+
security_source=self.sdk_configuration.security,
|
|
2014
|
+
),
|
|
2015
|
+
request=req,
|
|
2016
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2017
|
+
retry_config=retry_config,
|
|
2018
|
+
)
|
|
2019
|
+
|
|
2020
|
+
response_data: Any = None
|
|
2021
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2022
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2023
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2024
|
+
response_data = utils.unmarshal_json(
|
|
2025
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2026
|
+
)
|
|
2027
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2028
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2029
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2030
|
+
raise errors.APIError(
|
|
2031
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2032
|
+
)
|
|
2033
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2034
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2035
|
+
raise errors.APIError(
|
|
2036
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2037
|
+
)
|
|
2038
|
+
|
|
2039
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2040
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2041
|
+
raise errors.APIError(
|
|
2042
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2043
|
+
http_res.status_code,
|
|
2044
|
+
http_res_text,
|
|
2045
|
+
http_res,
|
|
2046
|
+
)
|
|
2047
|
+
|
|
2048
|
+
async def transfer_erc20_async(
|
|
2049
|
+
self,
|
|
2050
|
+
*,
|
|
2051
|
+
amount: Union[
|
|
2052
|
+
models.TransferErc20RequestAmount,
|
|
2053
|
+
models.TransferErc20RequestAmountTypedDict,
|
|
2054
|
+
],
|
|
2055
|
+
token: models.TokenEnum,
|
|
2056
|
+
to: str,
|
|
2057
|
+
chain: models.Chain,
|
|
2058
|
+
sender: str,
|
|
2059
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2060
|
+
server_url: Optional[str] = None,
|
|
2061
|
+
timeout_ms: Optional[int] = None,
|
|
2062
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2063
|
+
) -> models.UnsignedTransaction:
|
|
2064
|
+
r"""Transfer Token
|
|
2065
|
+
|
|
2066
|
+
Sends ERC20 tokens from the sender's address to the specified recipient.
|
|
2067
|
+
|
|
2068
|
+
:param amount: Amount of token to transfer
|
|
2069
|
+
: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.
|
|
2070
|
+
:param to: The recipient of the tokens.
|
|
2071
|
+
:param chain: The chain to use.
|
|
2072
|
+
:param sender: The address of the transaction sender.
|
|
2073
|
+
:param retries: Override the default retry configuration for this method
|
|
2074
|
+
:param server_url: Override the default server URL for this method
|
|
2075
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2076
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2077
|
+
"""
|
|
2078
|
+
base_url = None
|
|
2079
|
+
url_variables = None
|
|
2080
|
+
if timeout_ms is None:
|
|
2081
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2082
|
+
|
|
2083
|
+
if server_url is not None:
|
|
2084
|
+
base_url = server_url
|
|
2085
|
+
else:
|
|
2086
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2087
|
+
|
|
2088
|
+
request = models.TransferErc20Request(
|
|
2089
|
+
amount=amount,
|
|
2090
|
+
token=token,
|
|
2091
|
+
to=to,
|
|
2092
|
+
chain=chain,
|
|
2093
|
+
sender=sender,
|
|
2094
|
+
)
|
|
2095
|
+
|
|
2096
|
+
req = self._build_request_async(
|
|
2097
|
+
method="POST",
|
|
2098
|
+
path="/v0/generic/transfer/erc20",
|
|
2099
|
+
base_url=base_url,
|
|
2100
|
+
url_variables=url_variables,
|
|
2101
|
+
request=request,
|
|
2102
|
+
request_body_required=True,
|
|
2103
|
+
request_has_path_params=False,
|
|
2104
|
+
request_has_query_params=True,
|
|
2105
|
+
user_agent_header="user-agent",
|
|
2106
|
+
accept_header_value="application/json",
|
|
2107
|
+
http_headers=http_headers,
|
|
2108
|
+
security=self.sdk_configuration.security,
|
|
2109
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2110
|
+
request, False, False, "json", models.TransferErc20Request
|
|
2111
|
+
),
|
|
2112
|
+
timeout_ms=timeout_ms,
|
|
2113
|
+
)
|
|
2114
|
+
|
|
2115
|
+
if retries == UNSET:
|
|
2116
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2117
|
+
retries = self.sdk_configuration.retry_config
|
|
2118
|
+
|
|
2119
|
+
retry_config = None
|
|
2120
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2121
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2122
|
+
|
|
2123
|
+
http_res = await self.do_request_async(
|
|
2124
|
+
hook_ctx=HookContext(
|
|
2125
|
+
base_url=base_url or "",
|
|
2126
|
+
operation_id="generic_transfer_erc20",
|
|
2127
|
+
oauth2_scopes=[],
|
|
2128
|
+
security_source=self.sdk_configuration.security,
|
|
2129
|
+
),
|
|
2130
|
+
request=req,
|
|
2131
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2132
|
+
retry_config=retry_config,
|
|
2133
|
+
)
|
|
2134
|
+
|
|
2135
|
+
response_data: Any = None
|
|
2136
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2137
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2138
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2139
|
+
response_data = utils.unmarshal_json(
|
|
2140
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2141
|
+
)
|
|
2142
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2143
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2144
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2145
|
+
raise errors.APIError(
|
|
2146
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2147
|
+
)
|
|
2148
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2149
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2150
|
+
raise errors.APIError(
|
|
2151
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2152
|
+
)
|
|
2153
|
+
|
|
2154
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2155
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2156
|
+
raise errors.APIError(
|
|
2157
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2158
|
+
http_res.status_code,
|
|
2159
|
+
http_res_text,
|
|
2160
|
+
http_res,
|
|
2161
|
+
)
|
|
2162
|
+
|
|
2163
|
+
def transfer_native_token(
|
|
2164
|
+
self,
|
|
2165
|
+
*,
|
|
2166
|
+
amount: Union[
|
|
2167
|
+
models.TransferEthRequestAmount, models.TransferEthRequestAmountTypedDict
|
|
2168
|
+
],
|
|
2169
|
+
to: str,
|
|
2170
|
+
chain: models.Chain,
|
|
2171
|
+
sender: str,
|
|
2172
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2173
|
+
server_url: Optional[str] = None,
|
|
2174
|
+
timeout_ms: Optional[int] = None,
|
|
2175
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2176
|
+
) -> models.UnsignedTransaction:
|
|
2177
|
+
r"""Transfer ETH
|
|
2178
|
+
|
|
2179
|
+
Sends native ETH from the sender's address to the specified recipient.
|
|
2180
|
+
|
|
2181
|
+
:param amount: Amount of ETH to transfer
|
|
2182
|
+
:param to: The recipient of the ETH.
|
|
2183
|
+
:param chain: The chain to use.
|
|
2184
|
+
:param sender: The address of the transaction sender.
|
|
2185
|
+
:param retries: Override the default retry configuration for this method
|
|
2186
|
+
:param server_url: Override the default server URL for this method
|
|
2187
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2188
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2189
|
+
"""
|
|
2190
|
+
base_url = None
|
|
2191
|
+
url_variables = None
|
|
2192
|
+
if timeout_ms is None:
|
|
2193
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2194
|
+
|
|
2195
|
+
if server_url is not None:
|
|
2196
|
+
base_url = server_url
|
|
2197
|
+
else:
|
|
2198
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2199
|
+
|
|
2200
|
+
request = models.TransferEthRequest(
|
|
2201
|
+
amount=amount,
|
|
2202
|
+
to=to,
|
|
2203
|
+
chain=chain,
|
|
2204
|
+
sender=sender,
|
|
2205
|
+
)
|
|
2206
|
+
|
|
2207
|
+
req = self._build_request(
|
|
2208
|
+
method="POST",
|
|
2209
|
+
path="/v0/generic/transfer/native_token",
|
|
2210
|
+
base_url=base_url,
|
|
2211
|
+
url_variables=url_variables,
|
|
2212
|
+
request=request,
|
|
2213
|
+
request_body_required=True,
|
|
2214
|
+
request_has_path_params=False,
|
|
2215
|
+
request_has_query_params=True,
|
|
2216
|
+
user_agent_header="user-agent",
|
|
2217
|
+
accept_header_value="application/json",
|
|
2218
|
+
http_headers=http_headers,
|
|
2219
|
+
security=self.sdk_configuration.security,
|
|
2220
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2221
|
+
request, False, False, "json", models.TransferEthRequest
|
|
2222
|
+
),
|
|
2223
|
+
timeout_ms=timeout_ms,
|
|
2224
|
+
)
|
|
2225
|
+
|
|
2226
|
+
if retries == UNSET:
|
|
2227
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2228
|
+
retries = self.sdk_configuration.retry_config
|
|
2229
|
+
|
|
2230
|
+
retry_config = None
|
|
2231
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2232
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2233
|
+
|
|
2234
|
+
http_res = self.do_request(
|
|
2235
|
+
hook_ctx=HookContext(
|
|
2236
|
+
base_url=base_url or "",
|
|
2237
|
+
operation_id="generic_transfer_native_token",
|
|
2238
|
+
oauth2_scopes=[],
|
|
2239
|
+
security_source=self.sdk_configuration.security,
|
|
2240
|
+
),
|
|
2241
|
+
request=req,
|
|
2242
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2243
|
+
retry_config=retry_config,
|
|
2244
|
+
)
|
|
2245
|
+
|
|
2246
|
+
response_data: Any = None
|
|
2247
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2248
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2249
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2250
|
+
response_data = utils.unmarshal_json(
|
|
2251
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2252
|
+
)
|
|
2253
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2254
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2255
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2256
|
+
raise errors.APIError(
|
|
2257
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2258
|
+
)
|
|
2259
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2260
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2261
|
+
raise errors.APIError(
|
|
2262
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2263
|
+
)
|
|
2264
|
+
|
|
2265
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2266
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2267
|
+
raise errors.APIError(
|
|
2268
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2269
|
+
http_res.status_code,
|
|
2270
|
+
http_res_text,
|
|
2271
|
+
http_res,
|
|
2272
|
+
)
|
|
2273
|
+
|
|
2274
|
+
async def transfer_native_token_async(
|
|
2275
|
+
self,
|
|
2276
|
+
*,
|
|
2277
|
+
amount: Union[
|
|
2278
|
+
models.TransferEthRequestAmount, models.TransferEthRequestAmountTypedDict
|
|
2279
|
+
],
|
|
2280
|
+
to: str,
|
|
2281
|
+
chain: models.Chain,
|
|
2282
|
+
sender: str,
|
|
2283
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2284
|
+
server_url: Optional[str] = None,
|
|
2285
|
+
timeout_ms: Optional[int] = None,
|
|
2286
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2287
|
+
) -> models.UnsignedTransaction:
|
|
2288
|
+
r"""Transfer ETH
|
|
2289
|
+
|
|
2290
|
+
Sends native ETH from the sender's address to the specified recipient.
|
|
2291
|
+
|
|
2292
|
+
:param amount: Amount of ETH to transfer
|
|
2293
|
+
:param to: The recipient of the ETH.
|
|
2294
|
+
:param chain: The chain to use.
|
|
2295
|
+
:param sender: The address of the transaction sender.
|
|
2296
|
+
:param retries: Override the default retry configuration for this method
|
|
2297
|
+
:param server_url: Override the default server URL for this method
|
|
2298
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2299
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2300
|
+
"""
|
|
2301
|
+
base_url = None
|
|
2302
|
+
url_variables = None
|
|
2303
|
+
if timeout_ms is None:
|
|
2304
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2305
|
+
|
|
2306
|
+
if server_url is not None:
|
|
2307
|
+
base_url = server_url
|
|
2308
|
+
else:
|
|
2309
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2310
|
+
|
|
2311
|
+
request = models.TransferEthRequest(
|
|
2312
|
+
amount=amount,
|
|
2313
|
+
to=to,
|
|
2314
|
+
chain=chain,
|
|
2315
|
+
sender=sender,
|
|
2316
|
+
)
|
|
2317
|
+
|
|
2318
|
+
req = self._build_request_async(
|
|
2319
|
+
method="POST",
|
|
2320
|
+
path="/v0/generic/transfer/native_token",
|
|
2321
|
+
base_url=base_url,
|
|
2322
|
+
url_variables=url_variables,
|
|
2323
|
+
request=request,
|
|
2324
|
+
request_body_required=True,
|
|
2325
|
+
request_has_path_params=False,
|
|
2326
|
+
request_has_query_params=True,
|
|
2327
|
+
user_agent_header="user-agent",
|
|
2328
|
+
accept_header_value="application/json",
|
|
2329
|
+
http_headers=http_headers,
|
|
2330
|
+
security=self.sdk_configuration.security,
|
|
2331
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2332
|
+
request, False, False, "json", models.TransferEthRequest
|
|
2333
|
+
),
|
|
2334
|
+
timeout_ms=timeout_ms,
|
|
2335
|
+
)
|
|
2336
|
+
|
|
2337
|
+
if retries == UNSET:
|
|
2338
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2339
|
+
retries = self.sdk_configuration.retry_config
|
|
2340
|
+
|
|
2341
|
+
retry_config = None
|
|
2342
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2343
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2344
|
+
|
|
2345
|
+
http_res = await self.do_request_async(
|
|
2346
|
+
hook_ctx=HookContext(
|
|
2347
|
+
base_url=base_url or "",
|
|
2348
|
+
operation_id="generic_transfer_native_token",
|
|
2349
|
+
oauth2_scopes=[],
|
|
2350
|
+
security_source=self.sdk_configuration.security,
|
|
2351
|
+
),
|
|
2352
|
+
request=req,
|
|
2353
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2354
|
+
retry_config=retry_config,
|
|
2355
|
+
)
|
|
2356
|
+
|
|
2357
|
+
response_data: Any = None
|
|
2358
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2359
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2360
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2361
|
+
response_data = utils.unmarshal_json(
|
|
2362
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2363
|
+
)
|
|
2364
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2365
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2366
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2367
|
+
raise errors.APIError(
|
|
2368
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2369
|
+
)
|
|
2370
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2371
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2372
|
+
raise errors.APIError(
|
|
2373
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2374
|
+
)
|
|
2375
|
+
|
|
2376
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2377
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2378
|
+
raise errors.APIError(
|
|
2379
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2380
|
+
http_res.status_code,
|
|
2381
|
+
http_res_text,
|
|
2382
|
+
http_res,
|
|
2383
|
+
)
|
|
2384
|
+
|
|
2385
|
+
def allowance_set(
|
|
2386
|
+
self,
|
|
2387
|
+
*,
|
|
2388
|
+
token: models.TokenEnum,
|
|
2389
|
+
contract_name: models.ContractName,
|
|
2390
|
+
amount: Union[
|
|
2391
|
+
models.IncreaseAllowanceRequestAmount,
|
|
2392
|
+
models.IncreaseAllowanceRequestAmountTypedDict,
|
|
2393
|
+
],
|
|
2394
|
+
chain: models.Chain,
|
|
2395
|
+
sender: str,
|
|
2396
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2397
|
+
server_url: Optional[str] = None,
|
|
2398
|
+
timeout_ms: Optional[int] = None,
|
|
2399
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2400
|
+
) -> models.UnsignedTransaction:
|
|
2401
|
+
r"""Set Allowance - Protocol
|
|
2402
|
+
|
|
2403
|
+
This endpoint allows users to modify the token allowance for a specific protocol.
|
|
2404
|
+
|
|
2405
|
+
In decentralized finance (DeFi), setting an allowance is a necessary step to
|
|
2406
|
+
authorize a protocol to spend a specified amount of tokens on behalf of the user.
|
|
2407
|
+
This operation is crucial for ensuring that the protocol can manage the user's
|
|
2408
|
+
tokens securely and efficiently, enabling seamless transactions and operations
|
|
2409
|
+
within the DeFi ecosystem.
|
|
2410
|
+
|
|
2411
|
+
: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.
|
|
2412
|
+
:param contract_name: The name of the contract to increase allowance for.
|
|
2413
|
+
:param amount: The amount of tokens to increase the allowance by.
|
|
2414
|
+
:param chain: The chain to use.
|
|
2415
|
+
:param sender: The address of the transaction sender.
|
|
2416
|
+
:param retries: Override the default retry configuration for this method
|
|
2417
|
+
:param server_url: Override the default server URL for this method
|
|
2418
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2419
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2420
|
+
"""
|
|
2421
|
+
base_url = None
|
|
2422
|
+
url_variables = None
|
|
2423
|
+
if timeout_ms is None:
|
|
2424
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2425
|
+
|
|
2426
|
+
if server_url is not None:
|
|
2427
|
+
base_url = server_url
|
|
2428
|
+
else:
|
|
2429
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2430
|
+
|
|
2431
|
+
request = models.IncreaseAllowanceRequest(
|
|
2432
|
+
token=token,
|
|
2433
|
+
contract_name=contract_name,
|
|
2434
|
+
amount=amount,
|
|
2435
|
+
chain=chain,
|
|
2436
|
+
sender=sender,
|
|
2437
|
+
)
|
|
2438
|
+
|
|
2439
|
+
req = self._build_request(
|
|
2440
|
+
method="POST",
|
|
2441
|
+
path="/v0/generic/allowance/set",
|
|
2442
|
+
base_url=base_url,
|
|
2443
|
+
url_variables=url_variables,
|
|
2444
|
+
request=request,
|
|
2445
|
+
request_body_required=True,
|
|
2446
|
+
request_has_path_params=False,
|
|
2447
|
+
request_has_query_params=True,
|
|
2448
|
+
user_agent_header="user-agent",
|
|
2449
|
+
accept_header_value="application/json",
|
|
2450
|
+
http_headers=http_headers,
|
|
2451
|
+
security=self.sdk_configuration.security,
|
|
2452
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2453
|
+
request, False, False, "json", models.IncreaseAllowanceRequest
|
|
2454
|
+
),
|
|
2455
|
+
timeout_ms=timeout_ms,
|
|
2456
|
+
)
|
|
2457
|
+
|
|
2458
|
+
if retries == UNSET:
|
|
2459
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2460
|
+
retries = self.sdk_configuration.retry_config
|
|
2461
|
+
|
|
2462
|
+
retry_config = None
|
|
2463
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2464
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2465
|
+
|
|
2466
|
+
http_res = self.do_request(
|
|
2467
|
+
hook_ctx=HookContext(
|
|
2468
|
+
base_url=base_url or "",
|
|
2469
|
+
operation_id="generic_allowance_set",
|
|
2470
|
+
oauth2_scopes=[],
|
|
2471
|
+
security_source=self.sdk_configuration.security,
|
|
2472
|
+
),
|
|
2473
|
+
request=req,
|
|
2474
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2475
|
+
retry_config=retry_config,
|
|
2476
|
+
)
|
|
2477
|
+
|
|
2478
|
+
response_data: Any = None
|
|
2479
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2480
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2481
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2482
|
+
response_data = utils.unmarshal_json(
|
|
2483
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2484
|
+
)
|
|
2485
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2486
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2487
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2488
|
+
raise errors.APIError(
|
|
2489
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2490
|
+
)
|
|
2491
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2492
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2493
|
+
raise errors.APIError(
|
|
2494
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2495
|
+
)
|
|
2496
|
+
|
|
2497
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2498
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2499
|
+
raise errors.APIError(
|
|
2500
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2501
|
+
http_res.status_code,
|
|
2502
|
+
http_res_text,
|
|
2503
|
+
http_res,
|
|
2504
|
+
)
|
|
2505
|
+
|
|
2506
|
+
async def allowance_set_async(
|
|
2507
|
+
self,
|
|
2508
|
+
*,
|
|
2509
|
+
token: models.TokenEnum,
|
|
2510
|
+
contract_name: models.ContractName,
|
|
2511
|
+
amount: Union[
|
|
2512
|
+
models.IncreaseAllowanceRequestAmount,
|
|
2513
|
+
models.IncreaseAllowanceRequestAmountTypedDict,
|
|
2514
|
+
],
|
|
2515
|
+
chain: models.Chain,
|
|
2516
|
+
sender: str,
|
|
2517
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2518
|
+
server_url: Optional[str] = None,
|
|
2519
|
+
timeout_ms: Optional[int] = None,
|
|
2520
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2521
|
+
) -> models.UnsignedTransaction:
|
|
2522
|
+
r"""Set Allowance - Protocol
|
|
2523
|
+
|
|
2524
|
+
This endpoint allows users to modify the token allowance for a specific protocol.
|
|
2525
|
+
|
|
2526
|
+
In decentralized finance (DeFi), setting an allowance is a necessary step to
|
|
2527
|
+
authorize a protocol to spend a specified amount of tokens on behalf of the user.
|
|
2528
|
+
This operation is crucial for ensuring that the protocol can manage the user's
|
|
2529
|
+
tokens securely and efficiently, enabling seamless transactions and operations
|
|
2530
|
+
within the DeFi ecosystem.
|
|
2531
|
+
|
|
2532
|
+
: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.
|
|
2533
|
+
:param contract_name: The name of the contract to increase allowance for.
|
|
2534
|
+
:param amount: The amount of tokens to increase the allowance by.
|
|
2535
|
+
:param chain: The chain to use.
|
|
2536
|
+
:param sender: The address of the transaction sender.
|
|
2537
|
+
:param retries: Override the default retry configuration for this method
|
|
2538
|
+
:param server_url: Override the default server URL for this method
|
|
2539
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2540
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2541
|
+
"""
|
|
2542
|
+
base_url = None
|
|
2543
|
+
url_variables = None
|
|
2544
|
+
if timeout_ms is None:
|
|
2545
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2546
|
+
|
|
2547
|
+
if server_url is not None:
|
|
2548
|
+
base_url = server_url
|
|
2549
|
+
else:
|
|
2550
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2551
|
+
|
|
2552
|
+
request = models.IncreaseAllowanceRequest(
|
|
2553
|
+
token=token,
|
|
2554
|
+
contract_name=contract_name,
|
|
2555
|
+
amount=amount,
|
|
2556
|
+
chain=chain,
|
|
2557
|
+
sender=sender,
|
|
2558
|
+
)
|
|
2559
|
+
|
|
2560
|
+
req = self._build_request_async(
|
|
2561
|
+
method="POST",
|
|
2562
|
+
path="/v0/generic/allowance/set",
|
|
2563
|
+
base_url=base_url,
|
|
2564
|
+
url_variables=url_variables,
|
|
2565
|
+
request=request,
|
|
2566
|
+
request_body_required=True,
|
|
2567
|
+
request_has_path_params=False,
|
|
2568
|
+
request_has_query_params=True,
|
|
2569
|
+
user_agent_header="user-agent",
|
|
2570
|
+
accept_header_value="application/json",
|
|
2571
|
+
http_headers=http_headers,
|
|
2572
|
+
security=self.sdk_configuration.security,
|
|
2573
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2574
|
+
request, False, False, "json", models.IncreaseAllowanceRequest
|
|
2575
|
+
),
|
|
2576
|
+
timeout_ms=timeout_ms,
|
|
2577
|
+
)
|
|
2578
|
+
|
|
2579
|
+
if retries == UNSET:
|
|
2580
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2581
|
+
retries = self.sdk_configuration.retry_config
|
|
2582
|
+
|
|
2583
|
+
retry_config = None
|
|
2584
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2585
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2586
|
+
|
|
2587
|
+
http_res = await self.do_request_async(
|
|
2588
|
+
hook_ctx=HookContext(
|
|
2589
|
+
base_url=base_url or "",
|
|
2590
|
+
operation_id="generic_allowance_set",
|
|
2591
|
+
oauth2_scopes=[],
|
|
2592
|
+
security_source=self.sdk_configuration.security,
|
|
2593
|
+
),
|
|
2594
|
+
request=req,
|
|
2595
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2596
|
+
retry_config=retry_config,
|
|
2597
|
+
)
|
|
2598
|
+
|
|
2599
|
+
response_data: Any = None
|
|
2600
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2601
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2602
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2603
|
+
response_data = utils.unmarshal_json(
|
|
2604
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2605
|
+
)
|
|
2606
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2607
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2608
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2609
|
+
raise errors.APIError(
|
|
2610
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2611
|
+
)
|
|
2612
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2613
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2614
|
+
raise errors.APIError(
|
|
2615
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2616
|
+
)
|
|
2617
|
+
|
|
2618
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2619
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2620
|
+
raise errors.APIError(
|
|
2621
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2622
|
+
http_res.status_code,
|
|
2623
|
+
http_res_text,
|
|
2624
|
+
http_res,
|
|
2625
|
+
)
|