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,2551 @@
|
|
|
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 UniswapV3(BaseSDK):
|
|
11
|
+
def quote_buy_exactly(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
fee: models.UniswapQuoteBuyExactlyFeeEnum = models.UniswapQuoteBuyExactlyFeeEnum.ZERO_DOT_01,
|
|
15
|
+
amount_out: Union[
|
|
16
|
+
models.UniswapQuoteBuyExactlyAmountOut,
|
|
17
|
+
models.UniswapQuoteBuyExactlyAmountOutTypedDict,
|
|
18
|
+
],
|
|
19
|
+
chain: Optional[
|
|
20
|
+
models.UniswapQuoteBuyExactlyChain
|
|
21
|
+
] = models.UniswapQuoteBuyExactlyChain.ARBITRUM_MAINNET,
|
|
22
|
+
token_in: Optional[
|
|
23
|
+
models.UniswapQuoteBuyExactlyTokenInToken
|
|
24
|
+
] = models.UniswapQuoteBuyExactlyTokenInToken.USDC,
|
|
25
|
+
token_out: Optional[
|
|
26
|
+
models.UniswapQuoteBuyExactlyTokenOutToken
|
|
27
|
+
] = models.UniswapQuoteBuyExactlyTokenOutToken.USDT,
|
|
28
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
29
|
+
server_url: Optional[str] = None,
|
|
30
|
+
timeout_ms: Optional[int] = None,
|
|
31
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
32
|
+
) -> models.UniswapBuyQuoteInfoResponse:
|
|
33
|
+
r"""Get quote - to specified amount
|
|
34
|
+
|
|
35
|
+
This endpoint calculates the amount of input tokens required to purchase a
|
|
36
|
+
specified amount of output tokens from a Uniswap pool.
|
|
37
|
+
|
|
38
|
+
It also provides the resulting price after the transaction. The calculation takes
|
|
39
|
+
into account the current pool state and the specified fee tier.
|
|
40
|
+
|
|
41
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
42
|
+
:param amount_out:
|
|
43
|
+
:param chain: The chain to use.
|
|
44
|
+
:param token_in: 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.
|
|
45
|
+
:param token_out: 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.
|
|
46
|
+
:param retries: Override the default retry configuration for this method
|
|
47
|
+
:param server_url: Override the default server URL for this method
|
|
48
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
49
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
50
|
+
"""
|
|
51
|
+
base_url = None
|
|
52
|
+
url_variables = None
|
|
53
|
+
if timeout_ms is None:
|
|
54
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
55
|
+
|
|
56
|
+
if server_url is not None:
|
|
57
|
+
base_url = server_url
|
|
58
|
+
else:
|
|
59
|
+
base_url = self._get_url(base_url, url_variables)
|
|
60
|
+
|
|
61
|
+
request = models.UniswapQuoteBuyExactlyRequest(
|
|
62
|
+
chain=chain,
|
|
63
|
+
token_in=token_in,
|
|
64
|
+
token_out=token_out,
|
|
65
|
+
fee=fee,
|
|
66
|
+
amount_out=amount_out,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
req = self._build_request(
|
|
70
|
+
method="GET",
|
|
71
|
+
path="/v0/uniswap/quote/buy_exactly/get",
|
|
72
|
+
base_url=base_url,
|
|
73
|
+
url_variables=url_variables,
|
|
74
|
+
request=request,
|
|
75
|
+
request_body_required=False,
|
|
76
|
+
request_has_path_params=False,
|
|
77
|
+
request_has_query_params=True,
|
|
78
|
+
user_agent_header="user-agent",
|
|
79
|
+
accept_header_value="application/json",
|
|
80
|
+
http_headers=http_headers,
|
|
81
|
+
security=self.sdk_configuration.security,
|
|
82
|
+
timeout_ms=timeout_ms,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
if retries == UNSET:
|
|
86
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
87
|
+
retries = self.sdk_configuration.retry_config
|
|
88
|
+
|
|
89
|
+
retry_config = None
|
|
90
|
+
if isinstance(retries, utils.RetryConfig):
|
|
91
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
92
|
+
|
|
93
|
+
http_res = self.do_request(
|
|
94
|
+
hook_ctx=HookContext(
|
|
95
|
+
base_url=base_url or "",
|
|
96
|
+
operation_id="uniswap_quote_buy_exactly",
|
|
97
|
+
oauth2_scopes=[],
|
|
98
|
+
security_source=self.sdk_configuration.security,
|
|
99
|
+
),
|
|
100
|
+
request=req,
|
|
101
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
102
|
+
retry_config=retry_config,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
response_data: Any = None
|
|
106
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
107
|
+
return utils.unmarshal_json(
|
|
108
|
+
http_res.text, models.UniswapBuyQuoteInfoResponse
|
|
109
|
+
)
|
|
110
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
111
|
+
response_data = utils.unmarshal_json(
|
|
112
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
113
|
+
)
|
|
114
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
115
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
116
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
117
|
+
raise errors.APIError(
|
|
118
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
119
|
+
)
|
|
120
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
121
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
122
|
+
raise errors.APIError(
|
|
123
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
content_type = http_res.headers.get("Content-Type")
|
|
127
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
128
|
+
raise errors.APIError(
|
|
129
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
130
|
+
http_res.status_code,
|
|
131
|
+
http_res_text,
|
|
132
|
+
http_res,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
async def quote_buy_exactly_async(
|
|
136
|
+
self,
|
|
137
|
+
*,
|
|
138
|
+
fee: models.UniswapQuoteBuyExactlyFeeEnum = models.UniswapQuoteBuyExactlyFeeEnum.ZERO_DOT_01,
|
|
139
|
+
amount_out: Union[
|
|
140
|
+
models.UniswapQuoteBuyExactlyAmountOut,
|
|
141
|
+
models.UniswapQuoteBuyExactlyAmountOutTypedDict,
|
|
142
|
+
],
|
|
143
|
+
chain: Optional[
|
|
144
|
+
models.UniswapQuoteBuyExactlyChain
|
|
145
|
+
] = models.UniswapQuoteBuyExactlyChain.ARBITRUM_MAINNET,
|
|
146
|
+
token_in: Optional[
|
|
147
|
+
models.UniswapQuoteBuyExactlyTokenInToken
|
|
148
|
+
] = models.UniswapQuoteBuyExactlyTokenInToken.USDC,
|
|
149
|
+
token_out: Optional[
|
|
150
|
+
models.UniswapQuoteBuyExactlyTokenOutToken
|
|
151
|
+
] = models.UniswapQuoteBuyExactlyTokenOutToken.USDT,
|
|
152
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
153
|
+
server_url: Optional[str] = None,
|
|
154
|
+
timeout_ms: Optional[int] = None,
|
|
155
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
156
|
+
) -> models.UniswapBuyQuoteInfoResponse:
|
|
157
|
+
r"""Get quote - to specified amount
|
|
158
|
+
|
|
159
|
+
This endpoint calculates the amount of input tokens required to purchase a
|
|
160
|
+
specified amount of output tokens from a Uniswap pool.
|
|
161
|
+
|
|
162
|
+
It also provides the resulting price after the transaction. The calculation takes
|
|
163
|
+
into account the current pool state and the specified fee tier.
|
|
164
|
+
|
|
165
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
166
|
+
:param amount_out:
|
|
167
|
+
:param chain: The chain to use.
|
|
168
|
+
:param token_in: 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.
|
|
169
|
+
:param token_out: 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.
|
|
170
|
+
:param retries: Override the default retry configuration for this method
|
|
171
|
+
:param server_url: Override the default server URL for this method
|
|
172
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
173
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
174
|
+
"""
|
|
175
|
+
base_url = None
|
|
176
|
+
url_variables = None
|
|
177
|
+
if timeout_ms is None:
|
|
178
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
179
|
+
|
|
180
|
+
if server_url is not None:
|
|
181
|
+
base_url = server_url
|
|
182
|
+
else:
|
|
183
|
+
base_url = self._get_url(base_url, url_variables)
|
|
184
|
+
|
|
185
|
+
request = models.UniswapQuoteBuyExactlyRequest(
|
|
186
|
+
chain=chain,
|
|
187
|
+
token_in=token_in,
|
|
188
|
+
token_out=token_out,
|
|
189
|
+
fee=fee,
|
|
190
|
+
amount_out=amount_out,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
req = self._build_request_async(
|
|
194
|
+
method="GET",
|
|
195
|
+
path="/v0/uniswap/quote/buy_exactly/get",
|
|
196
|
+
base_url=base_url,
|
|
197
|
+
url_variables=url_variables,
|
|
198
|
+
request=request,
|
|
199
|
+
request_body_required=False,
|
|
200
|
+
request_has_path_params=False,
|
|
201
|
+
request_has_query_params=True,
|
|
202
|
+
user_agent_header="user-agent",
|
|
203
|
+
accept_header_value="application/json",
|
|
204
|
+
http_headers=http_headers,
|
|
205
|
+
security=self.sdk_configuration.security,
|
|
206
|
+
timeout_ms=timeout_ms,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
if retries == UNSET:
|
|
210
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
211
|
+
retries = self.sdk_configuration.retry_config
|
|
212
|
+
|
|
213
|
+
retry_config = None
|
|
214
|
+
if isinstance(retries, utils.RetryConfig):
|
|
215
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
216
|
+
|
|
217
|
+
http_res = await self.do_request_async(
|
|
218
|
+
hook_ctx=HookContext(
|
|
219
|
+
base_url=base_url or "",
|
|
220
|
+
operation_id="uniswap_quote_buy_exactly",
|
|
221
|
+
oauth2_scopes=[],
|
|
222
|
+
security_source=self.sdk_configuration.security,
|
|
223
|
+
),
|
|
224
|
+
request=req,
|
|
225
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
226
|
+
retry_config=retry_config,
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
response_data: Any = None
|
|
230
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
231
|
+
return utils.unmarshal_json(
|
|
232
|
+
http_res.text, models.UniswapBuyQuoteInfoResponse
|
|
233
|
+
)
|
|
234
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
235
|
+
response_data = utils.unmarshal_json(
|
|
236
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
237
|
+
)
|
|
238
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
239
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
240
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
241
|
+
raise errors.APIError(
|
|
242
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
243
|
+
)
|
|
244
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
245
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
246
|
+
raise errors.APIError(
|
|
247
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
content_type = http_res.headers.get("Content-Type")
|
|
251
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
252
|
+
raise errors.APIError(
|
|
253
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
254
|
+
http_res.status_code,
|
|
255
|
+
http_res_text,
|
|
256
|
+
http_res,
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
def quote_sell_exactly(
|
|
260
|
+
self,
|
|
261
|
+
*,
|
|
262
|
+
fee: models.UniswapQuoteSellExactlyFeeEnum = models.UniswapQuoteSellExactlyFeeEnum.ZERO_DOT_01,
|
|
263
|
+
amount_in: Union[
|
|
264
|
+
models.UniswapQuoteSellExactlyAmountIn,
|
|
265
|
+
models.UniswapQuoteSellExactlyAmountInTypedDict,
|
|
266
|
+
],
|
|
267
|
+
chain: Optional[
|
|
268
|
+
models.UniswapQuoteSellExactlyChain
|
|
269
|
+
] = models.UniswapQuoteSellExactlyChain.ARBITRUM_MAINNET,
|
|
270
|
+
token_in: Optional[
|
|
271
|
+
models.UniswapQuoteSellExactlyTokenInToken
|
|
272
|
+
] = models.UniswapQuoteSellExactlyTokenInToken.USDC,
|
|
273
|
+
token_out: Optional[
|
|
274
|
+
models.UniswapQuoteSellExactlyTokenOutToken
|
|
275
|
+
] = models.UniswapQuoteSellExactlyTokenOutToken.USDT,
|
|
276
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
277
|
+
server_url: Optional[str] = None,
|
|
278
|
+
timeout_ms: Optional[int] = None,
|
|
279
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
280
|
+
) -> models.UniswapSellQuoteInfoResponse:
|
|
281
|
+
r"""Get quote - from specified amount
|
|
282
|
+
|
|
283
|
+
This endpoint calculates the amount of input tokens required to purchase a
|
|
284
|
+
specified amount of output tokens from a Uniswap pool.
|
|
285
|
+
|
|
286
|
+
It also provides the resulting price after the transaction. The calculation takes
|
|
287
|
+
into account the current pool state and the specified fee tier.
|
|
288
|
+
|
|
289
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
290
|
+
:param amount_in:
|
|
291
|
+
:param chain: The chain to use.
|
|
292
|
+
:param token_in: 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.
|
|
293
|
+
:param token_out: 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.
|
|
294
|
+
:param retries: Override the default retry configuration for this method
|
|
295
|
+
:param server_url: Override the default server URL for this method
|
|
296
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
297
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
298
|
+
"""
|
|
299
|
+
base_url = None
|
|
300
|
+
url_variables = None
|
|
301
|
+
if timeout_ms is None:
|
|
302
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
303
|
+
|
|
304
|
+
if server_url is not None:
|
|
305
|
+
base_url = server_url
|
|
306
|
+
else:
|
|
307
|
+
base_url = self._get_url(base_url, url_variables)
|
|
308
|
+
|
|
309
|
+
request = models.UniswapQuoteSellExactlyRequest(
|
|
310
|
+
chain=chain,
|
|
311
|
+
token_in=token_in,
|
|
312
|
+
token_out=token_out,
|
|
313
|
+
fee=fee,
|
|
314
|
+
amount_in=amount_in,
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
req = self._build_request(
|
|
318
|
+
method="GET",
|
|
319
|
+
path="/v0/uniswap/quote/sell_exactly/get",
|
|
320
|
+
base_url=base_url,
|
|
321
|
+
url_variables=url_variables,
|
|
322
|
+
request=request,
|
|
323
|
+
request_body_required=False,
|
|
324
|
+
request_has_path_params=False,
|
|
325
|
+
request_has_query_params=True,
|
|
326
|
+
user_agent_header="user-agent",
|
|
327
|
+
accept_header_value="application/json",
|
|
328
|
+
http_headers=http_headers,
|
|
329
|
+
security=self.sdk_configuration.security,
|
|
330
|
+
timeout_ms=timeout_ms,
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
if retries == UNSET:
|
|
334
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
335
|
+
retries = self.sdk_configuration.retry_config
|
|
336
|
+
|
|
337
|
+
retry_config = None
|
|
338
|
+
if isinstance(retries, utils.RetryConfig):
|
|
339
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
340
|
+
|
|
341
|
+
http_res = self.do_request(
|
|
342
|
+
hook_ctx=HookContext(
|
|
343
|
+
base_url=base_url or "",
|
|
344
|
+
operation_id="uniswap_quote_sell_exactly",
|
|
345
|
+
oauth2_scopes=[],
|
|
346
|
+
security_source=self.sdk_configuration.security,
|
|
347
|
+
),
|
|
348
|
+
request=req,
|
|
349
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
350
|
+
retry_config=retry_config,
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
response_data: Any = None
|
|
354
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
355
|
+
return utils.unmarshal_json(
|
|
356
|
+
http_res.text, models.UniswapSellQuoteInfoResponse
|
|
357
|
+
)
|
|
358
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
359
|
+
response_data = utils.unmarshal_json(
|
|
360
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
361
|
+
)
|
|
362
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
363
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
364
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
365
|
+
raise errors.APIError(
|
|
366
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
367
|
+
)
|
|
368
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
369
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
370
|
+
raise errors.APIError(
|
|
371
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
content_type = http_res.headers.get("Content-Type")
|
|
375
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
376
|
+
raise errors.APIError(
|
|
377
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
378
|
+
http_res.status_code,
|
|
379
|
+
http_res_text,
|
|
380
|
+
http_res,
|
|
381
|
+
)
|
|
382
|
+
|
|
383
|
+
async def quote_sell_exactly_async(
|
|
384
|
+
self,
|
|
385
|
+
*,
|
|
386
|
+
fee: models.UniswapQuoteSellExactlyFeeEnum = models.UniswapQuoteSellExactlyFeeEnum.ZERO_DOT_01,
|
|
387
|
+
amount_in: Union[
|
|
388
|
+
models.UniswapQuoteSellExactlyAmountIn,
|
|
389
|
+
models.UniswapQuoteSellExactlyAmountInTypedDict,
|
|
390
|
+
],
|
|
391
|
+
chain: Optional[
|
|
392
|
+
models.UniswapQuoteSellExactlyChain
|
|
393
|
+
] = models.UniswapQuoteSellExactlyChain.ARBITRUM_MAINNET,
|
|
394
|
+
token_in: Optional[
|
|
395
|
+
models.UniswapQuoteSellExactlyTokenInToken
|
|
396
|
+
] = models.UniswapQuoteSellExactlyTokenInToken.USDC,
|
|
397
|
+
token_out: Optional[
|
|
398
|
+
models.UniswapQuoteSellExactlyTokenOutToken
|
|
399
|
+
] = models.UniswapQuoteSellExactlyTokenOutToken.USDT,
|
|
400
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
401
|
+
server_url: Optional[str] = None,
|
|
402
|
+
timeout_ms: Optional[int] = None,
|
|
403
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
404
|
+
) -> models.UniswapSellQuoteInfoResponse:
|
|
405
|
+
r"""Get quote - from specified amount
|
|
406
|
+
|
|
407
|
+
This endpoint calculates the amount of input tokens required to purchase a
|
|
408
|
+
specified amount of output tokens from a Uniswap pool.
|
|
409
|
+
|
|
410
|
+
It also provides the resulting price after the transaction. The calculation takes
|
|
411
|
+
into account the current pool state and the specified fee tier.
|
|
412
|
+
|
|
413
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
414
|
+
:param amount_in:
|
|
415
|
+
:param chain: The chain to use.
|
|
416
|
+
:param token_in: 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.
|
|
417
|
+
:param token_out: 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.
|
|
418
|
+
:param retries: Override the default retry configuration for this method
|
|
419
|
+
:param server_url: Override the default server URL for this method
|
|
420
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
421
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
422
|
+
"""
|
|
423
|
+
base_url = None
|
|
424
|
+
url_variables = None
|
|
425
|
+
if timeout_ms is None:
|
|
426
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
427
|
+
|
|
428
|
+
if server_url is not None:
|
|
429
|
+
base_url = server_url
|
|
430
|
+
else:
|
|
431
|
+
base_url = self._get_url(base_url, url_variables)
|
|
432
|
+
|
|
433
|
+
request = models.UniswapQuoteSellExactlyRequest(
|
|
434
|
+
chain=chain,
|
|
435
|
+
token_in=token_in,
|
|
436
|
+
token_out=token_out,
|
|
437
|
+
fee=fee,
|
|
438
|
+
amount_in=amount_in,
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
req = self._build_request_async(
|
|
442
|
+
method="GET",
|
|
443
|
+
path="/v0/uniswap/quote/sell_exactly/get",
|
|
444
|
+
base_url=base_url,
|
|
445
|
+
url_variables=url_variables,
|
|
446
|
+
request=request,
|
|
447
|
+
request_body_required=False,
|
|
448
|
+
request_has_path_params=False,
|
|
449
|
+
request_has_query_params=True,
|
|
450
|
+
user_agent_header="user-agent",
|
|
451
|
+
accept_header_value="application/json",
|
|
452
|
+
http_headers=http_headers,
|
|
453
|
+
security=self.sdk_configuration.security,
|
|
454
|
+
timeout_ms=timeout_ms,
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
if retries == UNSET:
|
|
458
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
459
|
+
retries = self.sdk_configuration.retry_config
|
|
460
|
+
|
|
461
|
+
retry_config = None
|
|
462
|
+
if isinstance(retries, utils.RetryConfig):
|
|
463
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
464
|
+
|
|
465
|
+
http_res = await self.do_request_async(
|
|
466
|
+
hook_ctx=HookContext(
|
|
467
|
+
base_url=base_url or "",
|
|
468
|
+
operation_id="uniswap_quote_sell_exactly",
|
|
469
|
+
oauth2_scopes=[],
|
|
470
|
+
security_source=self.sdk_configuration.security,
|
|
471
|
+
),
|
|
472
|
+
request=req,
|
|
473
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
474
|
+
retry_config=retry_config,
|
|
475
|
+
)
|
|
476
|
+
|
|
477
|
+
response_data: Any = None
|
|
478
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
479
|
+
return utils.unmarshal_json(
|
|
480
|
+
http_res.text, models.UniswapSellQuoteInfoResponse
|
|
481
|
+
)
|
|
482
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
483
|
+
response_data = utils.unmarshal_json(
|
|
484
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
485
|
+
)
|
|
486
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
487
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
488
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
489
|
+
raise errors.APIError(
|
|
490
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
491
|
+
)
|
|
492
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
493
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
494
|
+
raise errors.APIError(
|
|
495
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
496
|
+
)
|
|
497
|
+
|
|
498
|
+
content_type = http_res.headers.get("Content-Type")
|
|
499
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
500
|
+
raise errors.APIError(
|
|
501
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
502
|
+
http_res.status_code,
|
|
503
|
+
http_res_text,
|
|
504
|
+
http_res,
|
|
505
|
+
)
|
|
506
|
+
|
|
507
|
+
def pool_price(
|
|
508
|
+
self,
|
|
509
|
+
*,
|
|
510
|
+
token_in: models.UniswapPoolPriceTokenInToken = models.UniswapPoolPriceTokenInToken.USDC,
|
|
511
|
+
token_out: models.UniswapPoolPriceTokenOutToken = models.UniswapPoolPriceTokenOutToken.USDT,
|
|
512
|
+
fee: models.UniswapPoolPriceFeeEnum = models.UniswapPoolPriceFeeEnum.ZERO_DOT_01,
|
|
513
|
+
chain: Optional[
|
|
514
|
+
models.UniswapPoolPriceChain
|
|
515
|
+
] = models.UniswapPoolPriceChain.ARBITRUM_MAINNET,
|
|
516
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
517
|
+
server_url: Optional[str] = None,
|
|
518
|
+
timeout_ms: Optional[int] = None,
|
|
519
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
520
|
+
) -> models.UniswapPoolPriceResponse:
|
|
521
|
+
r"""Pool price
|
|
522
|
+
|
|
523
|
+
This endpoint calculates the price of a token in a Uniswap pool.
|
|
524
|
+
|
|
525
|
+
The price is calculated based on the current pool state and the specified fee tier.
|
|
526
|
+
|
|
527
|
+
:param token_in: 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.
|
|
528
|
+
:param token_out: 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.
|
|
529
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
530
|
+
:param chain: The chain to use.
|
|
531
|
+
:param retries: Override the default retry configuration for this method
|
|
532
|
+
:param server_url: Override the default server URL for this method
|
|
533
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
534
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
535
|
+
"""
|
|
536
|
+
base_url = None
|
|
537
|
+
url_variables = None
|
|
538
|
+
if timeout_ms is None:
|
|
539
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
540
|
+
|
|
541
|
+
if server_url is not None:
|
|
542
|
+
base_url = server_url
|
|
543
|
+
else:
|
|
544
|
+
base_url = self._get_url(base_url, url_variables)
|
|
545
|
+
|
|
546
|
+
request = models.UniswapPoolPriceRequest(
|
|
547
|
+
chain=chain,
|
|
548
|
+
token_in=token_in,
|
|
549
|
+
token_out=token_out,
|
|
550
|
+
fee=fee,
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
req = self._build_request(
|
|
554
|
+
method="GET",
|
|
555
|
+
path="/v0/uniswap/pool_price/get",
|
|
556
|
+
base_url=base_url,
|
|
557
|
+
url_variables=url_variables,
|
|
558
|
+
request=request,
|
|
559
|
+
request_body_required=False,
|
|
560
|
+
request_has_path_params=False,
|
|
561
|
+
request_has_query_params=True,
|
|
562
|
+
user_agent_header="user-agent",
|
|
563
|
+
accept_header_value="application/json",
|
|
564
|
+
http_headers=http_headers,
|
|
565
|
+
security=self.sdk_configuration.security,
|
|
566
|
+
timeout_ms=timeout_ms,
|
|
567
|
+
)
|
|
568
|
+
|
|
569
|
+
if retries == UNSET:
|
|
570
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
571
|
+
retries = self.sdk_configuration.retry_config
|
|
572
|
+
|
|
573
|
+
retry_config = None
|
|
574
|
+
if isinstance(retries, utils.RetryConfig):
|
|
575
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
576
|
+
|
|
577
|
+
http_res = self.do_request(
|
|
578
|
+
hook_ctx=HookContext(
|
|
579
|
+
base_url=base_url or "",
|
|
580
|
+
operation_id="uniswap_pool_price",
|
|
581
|
+
oauth2_scopes=[],
|
|
582
|
+
security_source=self.sdk_configuration.security,
|
|
583
|
+
),
|
|
584
|
+
request=req,
|
|
585
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
586
|
+
retry_config=retry_config,
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
response_data: Any = None
|
|
590
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
591
|
+
return utils.unmarshal_json(http_res.text, models.UniswapPoolPriceResponse)
|
|
592
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
593
|
+
response_data = utils.unmarshal_json(
|
|
594
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
595
|
+
)
|
|
596
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
597
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
598
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
599
|
+
raise errors.APIError(
|
|
600
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
601
|
+
)
|
|
602
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
603
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
604
|
+
raise errors.APIError(
|
|
605
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
606
|
+
)
|
|
607
|
+
|
|
608
|
+
content_type = http_res.headers.get("Content-Type")
|
|
609
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
610
|
+
raise errors.APIError(
|
|
611
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
612
|
+
http_res.status_code,
|
|
613
|
+
http_res_text,
|
|
614
|
+
http_res,
|
|
615
|
+
)
|
|
616
|
+
|
|
617
|
+
async def pool_price_async(
|
|
618
|
+
self,
|
|
619
|
+
*,
|
|
620
|
+
token_in: models.UniswapPoolPriceTokenInToken = models.UniswapPoolPriceTokenInToken.USDC,
|
|
621
|
+
token_out: models.UniswapPoolPriceTokenOutToken = models.UniswapPoolPriceTokenOutToken.USDT,
|
|
622
|
+
fee: models.UniswapPoolPriceFeeEnum = models.UniswapPoolPriceFeeEnum.ZERO_DOT_01,
|
|
623
|
+
chain: Optional[
|
|
624
|
+
models.UniswapPoolPriceChain
|
|
625
|
+
] = models.UniswapPoolPriceChain.ARBITRUM_MAINNET,
|
|
626
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
627
|
+
server_url: Optional[str] = None,
|
|
628
|
+
timeout_ms: Optional[int] = None,
|
|
629
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
630
|
+
) -> models.UniswapPoolPriceResponse:
|
|
631
|
+
r"""Pool price
|
|
632
|
+
|
|
633
|
+
This endpoint calculates the price of a token in a Uniswap pool.
|
|
634
|
+
|
|
635
|
+
The price is calculated based on the current pool state and the specified fee tier.
|
|
636
|
+
|
|
637
|
+
:param token_in: 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.
|
|
638
|
+
:param token_out: 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.
|
|
639
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
640
|
+
:param chain: The chain to use.
|
|
641
|
+
:param retries: Override the default retry configuration for this method
|
|
642
|
+
:param server_url: Override the default server URL for this method
|
|
643
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
644
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
645
|
+
"""
|
|
646
|
+
base_url = None
|
|
647
|
+
url_variables = None
|
|
648
|
+
if timeout_ms is None:
|
|
649
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
650
|
+
|
|
651
|
+
if server_url is not None:
|
|
652
|
+
base_url = server_url
|
|
653
|
+
else:
|
|
654
|
+
base_url = self._get_url(base_url, url_variables)
|
|
655
|
+
|
|
656
|
+
request = models.UniswapPoolPriceRequest(
|
|
657
|
+
chain=chain,
|
|
658
|
+
token_in=token_in,
|
|
659
|
+
token_out=token_out,
|
|
660
|
+
fee=fee,
|
|
661
|
+
)
|
|
662
|
+
|
|
663
|
+
req = self._build_request_async(
|
|
664
|
+
method="GET",
|
|
665
|
+
path="/v0/uniswap/pool_price/get",
|
|
666
|
+
base_url=base_url,
|
|
667
|
+
url_variables=url_variables,
|
|
668
|
+
request=request,
|
|
669
|
+
request_body_required=False,
|
|
670
|
+
request_has_path_params=False,
|
|
671
|
+
request_has_query_params=True,
|
|
672
|
+
user_agent_header="user-agent",
|
|
673
|
+
accept_header_value="application/json",
|
|
674
|
+
http_headers=http_headers,
|
|
675
|
+
security=self.sdk_configuration.security,
|
|
676
|
+
timeout_ms=timeout_ms,
|
|
677
|
+
)
|
|
678
|
+
|
|
679
|
+
if retries == UNSET:
|
|
680
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
681
|
+
retries = self.sdk_configuration.retry_config
|
|
682
|
+
|
|
683
|
+
retry_config = None
|
|
684
|
+
if isinstance(retries, utils.RetryConfig):
|
|
685
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
686
|
+
|
|
687
|
+
http_res = await self.do_request_async(
|
|
688
|
+
hook_ctx=HookContext(
|
|
689
|
+
base_url=base_url or "",
|
|
690
|
+
operation_id="uniswap_pool_price",
|
|
691
|
+
oauth2_scopes=[],
|
|
692
|
+
security_source=self.sdk_configuration.security,
|
|
693
|
+
),
|
|
694
|
+
request=req,
|
|
695
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
696
|
+
retry_config=retry_config,
|
|
697
|
+
)
|
|
698
|
+
|
|
699
|
+
response_data: Any = None
|
|
700
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
701
|
+
return utils.unmarshal_json(http_res.text, models.UniswapPoolPriceResponse)
|
|
702
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
703
|
+
response_data = utils.unmarshal_json(
|
|
704
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
705
|
+
)
|
|
706
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
707
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
708
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
709
|
+
raise errors.APIError(
|
|
710
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
711
|
+
)
|
|
712
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
713
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
714
|
+
raise errors.APIError(
|
|
715
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
716
|
+
)
|
|
717
|
+
|
|
718
|
+
content_type = http_res.headers.get("Content-Type")
|
|
719
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
720
|
+
raise errors.APIError(
|
|
721
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
722
|
+
http_res.status_code,
|
|
723
|
+
http_res_text,
|
|
724
|
+
http_res,
|
|
725
|
+
)
|
|
726
|
+
|
|
727
|
+
def liquidity_provision_in_range(
|
|
728
|
+
self,
|
|
729
|
+
*,
|
|
730
|
+
token_id: int = 4318185,
|
|
731
|
+
chain: Optional[
|
|
732
|
+
models.UniswapLiquidityProvisionInRangeChain
|
|
733
|
+
] = models.UniswapLiquidityProvisionInRangeChain.ARBITRUM_MAINNET,
|
|
734
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
735
|
+
server_url: Optional[str] = None,
|
|
736
|
+
timeout_ms: Optional[int] = None,
|
|
737
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
738
|
+
) -> models.UniswapCheckInRangeResponse:
|
|
739
|
+
r"""Check if LP is active.
|
|
740
|
+
|
|
741
|
+
This endpoint allows users to check whether a specific liquidity provider ()
|
|
742
|
+
position is within the active tick range on the uniswap platform.
|
|
743
|
+
|
|
744
|
+
by providing the token id associated with the position, users can verify if the
|
|
745
|
+
position is currently within the tick range where trading occurs. this information
|
|
746
|
+
is essential for users to monitor the status of their lp positions and ensure that
|
|
747
|
+
they are actively participating in the trading activities within the liquidity pool
|
|
748
|
+
and earning trading fees.
|
|
749
|
+
|
|
750
|
+
:param token_id:
|
|
751
|
+
:param chain: The chain to use.
|
|
752
|
+
:param retries: Override the default retry configuration for this method
|
|
753
|
+
:param server_url: Override the default server URL for this method
|
|
754
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
755
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
756
|
+
"""
|
|
757
|
+
base_url = None
|
|
758
|
+
url_variables = None
|
|
759
|
+
if timeout_ms is None:
|
|
760
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
761
|
+
|
|
762
|
+
if server_url is not None:
|
|
763
|
+
base_url = server_url
|
|
764
|
+
else:
|
|
765
|
+
base_url = self._get_url(base_url, url_variables)
|
|
766
|
+
|
|
767
|
+
request = models.UniswapLiquidityProvisionInRangeRequest(
|
|
768
|
+
chain=chain,
|
|
769
|
+
token_id=token_id,
|
|
770
|
+
)
|
|
771
|
+
|
|
772
|
+
req = self._build_request(
|
|
773
|
+
method="GET",
|
|
774
|
+
path="/v0/uniswap/liquidity_provision/in_range/get",
|
|
775
|
+
base_url=base_url,
|
|
776
|
+
url_variables=url_variables,
|
|
777
|
+
request=request,
|
|
778
|
+
request_body_required=False,
|
|
779
|
+
request_has_path_params=False,
|
|
780
|
+
request_has_query_params=True,
|
|
781
|
+
user_agent_header="user-agent",
|
|
782
|
+
accept_header_value="application/json",
|
|
783
|
+
http_headers=http_headers,
|
|
784
|
+
security=self.sdk_configuration.security,
|
|
785
|
+
timeout_ms=timeout_ms,
|
|
786
|
+
)
|
|
787
|
+
|
|
788
|
+
if retries == UNSET:
|
|
789
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
790
|
+
retries = self.sdk_configuration.retry_config
|
|
791
|
+
|
|
792
|
+
retry_config = None
|
|
793
|
+
if isinstance(retries, utils.RetryConfig):
|
|
794
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
795
|
+
|
|
796
|
+
http_res = self.do_request(
|
|
797
|
+
hook_ctx=HookContext(
|
|
798
|
+
base_url=base_url or "",
|
|
799
|
+
operation_id="uniswap_liquidity_provision_in_range",
|
|
800
|
+
oauth2_scopes=[],
|
|
801
|
+
security_source=self.sdk_configuration.security,
|
|
802
|
+
),
|
|
803
|
+
request=req,
|
|
804
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
805
|
+
retry_config=retry_config,
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
response_data: Any = None
|
|
809
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
810
|
+
return utils.unmarshal_json(
|
|
811
|
+
http_res.text, models.UniswapCheckInRangeResponse
|
|
812
|
+
)
|
|
813
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
814
|
+
response_data = utils.unmarshal_json(
|
|
815
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
816
|
+
)
|
|
817
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
818
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
819
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
820
|
+
raise errors.APIError(
|
|
821
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
822
|
+
)
|
|
823
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
824
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
825
|
+
raise errors.APIError(
|
|
826
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
827
|
+
)
|
|
828
|
+
|
|
829
|
+
content_type = http_res.headers.get("Content-Type")
|
|
830
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
831
|
+
raise errors.APIError(
|
|
832
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
833
|
+
http_res.status_code,
|
|
834
|
+
http_res_text,
|
|
835
|
+
http_res,
|
|
836
|
+
)
|
|
837
|
+
|
|
838
|
+
async def liquidity_provision_in_range_async(
|
|
839
|
+
self,
|
|
840
|
+
*,
|
|
841
|
+
token_id: int = 4318185,
|
|
842
|
+
chain: Optional[
|
|
843
|
+
models.UniswapLiquidityProvisionInRangeChain
|
|
844
|
+
] = models.UniswapLiquidityProvisionInRangeChain.ARBITRUM_MAINNET,
|
|
845
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
846
|
+
server_url: Optional[str] = None,
|
|
847
|
+
timeout_ms: Optional[int] = None,
|
|
848
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
849
|
+
) -> models.UniswapCheckInRangeResponse:
|
|
850
|
+
r"""Check if LP is active.
|
|
851
|
+
|
|
852
|
+
This endpoint allows users to check whether a specific liquidity provider ()
|
|
853
|
+
position is within the active tick range on the uniswap platform.
|
|
854
|
+
|
|
855
|
+
by providing the token id associated with the position, users can verify if the
|
|
856
|
+
position is currently within the tick range where trading occurs. this information
|
|
857
|
+
is essential for users to monitor the status of their lp positions and ensure that
|
|
858
|
+
they are actively participating in the trading activities within the liquidity pool
|
|
859
|
+
and earning trading fees.
|
|
860
|
+
|
|
861
|
+
:param token_id:
|
|
862
|
+
:param chain: The chain to use.
|
|
863
|
+
:param retries: Override the default retry configuration for this method
|
|
864
|
+
:param server_url: Override the default server URL for this method
|
|
865
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
866
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
867
|
+
"""
|
|
868
|
+
base_url = None
|
|
869
|
+
url_variables = None
|
|
870
|
+
if timeout_ms is None:
|
|
871
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
872
|
+
|
|
873
|
+
if server_url is not None:
|
|
874
|
+
base_url = server_url
|
|
875
|
+
else:
|
|
876
|
+
base_url = self._get_url(base_url, url_variables)
|
|
877
|
+
|
|
878
|
+
request = models.UniswapLiquidityProvisionInRangeRequest(
|
|
879
|
+
chain=chain,
|
|
880
|
+
token_id=token_id,
|
|
881
|
+
)
|
|
882
|
+
|
|
883
|
+
req = self._build_request_async(
|
|
884
|
+
method="GET",
|
|
885
|
+
path="/v0/uniswap/liquidity_provision/in_range/get",
|
|
886
|
+
base_url=base_url,
|
|
887
|
+
url_variables=url_variables,
|
|
888
|
+
request=request,
|
|
889
|
+
request_body_required=False,
|
|
890
|
+
request_has_path_params=False,
|
|
891
|
+
request_has_query_params=True,
|
|
892
|
+
user_agent_header="user-agent",
|
|
893
|
+
accept_header_value="application/json",
|
|
894
|
+
http_headers=http_headers,
|
|
895
|
+
security=self.sdk_configuration.security,
|
|
896
|
+
timeout_ms=timeout_ms,
|
|
897
|
+
)
|
|
898
|
+
|
|
899
|
+
if retries == UNSET:
|
|
900
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
901
|
+
retries = self.sdk_configuration.retry_config
|
|
902
|
+
|
|
903
|
+
retry_config = None
|
|
904
|
+
if isinstance(retries, utils.RetryConfig):
|
|
905
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
906
|
+
|
|
907
|
+
http_res = await self.do_request_async(
|
|
908
|
+
hook_ctx=HookContext(
|
|
909
|
+
base_url=base_url or "",
|
|
910
|
+
operation_id="uniswap_liquidity_provision_in_range",
|
|
911
|
+
oauth2_scopes=[],
|
|
912
|
+
security_source=self.sdk_configuration.security,
|
|
913
|
+
),
|
|
914
|
+
request=req,
|
|
915
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
916
|
+
retry_config=retry_config,
|
|
917
|
+
)
|
|
918
|
+
|
|
919
|
+
response_data: Any = None
|
|
920
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
921
|
+
return utils.unmarshal_json(
|
|
922
|
+
http_res.text, models.UniswapCheckInRangeResponse
|
|
923
|
+
)
|
|
924
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
925
|
+
response_data = utils.unmarshal_json(
|
|
926
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
927
|
+
)
|
|
928
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
929
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
930
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
931
|
+
raise errors.APIError(
|
|
932
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
933
|
+
)
|
|
934
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
935
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
936
|
+
raise errors.APIError(
|
|
937
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
938
|
+
)
|
|
939
|
+
|
|
940
|
+
content_type = http_res.headers.get("Content-Type")
|
|
941
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
942
|
+
raise errors.APIError(
|
|
943
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
944
|
+
http_res.status_code,
|
|
945
|
+
http_res_text,
|
|
946
|
+
http_res,
|
|
947
|
+
)
|
|
948
|
+
|
|
949
|
+
def liquidity_provision_positions(
|
|
950
|
+
self,
|
|
951
|
+
*,
|
|
952
|
+
chain: Optional[
|
|
953
|
+
models.UniswapLiquidityProvisionPositionsChain
|
|
954
|
+
] = models.UniswapLiquidityProvisionPositionsChain.ARBITRUM_MAINNET,
|
|
955
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
956
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
957
|
+
server_url: Optional[str] = None,
|
|
958
|
+
timeout_ms: Optional[int] = None,
|
|
959
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
960
|
+
) -> models.UniswapLPPositionsInfoResponse:
|
|
961
|
+
r"""List LP
|
|
962
|
+
|
|
963
|
+
This endpoint retrieves the number of Liquidity Provider (LP) positions
|
|
964
|
+
associated with a specific sender address on the Uniswap platform.
|
|
965
|
+
|
|
966
|
+
Users can query this endpoint to obtain detailed information about their LP
|
|
967
|
+
positions, including the total number of positions and relevant metadata. This
|
|
968
|
+
information is crucial for users to manage and analyze their liquidity provision
|
|
969
|
+
activities effectively.
|
|
970
|
+
|
|
971
|
+
:param chain: The chain to use.
|
|
972
|
+
:param user:
|
|
973
|
+
:param retries: Override the default retry configuration for this method
|
|
974
|
+
:param server_url: Override the default server URL for this method
|
|
975
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
976
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
977
|
+
"""
|
|
978
|
+
base_url = None
|
|
979
|
+
url_variables = None
|
|
980
|
+
if timeout_ms is None:
|
|
981
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
982
|
+
|
|
983
|
+
if server_url is not None:
|
|
984
|
+
base_url = server_url
|
|
985
|
+
else:
|
|
986
|
+
base_url = self._get_url(base_url, url_variables)
|
|
987
|
+
|
|
988
|
+
request = models.UniswapLiquidityProvisionPositionsRequest(
|
|
989
|
+
chain=chain,
|
|
990
|
+
user=user,
|
|
991
|
+
)
|
|
992
|
+
|
|
993
|
+
req = self._build_request(
|
|
994
|
+
method="GET",
|
|
995
|
+
path="/v0/uniswap/liquidity_provision/positions/get",
|
|
996
|
+
base_url=base_url,
|
|
997
|
+
url_variables=url_variables,
|
|
998
|
+
request=request,
|
|
999
|
+
request_body_required=False,
|
|
1000
|
+
request_has_path_params=False,
|
|
1001
|
+
request_has_query_params=True,
|
|
1002
|
+
user_agent_header="user-agent",
|
|
1003
|
+
accept_header_value="application/json",
|
|
1004
|
+
http_headers=http_headers,
|
|
1005
|
+
security=self.sdk_configuration.security,
|
|
1006
|
+
timeout_ms=timeout_ms,
|
|
1007
|
+
)
|
|
1008
|
+
|
|
1009
|
+
if retries == UNSET:
|
|
1010
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1011
|
+
retries = self.sdk_configuration.retry_config
|
|
1012
|
+
|
|
1013
|
+
retry_config = None
|
|
1014
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1015
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1016
|
+
|
|
1017
|
+
http_res = self.do_request(
|
|
1018
|
+
hook_ctx=HookContext(
|
|
1019
|
+
base_url=base_url or "",
|
|
1020
|
+
operation_id="uniswap_liquidity_provision_positions",
|
|
1021
|
+
oauth2_scopes=[],
|
|
1022
|
+
security_source=self.sdk_configuration.security,
|
|
1023
|
+
),
|
|
1024
|
+
request=req,
|
|
1025
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1026
|
+
retry_config=retry_config,
|
|
1027
|
+
)
|
|
1028
|
+
|
|
1029
|
+
response_data: Any = None
|
|
1030
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1031
|
+
return utils.unmarshal_json(
|
|
1032
|
+
http_res.text, models.UniswapLPPositionsInfoResponse
|
|
1033
|
+
)
|
|
1034
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1035
|
+
response_data = utils.unmarshal_json(
|
|
1036
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1037
|
+
)
|
|
1038
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1039
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1040
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1041
|
+
raise errors.APIError(
|
|
1042
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1043
|
+
)
|
|
1044
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1045
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1046
|
+
raise errors.APIError(
|
|
1047
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1048
|
+
)
|
|
1049
|
+
|
|
1050
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1051
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1052
|
+
raise errors.APIError(
|
|
1053
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1054
|
+
http_res.status_code,
|
|
1055
|
+
http_res_text,
|
|
1056
|
+
http_res,
|
|
1057
|
+
)
|
|
1058
|
+
|
|
1059
|
+
async def liquidity_provision_positions_async(
|
|
1060
|
+
self,
|
|
1061
|
+
*,
|
|
1062
|
+
chain: Optional[
|
|
1063
|
+
models.UniswapLiquidityProvisionPositionsChain
|
|
1064
|
+
] = models.UniswapLiquidityProvisionPositionsChain.ARBITRUM_MAINNET,
|
|
1065
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
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.UniswapLPPositionsInfoResponse:
|
|
1071
|
+
r"""List LP
|
|
1072
|
+
|
|
1073
|
+
This endpoint retrieves the number of Liquidity Provider (LP) positions
|
|
1074
|
+
associated with a specific sender address on the Uniswap platform.
|
|
1075
|
+
|
|
1076
|
+
Users can query this endpoint to obtain detailed information about their LP
|
|
1077
|
+
positions, including the total number of positions and relevant metadata. This
|
|
1078
|
+
information is crucial for users to manage and analyze their liquidity provision
|
|
1079
|
+
activities effectively.
|
|
1080
|
+
|
|
1081
|
+
:param chain: The chain to use.
|
|
1082
|
+
:param user:
|
|
1083
|
+
:param retries: Override the default retry configuration for this method
|
|
1084
|
+
:param server_url: Override the default server URL for this method
|
|
1085
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1086
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1087
|
+
"""
|
|
1088
|
+
base_url = None
|
|
1089
|
+
url_variables = None
|
|
1090
|
+
if timeout_ms is None:
|
|
1091
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1092
|
+
|
|
1093
|
+
if server_url is not None:
|
|
1094
|
+
base_url = server_url
|
|
1095
|
+
else:
|
|
1096
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1097
|
+
|
|
1098
|
+
request = models.UniswapLiquidityProvisionPositionsRequest(
|
|
1099
|
+
chain=chain,
|
|
1100
|
+
user=user,
|
|
1101
|
+
)
|
|
1102
|
+
|
|
1103
|
+
req = self._build_request_async(
|
|
1104
|
+
method="GET",
|
|
1105
|
+
path="/v0/uniswap/liquidity_provision/positions/get",
|
|
1106
|
+
base_url=base_url,
|
|
1107
|
+
url_variables=url_variables,
|
|
1108
|
+
request=request,
|
|
1109
|
+
request_body_required=False,
|
|
1110
|
+
request_has_path_params=False,
|
|
1111
|
+
request_has_query_params=True,
|
|
1112
|
+
user_agent_header="user-agent",
|
|
1113
|
+
accept_header_value="application/json",
|
|
1114
|
+
http_headers=http_headers,
|
|
1115
|
+
security=self.sdk_configuration.security,
|
|
1116
|
+
timeout_ms=timeout_ms,
|
|
1117
|
+
)
|
|
1118
|
+
|
|
1119
|
+
if retries == UNSET:
|
|
1120
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1121
|
+
retries = self.sdk_configuration.retry_config
|
|
1122
|
+
|
|
1123
|
+
retry_config = None
|
|
1124
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1125
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1126
|
+
|
|
1127
|
+
http_res = await self.do_request_async(
|
|
1128
|
+
hook_ctx=HookContext(
|
|
1129
|
+
base_url=base_url or "",
|
|
1130
|
+
operation_id="uniswap_liquidity_provision_positions",
|
|
1131
|
+
oauth2_scopes=[],
|
|
1132
|
+
security_source=self.sdk_configuration.security,
|
|
1133
|
+
),
|
|
1134
|
+
request=req,
|
|
1135
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1136
|
+
retry_config=retry_config,
|
|
1137
|
+
)
|
|
1138
|
+
|
|
1139
|
+
response_data: Any = None
|
|
1140
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1141
|
+
return utils.unmarshal_json(
|
|
1142
|
+
http_res.text, models.UniswapLPPositionsInfoResponse
|
|
1143
|
+
)
|
|
1144
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1145
|
+
response_data = utils.unmarshal_json(
|
|
1146
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1147
|
+
)
|
|
1148
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1149
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1150
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1151
|
+
raise errors.APIError(
|
|
1152
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1153
|
+
)
|
|
1154
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1155
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1156
|
+
raise errors.APIError(
|
|
1157
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1158
|
+
)
|
|
1159
|
+
|
|
1160
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1161
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1162
|
+
raise errors.APIError(
|
|
1163
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1164
|
+
http_res.status_code,
|
|
1165
|
+
http_res_text,
|
|
1166
|
+
http_res,
|
|
1167
|
+
)
|
|
1168
|
+
|
|
1169
|
+
def swap_buy_exactly(
|
|
1170
|
+
self,
|
|
1171
|
+
*,
|
|
1172
|
+
token_in: models.TokenEnum,
|
|
1173
|
+
token_out: models.TokenEnum,
|
|
1174
|
+
fee: models.FeeEnum,
|
|
1175
|
+
amount_out: Union[
|
|
1176
|
+
models.UniswapBuyExactlyRequestAmountOut,
|
|
1177
|
+
models.UniswapBuyExactlyRequestAmountOutTypedDict,
|
|
1178
|
+
],
|
|
1179
|
+
amount_in_maximum: Union[
|
|
1180
|
+
models.UniswapBuyExactlyRequestAmountInMaximum,
|
|
1181
|
+
models.UniswapBuyExactlyRequestAmountInMaximumTypedDict,
|
|
1182
|
+
],
|
|
1183
|
+
chain: models.Chain,
|
|
1184
|
+
sender: str,
|
|
1185
|
+
wrap_eth: Optional[bool] = False,
|
|
1186
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1187
|
+
server_url: Optional[str] = None,
|
|
1188
|
+
timeout_ms: Optional[int] = None,
|
|
1189
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1190
|
+
) -> models.UnsignedTransaction:
|
|
1191
|
+
r"""Buy exact amount
|
|
1192
|
+
|
|
1193
|
+
This endpoint allows users to trade a variable amount of one token to receive an
|
|
1194
|
+
exact amount of another token using the Uniswap protocol.
|
|
1195
|
+
|
|
1196
|
+
The transaction is executed on the specified blockchain network, and the user must
|
|
1197
|
+
provide the necessary transaction details, including the token to buy, the token to
|
|
1198
|
+
pay with, and the exact amount to receive. If the token being paid with is WETH and
|
|
1199
|
+
needs to be wrapped, the appropriate amount will be wrapped automatically.
|
|
1200
|
+
|
|
1201
|
+
:param token_in: 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.
|
|
1202
|
+
:param token_out: 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.
|
|
1203
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
1204
|
+
:param amount_out: The amount of the token to swap to
|
|
1205
|
+
:param amount_in_maximum: The maximum amount of the token to swap from
|
|
1206
|
+
:param chain: The chain to use.
|
|
1207
|
+
:param sender: The address of the transaction sender.
|
|
1208
|
+
:param wrap_eth: Whether to wrap ETH to WETH, only use when swapping WETH into something
|
|
1209
|
+
:param retries: Override the default retry configuration for this method
|
|
1210
|
+
:param server_url: Override the default server URL for this method
|
|
1211
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1212
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1213
|
+
"""
|
|
1214
|
+
base_url = None
|
|
1215
|
+
url_variables = None
|
|
1216
|
+
if timeout_ms is None:
|
|
1217
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1218
|
+
|
|
1219
|
+
if server_url is not None:
|
|
1220
|
+
base_url = server_url
|
|
1221
|
+
else:
|
|
1222
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1223
|
+
|
|
1224
|
+
request = models.UniswapBuyExactlyRequest(
|
|
1225
|
+
token_in=token_in,
|
|
1226
|
+
token_out=token_out,
|
|
1227
|
+
fee=fee,
|
|
1228
|
+
amount_out=amount_out,
|
|
1229
|
+
amount_in_maximum=amount_in_maximum,
|
|
1230
|
+
wrap_eth=wrap_eth,
|
|
1231
|
+
chain=chain,
|
|
1232
|
+
sender=sender,
|
|
1233
|
+
)
|
|
1234
|
+
|
|
1235
|
+
req = self._build_request(
|
|
1236
|
+
method="POST",
|
|
1237
|
+
path="/v0/uniswap/swap/buy_exactly",
|
|
1238
|
+
base_url=base_url,
|
|
1239
|
+
url_variables=url_variables,
|
|
1240
|
+
request=request,
|
|
1241
|
+
request_body_required=True,
|
|
1242
|
+
request_has_path_params=False,
|
|
1243
|
+
request_has_query_params=True,
|
|
1244
|
+
user_agent_header="user-agent",
|
|
1245
|
+
accept_header_value="application/json",
|
|
1246
|
+
http_headers=http_headers,
|
|
1247
|
+
security=self.sdk_configuration.security,
|
|
1248
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1249
|
+
request, False, False, "json", models.UniswapBuyExactlyRequest
|
|
1250
|
+
),
|
|
1251
|
+
timeout_ms=timeout_ms,
|
|
1252
|
+
)
|
|
1253
|
+
|
|
1254
|
+
if retries == UNSET:
|
|
1255
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1256
|
+
retries = self.sdk_configuration.retry_config
|
|
1257
|
+
|
|
1258
|
+
retry_config = None
|
|
1259
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1260
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1261
|
+
|
|
1262
|
+
http_res = self.do_request(
|
|
1263
|
+
hook_ctx=HookContext(
|
|
1264
|
+
base_url=base_url or "",
|
|
1265
|
+
operation_id="uniswap_swap_buy_exactly",
|
|
1266
|
+
oauth2_scopes=[],
|
|
1267
|
+
security_source=self.sdk_configuration.security,
|
|
1268
|
+
),
|
|
1269
|
+
request=req,
|
|
1270
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1271
|
+
retry_config=retry_config,
|
|
1272
|
+
)
|
|
1273
|
+
|
|
1274
|
+
response_data: Any = None
|
|
1275
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1276
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1277
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1278
|
+
response_data = utils.unmarshal_json(
|
|
1279
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1280
|
+
)
|
|
1281
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1282
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1283
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1284
|
+
raise errors.APIError(
|
|
1285
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1286
|
+
)
|
|
1287
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1288
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1289
|
+
raise errors.APIError(
|
|
1290
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1291
|
+
)
|
|
1292
|
+
|
|
1293
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1294
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1295
|
+
raise errors.APIError(
|
|
1296
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1297
|
+
http_res.status_code,
|
|
1298
|
+
http_res_text,
|
|
1299
|
+
http_res,
|
|
1300
|
+
)
|
|
1301
|
+
|
|
1302
|
+
async def swap_buy_exactly_async(
|
|
1303
|
+
self,
|
|
1304
|
+
*,
|
|
1305
|
+
token_in: models.TokenEnum,
|
|
1306
|
+
token_out: models.TokenEnum,
|
|
1307
|
+
fee: models.FeeEnum,
|
|
1308
|
+
amount_out: Union[
|
|
1309
|
+
models.UniswapBuyExactlyRequestAmountOut,
|
|
1310
|
+
models.UniswapBuyExactlyRequestAmountOutTypedDict,
|
|
1311
|
+
],
|
|
1312
|
+
amount_in_maximum: Union[
|
|
1313
|
+
models.UniswapBuyExactlyRequestAmountInMaximum,
|
|
1314
|
+
models.UniswapBuyExactlyRequestAmountInMaximumTypedDict,
|
|
1315
|
+
],
|
|
1316
|
+
chain: models.Chain,
|
|
1317
|
+
sender: str,
|
|
1318
|
+
wrap_eth: Optional[bool] = False,
|
|
1319
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1320
|
+
server_url: Optional[str] = None,
|
|
1321
|
+
timeout_ms: Optional[int] = None,
|
|
1322
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1323
|
+
) -> models.UnsignedTransaction:
|
|
1324
|
+
r"""Buy exact amount
|
|
1325
|
+
|
|
1326
|
+
This endpoint allows users to trade a variable amount of one token to receive an
|
|
1327
|
+
exact amount of another token using the Uniswap protocol.
|
|
1328
|
+
|
|
1329
|
+
The transaction is executed on the specified blockchain network, and the user must
|
|
1330
|
+
provide the necessary transaction details, including the token to buy, the token to
|
|
1331
|
+
pay with, and the exact amount to receive. If the token being paid with is WETH and
|
|
1332
|
+
needs to be wrapped, the appropriate amount will be wrapped automatically.
|
|
1333
|
+
|
|
1334
|
+
:param token_in: 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.
|
|
1335
|
+
:param token_out: 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.
|
|
1336
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
1337
|
+
:param amount_out: The amount of the token to swap to
|
|
1338
|
+
:param amount_in_maximum: The maximum amount of the token to swap from
|
|
1339
|
+
:param chain: The chain to use.
|
|
1340
|
+
:param sender: The address of the transaction sender.
|
|
1341
|
+
:param wrap_eth: Whether to wrap ETH to WETH, only use when swapping WETH into something
|
|
1342
|
+
:param retries: Override the default retry configuration for this method
|
|
1343
|
+
:param server_url: Override the default server URL for this method
|
|
1344
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1345
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1346
|
+
"""
|
|
1347
|
+
base_url = None
|
|
1348
|
+
url_variables = None
|
|
1349
|
+
if timeout_ms is None:
|
|
1350
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1351
|
+
|
|
1352
|
+
if server_url is not None:
|
|
1353
|
+
base_url = server_url
|
|
1354
|
+
else:
|
|
1355
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1356
|
+
|
|
1357
|
+
request = models.UniswapBuyExactlyRequest(
|
|
1358
|
+
token_in=token_in,
|
|
1359
|
+
token_out=token_out,
|
|
1360
|
+
fee=fee,
|
|
1361
|
+
amount_out=amount_out,
|
|
1362
|
+
amount_in_maximum=amount_in_maximum,
|
|
1363
|
+
wrap_eth=wrap_eth,
|
|
1364
|
+
chain=chain,
|
|
1365
|
+
sender=sender,
|
|
1366
|
+
)
|
|
1367
|
+
|
|
1368
|
+
req = self._build_request_async(
|
|
1369
|
+
method="POST",
|
|
1370
|
+
path="/v0/uniswap/swap/buy_exactly",
|
|
1371
|
+
base_url=base_url,
|
|
1372
|
+
url_variables=url_variables,
|
|
1373
|
+
request=request,
|
|
1374
|
+
request_body_required=True,
|
|
1375
|
+
request_has_path_params=False,
|
|
1376
|
+
request_has_query_params=True,
|
|
1377
|
+
user_agent_header="user-agent",
|
|
1378
|
+
accept_header_value="application/json",
|
|
1379
|
+
http_headers=http_headers,
|
|
1380
|
+
security=self.sdk_configuration.security,
|
|
1381
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1382
|
+
request, False, False, "json", models.UniswapBuyExactlyRequest
|
|
1383
|
+
),
|
|
1384
|
+
timeout_ms=timeout_ms,
|
|
1385
|
+
)
|
|
1386
|
+
|
|
1387
|
+
if retries == UNSET:
|
|
1388
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1389
|
+
retries = self.sdk_configuration.retry_config
|
|
1390
|
+
|
|
1391
|
+
retry_config = None
|
|
1392
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1393
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1394
|
+
|
|
1395
|
+
http_res = await self.do_request_async(
|
|
1396
|
+
hook_ctx=HookContext(
|
|
1397
|
+
base_url=base_url or "",
|
|
1398
|
+
operation_id="uniswap_swap_buy_exactly",
|
|
1399
|
+
oauth2_scopes=[],
|
|
1400
|
+
security_source=self.sdk_configuration.security,
|
|
1401
|
+
),
|
|
1402
|
+
request=req,
|
|
1403
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1404
|
+
retry_config=retry_config,
|
|
1405
|
+
)
|
|
1406
|
+
|
|
1407
|
+
response_data: Any = None
|
|
1408
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1409
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1410
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1411
|
+
response_data = utils.unmarshal_json(
|
|
1412
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1413
|
+
)
|
|
1414
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1415
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1416
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1417
|
+
raise errors.APIError(
|
|
1418
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1419
|
+
)
|
|
1420
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1421
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1422
|
+
raise errors.APIError(
|
|
1423
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1424
|
+
)
|
|
1425
|
+
|
|
1426
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1427
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1428
|
+
raise errors.APIError(
|
|
1429
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1430
|
+
http_res.status_code,
|
|
1431
|
+
http_res_text,
|
|
1432
|
+
http_res,
|
|
1433
|
+
)
|
|
1434
|
+
|
|
1435
|
+
def swap_sell_exactly(
|
|
1436
|
+
self,
|
|
1437
|
+
*,
|
|
1438
|
+
token_in: models.TokenEnum,
|
|
1439
|
+
token_out: models.TokenEnum,
|
|
1440
|
+
fee: models.FeeEnum,
|
|
1441
|
+
amount_in: Union[
|
|
1442
|
+
models.UniswapSellExactlyRequestAmountIn,
|
|
1443
|
+
models.UniswapSellExactlyRequestAmountInTypedDict,
|
|
1444
|
+
],
|
|
1445
|
+
chain: models.Chain,
|
|
1446
|
+
sender: str,
|
|
1447
|
+
amount_out_minimum: Optional[
|
|
1448
|
+
Union[
|
|
1449
|
+
models.UniswapSellExactlyRequestAmountOutMinimum,
|
|
1450
|
+
models.UniswapSellExactlyRequestAmountOutMinimumTypedDict,
|
|
1451
|
+
]
|
|
1452
|
+
] = None,
|
|
1453
|
+
wrap_eth: Optional[bool] = False,
|
|
1454
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1455
|
+
server_url: Optional[str] = None,
|
|
1456
|
+
timeout_ms: Optional[int] = None,
|
|
1457
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1458
|
+
) -> models.UnsignedTransaction:
|
|
1459
|
+
r"""Sell exact amount
|
|
1460
|
+
|
|
1461
|
+
This endpoint allows users to trade a specific amount of one token into another
|
|
1462
|
+
token using the Uniswap protocol.
|
|
1463
|
+
|
|
1464
|
+
The transaction is executed on the specified blockchain network, and the user must
|
|
1465
|
+
provide the necessary transaction details, including the token to sell, the token to
|
|
1466
|
+
receive, and the amount to sell. If the token being sold is WETH and needs to be
|
|
1467
|
+
wrapped, the appropriate amount will be wrapped automatically.
|
|
1468
|
+
|
|
1469
|
+
:param token_in: 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.
|
|
1470
|
+
:param token_out: 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.
|
|
1471
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
1472
|
+
:param amount_in: The amount of the token to swap from
|
|
1473
|
+
:param chain: The chain to use.
|
|
1474
|
+
:param sender: The address of the transaction sender.
|
|
1475
|
+
:param amount_out_minimum: The minimum amount of the token to swap to, defaults to 0
|
|
1476
|
+
:param wrap_eth: Whether to wrap ETH to WETH, only use when swapping WETH into something
|
|
1477
|
+
:param retries: Override the default retry configuration for this method
|
|
1478
|
+
:param server_url: Override the default server URL for this method
|
|
1479
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1480
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1481
|
+
"""
|
|
1482
|
+
base_url = None
|
|
1483
|
+
url_variables = None
|
|
1484
|
+
if timeout_ms is None:
|
|
1485
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1486
|
+
|
|
1487
|
+
if server_url is not None:
|
|
1488
|
+
base_url = server_url
|
|
1489
|
+
else:
|
|
1490
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1491
|
+
|
|
1492
|
+
request = models.UniswapSellExactlyRequest(
|
|
1493
|
+
token_in=token_in,
|
|
1494
|
+
token_out=token_out,
|
|
1495
|
+
fee=fee,
|
|
1496
|
+
amount_in=amount_in,
|
|
1497
|
+
amount_out_minimum=amount_out_minimum,
|
|
1498
|
+
wrap_eth=wrap_eth,
|
|
1499
|
+
chain=chain,
|
|
1500
|
+
sender=sender,
|
|
1501
|
+
)
|
|
1502
|
+
|
|
1503
|
+
req = self._build_request(
|
|
1504
|
+
method="POST",
|
|
1505
|
+
path="/v0/uniswap/swap/sell_exactly",
|
|
1506
|
+
base_url=base_url,
|
|
1507
|
+
url_variables=url_variables,
|
|
1508
|
+
request=request,
|
|
1509
|
+
request_body_required=True,
|
|
1510
|
+
request_has_path_params=False,
|
|
1511
|
+
request_has_query_params=True,
|
|
1512
|
+
user_agent_header="user-agent",
|
|
1513
|
+
accept_header_value="application/json",
|
|
1514
|
+
http_headers=http_headers,
|
|
1515
|
+
security=self.sdk_configuration.security,
|
|
1516
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1517
|
+
request, False, False, "json", models.UniswapSellExactlyRequest
|
|
1518
|
+
),
|
|
1519
|
+
timeout_ms=timeout_ms,
|
|
1520
|
+
)
|
|
1521
|
+
|
|
1522
|
+
if retries == UNSET:
|
|
1523
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1524
|
+
retries = self.sdk_configuration.retry_config
|
|
1525
|
+
|
|
1526
|
+
retry_config = None
|
|
1527
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1528
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1529
|
+
|
|
1530
|
+
http_res = self.do_request(
|
|
1531
|
+
hook_ctx=HookContext(
|
|
1532
|
+
base_url=base_url or "",
|
|
1533
|
+
operation_id="uniswap_swap_sell_exactly",
|
|
1534
|
+
oauth2_scopes=[],
|
|
1535
|
+
security_source=self.sdk_configuration.security,
|
|
1536
|
+
),
|
|
1537
|
+
request=req,
|
|
1538
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1539
|
+
retry_config=retry_config,
|
|
1540
|
+
)
|
|
1541
|
+
|
|
1542
|
+
response_data: Any = None
|
|
1543
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1544
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1545
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1546
|
+
response_data = utils.unmarshal_json(
|
|
1547
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1548
|
+
)
|
|
1549
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1550
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1551
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1552
|
+
raise errors.APIError(
|
|
1553
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1554
|
+
)
|
|
1555
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1556
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1557
|
+
raise errors.APIError(
|
|
1558
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1559
|
+
)
|
|
1560
|
+
|
|
1561
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1562
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1563
|
+
raise errors.APIError(
|
|
1564
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1565
|
+
http_res.status_code,
|
|
1566
|
+
http_res_text,
|
|
1567
|
+
http_res,
|
|
1568
|
+
)
|
|
1569
|
+
|
|
1570
|
+
async def swap_sell_exactly_async(
|
|
1571
|
+
self,
|
|
1572
|
+
*,
|
|
1573
|
+
token_in: models.TokenEnum,
|
|
1574
|
+
token_out: models.TokenEnum,
|
|
1575
|
+
fee: models.FeeEnum,
|
|
1576
|
+
amount_in: Union[
|
|
1577
|
+
models.UniswapSellExactlyRequestAmountIn,
|
|
1578
|
+
models.UniswapSellExactlyRequestAmountInTypedDict,
|
|
1579
|
+
],
|
|
1580
|
+
chain: models.Chain,
|
|
1581
|
+
sender: str,
|
|
1582
|
+
amount_out_minimum: Optional[
|
|
1583
|
+
Union[
|
|
1584
|
+
models.UniswapSellExactlyRequestAmountOutMinimum,
|
|
1585
|
+
models.UniswapSellExactlyRequestAmountOutMinimumTypedDict,
|
|
1586
|
+
]
|
|
1587
|
+
] = None,
|
|
1588
|
+
wrap_eth: Optional[bool] = False,
|
|
1589
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1590
|
+
server_url: Optional[str] = None,
|
|
1591
|
+
timeout_ms: Optional[int] = None,
|
|
1592
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1593
|
+
) -> models.UnsignedTransaction:
|
|
1594
|
+
r"""Sell exact amount
|
|
1595
|
+
|
|
1596
|
+
This endpoint allows users to trade a specific amount of one token into another
|
|
1597
|
+
token using the Uniswap protocol.
|
|
1598
|
+
|
|
1599
|
+
The transaction is executed on the specified blockchain network, and the user must
|
|
1600
|
+
provide the necessary transaction details, including the token to sell, the token to
|
|
1601
|
+
receive, and the amount to sell. If the token being sold is WETH and needs to be
|
|
1602
|
+
wrapped, the appropriate amount will be wrapped automatically.
|
|
1603
|
+
|
|
1604
|
+
:param token_in: 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.
|
|
1605
|
+
:param token_out: 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.
|
|
1606
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
1607
|
+
:param amount_in: The amount of the token to swap from
|
|
1608
|
+
:param chain: The chain to use.
|
|
1609
|
+
:param sender: The address of the transaction sender.
|
|
1610
|
+
:param amount_out_minimum: The minimum amount of the token to swap to, defaults to 0
|
|
1611
|
+
:param wrap_eth: Whether to wrap ETH to WETH, only use when swapping WETH into something
|
|
1612
|
+
:param retries: Override the default retry configuration for this method
|
|
1613
|
+
:param server_url: Override the default server URL for this method
|
|
1614
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1615
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1616
|
+
"""
|
|
1617
|
+
base_url = None
|
|
1618
|
+
url_variables = None
|
|
1619
|
+
if timeout_ms is None:
|
|
1620
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1621
|
+
|
|
1622
|
+
if server_url is not None:
|
|
1623
|
+
base_url = server_url
|
|
1624
|
+
else:
|
|
1625
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1626
|
+
|
|
1627
|
+
request = models.UniswapSellExactlyRequest(
|
|
1628
|
+
token_in=token_in,
|
|
1629
|
+
token_out=token_out,
|
|
1630
|
+
fee=fee,
|
|
1631
|
+
amount_in=amount_in,
|
|
1632
|
+
amount_out_minimum=amount_out_minimum,
|
|
1633
|
+
wrap_eth=wrap_eth,
|
|
1634
|
+
chain=chain,
|
|
1635
|
+
sender=sender,
|
|
1636
|
+
)
|
|
1637
|
+
|
|
1638
|
+
req = self._build_request_async(
|
|
1639
|
+
method="POST",
|
|
1640
|
+
path="/v0/uniswap/swap/sell_exactly",
|
|
1641
|
+
base_url=base_url,
|
|
1642
|
+
url_variables=url_variables,
|
|
1643
|
+
request=request,
|
|
1644
|
+
request_body_required=True,
|
|
1645
|
+
request_has_path_params=False,
|
|
1646
|
+
request_has_query_params=True,
|
|
1647
|
+
user_agent_header="user-agent",
|
|
1648
|
+
accept_header_value="application/json",
|
|
1649
|
+
http_headers=http_headers,
|
|
1650
|
+
security=self.sdk_configuration.security,
|
|
1651
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1652
|
+
request, False, False, "json", models.UniswapSellExactlyRequest
|
|
1653
|
+
),
|
|
1654
|
+
timeout_ms=timeout_ms,
|
|
1655
|
+
)
|
|
1656
|
+
|
|
1657
|
+
if retries == UNSET:
|
|
1658
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1659
|
+
retries = self.sdk_configuration.retry_config
|
|
1660
|
+
|
|
1661
|
+
retry_config = None
|
|
1662
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1663
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1664
|
+
|
|
1665
|
+
http_res = await self.do_request_async(
|
|
1666
|
+
hook_ctx=HookContext(
|
|
1667
|
+
base_url=base_url or "",
|
|
1668
|
+
operation_id="uniswap_swap_sell_exactly",
|
|
1669
|
+
oauth2_scopes=[],
|
|
1670
|
+
security_source=self.sdk_configuration.security,
|
|
1671
|
+
),
|
|
1672
|
+
request=req,
|
|
1673
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1674
|
+
retry_config=retry_config,
|
|
1675
|
+
)
|
|
1676
|
+
|
|
1677
|
+
response_data: Any = None
|
|
1678
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1679
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1680
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1681
|
+
response_data = utils.unmarshal_json(
|
|
1682
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1683
|
+
)
|
|
1684
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1685
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1686
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1687
|
+
raise errors.APIError(
|
|
1688
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1689
|
+
)
|
|
1690
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1691
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1692
|
+
raise errors.APIError(
|
|
1693
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1694
|
+
)
|
|
1695
|
+
|
|
1696
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1697
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1698
|
+
raise errors.APIError(
|
|
1699
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1700
|
+
http_res.status_code,
|
|
1701
|
+
http_res_text,
|
|
1702
|
+
http_res,
|
|
1703
|
+
)
|
|
1704
|
+
|
|
1705
|
+
def liquidity_provision_increase(
|
|
1706
|
+
self,
|
|
1707
|
+
*,
|
|
1708
|
+
token_id: int,
|
|
1709
|
+
amount0_desired: Union[
|
|
1710
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0Desired,
|
|
1711
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0DesiredTypedDict,
|
|
1712
|
+
],
|
|
1713
|
+
amount1_desired: Union[
|
|
1714
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1Desired,
|
|
1715
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1DesiredTypedDict,
|
|
1716
|
+
],
|
|
1717
|
+
amount0_min: Union[
|
|
1718
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0Min,
|
|
1719
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0MinTypedDict,
|
|
1720
|
+
],
|
|
1721
|
+
amount1_min: Union[
|
|
1722
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1Min,
|
|
1723
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1MinTypedDict,
|
|
1724
|
+
],
|
|
1725
|
+
chain: models.Chain,
|
|
1726
|
+
sender: str,
|
|
1727
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1728
|
+
server_url: Optional[str] = None,
|
|
1729
|
+
timeout_ms: Optional[int] = None,
|
|
1730
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1731
|
+
) -> models.UnsignedTransaction:
|
|
1732
|
+
r"""Increase an LP position
|
|
1733
|
+
|
|
1734
|
+
This endpoint allows users to increase their existing Liquidity Provider (LP)
|
|
1735
|
+
positions on the Uniswap platform.
|
|
1736
|
+
|
|
1737
|
+
By providing the necessary parameters, users can add more liquidity to their current
|
|
1738
|
+
positions, thereby increasing their stake in the liquidity pool. This operation is
|
|
1739
|
+
beneficial for users who wish to enhance their potential earnings from trading fees
|
|
1740
|
+
within the pool. The endpoint requires details such as the token pair, additional
|
|
1741
|
+
amount to be added, and any other parameters necessary for the liquidity increase
|
|
1742
|
+
process.
|
|
1743
|
+
|
|
1744
|
+
:param token_id: Token ID of the NFT representing the liquidity provisioned position.
|
|
1745
|
+
:param amount0_desired: The desired amount of the first token to deposit
|
|
1746
|
+
:param amount1_desired: The desired amount of the second token to deposit
|
|
1747
|
+
:param amount0_min: The minimum amount of the first token to deposit
|
|
1748
|
+
:param amount1_min: The minimum amount of the second token to deposit
|
|
1749
|
+
:param chain: The chain to use.
|
|
1750
|
+
:param sender: The address of the transaction sender.
|
|
1751
|
+
:param retries: Override the default retry configuration for this method
|
|
1752
|
+
:param server_url: Override the default server URL for this method
|
|
1753
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1754
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1755
|
+
"""
|
|
1756
|
+
base_url = None
|
|
1757
|
+
url_variables = None
|
|
1758
|
+
if timeout_ms is None:
|
|
1759
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1760
|
+
|
|
1761
|
+
if server_url is not None:
|
|
1762
|
+
base_url = server_url
|
|
1763
|
+
else:
|
|
1764
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1765
|
+
|
|
1766
|
+
request = models.UniswapIncreaseLiquidityProvisionRequest(
|
|
1767
|
+
token_id=token_id,
|
|
1768
|
+
amount0_desired=amount0_desired,
|
|
1769
|
+
amount1_desired=amount1_desired,
|
|
1770
|
+
amount0_min=amount0_min,
|
|
1771
|
+
amount1_min=amount1_min,
|
|
1772
|
+
chain=chain,
|
|
1773
|
+
sender=sender,
|
|
1774
|
+
)
|
|
1775
|
+
|
|
1776
|
+
req = self._build_request(
|
|
1777
|
+
method="POST",
|
|
1778
|
+
path="/v0/uniswap/liquidity_provision/increase",
|
|
1779
|
+
base_url=base_url,
|
|
1780
|
+
url_variables=url_variables,
|
|
1781
|
+
request=request,
|
|
1782
|
+
request_body_required=True,
|
|
1783
|
+
request_has_path_params=False,
|
|
1784
|
+
request_has_query_params=True,
|
|
1785
|
+
user_agent_header="user-agent",
|
|
1786
|
+
accept_header_value="application/json",
|
|
1787
|
+
http_headers=http_headers,
|
|
1788
|
+
security=self.sdk_configuration.security,
|
|
1789
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1790
|
+
request,
|
|
1791
|
+
False,
|
|
1792
|
+
False,
|
|
1793
|
+
"json",
|
|
1794
|
+
models.UniswapIncreaseLiquidityProvisionRequest,
|
|
1795
|
+
),
|
|
1796
|
+
timeout_ms=timeout_ms,
|
|
1797
|
+
)
|
|
1798
|
+
|
|
1799
|
+
if retries == UNSET:
|
|
1800
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1801
|
+
retries = self.sdk_configuration.retry_config
|
|
1802
|
+
|
|
1803
|
+
retry_config = None
|
|
1804
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1805
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1806
|
+
|
|
1807
|
+
http_res = self.do_request(
|
|
1808
|
+
hook_ctx=HookContext(
|
|
1809
|
+
base_url=base_url or "",
|
|
1810
|
+
operation_id="uniswap_liquidity_provision_increase",
|
|
1811
|
+
oauth2_scopes=[],
|
|
1812
|
+
security_source=self.sdk_configuration.security,
|
|
1813
|
+
),
|
|
1814
|
+
request=req,
|
|
1815
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1816
|
+
retry_config=retry_config,
|
|
1817
|
+
)
|
|
1818
|
+
|
|
1819
|
+
response_data: Any = None
|
|
1820
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1821
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1822
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1823
|
+
response_data = utils.unmarshal_json(
|
|
1824
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1825
|
+
)
|
|
1826
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1827
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1828
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1829
|
+
raise errors.APIError(
|
|
1830
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1831
|
+
)
|
|
1832
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1833
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1834
|
+
raise errors.APIError(
|
|
1835
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1836
|
+
)
|
|
1837
|
+
|
|
1838
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1839
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1840
|
+
raise errors.APIError(
|
|
1841
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1842
|
+
http_res.status_code,
|
|
1843
|
+
http_res_text,
|
|
1844
|
+
http_res,
|
|
1845
|
+
)
|
|
1846
|
+
|
|
1847
|
+
async def liquidity_provision_increase_async(
|
|
1848
|
+
self,
|
|
1849
|
+
*,
|
|
1850
|
+
token_id: int,
|
|
1851
|
+
amount0_desired: Union[
|
|
1852
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0Desired,
|
|
1853
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0DesiredTypedDict,
|
|
1854
|
+
],
|
|
1855
|
+
amount1_desired: Union[
|
|
1856
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1Desired,
|
|
1857
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1DesiredTypedDict,
|
|
1858
|
+
],
|
|
1859
|
+
amount0_min: Union[
|
|
1860
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0Min,
|
|
1861
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount0MinTypedDict,
|
|
1862
|
+
],
|
|
1863
|
+
amount1_min: Union[
|
|
1864
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1Min,
|
|
1865
|
+
models.UniswapIncreaseLiquidityProvisionRequestAmount1MinTypedDict,
|
|
1866
|
+
],
|
|
1867
|
+
chain: models.Chain,
|
|
1868
|
+
sender: str,
|
|
1869
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1870
|
+
server_url: Optional[str] = None,
|
|
1871
|
+
timeout_ms: Optional[int] = None,
|
|
1872
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1873
|
+
) -> models.UnsignedTransaction:
|
|
1874
|
+
r"""Increase an LP position
|
|
1875
|
+
|
|
1876
|
+
This endpoint allows users to increase their existing Liquidity Provider (LP)
|
|
1877
|
+
positions on the Uniswap platform.
|
|
1878
|
+
|
|
1879
|
+
By providing the necessary parameters, users can add more liquidity to their current
|
|
1880
|
+
positions, thereby increasing their stake in the liquidity pool. This operation is
|
|
1881
|
+
beneficial for users who wish to enhance their potential earnings from trading fees
|
|
1882
|
+
within the pool. The endpoint requires details such as the token pair, additional
|
|
1883
|
+
amount to be added, and any other parameters necessary for the liquidity increase
|
|
1884
|
+
process.
|
|
1885
|
+
|
|
1886
|
+
:param token_id: Token ID of the NFT representing the liquidity provisioned position.
|
|
1887
|
+
:param amount0_desired: The desired amount of the first token to deposit
|
|
1888
|
+
:param amount1_desired: The desired amount of the second token to deposit
|
|
1889
|
+
:param amount0_min: The minimum amount of the first token to deposit
|
|
1890
|
+
:param amount1_min: The minimum amount of the second token to deposit
|
|
1891
|
+
:param chain: The chain to use.
|
|
1892
|
+
:param sender: The address of the transaction sender.
|
|
1893
|
+
:param retries: Override the default retry configuration for this method
|
|
1894
|
+
:param server_url: Override the default server URL for this method
|
|
1895
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1896
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1897
|
+
"""
|
|
1898
|
+
base_url = None
|
|
1899
|
+
url_variables = None
|
|
1900
|
+
if timeout_ms is None:
|
|
1901
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1902
|
+
|
|
1903
|
+
if server_url is not None:
|
|
1904
|
+
base_url = server_url
|
|
1905
|
+
else:
|
|
1906
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1907
|
+
|
|
1908
|
+
request = models.UniswapIncreaseLiquidityProvisionRequest(
|
|
1909
|
+
token_id=token_id,
|
|
1910
|
+
amount0_desired=amount0_desired,
|
|
1911
|
+
amount1_desired=amount1_desired,
|
|
1912
|
+
amount0_min=amount0_min,
|
|
1913
|
+
amount1_min=amount1_min,
|
|
1914
|
+
chain=chain,
|
|
1915
|
+
sender=sender,
|
|
1916
|
+
)
|
|
1917
|
+
|
|
1918
|
+
req = self._build_request_async(
|
|
1919
|
+
method="POST",
|
|
1920
|
+
path="/v0/uniswap/liquidity_provision/increase",
|
|
1921
|
+
base_url=base_url,
|
|
1922
|
+
url_variables=url_variables,
|
|
1923
|
+
request=request,
|
|
1924
|
+
request_body_required=True,
|
|
1925
|
+
request_has_path_params=False,
|
|
1926
|
+
request_has_query_params=True,
|
|
1927
|
+
user_agent_header="user-agent",
|
|
1928
|
+
accept_header_value="application/json",
|
|
1929
|
+
http_headers=http_headers,
|
|
1930
|
+
security=self.sdk_configuration.security,
|
|
1931
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1932
|
+
request,
|
|
1933
|
+
False,
|
|
1934
|
+
False,
|
|
1935
|
+
"json",
|
|
1936
|
+
models.UniswapIncreaseLiquidityProvisionRequest,
|
|
1937
|
+
),
|
|
1938
|
+
timeout_ms=timeout_ms,
|
|
1939
|
+
)
|
|
1940
|
+
|
|
1941
|
+
if retries == UNSET:
|
|
1942
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1943
|
+
retries = self.sdk_configuration.retry_config
|
|
1944
|
+
|
|
1945
|
+
retry_config = None
|
|
1946
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1947
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1948
|
+
|
|
1949
|
+
http_res = await self.do_request_async(
|
|
1950
|
+
hook_ctx=HookContext(
|
|
1951
|
+
base_url=base_url or "",
|
|
1952
|
+
operation_id="uniswap_liquidity_provision_increase",
|
|
1953
|
+
oauth2_scopes=[],
|
|
1954
|
+
security_source=self.sdk_configuration.security,
|
|
1955
|
+
),
|
|
1956
|
+
request=req,
|
|
1957
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1958
|
+
retry_config=retry_config,
|
|
1959
|
+
)
|
|
1960
|
+
|
|
1961
|
+
response_data: Any = None
|
|
1962
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1963
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1964
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1965
|
+
response_data = utils.unmarshal_json(
|
|
1966
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1967
|
+
)
|
|
1968
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1969
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1970
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1971
|
+
raise errors.APIError(
|
|
1972
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1973
|
+
)
|
|
1974
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1975
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1976
|
+
raise errors.APIError(
|
|
1977
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1978
|
+
)
|
|
1979
|
+
|
|
1980
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1981
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1982
|
+
raise errors.APIError(
|
|
1983
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1984
|
+
http_res.status_code,
|
|
1985
|
+
http_res_text,
|
|
1986
|
+
http_res,
|
|
1987
|
+
)
|
|
1988
|
+
|
|
1989
|
+
def liquidity_provision_mint(
|
|
1990
|
+
self,
|
|
1991
|
+
*,
|
|
1992
|
+
token0: models.TokenEnum,
|
|
1993
|
+
token1: models.TokenEnum,
|
|
1994
|
+
fee: models.FeeEnum,
|
|
1995
|
+
tick_lower: int,
|
|
1996
|
+
tick_upper: int,
|
|
1997
|
+
amount0_desired: Union[
|
|
1998
|
+
models.UniswapMintLiquidityProvisionRequestAmount0Desired,
|
|
1999
|
+
models.UniswapMintLiquidityProvisionRequestAmount0DesiredTypedDict,
|
|
2000
|
+
],
|
|
2001
|
+
amount1_desired: Union[
|
|
2002
|
+
models.UniswapMintLiquidityProvisionRequestAmount1Desired,
|
|
2003
|
+
models.UniswapMintLiquidityProvisionRequestAmount1DesiredTypedDict,
|
|
2004
|
+
],
|
|
2005
|
+
amount0_min: Union[
|
|
2006
|
+
models.UniswapMintLiquidityProvisionRequestAmount0Min,
|
|
2007
|
+
models.UniswapMintLiquidityProvisionRequestAmount0MinTypedDict,
|
|
2008
|
+
],
|
|
2009
|
+
amount1_min: Union[
|
|
2010
|
+
models.UniswapMintLiquidityProvisionRequestAmount1Min,
|
|
2011
|
+
models.UniswapMintLiquidityProvisionRequestAmount1MinTypedDict,
|
|
2012
|
+
],
|
|
2013
|
+
chain: models.Chain,
|
|
2014
|
+
sender: str,
|
|
2015
|
+
recipient: OptionalNullable[str] = UNSET,
|
|
2016
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2017
|
+
server_url: Optional[str] = None,
|
|
2018
|
+
timeout_ms: Optional[int] = None,
|
|
2019
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2020
|
+
) -> models.UnsignedTransaction:
|
|
2021
|
+
r"""Open a new LP position
|
|
2022
|
+
|
|
2023
|
+
This endpoint allows users to open a new Liquidity Provider (LP) position on the
|
|
2024
|
+
Uniswap platform.
|
|
2025
|
+
|
|
2026
|
+
By providing the necessary parameters, users can initiate a minting process to
|
|
2027
|
+
create a new LP token, which represents their stake in a specific liquidity pool.
|
|
2028
|
+
This operation is essential for users looking to participate in liquidity provision,
|
|
2029
|
+
enabling them to earn fees from trades that occur within the pool. The endpoint
|
|
2030
|
+
requires details such as the token pair, amount, and any additional parameters
|
|
2031
|
+
needed for the minting process.
|
|
2032
|
+
|
|
2033
|
+
:param token0: 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.
|
|
2034
|
+
:param token1: 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.
|
|
2035
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
2036
|
+
:param tick_lower: The lower tick of the range to mint the position in
|
|
2037
|
+
:param tick_upper: The upper tick of the range to mint the position in
|
|
2038
|
+
:param amount0_desired: The desired amount of the first token to deposit
|
|
2039
|
+
:param amount1_desired: The desired amount of the second token to deposit
|
|
2040
|
+
:param amount0_min: The minimum amount of the first token to deposit
|
|
2041
|
+
:param amount1_min: The minimum amount of the second token to deposit
|
|
2042
|
+
:param chain: The chain to use.
|
|
2043
|
+
:param sender: The address of the transaction sender.
|
|
2044
|
+
:param recipient: The address that will receive the LP tokens
|
|
2045
|
+
:param retries: Override the default retry configuration for this method
|
|
2046
|
+
:param server_url: Override the default server URL for this method
|
|
2047
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2048
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2049
|
+
"""
|
|
2050
|
+
base_url = None
|
|
2051
|
+
url_variables = None
|
|
2052
|
+
if timeout_ms is None:
|
|
2053
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2054
|
+
|
|
2055
|
+
if server_url is not None:
|
|
2056
|
+
base_url = server_url
|
|
2057
|
+
else:
|
|
2058
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2059
|
+
|
|
2060
|
+
request = models.UniswapMintLiquidityProvisionRequest(
|
|
2061
|
+
token0=token0,
|
|
2062
|
+
token1=token1,
|
|
2063
|
+
fee=fee,
|
|
2064
|
+
tick_lower=tick_lower,
|
|
2065
|
+
tick_upper=tick_upper,
|
|
2066
|
+
amount0_desired=amount0_desired,
|
|
2067
|
+
amount1_desired=amount1_desired,
|
|
2068
|
+
amount0_min=amount0_min,
|
|
2069
|
+
amount1_min=amount1_min,
|
|
2070
|
+
recipient=recipient,
|
|
2071
|
+
chain=chain,
|
|
2072
|
+
sender=sender,
|
|
2073
|
+
)
|
|
2074
|
+
|
|
2075
|
+
req = self._build_request(
|
|
2076
|
+
method="POST",
|
|
2077
|
+
path="/v0/uniswap/liquidity_provision/mint",
|
|
2078
|
+
base_url=base_url,
|
|
2079
|
+
url_variables=url_variables,
|
|
2080
|
+
request=request,
|
|
2081
|
+
request_body_required=True,
|
|
2082
|
+
request_has_path_params=False,
|
|
2083
|
+
request_has_query_params=True,
|
|
2084
|
+
user_agent_header="user-agent",
|
|
2085
|
+
accept_header_value="application/json",
|
|
2086
|
+
http_headers=http_headers,
|
|
2087
|
+
security=self.sdk_configuration.security,
|
|
2088
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2089
|
+
request,
|
|
2090
|
+
False,
|
|
2091
|
+
False,
|
|
2092
|
+
"json",
|
|
2093
|
+
models.UniswapMintLiquidityProvisionRequest,
|
|
2094
|
+
),
|
|
2095
|
+
timeout_ms=timeout_ms,
|
|
2096
|
+
)
|
|
2097
|
+
|
|
2098
|
+
if retries == UNSET:
|
|
2099
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2100
|
+
retries = self.sdk_configuration.retry_config
|
|
2101
|
+
|
|
2102
|
+
retry_config = None
|
|
2103
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2104
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2105
|
+
|
|
2106
|
+
http_res = self.do_request(
|
|
2107
|
+
hook_ctx=HookContext(
|
|
2108
|
+
base_url=base_url or "",
|
|
2109
|
+
operation_id="uniswap_liquidity_provision_mint",
|
|
2110
|
+
oauth2_scopes=[],
|
|
2111
|
+
security_source=self.sdk_configuration.security,
|
|
2112
|
+
),
|
|
2113
|
+
request=req,
|
|
2114
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2115
|
+
retry_config=retry_config,
|
|
2116
|
+
)
|
|
2117
|
+
|
|
2118
|
+
response_data: Any = None
|
|
2119
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2120
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2121
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2122
|
+
response_data = utils.unmarshal_json(
|
|
2123
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2124
|
+
)
|
|
2125
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2126
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2127
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2128
|
+
raise errors.APIError(
|
|
2129
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2130
|
+
)
|
|
2131
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2132
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2133
|
+
raise errors.APIError(
|
|
2134
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2135
|
+
)
|
|
2136
|
+
|
|
2137
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2138
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2139
|
+
raise errors.APIError(
|
|
2140
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2141
|
+
http_res.status_code,
|
|
2142
|
+
http_res_text,
|
|
2143
|
+
http_res,
|
|
2144
|
+
)
|
|
2145
|
+
|
|
2146
|
+
async def liquidity_provision_mint_async(
|
|
2147
|
+
self,
|
|
2148
|
+
*,
|
|
2149
|
+
token0: models.TokenEnum,
|
|
2150
|
+
token1: models.TokenEnum,
|
|
2151
|
+
fee: models.FeeEnum,
|
|
2152
|
+
tick_lower: int,
|
|
2153
|
+
tick_upper: int,
|
|
2154
|
+
amount0_desired: Union[
|
|
2155
|
+
models.UniswapMintLiquidityProvisionRequestAmount0Desired,
|
|
2156
|
+
models.UniswapMintLiquidityProvisionRequestAmount0DesiredTypedDict,
|
|
2157
|
+
],
|
|
2158
|
+
amount1_desired: Union[
|
|
2159
|
+
models.UniswapMintLiquidityProvisionRequestAmount1Desired,
|
|
2160
|
+
models.UniswapMintLiquidityProvisionRequestAmount1DesiredTypedDict,
|
|
2161
|
+
],
|
|
2162
|
+
amount0_min: Union[
|
|
2163
|
+
models.UniswapMintLiquidityProvisionRequestAmount0Min,
|
|
2164
|
+
models.UniswapMintLiquidityProvisionRequestAmount0MinTypedDict,
|
|
2165
|
+
],
|
|
2166
|
+
amount1_min: Union[
|
|
2167
|
+
models.UniswapMintLiquidityProvisionRequestAmount1Min,
|
|
2168
|
+
models.UniswapMintLiquidityProvisionRequestAmount1MinTypedDict,
|
|
2169
|
+
],
|
|
2170
|
+
chain: models.Chain,
|
|
2171
|
+
sender: str,
|
|
2172
|
+
recipient: OptionalNullable[str] = UNSET,
|
|
2173
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2174
|
+
server_url: Optional[str] = None,
|
|
2175
|
+
timeout_ms: Optional[int] = None,
|
|
2176
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2177
|
+
) -> models.UnsignedTransaction:
|
|
2178
|
+
r"""Open a new LP position
|
|
2179
|
+
|
|
2180
|
+
This endpoint allows users to open a new Liquidity Provider (LP) position on the
|
|
2181
|
+
Uniswap platform.
|
|
2182
|
+
|
|
2183
|
+
By providing the necessary parameters, users can initiate a minting process to
|
|
2184
|
+
create a new LP token, which represents their stake in a specific liquidity pool.
|
|
2185
|
+
This operation is essential for users looking to participate in liquidity provision,
|
|
2186
|
+
enabling them to earn fees from trades that occur within the pool. The endpoint
|
|
2187
|
+
requires details such as the token pair, amount, and any additional parameters
|
|
2188
|
+
needed for the minting process.
|
|
2189
|
+
|
|
2190
|
+
:param token0: 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.
|
|
2191
|
+
:param token1: 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.
|
|
2192
|
+
:param fee: The transaction fee of a Uniswap pool in bips. Uniswap supports 4 different fee levels.
|
|
2193
|
+
:param tick_lower: The lower tick of the range to mint the position in
|
|
2194
|
+
:param tick_upper: The upper tick of the range to mint the position in
|
|
2195
|
+
:param amount0_desired: The desired amount of the first token to deposit
|
|
2196
|
+
:param amount1_desired: The desired amount of the second token to deposit
|
|
2197
|
+
:param amount0_min: The minimum amount of the first token to deposit
|
|
2198
|
+
:param amount1_min: The minimum amount of the second token to deposit
|
|
2199
|
+
:param chain: The chain to use.
|
|
2200
|
+
:param sender: The address of the transaction sender.
|
|
2201
|
+
:param recipient: The address that will receive the LP tokens
|
|
2202
|
+
:param retries: Override the default retry configuration for this method
|
|
2203
|
+
:param server_url: Override the default server URL for this method
|
|
2204
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2205
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2206
|
+
"""
|
|
2207
|
+
base_url = None
|
|
2208
|
+
url_variables = None
|
|
2209
|
+
if timeout_ms is None:
|
|
2210
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2211
|
+
|
|
2212
|
+
if server_url is not None:
|
|
2213
|
+
base_url = server_url
|
|
2214
|
+
else:
|
|
2215
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2216
|
+
|
|
2217
|
+
request = models.UniswapMintLiquidityProvisionRequest(
|
|
2218
|
+
token0=token0,
|
|
2219
|
+
token1=token1,
|
|
2220
|
+
fee=fee,
|
|
2221
|
+
tick_lower=tick_lower,
|
|
2222
|
+
tick_upper=tick_upper,
|
|
2223
|
+
amount0_desired=amount0_desired,
|
|
2224
|
+
amount1_desired=amount1_desired,
|
|
2225
|
+
amount0_min=amount0_min,
|
|
2226
|
+
amount1_min=amount1_min,
|
|
2227
|
+
recipient=recipient,
|
|
2228
|
+
chain=chain,
|
|
2229
|
+
sender=sender,
|
|
2230
|
+
)
|
|
2231
|
+
|
|
2232
|
+
req = self._build_request_async(
|
|
2233
|
+
method="POST",
|
|
2234
|
+
path="/v0/uniswap/liquidity_provision/mint",
|
|
2235
|
+
base_url=base_url,
|
|
2236
|
+
url_variables=url_variables,
|
|
2237
|
+
request=request,
|
|
2238
|
+
request_body_required=True,
|
|
2239
|
+
request_has_path_params=False,
|
|
2240
|
+
request_has_query_params=True,
|
|
2241
|
+
user_agent_header="user-agent",
|
|
2242
|
+
accept_header_value="application/json",
|
|
2243
|
+
http_headers=http_headers,
|
|
2244
|
+
security=self.sdk_configuration.security,
|
|
2245
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2246
|
+
request,
|
|
2247
|
+
False,
|
|
2248
|
+
False,
|
|
2249
|
+
"json",
|
|
2250
|
+
models.UniswapMintLiquidityProvisionRequest,
|
|
2251
|
+
),
|
|
2252
|
+
timeout_ms=timeout_ms,
|
|
2253
|
+
)
|
|
2254
|
+
|
|
2255
|
+
if retries == UNSET:
|
|
2256
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2257
|
+
retries = self.sdk_configuration.retry_config
|
|
2258
|
+
|
|
2259
|
+
retry_config = None
|
|
2260
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2261
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2262
|
+
|
|
2263
|
+
http_res = await self.do_request_async(
|
|
2264
|
+
hook_ctx=HookContext(
|
|
2265
|
+
base_url=base_url or "",
|
|
2266
|
+
operation_id="uniswap_liquidity_provision_mint",
|
|
2267
|
+
oauth2_scopes=[],
|
|
2268
|
+
security_source=self.sdk_configuration.security,
|
|
2269
|
+
),
|
|
2270
|
+
request=req,
|
|
2271
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2272
|
+
retry_config=retry_config,
|
|
2273
|
+
)
|
|
2274
|
+
|
|
2275
|
+
response_data: Any = None
|
|
2276
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2277
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2278
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2279
|
+
response_data = utils.unmarshal_json(
|
|
2280
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2281
|
+
)
|
|
2282
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2283
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2284
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2285
|
+
raise errors.APIError(
|
|
2286
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2287
|
+
)
|
|
2288
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2289
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2290
|
+
raise errors.APIError(
|
|
2291
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2292
|
+
)
|
|
2293
|
+
|
|
2294
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2295
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2296
|
+
raise errors.APIError(
|
|
2297
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2298
|
+
http_res.status_code,
|
|
2299
|
+
http_res_text,
|
|
2300
|
+
http_res,
|
|
2301
|
+
)
|
|
2302
|
+
|
|
2303
|
+
def liquidity_provision_withdraw(
|
|
2304
|
+
self,
|
|
2305
|
+
*,
|
|
2306
|
+
token_id: int,
|
|
2307
|
+
percentage_for_withdrawal: Union[
|
|
2308
|
+
models.UniswapWithdrawLiquidityProvisionRequestPercentageForWithdrawal,
|
|
2309
|
+
models.UniswapWithdrawLiquidityProvisionRequestPercentageForWithdrawalTypedDict,
|
|
2310
|
+
],
|
|
2311
|
+
chain: models.Chain,
|
|
2312
|
+
sender: str,
|
|
2313
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2314
|
+
server_url: Optional[str] = None,
|
|
2315
|
+
timeout_ms: Optional[int] = None,
|
|
2316
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2317
|
+
) -> models.UnsignedTransaction:
|
|
2318
|
+
r"""Withdraw an LP position
|
|
2319
|
+
|
|
2320
|
+
This endpoint allows users to withdraw their Liquidity Provider (LP) positions
|
|
2321
|
+
from the Uniswap platform.
|
|
2322
|
+
|
|
2323
|
+
By specifying the necessary parameters, users can initiate the withdrawal process to
|
|
2324
|
+
remove their stake from a specific liquidity pool. This operation is crucial for
|
|
2325
|
+
users who wish to reclaim their assets or reallocate their liquidity to different
|
|
2326
|
+
pools or investments. The endpoint requires details such as the token pair, the
|
|
2327
|
+
amount to be withdrawn, and any additional parameters needed for the withdrawal
|
|
2328
|
+
process. Users should ensure they meet any protocol requirements or conditions
|
|
2329
|
+
before initiating a withdrawal to avoid potential issues or penalties.
|
|
2330
|
+
|
|
2331
|
+
:param token_id: Token ID of the NFT representing the liquidity provisioned position.
|
|
2332
|
+
:param percentage_for_withdrawal: How much liquidity to take out in percentage.
|
|
2333
|
+
:param chain: The chain to use.
|
|
2334
|
+
:param sender: The address of the transaction sender.
|
|
2335
|
+
:param retries: Override the default retry configuration for this method
|
|
2336
|
+
:param server_url: Override the default server URL for this method
|
|
2337
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2338
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2339
|
+
"""
|
|
2340
|
+
base_url = None
|
|
2341
|
+
url_variables = None
|
|
2342
|
+
if timeout_ms is None:
|
|
2343
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2344
|
+
|
|
2345
|
+
if server_url is not None:
|
|
2346
|
+
base_url = server_url
|
|
2347
|
+
else:
|
|
2348
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2349
|
+
|
|
2350
|
+
request = models.UniswapWithdrawLiquidityProvisionRequest(
|
|
2351
|
+
token_id=token_id,
|
|
2352
|
+
percentage_for_withdrawal=percentage_for_withdrawal,
|
|
2353
|
+
chain=chain,
|
|
2354
|
+
sender=sender,
|
|
2355
|
+
)
|
|
2356
|
+
|
|
2357
|
+
req = self._build_request(
|
|
2358
|
+
method="POST",
|
|
2359
|
+
path="/v0/uniswap/liquidity_provision/withdraw",
|
|
2360
|
+
base_url=base_url,
|
|
2361
|
+
url_variables=url_variables,
|
|
2362
|
+
request=request,
|
|
2363
|
+
request_body_required=True,
|
|
2364
|
+
request_has_path_params=False,
|
|
2365
|
+
request_has_query_params=True,
|
|
2366
|
+
user_agent_header="user-agent",
|
|
2367
|
+
accept_header_value="application/json",
|
|
2368
|
+
http_headers=http_headers,
|
|
2369
|
+
security=self.sdk_configuration.security,
|
|
2370
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2371
|
+
request,
|
|
2372
|
+
False,
|
|
2373
|
+
False,
|
|
2374
|
+
"json",
|
|
2375
|
+
models.UniswapWithdrawLiquidityProvisionRequest,
|
|
2376
|
+
),
|
|
2377
|
+
timeout_ms=timeout_ms,
|
|
2378
|
+
)
|
|
2379
|
+
|
|
2380
|
+
if retries == UNSET:
|
|
2381
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2382
|
+
retries = self.sdk_configuration.retry_config
|
|
2383
|
+
|
|
2384
|
+
retry_config = None
|
|
2385
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2386
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2387
|
+
|
|
2388
|
+
http_res = self.do_request(
|
|
2389
|
+
hook_ctx=HookContext(
|
|
2390
|
+
base_url=base_url or "",
|
|
2391
|
+
operation_id="uniswap_liquidity_provision_withdraw",
|
|
2392
|
+
oauth2_scopes=[],
|
|
2393
|
+
security_source=self.sdk_configuration.security,
|
|
2394
|
+
),
|
|
2395
|
+
request=req,
|
|
2396
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2397
|
+
retry_config=retry_config,
|
|
2398
|
+
)
|
|
2399
|
+
|
|
2400
|
+
response_data: Any = None
|
|
2401
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2402
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2403
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2404
|
+
response_data = utils.unmarshal_json(
|
|
2405
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2406
|
+
)
|
|
2407
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2408
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2409
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2410
|
+
raise errors.APIError(
|
|
2411
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2412
|
+
)
|
|
2413
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2414
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2415
|
+
raise errors.APIError(
|
|
2416
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2417
|
+
)
|
|
2418
|
+
|
|
2419
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2420
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
2421
|
+
raise errors.APIError(
|
|
2422
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2423
|
+
http_res.status_code,
|
|
2424
|
+
http_res_text,
|
|
2425
|
+
http_res,
|
|
2426
|
+
)
|
|
2427
|
+
|
|
2428
|
+
async def liquidity_provision_withdraw_async(
|
|
2429
|
+
self,
|
|
2430
|
+
*,
|
|
2431
|
+
token_id: int,
|
|
2432
|
+
percentage_for_withdrawal: Union[
|
|
2433
|
+
models.UniswapWithdrawLiquidityProvisionRequestPercentageForWithdrawal,
|
|
2434
|
+
models.UniswapWithdrawLiquidityProvisionRequestPercentageForWithdrawalTypedDict,
|
|
2435
|
+
],
|
|
2436
|
+
chain: models.Chain,
|
|
2437
|
+
sender: str,
|
|
2438
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
2439
|
+
server_url: Optional[str] = None,
|
|
2440
|
+
timeout_ms: Optional[int] = None,
|
|
2441
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
2442
|
+
) -> models.UnsignedTransaction:
|
|
2443
|
+
r"""Withdraw an LP position
|
|
2444
|
+
|
|
2445
|
+
This endpoint allows users to withdraw their Liquidity Provider (LP) positions
|
|
2446
|
+
from the Uniswap platform.
|
|
2447
|
+
|
|
2448
|
+
By specifying the necessary parameters, users can initiate the withdrawal process to
|
|
2449
|
+
remove their stake from a specific liquidity pool. This operation is crucial for
|
|
2450
|
+
users who wish to reclaim their assets or reallocate their liquidity to different
|
|
2451
|
+
pools or investments. The endpoint requires details such as the token pair, the
|
|
2452
|
+
amount to be withdrawn, and any additional parameters needed for the withdrawal
|
|
2453
|
+
process. Users should ensure they meet any protocol requirements or conditions
|
|
2454
|
+
before initiating a withdrawal to avoid potential issues or penalties.
|
|
2455
|
+
|
|
2456
|
+
:param token_id: Token ID of the NFT representing the liquidity provisioned position.
|
|
2457
|
+
:param percentage_for_withdrawal: How much liquidity to take out in percentage.
|
|
2458
|
+
:param chain: The chain to use.
|
|
2459
|
+
:param sender: The address of the transaction sender.
|
|
2460
|
+
:param retries: Override the default retry configuration for this method
|
|
2461
|
+
:param server_url: Override the default server URL for this method
|
|
2462
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
2463
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
2464
|
+
"""
|
|
2465
|
+
base_url = None
|
|
2466
|
+
url_variables = None
|
|
2467
|
+
if timeout_ms is None:
|
|
2468
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
2469
|
+
|
|
2470
|
+
if server_url is not None:
|
|
2471
|
+
base_url = server_url
|
|
2472
|
+
else:
|
|
2473
|
+
base_url = self._get_url(base_url, url_variables)
|
|
2474
|
+
|
|
2475
|
+
request = models.UniswapWithdrawLiquidityProvisionRequest(
|
|
2476
|
+
token_id=token_id,
|
|
2477
|
+
percentage_for_withdrawal=percentage_for_withdrawal,
|
|
2478
|
+
chain=chain,
|
|
2479
|
+
sender=sender,
|
|
2480
|
+
)
|
|
2481
|
+
|
|
2482
|
+
req = self._build_request_async(
|
|
2483
|
+
method="POST",
|
|
2484
|
+
path="/v0/uniswap/liquidity_provision/withdraw",
|
|
2485
|
+
base_url=base_url,
|
|
2486
|
+
url_variables=url_variables,
|
|
2487
|
+
request=request,
|
|
2488
|
+
request_body_required=True,
|
|
2489
|
+
request_has_path_params=False,
|
|
2490
|
+
request_has_query_params=True,
|
|
2491
|
+
user_agent_header="user-agent",
|
|
2492
|
+
accept_header_value="application/json",
|
|
2493
|
+
http_headers=http_headers,
|
|
2494
|
+
security=self.sdk_configuration.security,
|
|
2495
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
2496
|
+
request,
|
|
2497
|
+
False,
|
|
2498
|
+
False,
|
|
2499
|
+
"json",
|
|
2500
|
+
models.UniswapWithdrawLiquidityProvisionRequest,
|
|
2501
|
+
),
|
|
2502
|
+
timeout_ms=timeout_ms,
|
|
2503
|
+
)
|
|
2504
|
+
|
|
2505
|
+
if retries == UNSET:
|
|
2506
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
2507
|
+
retries = self.sdk_configuration.retry_config
|
|
2508
|
+
|
|
2509
|
+
retry_config = None
|
|
2510
|
+
if isinstance(retries, utils.RetryConfig):
|
|
2511
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
2512
|
+
|
|
2513
|
+
http_res = await self.do_request_async(
|
|
2514
|
+
hook_ctx=HookContext(
|
|
2515
|
+
base_url=base_url or "",
|
|
2516
|
+
operation_id="uniswap_liquidity_provision_withdraw",
|
|
2517
|
+
oauth2_scopes=[],
|
|
2518
|
+
security_source=self.sdk_configuration.security,
|
|
2519
|
+
),
|
|
2520
|
+
request=req,
|
|
2521
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
2522
|
+
retry_config=retry_config,
|
|
2523
|
+
)
|
|
2524
|
+
|
|
2525
|
+
response_data: Any = None
|
|
2526
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
2527
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
2528
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
2529
|
+
response_data = utils.unmarshal_json(
|
|
2530
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
2531
|
+
)
|
|
2532
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
2533
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
2534
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2535
|
+
raise errors.APIError(
|
|
2536
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2537
|
+
)
|
|
2538
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
2539
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2540
|
+
raise errors.APIError(
|
|
2541
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
2542
|
+
)
|
|
2543
|
+
|
|
2544
|
+
content_type = http_res.headers.get("Content-Type")
|
|
2545
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
2546
|
+
raise errors.APIError(
|
|
2547
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
2548
|
+
http_res.status_code,
|
|
2549
|
+
http_res_text,
|
|
2550
|
+
http_res,
|
|
2551
|
+
)
|