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,1903 @@
|
|
|
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 AaveV3(BaseSDK):
|
|
11
|
+
def token_price(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
chain: Optional[
|
|
15
|
+
models.AaveTokenPriceChain
|
|
16
|
+
] = models.AaveTokenPriceChain.ARBITRUM_MAINNET,
|
|
17
|
+
token: Optional[models.AaveTokenPriceToken] = models.AaveTokenPriceToken.USDC,
|
|
18
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
19
|
+
server_url: Optional[str] = None,
|
|
20
|
+
timeout_ms: Optional[int] = None,
|
|
21
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
22
|
+
) -> models.AaveTokenPriceResponse:
|
|
23
|
+
r"""Token prices
|
|
24
|
+
|
|
25
|
+
This endpoint retrieves the current price of a specified token in USD as
|
|
26
|
+
determined by the Aave protocol.
|
|
27
|
+
|
|
28
|
+
It utilizes the Aave V3 Oracle to fetch the token price, ensuring accurate and up-
|
|
29
|
+
to-date information. The request requires the token identifier and the blockchain
|
|
30
|
+
network (chain) on which the token resides. The response provides the token price in
|
|
31
|
+
a standardized format, converted from Wei to the base currency decimals defined by
|
|
32
|
+
Aave.
|
|
33
|
+
|
|
34
|
+
:param chain: The chain to use.
|
|
35
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
36
|
+
:param retries: Override the default retry configuration for this method
|
|
37
|
+
:param server_url: Override the default server URL for this method
|
|
38
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
39
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
40
|
+
"""
|
|
41
|
+
base_url = None
|
|
42
|
+
url_variables = None
|
|
43
|
+
if timeout_ms is None:
|
|
44
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
45
|
+
|
|
46
|
+
if server_url is not None:
|
|
47
|
+
base_url = server_url
|
|
48
|
+
else:
|
|
49
|
+
base_url = self._get_url(base_url, url_variables)
|
|
50
|
+
|
|
51
|
+
request = models.AaveTokenPriceRequest(
|
|
52
|
+
chain=chain,
|
|
53
|
+
token=token,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
req = self._build_request(
|
|
57
|
+
method="GET",
|
|
58
|
+
path="/v0/aave/token_price/get",
|
|
59
|
+
base_url=base_url,
|
|
60
|
+
url_variables=url_variables,
|
|
61
|
+
request=request,
|
|
62
|
+
request_body_required=False,
|
|
63
|
+
request_has_path_params=False,
|
|
64
|
+
request_has_query_params=True,
|
|
65
|
+
user_agent_header="user-agent",
|
|
66
|
+
accept_header_value="application/json",
|
|
67
|
+
http_headers=http_headers,
|
|
68
|
+
security=self.sdk_configuration.security,
|
|
69
|
+
timeout_ms=timeout_ms,
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if retries == UNSET:
|
|
73
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
74
|
+
retries = self.sdk_configuration.retry_config
|
|
75
|
+
|
|
76
|
+
retry_config = None
|
|
77
|
+
if isinstance(retries, utils.RetryConfig):
|
|
78
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
79
|
+
|
|
80
|
+
http_res = self.do_request(
|
|
81
|
+
hook_ctx=HookContext(
|
|
82
|
+
base_url=base_url or "",
|
|
83
|
+
operation_id="aave_token_price",
|
|
84
|
+
oauth2_scopes=[],
|
|
85
|
+
security_source=self.sdk_configuration.security,
|
|
86
|
+
),
|
|
87
|
+
request=req,
|
|
88
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
89
|
+
retry_config=retry_config,
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
response_data: Any = None
|
|
93
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
94
|
+
return utils.unmarshal_json(http_res.text, models.AaveTokenPriceResponse)
|
|
95
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
96
|
+
response_data = utils.unmarshal_json(
|
|
97
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
98
|
+
)
|
|
99
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
100
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
101
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
102
|
+
raise errors.APIError(
|
|
103
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
104
|
+
)
|
|
105
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
106
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
107
|
+
raise errors.APIError(
|
|
108
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
content_type = http_res.headers.get("Content-Type")
|
|
112
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
113
|
+
raise errors.APIError(
|
|
114
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
115
|
+
http_res.status_code,
|
|
116
|
+
http_res_text,
|
|
117
|
+
http_res,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
async def token_price_async(
|
|
121
|
+
self,
|
|
122
|
+
*,
|
|
123
|
+
chain: Optional[
|
|
124
|
+
models.AaveTokenPriceChain
|
|
125
|
+
] = models.AaveTokenPriceChain.ARBITRUM_MAINNET,
|
|
126
|
+
token: Optional[models.AaveTokenPriceToken] = models.AaveTokenPriceToken.USDC,
|
|
127
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
128
|
+
server_url: Optional[str] = None,
|
|
129
|
+
timeout_ms: Optional[int] = None,
|
|
130
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
131
|
+
) -> models.AaveTokenPriceResponse:
|
|
132
|
+
r"""Token prices
|
|
133
|
+
|
|
134
|
+
This endpoint retrieves the current price of a specified token in USD as
|
|
135
|
+
determined by the Aave protocol.
|
|
136
|
+
|
|
137
|
+
It utilizes the Aave V3 Oracle to fetch the token price, ensuring accurate and up-
|
|
138
|
+
to-date information. The request requires the token identifier and the blockchain
|
|
139
|
+
network (chain) on which the token resides. The response provides the token price in
|
|
140
|
+
a standardized format, converted from Wei to the base currency decimals defined by
|
|
141
|
+
Aave.
|
|
142
|
+
|
|
143
|
+
:param chain: The chain to use.
|
|
144
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
145
|
+
:param retries: Override the default retry configuration for this method
|
|
146
|
+
:param server_url: Override the default server URL for this method
|
|
147
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
148
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
149
|
+
"""
|
|
150
|
+
base_url = None
|
|
151
|
+
url_variables = None
|
|
152
|
+
if timeout_ms is None:
|
|
153
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
154
|
+
|
|
155
|
+
if server_url is not None:
|
|
156
|
+
base_url = server_url
|
|
157
|
+
else:
|
|
158
|
+
base_url = self._get_url(base_url, url_variables)
|
|
159
|
+
|
|
160
|
+
request = models.AaveTokenPriceRequest(
|
|
161
|
+
chain=chain,
|
|
162
|
+
token=token,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
req = self._build_request_async(
|
|
166
|
+
method="GET",
|
|
167
|
+
path="/v0/aave/token_price/get",
|
|
168
|
+
base_url=base_url,
|
|
169
|
+
url_variables=url_variables,
|
|
170
|
+
request=request,
|
|
171
|
+
request_body_required=False,
|
|
172
|
+
request_has_path_params=False,
|
|
173
|
+
request_has_query_params=True,
|
|
174
|
+
user_agent_header="user-agent",
|
|
175
|
+
accept_header_value="application/json",
|
|
176
|
+
http_headers=http_headers,
|
|
177
|
+
security=self.sdk_configuration.security,
|
|
178
|
+
timeout_ms=timeout_ms,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
if retries == UNSET:
|
|
182
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
183
|
+
retries = self.sdk_configuration.retry_config
|
|
184
|
+
|
|
185
|
+
retry_config = None
|
|
186
|
+
if isinstance(retries, utils.RetryConfig):
|
|
187
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
188
|
+
|
|
189
|
+
http_res = await self.do_request_async(
|
|
190
|
+
hook_ctx=HookContext(
|
|
191
|
+
base_url=base_url or "",
|
|
192
|
+
operation_id="aave_token_price",
|
|
193
|
+
oauth2_scopes=[],
|
|
194
|
+
security_source=self.sdk_configuration.security,
|
|
195
|
+
),
|
|
196
|
+
request=req,
|
|
197
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
198
|
+
retry_config=retry_config,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
response_data: Any = None
|
|
202
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
203
|
+
return utils.unmarshal_json(http_res.text, models.AaveTokenPriceResponse)
|
|
204
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
205
|
+
response_data = utils.unmarshal_json(
|
|
206
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
207
|
+
)
|
|
208
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
209
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
210
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
211
|
+
raise errors.APIError(
|
|
212
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
213
|
+
)
|
|
214
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
215
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
216
|
+
raise errors.APIError(
|
|
217
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
content_type = http_res.headers.get("Content-Type")
|
|
221
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
222
|
+
raise errors.APIError(
|
|
223
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
224
|
+
http_res.status_code,
|
|
225
|
+
http_res_text,
|
|
226
|
+
http_res,
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
def liquidity_change(
|
|
230
|
+
self,
|
|
231
|
+
*,
|
|
232
|
+
start_block: int = 0,
|
|
233
|
+
end_block: int = 319407231,
|
|
234
|
+
chain: Optional[
|
|
235
|
+
models.AaveLiquidityChangeChain
|
|
236
|
+
] = models.AaveLiquidityChangeChain.ARBITRUM_MAINNET,
|
|
237
|
+
token: Optional[
|
|
238
|
+
models.AaveLiquidityChangeToken
|
|
239
|
+
] = models.AaveLiquidityChangeToken.USDC,
|
|
240
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
241
|
+
server_url: Optional[str] = None,
|
|
242
|
+
timeout_ms: Optional[int] = None,
|
|
243
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
244
|
+
) -> models.AaveLiquidityChangeResponse:
|
|
245
|
+
r"""Liquidity index
|
|
246
|
+
|
|
247
|
+
This endpoint retrieves the change in the reserve liquidity index between two
|
|
248
|
+
provided blocks.
|
|
249
|
+
|
|
250
|
+
This is then converted to a percentage change. The liquidity index represents the
|
|
251
|
+
change in debt and interest accrual over each block. Aave does not store individual
|
|
252
|
+
user balances directly. Instead, it keeps a scaled balance and uses the liquidity
|
|
253
|
+
index to compute real balances dynamically. If a user was to have deposited tokens
|
|
254
|
+
at the start block, a positive liquidity index change will represent accrued
|
|
255
|
+
interest and a profit. If tokens were borrowed at the start block, this debt will
|
|
256
|
+
increase, compound on itself and represent large debt. The reverse in both cases is
|
|
257
|
+
true if the liquidity index is negative.
|
|
258
|
+
|
|
259
|
+
:param start_block:
|
|
260
|
+
:param end_block:
|
|
261
|
+
:param chain: The chain to use.
|
|
262
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
263
|
+
:param retries: Override the default retry configuration for this method
|
|
264
|
+
:param server_url: Override the default server URL for this method
|
|
265
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
266
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
267
|
+
"""
|
|
268
|
+
base_url = None
|
|
269
|
+
url_variables = None
|
|
270
|
+
if timeout_ms is None:
|
|
271
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
272
|
+
|
|
273
|
+
if server_url is not None:
|
|
274
|
+
base_url = server_url
|
|
275
|
+
else:
|
|
276
|
+
base_url = self._get_url(base_url, url_variables)
|
|
277
|
+
|
|
278
|
+
request = models.AaveLiquidityChangeRequest(
|
|
279
|
+
chain=chain,
|
|
280
|
+
token=token,
|
|
281
|
+
start_block=start_block,
|
|
282
|
+
end_block=end_block,
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
req = self._build_request(
|
|
286
|
+
method="GET",
|
|
287
|
+
path="/v0/aave/liquidity/change/get",
|
|
288
|
+
base_url=base_url,
|
|
289
|
+
url_variables=url_variables,
|
|
290
|
+
request=request,
|
|
291
|
+
request_body_required=False,
|
|
292
|
+
request_has_path_params=False,
|
|
293
|
+
request_has_query_params=True,
|
|
294
|
+
user_agent_header="user-agent",
|
|
295
|
+
accept_header_value="application/json",
|
|
296
|
+
http_headers=http_headers,
|
|
297
|
+
security=self.sdk_configuration.security,
|
|
298
|
+
timeout_ms=timeout_ms,
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
if retries == UNSET:
|
|
302
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
303
|
+
retries = self.sdk_configuration.retry_config
|
|
304
|
+
|
|
305
|
+
retry_config = None
|
|
306
|
+
if isinstance(retries, utils.RetryConfig):
|
|
307
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
308
|
+
|
|
309
|
+
http_res = self.do_request(
|
|
310
|
+
hook_ctx=HookContext(
|
|
311
|
+
base_url=base_url or "",
|
|
312
|
+
operation_id="aave_liquidity_change",
|
|
313
|
+
oauth2_scopes=[],
|
|
314
|
+
security_source=self.sdk_configuration.security,
|
|
315
|
+
),
|
|
316
|
+
request=req,
|
|
317
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
318
|
+
retry_config=retry_config,
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
response_data: Any = None
|
|
322
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
323
|
+
return utils.unmarshal_json(
|
|
324
|
+
http_res.text, models.AaveLiquidityChangeResponse
|
|
325
|
+
)
|
|
326
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
327
|
+
response_data = utils.unmarshal_json(
|
|
328
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
329
|
+
)
|
|
330
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
331
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
332
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
333
|
+
raise errors.APIError(
|
|
334
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
335
|
+
)
|
|
336
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
337
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
338
|
+
raise errors.APIError(
|
|
339
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
content_type = http_res.headers.get("Content-Type")
|
|
343
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
344
|
+
raise errors.APIError(
|
|
345
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
346
|
+
http_res.status_code,
|
|
347
|
+
http_res_text,
|
|
348
|
+
http_res,
|
|
349
|
+
)
|
|
350
|
+
|
|
351
|
+
async def liquidity_change_async(
|
|
352
|
+
self,
|
|
353
|
+
*,
|
|
354
|
+
start_block: int = 0,
|
|
355
|
+
end_block: int = 319407231,
|
|
356
|
+
chain: Optional[
|
|
357
|
+
models.AaveLiquidityChangeChain
|
|
358
|
+
] = models.AaveLiquidityChangeChain.ARBITRUM_MAINNET,
|
|
359
|
+
token: Optional[
|
|
360
|
+
models.AaveLiquidityChangeToken
|
|
361
|
+
] = models.AaveLiquidityChangeToken.USDC,
|
|
362
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
363
|
+
server_url: Optional[str] = None,
|
|
364
|
+
timeout_ms: Optional[int] = None,
|
|
365
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
366
|
+
) -> models.AaveLiquidityChangeResponse:
|
|
367
|
+
r"""Liquidity index
|
|
368
|
+
|
|
369
|
+
This endpoint retrieves the change in the reserve liquidity index between two
|
|
370
|
+
provided blocks.
|
|
371
|
+
|
|
372
|
+
This is then converted to a percentage change. The liquidity index represents the
|
|
373
|
+
change in debt and interest accrual over each block. Aave does not store individual
|
|
374
|
+
user balances directly. Instead, it keeps a scaled balance and uses the liquidity
|
|
375
|
+
index to compute real balances dynamically. If a user was to have deposited tokens
|
|
376
|
+
at the start block, a positive liquidity index change will represent accrued
|
|
377
|
+
interest and a profit. If tokens were borrowed at the start block, this debt will
|
|
378
|
+
increase, compound on itself and represent large debt. The reverse in both cases is
|
|
379
|
+
true if the liquidity index is negative.
|
|
380
|
+
|
|
381
|
+
:param start_block:
|
|
382
|
+
:param end_block:
|
|
383
|
+
:param chain: The chain to use.
|
|
384
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
385
|
+
:param retries: Override the default retry configuration for this method
|
|
386
|
+
:param server_url: Override the default server URL for this method
|
|
387
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
388
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
389
|
+
"""
|
|
390
|
+
base_url = None
|
|
391
|
+
url_variables = None
|
|
392
|
+
if timeout_ms is None:
|
|
393
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
394
|
+
|
|
395
|
+
if server_url is not None:
|
|
396
|
+
base_url = server_url
|
|
397
|
+
else:
|
|
398
|
+
base_url = self._get_url(base_url, url_variables)
|
|
399
|
+
|
|
400
|
+
request = models.AaveLiquidityChangeRequest(
|
|
401
|
+
chain=chain,
|
|
402
|
+
token=token,
|
|
403
|
+
start_block=start_block,
|
|
404
|
+
end_block=end_block,
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
req = self._build_request_async(
|
|
408
|
+
method="GET",
|
|
409
|
+
path="/v0/aave/liquidity/change/get",
|
|
410
|
+
base_url=base_url,
|
|
411
|
+
url_variables=url_variables,
|
|
412
|
+
request=request,
|
|
413
|
+
request_body_required=False,
|
|
414
|
+
request_has_path_params=False,
|
|
415
|
+
request_has_query_params=True,
|
|
416
|
+
user_agent_header="user-agent",
|
|
417
|
+
accept_header_value="application/json",
|
|
418
|
+
http_headers=http_headers,
|
|
419
|
+
security=self.sdk_configuration.security,
|
|
420
|
+
timeout_ms=timeout_ms,
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
if retries == UNSET:
|
|
424
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
425
|
+
retries = self.sdk_configuration.retry_config
|
|
426
|
+
|
|
427
|
+
retry_config = None
|
|
428
|
+
if isinstance(retries, utils.RetryConfig):
|
|
429
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
430
|
+
|
|
431
|
+
http_res = await self.do_request_async(
|
|
432
|
+
hook_ctx=HookContext(
|
|
433
|
+
base_url=base_url or "",
|
|
434
|
+
operation_id="aave_liquidity_change",
|
|
435
|
+
oauth2_scopes=[],
|
|
436
|
+
security_source=self.sdk_configuration.security,
|
|
437
|
+
),
|
|
438
|
+
request=req,
|
|
439
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
440
|
+
retry_config=retry_config,
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
response_data: Any = None
|
|
444
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
445
|
+
return utils.unmarshal_json(
|
|
446
|
+
http_res.text, models.AaveLiquidityChangeResponse
|
|
447
|
+
)
|
|
448
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
449
|
+
response_data = utils.unmarshal_json(
|
|
450
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
451
|
+
)
|
|
452
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
453
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
454
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
455
|
+
raise errors.APIError(
|
|
456
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
457
|
+
)
|
|
458
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
459
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
460
|
+
raise errors.APIError(
|
|
461
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
462
|
+
)
|
|
463
|
+
|
|
464
|
+
content_type = http_res.headers.get("Content-Type")
|
|
465
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
466
|
+
raise errors.APIError(
|
|
467
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
468
|
+
http_res.status_code,
|
|
469
|
+
http_res_text,
|
|
470
|
+
http_res,
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
def user_position_summary(
|
|
474
|
+
self,
|
|
475
|
+
*,
|
|
476
|
+
chain: Optional[
|
|
477
|
+
models.AaveUserPositionSummaryChain
|
|
478
|
+
] = models.AaveUserPositionSummaryChain.ARBITRUM_MAINNET,
|
|
479
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
480
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
481
|
+
server_url: Optional[str] = None,
|
|
482
|
+
timeout_ms: Optional[int] = None,
|
|
483
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
484
|
+
) -> models.AaveUserPositionSummaryResponse:
|
|
485
|
+
r"""Positions - total
|
|
486
|
+
|
|
487
|
+
This endpoint retrieves a comprehensive summary of a user's position on the AAVE
|
|
488
|
+
platform.
|
|
489
|
+
|
|
490
|
+
It provides key financial metrics including the total collateral deposited, total
|
|
491
|
+
debt accrued, available borrowing capacity, liquidation threshold, maximum loan-to-
|
|
492
|
+
value ratio, and the health factor of the user's account. These metrics are
|
|
493
|
+
calculated by aggregating data across all open positions held by the user, offering
|
|
494
|
+
a holistic view of their financial standing within the AAVE ecosystem.
|
|
495
|
+
|
|
496
|
+
:param chain: The chain to use.
|
|
497
|
+
:param user:
|
|
498
|
+
:param retries: Override the default retry configuration for this method
|
|
499
|
+
:param server_url: Override the default server URL for this method
|
|
500
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
501
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
502
|
+
"""
|
|
503
|
+
base_url = None
|
|
504
|
+
url_variables = None
|
|
505
|
+
if timeout_ms is None:
|
|
506
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
507
|
+
|
|
508
|
+
if server_url is not None:
|
|
509
|
+
base_url = server_url
|
|
510
|
+
else:
|
|
511
|
+
base_url = self._get_url(base_url, url_variables)
|
|
512
|
+
|
|
513
|
+
request = models.AaveUserPositionSummaryRequest(
|
|
514
|
+
chain=chain,
|
|
515
|
+
user=user,
|
|
516
|
+
)
|
|
517
|
+
|
|
518
|
+
req = self._build_request(
|
|
519
|
+
method="GET",
|
|
520
|
+
path="/v0/aave/user_position_summary/get",
|
|
521
|
+
base_url=base_url,
|
|
522
|
+
url_variables=url_variables,
|
|
523
|
+
request=request,
|
|
524
|
+
request_body_required=False,
|
|
525
|
+
request_has_path_params=False,
|
|
526
|
+
request_has_query_params=True,
|
|
527
|
+
user_agent_header="user-agent",
|
|
528
|
+
accept_header_value="application/json",
|
|
529
|
+
http_headers=http_headers,
|
|
530
|
+
security=self.sdk_configuration.security,
|
|
531
|
+
timeout_ms=timeout_ms,
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
if retries == UNSET:
|
|
535
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
536
|
+
retries = self.sdk_configuration.retry_config
|
|
537
|
+
|
|
538
|
+
retry_config = None
|
|
539
|
+
if isinstance(retries, utils.RetryConfig):
|
|
540
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
541
|
+
|
|
542
|
+
http_res = self.do_request(
|
|
543
|
+
hook_ctx=HookContext(
|
|
544
|
+
base_url=base_url or "",
|
|
545
|
+
operation_id="aave_user_position_summary",
|
|
546
|
+
oauth2_scopes=[],
|
|
547
|
+
security_source=self.sdk_configuration.security,
|
|
548
|
+
),
|
|
549
|
+
request=req,
|
|
550
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
551
|
+
retry_config=retry_config,
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
response_data: Any = None
|
|
555
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
556
|
+
return utils.unmarshal_json(
|
|
557
|
+
http_res.text, models.AaveUserPositionSummaryResponse
|
|
558
|
+
)
|
|
559
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
560
|
+
response_data = utils.unmarshal_json(
|
|
561
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
562
|
+
)
|
|
563
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
564
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
565
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
566
|
+
raise errors.APIError(
|
|
567
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
568
|
+
)
|
|
569
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
570
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
571
|
+
raise errors.APIError(
|
|
572
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
content_type = http_res.headers.get("Content-Type")
|
|
576
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
577
|
+
raise errors.APIError(
|
|
578
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
579
|
+
http_res.status_code,
|
|
580
|
+
http_res_text,
|
|
581
|
+
http_res,
|
|
582
|
+
)
|
|
583
|
+
|
|
584
|
+
async def user_position_summary_async(
|
|
585
|
+
self,
|
|
586
|
+
*,
|
|
587
|
+
chain: Optional[
|
|
588
|
+
models.AaveUserPositionSummaryChain
|
|
589
|
+
] = models.AaveUserPositionSummaryChain.ARBITRUM_MAINNET,
|
|
590
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
591
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
592
|
+
server_url: Optional[str] = None,
|
|
593
|
+
timeout_ms: Optional[int] = None,
|
|
594
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
595
|
+
) -> models.AaveUserPositionSummaryResponse:
|
|
596
|
+
r"""Positions - total
|
|
597
|
+
|
|
598
|
+
This endpoint retrieves a comprehensive summary of a user's position on the AAVE
|
|
599
|
+
platform.
|
|
600
|
+
|
|
601
|
+
It provides key financial metrics including the total collateral deposited, total
|
|
602
|
+
debt accrued, available borrowing capacity, liquidation threshold, maximum loan-to-
|
|
603
|
+
value ratio, and the health factor of the user's account. These metrics are
|
|
604
|
+
calculated by aggregating data across all open positions held by the user, offering
|
|
605
|
+
a holistic view of their financial standing within the AAVE ecosystem.
|
|
606
|
+
|
|
607
|
+
:param chain: The chain to use.
|
|
608
|
+
:param user:
|
|
609
|
+
:param retries: Override the default retry configuration for this method
|
|
610
|
+
:param server_url: Override the default server URL for this method
|
|
611
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
612
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
613
|
+
"""
|
|
614
|
+
base_url = None
|
|
615
|
+
url_variables = None
|
|
616
|
+
if timeout_ms is None:
|
|
617
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
618
|
+
|
|
619
|
+
if server_url is not None:
|
|
620
|
+
base_url = server_url
|
|
621
|
+
else:
|
|
622
|
+
base_url = self._get_url(base_url, url_variables)
|
|
623
|
+
|
|
624
|
+
request = models.AaveUserPositionSummaryRequest(
|
|
625
|
+
chain=chain,
|
|
626
|
+
user=user,
|
|
627
|
+
)
|
|
628
|
+
|
|
629
|
+
req = self._build_request_async(
|
|
630
|
+
method="GET",
|
|
631
|
+
path="/v0/aave/user_position_summary/get",
|
|
632
|
+
base_url=base_url,
|
|
633
|
+
url_variables=url_variables,
|
|
634
|
+
request=request,
|
|
635
|
+
request_body_required=False,
|
|
636
|
+
request_has_path_params=False,
|
|
637
|
+
request_has_query_params=True,
|
|
638
|
+
user_agent_header="user-agent",
|
|
639
|
+
accept_header_value="application/json",
|
|
640
|
+
http_headers=http_headers,
|
|
641
|
+
security=self.sdk_configuration.security,
|
|
642
|
+
timeout_ms=timeout_ms,
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
if retries == UNSET:
|
|
646
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
647
|
+
retries = self.sdk_configuration.retry_config
|
|
648
|
+
|
|
649
|
+
retry_config = None
|
|
650
|
+
if isinstance(retries, utils.RetryConfig):
|
|
651
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
652
|
+
|
|
653
|
+
http_res = await self.do_request_async(
|
|
654
|
+
hook_ctx=HookContext(
|
|
655
|
+
base_url=base_url or "",
|
|
656
|
+
operation_id="aave_user_position_summary",
|
|
657
|
+
oauth2_scopes=[],
|
|
658
|
+
security_source=self.sdk_configuration.security,
|
|
659
|
+
),
|
|
660
|
+
request=req,
|
|
661
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
662
|
+
retry_config=retry_config,
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
response_data: Any = None
|
|
666
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
667
|
+
return utils.unmarshal_json(
|
|
668
|
+
http_res.text, models.AaveUserPositionSummaryResponse
|
|
669
|
+
)
|
|
670
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
671
|
+
response_data = utils.unmarshal_json(
|
|
672
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
673
|
+
)
|
|
674
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
675
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
676
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
677
|
+
raise errors.APIError(
|
|
678
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
679
|
+
)
|
|
680
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
681
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
682
|
+
raise errors.APIError(
|
|
683
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
684
|
+
)
|
|
685
|
+
|
|
686
|
+
content_type = http_res.headers.get("Content-Type")
|
|
687
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
688
|
+
raise errors.APIError(
|
|
689
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
690
|
+
http_res.status_code,
|
|
691
|
+
http_res_text,
|
|
692
|
+
http_res,
|
|
693
|
+
)
|
|
694
|
+
|
|
695
|
+
def user_position_per_token(
|
|
696
|
+
self,
|
|
697
|
+
*,
|
|
698
|
+
chain: Optional[
|
|
699
|
+
models.AaveUserPositionPerTokenChain
|
|
700
|
+
] = models.AaveUserPositionPerTokenChain.ARBITRUM_MAINNET,
|
|
701
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
702
|
+
token: Optional[
|
|
703
|
+
models.AaveUserPositionPerTokenToken
|
|
704
|
+
] = models.AaveUserPositionPerTokenToken.USDC,
|
|
705
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
706
|
+
server_url: Optional[str] = None,
|
|
707
|
+
timeout_ms: Optional[int] = None,
|
|
708
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
709
|
+
) -> models.AaveUserPositionPerTokenResponse:
|
|
710
|
+
r"""Positions - per token
|
|
711
|
+
|
|
712
|
+
This endpoint retrieves the user's position for a specific token on the AAVE
|
|
713
|
+
platform.
|
|
714
|
+
|
|
715
|
+
It provides key financial metrics including the current aToken balance, current
|
|
716
|
+
stable debt, current variable debt, principal stable debt, principal variable debt,
|
|
717
|
+
stable borrow rate, stable borrow rate for new loans, variable borrow rate, and
|
|
718
|
+
liquidity rate. These metrics are calculated by aggregating data across all open
|
|
719
|
+
positions held by the user for the specified token, offering a detailed view of
|
|
720
|
+
their financial standing within the AAVE ecosystem.
|
|
721
|
+
|
|
722
|
+
:param chain: The chain to use.
|
|
723
|
+
:param user:
|
|
724
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
725
|
+
:param retries: Override the default retry configuration for this method
|
|
726
|
+
:param server_url: Override the default server URL for this method
|
|
727
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
728
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
729
|
+
"""
|
|
730
|
+
base_url = None
|
|
731
|
+
url_variables = None
|
|
732
|
+
if timeout_ms is None:
|
|
733
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
734
|
+
|
|
735
|
+
if server_url is not None:
|
|
736
|
+
base_url = server_url
|
|
737
|
+
else:
|
|
738
|
+
base_url = self._get_url(base_url, url_variables)
|
|
739
|
+
|
|
740
|
+
request = models.AaveUserPositionPerTokenRequest(
|
|
741
|
+
chain=chain,
|
|
742
|
+
user=user,
|
|
743
|
+
token=token,
|
|
744
|
+
)
|
|
745
|
+
|
|
746
|
+
req = self._build_request(
|
|
747
|
+
method="GET",
|
|
748
|
+
path="/v0/aave/user_position_per_token/get",
|
|
749
|
+
base_url=base_url,
|
|
750
|
+
url_variables=url_variables,
|
|
751
|
+
request=request,
|
|
752
|
+
request_body_required=False,
|
|
753
|
+
request_has_path_params=False,
|
|
754
|
+
request_has_query_params=True,
|
|
755
|
+
user_agent_header="user-agent",
|
|
756
|
+
accept_header_value="application/json",
|
|
757
|
+
http_headers=http_headers,
|
|
758
|
+
security=self.sdk_configuration.security,
|
|
759
|
+
timeout_ms=timeout_ms,
|
|
760
|
+
)
|
|
761
|
+
|
|
762
|
+
if retries == UNSET:
|
|
763
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
764
|
+
retries = self.sdk_configuration.retry_config
|
|
765
|
+
|
|
766
|
+
retry_config = None
|
|
767
|
+
if isinstance(retries, utils.RetryConfig):
|
|
768
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
769
|
+
|
|
770
|
+
http_res = self.do_request(
|
|
771
|
+
hook_ctx=HookContext(
|
|
772
|
+
base_url=base_url or "",
|
|
773
|
+
operation_id="aave_user_position_per_token",
|
|
774
|
+
oauth2_scopes=[],
|
|
775
|
+
security_source=self.sdk_configuration.security,
|
|
776
|
+
),
|
|
777
|
+
request=req,
|
|
778
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
779
|
+
retry_config=retry_config,
|
|
780
|
+
)
|
|
781
|
+
|
|
782
|
+
response_data: Any = None
|
|
783
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
784
|
+
return utils.unmarshal_json(
|
|
785
|
+
http_res.text, models.AaveUserPositionPerTokenResponse
|
|
786
|
+
)
|
|
787
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
788
|
+
response_data = utils.unmarshal_json(
|
|
789
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
790
|
+
)
|
|
791
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
792
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
793
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
794
|
+
raise errors.APIError(
|
|
795
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
796
|
+
)
|
|
797
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
798
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
799
|
+
raise errors.APIError(
|
|
800
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
801
|
+
)
|
|
802
|
+
|
|
803
|
+
content_type = http_res.headers.get("Content-Type")
|
|
804
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
805
|
+
raise errors.APIError(
|
|
806
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
807
|
+
http_res.status_code,
|
|
808
|
+
http_res_text,
|
|
809
|
+
http_res,
|
|
810
|
+
)
|
|
811
|
+
|
|
812
|
+
async def user_position_per_token_async(
|
|
813
|
+
self,
|
|
814
|
+
*,
|
|
815
|
+
chain: Optional[
|
|
816
|
+
models.AaveUserPositionPerTokenChain
|
|
817
|
+
] = models.AaveUserPositionPerTokenChain.ARBITRUM_MAINNET,
|
|
818
|
+
user: Optional[str] = "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
|
|
819
|
+
token: Optional[
|
|
820
|
+
models.AaveUserPositionPerTokenToken
|
|
821
|
+
] = models.AaveUserPositionPerTokenToken.USDC,
|
|
822
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
823
|
+
server_url: Optional[str] = None,
|
|
824
|
+
timeout_ms: Optional[int] = None,
|
|
825
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
826
|
+
) -> models.AaveUserPositionPerTokenResponse:
|
|
827
|
+
r"""Positions - per token
|
|
828
|
+
|
|
829
|
+
This endpoint retrieves the user's position for a specific token on the AAVE
|
|
830
|
+
platform.
|
|
831
|
+
|
|
832
|
+
It provides key financial metrics including the current aToken balance, current
|
|
833
|
+
stable debt, current variable debt, principal stable debt, principal variable debt,
|
|
834
|
+
stable borrow rate, stable borrow rate for new loans, variable borrow rate, and
|
|
835
|
+
liquidity rate. These metrics are calculated by aggregating data across all open
|
|
836
|
+
positions held by the user for the specified token, offering a detailed view of
|
|
837
|
+
their financial standing within the AAVE ecosystem.
|
|
838
|
+
|
|
839
|
+
:param chain: The chain to use.
|
|
840
|
+
:param user:
|
|
841
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
842
|
+
:param retries: Override the default retry configuration for this method
|
|
843
|
+
:param server_url: Override the default server URL for this method
|
|
844
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
845
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
846
|
+
"""
|
|
847
|
+
base_url = None
|
|
848
|
+
url_variables = None
|
|
849
|
+
if timeout_ms is None:
|
|
850
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
851
|
+
|
|
852
|
+
if server_url is not None:
|
|
853
|
+
base_url = server_url
|
|
854
|
+
else:
|
|
855
|
+
base_url = self._get_url(base_url, url_variables)
|
|
856
|
+
|
|
857
|
+
request = models.AaveUserPositionPerTokenRequest(
|
|
858
|
+
chain=chain,
|
|
859
|
+
user=user,
|
|
860
|
+
token=token,
|
|
861
|
+
)
|
|
862
|
+
|
|
863
|
+
req = self._build_request_async(
|
|
864
|
+
method="GET",
|
|
865
|
+
path="/v0/aave/user_position_per_token/get",
|
|
866
|
+
base_url=base_url,
|
|
867
|
+
url_variables=url_variables,
|
|
868
|
+
request=request,
|
|
869
|
+
request_body_required=False,
|
|
870
|
+
request_has_path_params=False,
|
|
871
|
+
request_has_query_params=True,
|
|
872
|
+
user_agent_header="user-agent",
|
|
873
|
+
accept_header_value="application/json",
|
|
874
|
+
http_headers=http_headers,
|
|
875
|
+
security=self.sdk_configuration.security,
|
|
876
|
+
timeout_ms=timeout_ms,
|
|
877
|
+
)
|
|
878
|
+
|
|
879
|
+
if retries == UNSET:
|
|
880
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
881
|
+
retries = self.sdk_configuration.retry_config
|
|
882
|
+
|
|
883
|
+
retry_config = None
|
|
884
|
+
if isinstance(retries, utils.RetryConfig):
|
|
885
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
886
|
+
|
|
887
|
+
http_res = await self.do_request_async(
|
|
888
|
+
hook_ctx=HookContext(
|
|
889
|
+
base_url=base_url or "",
|
|
890
|
+
operation_id="aave_user_position_per_token",
|
|
891
|
+
oauth2_scopes=[],
|
|
892
|
+
security_source=self.sdk_configuration.security,
|
|
893
|
+
),
|
|
894
|
+
request=req,
|
|
895
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
896
|
+
retry_config=retry_config,
|
|
897
|
+
)
|
|
898
|
+
|
|
899
|
+
response_data: Any = None
|
|
900
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
901
|
+
return utils.unmarshal_json(
|
|
902
|
+
http_res.text, models.AaveUserPositionPerTokenResponse
|
|
903
|
+
)
|
|
904
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
905
|
+
response_data = utils.unmarshal_json(
|
|
906
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
907
|
+
)
|
|
908
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
909
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
910
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
911
|
+
raise errors.APIError(
|
|
912
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
913
|
+
)
|
|
914
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
915
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
916
|
+
raise errors.APIError(
|
|
917
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
918
|
+
)
|
|
919
|
+
|
|
920
|
+
content_type = http_res.headers.get("Content-Type")
|
|
921
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
922
|
+
raise errors.APIError(
|
|
923
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
924
|
+
http_res.status_code,
|
|
925
|
+
http_res_text,
|
|
926
|
+
http_res,
|
|
927
|
+
)
|
|
928
|
+
|
|
929
|
+
def supply(
|
|
930
|
+
self,
|
|
931
|
+
*,
|
|
932
|
+
token: models.TokenEnum,
|
|
933
|
+
amount: Union[
|
|
934
|
+
models.AaveSupplyRequestAmount, models.AaveSupplyRequestAmountTypedDict
|
|
935
|
+
],
|
|
936
|
+
chain: models.Chain,
|
|
937
|
+
sender: str,
|
|
938
|
+
on_behalf_of: OptionalNullable[str] = UNSET,
|
|
939
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
940
|
+
server_url: Optional[str] = None,
|
|
941
|
+
timeout_ms: Optional[int] = None,
|
|
942
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
943
|
+
) -> models.UnsignedTransaction:
|
|
944
|
+
r"""Supply/Lend
|
|
945
|
+
|
|
946
|
+
By supplying assets, users can earn interest on their deposits.
|
|
947
|
+
|
|
948
|
+
The supplied collateral can be used as a basis for borrowing other assets, allowing
|
|
949
|
+
users to leverage their positions. In combination with a trading protocol, this can
|
|
950
|
+
create leverage.
|
|
951
|
+
|
|
952
|
+
Overall, this endpoint is a critical component for users looking to maximize their
|
|
953
|
+
asset utility within the AAVEv3 ecosystem, providing both earning potential and
|
|
954
|
+
borrowing flexibility.
|
|
955
|
+
|
|
956
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
957
|
+
:param amount: The amount of the asset to supply
|
|
958
|
+
:param chain: The chain to use.
|
|
959
|
+
:param sender: The address of the transaction sender.
|
|
960
|
+
:param on_behalf_of: The address on behalf of whom the supply is made. Defaults to the transaction sender.
|
|
961
|
+
:param retries: Override the default retry configuration for this method
|
|
962
|
+
:param server_url: Override the default server URL for this method
|
|
963
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
964
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
965
|
+
"""
|
|
966
|
+
base_url = None
|
|
967
|
+
url_variables = None
|
|
968
|
+
if timeout_ms is None:
|
|
969
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
970
|
+
|
|
971
|
+
if server_url is not None:
|
|
972
|
+
base_url = server_url
|
|
973
|
+
else:
|
|
974
|
+
base_url = self._get_url(base_url, url_variables)
|
|
975
|
+
|
|
976
|
+
request = models.AaveSupplyRequest(
|
|
977
|
+
token=token,
|
|
978
|
+
amount=amount,
|
|
979
|
+
on_behalf_of=on_behalf_of,
|
|
980
|
+
chain=chain,
|
|
981
|
+
sender=sender,
|
|
982
|
+
)
|
|
983
|
+
|
|
984
|
+
req = self._build_request(
|
|
985
|
+
method="POST",
|
|
986
|
+
path="/v0/aave/supply",
|
|
987
|
+
base_url=base_url,
|
|
988
|
+
url_variables=url_variables,
|
|
989
|
+
request=request,
|
|
990
|
+
request_body_required=True,
|
|
991
|
+
request_has_path_params=False,
|
|
992
|
+
request_has_query_params=True,
|
|
993
|
+
user_agent_header="user-agent",
|
|
994
|
+
accept_header_value="application/json",
|
|
995
|
+
http_headers=http_headers,
|
|
996
|
+
security=self.sdk_configuration.security,
|
|
997
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
998
|
+
request, False, False, "json", models.AaveSupplyRequest
|
|
999
|
+
),
|
|
1000
|
+
timeout_ms=timeout_ms,
|
|
1001
|
+
)
|
|
1002
|
+
|
|
1003
|
+
if retries == UNSET:
|
|
1004
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1005
|
+
retries = self.sdk_configuration.retry_config
|
|
1006
|
+
|
|
1007
|
+
retry_config = None
|
|
1008
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1009
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1010
|
+
|
|
1011
|
+
http_res = self.do_request(
|
|
1012
|
+
hook_ctx=HookContext(
|
|
1013
|
+
base_url=base_url or "",
|
|
1014
|
+
operation_id="aave_supply",
|
|
1015
|
+
oauth2_scopes=[],
|
|
1016
|
+
security_source=self.sdk_configuration.security,
|
|
1017
|
+
),
|
|
1018
|
+
request=req,
|
|
1019
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1020
|
+
retry_config=retry_config,
|
|
1021
|
+
)
|
|
1022
|
+
|
|
1023
|
+
response_data: Any = None
|
|
1024
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1025
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1026
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1027
|
+
response_data = utils.unmarshal_json(
|
|
1028
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1029
|
+
)
|
|
1030
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1031
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1032
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1033
|
+
raise errors.APIError(
|
|
1034
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1035
|
+
)
|
|
1036
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1037
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1038
|
+
raise errors.APIError(
|
|
1039
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1040
|
+
)
|
|
1041
|
+
|
|
1042
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1043
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1044
|
+
raise errors.APIError(
|
|
1045
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1046
|
+
http_res.status_code,
|
|
1047
|
+
http_res_text,
|
|
1048
|
+
http_res,
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
async def supply_async(
|
|
1052
|
+
self,
|
|
1053
|
+
*,
|
|
1054
|
+
token: models.TokenEnum,
|
|
1055
|
+
amount: Union[
|
|
1056
|
+
models.AaveSupplyRequestAmount, models.AaveSupplyRequestAmountTypedDict
|
|
1057
|
+
],
|
|
1058
|
+
chain: models.Chain,
|
|
1059
|
+
sender: str,
|
|
1060
|
+
on_behalf_of: OptionalNullable[str] = UNSET,
|
|
1061
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1062
|
+
server_url: Optional[str] = None,
|
|
1063
|
+
timeout_ms: Optional[int] = None,
|
|
1064
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1065
|
+
) -> models.UnsignedTransaction:
|
|
1066
|
+
r"""Supply/Lend
|
|
1067
|
+
|
|
1068
|
+
By supplying assets, users can earn interest on their deposits.
|
|
1069
|
+
|
|
1070
|
+
The supplied collateral can be used as a basis for borrowing other assets, allowing
|
|
1071
|
+
users to leverage their positions. In combination with a trading protocol, this can
|
|
1072
|
+
create leverage.
|
|
1073
|
+
|
|
1074
|
+
Overall, this endpoint is a critical component for users looking to maximize their
|
|
1075
|
+
asset utility within the AAVEv3 ecosystem, providing both earning potential and
|
|
1076
|
+
borrowing flexibility.
|
|
1077
|
+
|
|
1078
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
1079
|
+
:param amount: The amount of the asset to supply
|
|
1080
|
+
:param chain: The chain to use.
|
|
1081
|
+
:param sender: The address of the transaction sender.
|
|
1082
|
+
:param on_behalf_of: The address on behalf of whom the supply is made. Defaults to the transaction sender.
|
|
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.AaveSupplyRequest(
|
|
1099
|
+
token=token,
|
|
1100
|
+
amount=amount,
|
|
1101
|
+
on_behalf_of=on_behalf_of,
|
|
1102
|
+
chain=chain,
|
|
1103
|
+
sender=sender,
|
|
1104
|
+
)
|
|
1105
|
+
|
|
1106
|
+
req = self._build_request_async(
|
|
1107
|
+
method="POST",
|
|
1108
|
+
path="/v0/aave/supply",
|
|
1109
|
+
base_url=base_url,
|
|
1110
|
+
url_variables=url_variables,
|
|
1111
|
+
request=request,
|
|
1112
|
+
request_body_required=True,
|
|
1113
|
+
request_has_path_params=False,
|
|
1114
|
+
request_has_query_params=True,
|
|
1115
|
+
user_agent_header="user-agent",
|
|
1116
|
+
accept_header_value="application/json",
|
|
1117
|
+
http_headers=http_headers,
|
|
1118
|
+
security=self.sdk_configuration.security,
|
|
1119
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1120
|
+
request, False, False, "json", models.AaveSupplyRequest
|
|
1121
|
+
),
|
|
1122
|
+
timeout_ms=timeout_ms,
|
|
1123
|
+
)
|
|
1124
|
+
|
|
1125
|
+
if retries == UNSET:
|
|
1126
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1127
|
+
retries = self.sdk_configuration.retry_config
|
|
1128
|
+
|
|
1129
|
+
retry_config = None
|
|
1130
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1131
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1132
|
+
|
|
1133
|
+
http_res = await self.do_request_async(
|
|
1134
|
+
hook_ctx=HookContext(
|
|
1135
|
+
base_url=base_url or "",
|
|
1136
|
+
operation_id="aave_supply",
|
|
1137
|
+
oauth2_scopes=[],
|
|
1138
|
+
security_source=self.sdk_configuration.security,
|
|
1139
|
+
),
|
|
1140
|
+
request=req,
|
|
1141
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1142
|
+
retry_config=retry_config,
|
|
1143
|
+
)
|
|
1144
|
+
|
|
1145
|
+
response_data: Any = None
|
|
1146
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1147
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1148
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1149
|
+
response_data = utils.unmarshal_json(
|
|
1150
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1151
|
+
)
|
|
1152
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1153
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1154
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1155
|
+
raise errors.APIError(
|
|
1156
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1157
|
+
)
|
|
1158
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1159
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1160
|
+
raise errors.APIError(
|
|
1161
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1162
|
+
)
|
|
1163
|
+
|
|
1164
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1165
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1166
|
+
raise errors.APIError(
|
|
1167
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1168
|
+
http_res.status_code,
|
|
1169
|
+
http_res_text,
|
|
1170
|
+
http_res,
|
|
1171
|
+
)
|
|
1172
|
+
|
|
1173
|
+
def borrow(
|
|
1174
|
+
self,
|
|
1175
|
+
*,
|
|
1176
|
+
token: models.TokenEnum,
|
|
1177
|
+
amount: Union[
|
|
1178
|
+
models.AaveBorrowRequestAmount, models.AaveBorrowRequestAmountTypedDict
|
|
1179
|
+
],
|
|
1180
|
+
interest_rate_mode: models.InterestRateMode,
|
|
1181
|
+
chain: models.Chain,
|
|
1182
|
+
sender: str,
|
|
1183
|
+
on_behalf_of: OptionalNullable[str] = UNSET,
|
|
1184
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1185
|
+
server_url: Optional[str] = None,
|
|
1186
|
+
timeout_ms: Optional[int] = None,
|
|
1187
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1188
|
+
) -> models.UnsignedTransaction:
|
|
1189
|
+
r"""Borrow
|
|
1190
|
+
|
|
1191
|
+
You will pay interest for your borrows.
|
|
1192
|
+
|
|
1193
|
+
Price changes in the assets may lead to some or all of your collateral being
|
|
1194
|
+
liquidated, if the borrow position becomes unhealthy.
|
|
1195
|
+
|
|
1196
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
1197
|
+
:param amount: The amount of the asset to borrow
|
|
1198
|
+
:param interest_rate_mode: On AAVE there are 2 different interest modes. A stable (but typically higher rate), or a variable rate.
|
|
1199
|
+
:param chain: The chain to use.
|
|
1200
|
+
:param sender: The address of the transaction sender.
|
|
1201
|
+
:param on_behalf_of: The address on behalf of whom the supply is made
|
|
1202
|
+
:param retries: Override the default retry configuration for this method
|
|
1203
|
+
:param server_url: Override the default server URL for this method
|
|
1204
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1205
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1206
|
+
"""
|
|
1207
|
+
base_url = None
|
|
1208
|
+
url_variables = None
|
|
1209
|
+
if timeout_ms is None:
|
|
1210
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1211
|
+
|
|
1212
|
+
if server_url is not None:
|
|
1213
|
+
base_url = server_url
|
|
1214
|
+
else:
|
|
1215
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1216
|
+
|
|
1217
|
+
request = models.AaveBorrowRequest(
|
|
1218
|
+
token=token,
|
|
1219
|
+
amount=amount,
|
|
1220
|
+
interest_rate_mode=interest_rate_mode,
|
|
1221
|
+
on_behalf_of=on_behalf_of,
|
|
1222
|
+
chain=chain,
|
|
1223
|
+
sender=sender,
|
|
1224
|
+
)
|
|
1225
|
+
|
|
1226
|
+
req = self._build_request(
|
|
1227
|
+
method="POST",
|
|
1228
|
+
path="/v0/aave/borrow",
|
|
1229
|
+
base_url=base_url,
|
|
1230
|
+
url_variables=url_variables,
|
|
1231
|
+
request=request,
|
|
1232
|
+
request_body_required=True,
|
|
1233
|
+
request_has_path_params=False,
|
|
1234
|
+
request_has_query_params=True,
|
|
1235
|
+
user_agent_header="user-agent",
|
|
1236
|
+
accept_header_value="application/json",
|
|
1237
|
+
http_headers=http_headers,
|
|
1238
|
+
security=self.sdk_configuration.security,
|
|
1239
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1240
|
+
request, False, False, "json", models.AaveBorrowRequest
|
|
1241
|
+
),
|
|
1242
|
+
timeout_ms=timeout_ms,
|
|
1243
|
+
)
|
|
1244
|
+
|
|
1245
|
+
if retries == UNSET:
|
|
1246
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1247
|
+
retries = self.sdk_configuration.retry_config
|
|
1248
|
+
|
|
1249
|
+
retry_config = None
|
|
1250
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1251
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1252
|
+
|
|
1253
|
+
http_res = self.do_request(
|
|
1254
|
+
hook_ctx=HookContext(
|
|
1255
|
+
base_url=base_url or "",
|
|
1256
|
+
operation_id="aave_borrow",
|
|
1257
|
+
oauth2_scopes=[],
|
|
1258
|
+
security_source=self.sdk_configuration.security,
|
|
1259
|
+
),
|
|
1260
|
+
request=req,
|
|
1261
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1262
|
+
retry_config=retry_config,
|
|
1263
|
+
)
|
|
1264
|
+
|
|
1265
|
+
response_data: Any = None
|
|
1266
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1267
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1268
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1269
|
+
response_data = utils.unmarshal_json(
|
|
1270
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1271
|
+
)
|
|
1272
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1273
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1274
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1275
|
+
raise errors.APIError(
|
|
1276
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1277
|
+
)
|
|
1278
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1279
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1280
|
+
raise errors.APIError(
|
|
1281
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1282
|
+
)
|
|
1283
|
+
|
|
1284
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1285
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1286
|
+
raise errors.APIError(
|
|
1287
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1288
|
+
http_res.status_code,
|
|
1289
|
+
http_res_text,
|
|
1290
|
+
http_res,
|
|
1291
|
+
)
|
|
1292
|
+
|
|
1293
|
+
async def borrow_async(
|
|
1294
|
+
self,
|
|
1295
|
+
*,
|
|
1296
|
+
token: models.TokenEnum,
|
|
1297
|
+
amount: Union[
|
|
1298
|
+
models.AaveBorrowRequestAmount, models.AaveBorrowRequestAmountTypedDict
|
|
1299
|
+
],
|
|
1300
|
+
interest_rate_mode: models.InterestRateMode,
|
|
1301
|
+
chain: models.Chain,
|
|
1302
|
+
sender: str,
|
|
1303
|
+
on_behalf_of: OptionalNullable[str] = UNSET,
|
|
1304
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1305
|
+
server_url: Optional[str] = None,
|
|
1306
|
+
timeout_ms: Optional[int] = None,
|
|
1307
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1308
|
+
) -> models.UnsignedTransaction:
|
|
1309
|
+
r"""Borrow
|
|
1310
|
+
|
|
1311
|
+
You will pay interest for your borrows.
|
|
1312
|
+
|
|
1313
|
+
Price changes in the assets may lead to some or all of your collateral being
|
|
1314
|
+
liquidated, if the borrow position becomes unhealthy.
|
|
1315
|
+
|
|
1316
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
1317
|
+
:param amount: The amount of the asset to borrow
|
|
1318
|
+
:param interest_rate_mode: On AAVE there are 2 different interest modes. A stable (but typically higher rate), or a variable rate.
|
|
1319
|
+
:param chain: The chain to use.
|
|
1320
|
+
:param sender: The address of the transaction sender.
|
|
1321
|
+
:param on_behalf_of: The address on behalf of whom the supply is made
|
|
1322
|
+
:param retries: Override the default retry configuration for this method
|
|
1323
|
+
:param server_url: Override the default server URL for this method
|
|
1324
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1325
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1326
|
+
"""
|
|
1327
|
+
base_url = None
|
|
1328
|
+
url_variables = None
|
|
1329
|
+
if timeout_ms is None:
|
|
1330
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1331
|
+
|
|
1332
|
+
if server_url is not None:
|
|
1333
|
+
base_url = server_url
|
|
1334
|
+
else:
|
|
1335
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1336
|
+
|
|
1337
|
+
request = models.AaveBorrowRequest(
|
|
1338
|
+
token=token,
|
|
1339
|
+
amount=amount,
|
|
1340
|
+
interest_rate_mode=interest_rate_mode,
|
|
1341
|
+
on_behalf_of=on_behalf_of,
|
|
1342
|
+
chain=chain,
|
|
1343
|
+
sender=sender,
|
|
1344
|
+
)
|
|
1345
|
+
|
|
1346
|
+
req = self._build_request_async(
|
|
1347
|
+
method="POST",
|
|
1348
|
+
path="/v0/aave/borrow",
|
|
1349
|
+
base_url=base_url,
|
|
1350
|
+
url_variables=url_variables,
|
|
1351
|
+
request=request,
|
|
1352
|
+
request_body_required=True,
|
|
1353
|
+
request_has_path_params=False,
|
|
1354
|
+
request_has_query_params=True,
|
|
1355
|
+
user_agent_header="user-agent",
|
|
1356
|
+
accept_header_value="application/json",
|
|
1357
|
+
http_headers=http_headers,
|
|
1358
|
+
security=self.sdk_configuration.security,
|
|
1359
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1360
|
+
request, False, False, "json", models.AaveBorrowRequest
|
|
1361
|
+
),
|
|
1362
|
+
timeout_ms=timeout_ms,
|
|
1363
|
+
)
|
|
1364
|
+
|
|
1365
|
+
if retries == UNSET:
|
|
1366
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1367
|
+
retries = self.sdk_configuration.retry_config
|
|
1368
|
+
|
|
1369
|
+
retry_config = None
|
|
1370
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1371
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1372
|
+
|
|
1373
|
+
http_res = await self.do_request_async(
|
|
1374
|
+
hook_ctx=HookContext(
|
|
1375
|
+
base_url=base_url or "",
|
|
1376
|
+
operation_id="aave_borrow",
|
|
1377
|
+
oauth2_scopes=[],
|
|
1378
|
+
security_source=self.sdk_configuration.security,
|
|
1379
|
+
),
|
|
1380
|
+
request=req,
|
|
1381
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1382
|
+
retry_config=retry_config,
|
|
1383
|
+
)
|
|
1384
|
+
|
|
1385
|
+
response_data: Any = None
|
|
1386
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1387
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1388
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1389
|
+
response_data = utils.unmarshal_json(
|
|
1390
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1391
|
+
)
|
|
1392
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1393
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1394
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1395
|
+
raise errors.APIError(
|
|
1396
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1397
|
+
)
|
|
1398
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1399
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1400
|
+
raise errors.APIError(
|
|
1401
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1402
|
+
)
|
|
1403
|
+
|
|
1404
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1405
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1406
|
+
raise errors.APIError(
|
|
1407
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1408
|
+
http_res.status_code,
|
|
1409
|
+
http_res_text,
|
|
1410
|
+
http_res,
|
|
1411
|
+
)
|
|
1412
|
+
|
|
1413
|
+
def repay(
|
|
1414
|
+
self,
|
|
1415
|
+
*,
|
|
1416
|
+
token: models.TokenEnum,
|
|
1417
|
+
amount: Union[
|
|
1418
|
+
models.AaveRepayRequestAmount, models.AaveRepayRequestAmountTypedDict
|
|
1419
|
+
],
|
|
1420
|
+
interest_rate_mode: models.InterestRateMode,
|
|
1421
|
+
chain: models.Chain,
|
|
1422
|
+
sender: str,
|
|
1423
|
+
on_behalf_of: OptionalNullable[str] = UNSET,
|
|
1424
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1425
|
+
server_url: Optional[str] = None,
|
|
1426
|
+
timeout_ms: Optional[int] = None,
|
|
1427
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1428
|
+
) -> models.UnsignedTransaction:
|
|
1429
|
+
r"""Repay loans
|
|
1430
|
+
|
|
1431
|
+
This endpoint allows users to repay a portion or the entirety of their borrowed
|
|
1432
|
+
tokens on the Aave platform.
|
|
1433
|
+
|
|
1434
|
+
By repaying borrowed amounts, users can improve their health factor, which is a
|
|
1435
|
+
measure of the safety of their loan position. A higher health factor reduces the
|
|
1436
|
+
risk of liquidation, ensuring a more secure borrowing experience. The endpoint
|
|
1437
|
+
requires specifying the chain and the details of the repayment transaction,
|
|
1438
|
+
including the amount and the asset to be repaid.
|
|
1439
|
+
|
|
1440
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
1441
|
+
:param amount: The amount of the asset to repay
|
|
1442
|
+
:param interest_rate_mode: On AAVE there are 2 different interest modes. A stable (but typically higher rate), or a variable rate.
|
|
1443
|
+
:param chain: The chain to use.
|
|
1444
|
+
:param sender: The address of the transaction sender.
|
|
1445
|
+
:param on_behalf_of: The address on behalf of whom the supply is made
|
|
1446
|
+
:param retries: Override the default retry configuration for this method
|
|
1447
|
+
:param server_url: Override the default server URL for this method
|
|
1448
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1449
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1450
|
+
"""
|
|
1451
|
+
base_url = None
|
|
1452
|
+
url_variables = None
|
|
1453
|
+
if timeout_ms is None:
|
|
1454
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1455
|
+
|
|
1456
|
+
if server_url is not None:
|
|
1457
|
+
base_url = server_url
|
|
1458
|
+
else:
|
|
1459
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1460
|
+
|
|
1461
|
+
request = models.AaveRepayRequest(
|
|
1462
|
+
token=token,
|
|
1463
|
+
amount=amount,
|
|
1464
|
+
interest_rate_mode=interest_rate_mode,
|
|
1465
|
+
on_behalf_of=on_behalf_of,
|
|
1466
|
+
chain=chain,
|
|
1467
|
+
sender=sender,
|
|
1468
|
+
)
|
|
1469
|
+
|
|
1470
|
+
req = self._build_request(
|
|
1471
|
+
method="POST",
|
|
1472
|
+
path="/v0/aave/repay",
|
|
1473
|
+
base_url=base_url,
|
|
1474
|
+
url_variables=url_variables,
|
|
1475
|
+
request=request,
|
|
1476
|
+
request_body_required=True,
|
|
1477
|
+
request_has_path_params=False,
|
|
1478
|
+
request_has_query_params=True,
|
|
1479
|
+
user_agent_header="user-agent",
|
|
1480
|
+
accept_header_value="application/json",
|
|
1481
|
+
http_headers=http_headers,
|
|
1482
|
+
security=self.sdk_configuration.security,
|
|
1483
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1484
|
+
request, False, False, "json", models.AaveRepayRequest
|
|
1485
|
+
),
|
|
1486
|
+
timeout_ms=timeout_ms,
|
|
1487
|
+
)
|
|
1488
|
+
|
|
1489
|
+
if retries == UNSET:
|
|
1490
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1491
|
+
retries = self.sdk_configuration.retry_config
|
|
1492
|
+
|
|
1493
|
+
retry_config = None
|
|
1494
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1495
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1496
|
+
|
|
1497
|
+
http_res = self.do_request(
|
|
1498
|
+
hook_ctx=HookContext(
|
|
1499
|
+
base_url=base_url or "",
|
|
1500
|
+
operation_id="aave_repay",
|
|
1501
|
+
oauth2_scopes=[],
|
|
1502
|
+
security_source=self.sdk_configuration.security,
|
|
1503
|
+
),
|
|
1504
|
+
request=req,
|
|
1505
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1506
|
+
retry_config=retry_config,
|
|
1507
|
+
)
|
|
1508
|
+
|
|
1509
|
+
response_data: Any = None
|
|
1510
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1511
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1512
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1513
|
+
response_data = utils.unmarshal_json(
|
|
1514
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1515
|
+
)
|
|
1516
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1517
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1518
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1519
|
+
raise errors.APIError(
|
|
1520
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1521
|
+
)
|
|
1522
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1523
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1524
|
+
raise errors.APIError(
|
|
1525
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1526
|
+
)
|
|
1527
|
+
|
|
1528
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1529
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1530
|
+
raise errors.APIError(
|
|
1531
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1532
|
+
http_res.status_code,
|
|
1533
|
+
http_res_text,
|
|
1534
|
+
http_res,
|
|
1535
|
+
)
|
|
1536
|
+
|
|
1537
|
+
async def repay_async(
|
|
1538
|
+
self,
|
|
1539
|
+
*,
|
|
1540
|
+
token: models.TokenEnum,
|
|
1541
|
+
amount: Union[
|
|
1542
|
+
models.AaveRepayRequestAmount, models.AaveRepayRequestAmountTypedDict
|
|
1543
|
+
],
|
|
1544
|
+
interest_rate_mode: models.InterestRateMode,
|
|
1545
|
+
chain: models.Chain,
|
|
1546
|
+
sender: str,
|
|
1547
|
+
on_behalf_of: OptionalNullable[str] = UNSET,
|
|
1548
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1549
|
+
server_url: Optional[str] = None,
|
|
1550
|
+
timeout_ms: Optional[int] = None,
|
|
1551
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1552
|
+
) -> models.UnsignedTransaction:
|
|
1553
|
+
r"""Repay loans
|
|
1554
|
+
|
|
1555
|
+
This endpoint allows users to repay a portion or the entirety of their borrowed
|
|
1556
|
+
tokens on the Aave platform.
|
|
1557
|
+
|
|
1558
|
+
By repaying borrowed amounts, users can improve their health factor, which is a
|
|
1559
|
+
measure of the safety of their loan position. A higher health factor reduces the
|
|
1560
|
+
risk of liquidation, ensuring a more secure borrowing experience. The endpoint
|
|
1561
|
+
requires specifying the chain and the details of the repayment transaction,
|
|
1562
|
+
including the amount and the asset to be repaid.
|
|
1563
|
+
|
|
1564
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
1565
|
+
:param amount: The amount of the asset to repay
|
|
1566
|
+
:param interest_rate_mode: On AAVE there are 2 different interest modes. A stable (but typically higher rate), or a variable rate.
|
|
1567
|
+
:param chain: The chain to use.
|
|
1568
|
+
:param sender: The address of the transaction sender.
|
|
1569
|
+
:param on_behalf_of: The address on behalf of whom the supply is made
|
|
1570
|
+
:param retries: Override the default retry configuration for this method
|
|
1571
|
+
:param server_url: Override the default server URL for this method
|
|
1572
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1573
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1574
|
+
"""
|
|
1575
|
+
base_url = None
|
|
1576
|
+
url_variables = None
|
|
1577
|
+
if timeout_ms is None:
|
|
1578
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1579
|
+
|
|
1580
|
+
if server_url is not None:
|
|
1581
|
+
base_url = server_url
|
|
1582
|
+
else:
|
|
1583
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1584
|
+
|
|
1585
|
+
request = models.AaveRepayRequest(
|
|
1586
|
+
token=token,
|
|
1587
|
+
amount=amount,
|
|
1588
|
+
interest_rate_mode=interest_rate_mode,
|
|
1589
|
+
on_behalf_of=on_behalf_of,
|
|
1590
|
+
chain=chain,
|
|
1591
|
+
sender=sender,
|
|
1592
|
+
)
|
|
1593
|
+
|
|
1594
|
+
req = self._build_request_async(
|
|
1595
|
+
method="POST",
|
|
1596
|
+
path="/v0/aave/repay",
|
|
1597
|
+
base_url=base_url,
|
|
1598
|
+
url_variables=url_variables,
|
|
1599
|
+
request=request,
|
|
1600
|
+
request_body_required=True,
|
|
1601
|
+
request_has_path_params=False,
|
|
1602
|
+
request_has_query_params=True,
|
|
1603
|
+
user_agent_header="user-agent",
|
|
1604
|
+
accept_header_value="application/json",
|
|
1605
|
+
http_headers=http_headers,
|
|
1606
|
+
security=self.sdk_configuration.security,
|
|
1607
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1608
|
+
request, False, False, "json", models.AaveRepayRequest
|
|
1609
|
+
),
|
|
1610
|
+
timeout_ms=timeout_ms,
|
|
1611
|
+
)
|
|
1612
|
+
|
|
1613
|
+
if retries == UNSET:
|
|
1614
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1615
|
+
retries = self.sdk_configuration.retry_config
|
|
1616
|
+
|
|
1617
|
+
retry_config = None
|
|
1618
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1619
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1620
|
+
|
|
1621
|
+
http_res = await self.do_request_async(
|
|
1622
|
+
hook_ctx=HookContext(
|
|
1623
|
+
base_url=base_url or "",
|
|
1624
|
+
operation_id="aave_repay",
|
|
1625
|
+
oauth2_scopes=[],
|
|
1626
|
+
security_source=self.sdk_configuration.security,
|
|
1627
|
+
),
|
|
1628
|
+
request=req,
|
|
1629
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1630
|
+
retry_config=retry_config,
|
|
1631
|
+
)
|
|
1632
|
+
|
|
1633
|
+
response_data: Any = None
|
|
1634
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1635
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1636
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1637
|
+
response_data = utils.unmarshal_json(
|
|
1638
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1639
|
+
)
|
|
1640
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1641
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1642
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1643
|
+
raise errors.APIError(
|
|
1644
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1645
|
+
)
|
|
1646
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1647
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1648
|
+
raise errors.APIError(
|
|
1649
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1650
|
+
)
|
|
1651
|
+
|
|
1652
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1653
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1654
|
+
raise errors.APIError(
|
|
1655
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1656
|
+
http_res.status_code,
|
|
1657
|
+
http_res_text,
|
|
1658
|
+
http_res,
|
|
1659
|
+
)
|
|
1660
|
+
|
|
1661
|
+
def withdraw(
|
|
1662
|
+
self,
|
|
1663
|
+
*,
|
|
1664
|
+
token: models.TokenEnum,
|
|
1665
|
+
amount: Union[
|
|
1666
|
+
models.AaveWithdrawRequestAmount, models.AaveWithdrawRequestAmountTypedDict
|
|
1667
|
+
],
|
|
1668
|
+
recipient: str,
|
|
1669
|
+
chain: models.Chain,
|
|
1670
|
+
sender: str,
|
|
1671
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1672
|
+
server_url: Optional[str] = None,
|
|
1673
|
+
timeout_ms: Optional[int] = None,
|
|
1674
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1675
|
+
) -> models.UnsignedTransaction:
|
|
1676
|
+
r"""Unstake
|
|
1677
|
+
|
|
1678
|
+
This endpoint facilitates the withdrawal of collateral from the Aave protocol.
|
|
1679
|
+
|
|
1680
|
+
Users can withdraw a portion or all of their collateral, which may increase the risk
|
|
1681
|
+
of liquidation if there are outstanding borrows. The withdrawal process also
|
|
1682
|
+
includes the collection of any interest earned on the collateral. It is important
|
|
1683
|
+
for users to carefully consider their outstanding debts and the potential impact on
|
|
1684
|
+
their liquidation threshold before proceeding with a withdrawal. This endpoint is
|
|
1685
|
+
designed to provide a seamless and efficient way to manage your collateral within
|
|
1686
|
+
the Aave ecosystem.
|
|
1687
|
+
|
|
1688
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
1689
|
+
:param amount: The amount of the asset to withdraw
|
|
1690
|
+
:param recipient: The address of the recipient of the withdrawn funds.
|
|
1691
|
+
:param chain: The chain to use.
|
|
1692
|
+
:param sender: The address of the transaction sender.
|
|
1693
|
+
:param retries: Override the default retry configuration for this method
|
|
1694
|
+
:param server_url: Override the default server URL for this method
|
|
1695
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1696
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1697
|
+
"""
|
|
1698
|
+
base_url = None
|
|
1699
|
+
url_variables = None
|
|
1700
|
+
if timeout_ms is None:
|
|
1701
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1702
|
+
|
|
1703
|
+
if server_url is not None:
|
|
1704
|
+
base_url = server_url
|
|
1705
|
+
else:
|
|
1706
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1707
|
+
|
|
1708
|
+
request = models.AaveWithdrawRequest(
|
|
1709
|
+
token=token,
|
|
1710
|
+
amount=amount,
|
|
1711
|
+
recipient=recipient,
|
|
1712
|
+
chain=chain,
|
|
1713
|
+
sender=sender,
|
|
1714
|
+
)
|
|
1715
|
+
|
|
1716
|
+
req = self._build_request(
|
|
1717
|
+
method="POST",
|
|
1718
|
+
path="/v0/aave/withdraw",
|
|
1719
|
+
base_url=base_url,
|
|
1720
|
+
url_variables=url_variables,
|
|
1721
|
+
request=request,
|
|
1722
|
+
request_body_required=True,
|
|
1723
|
+
request_has_path_params=False,
|
|
1724
|
+
request_has_query_params=True,
|
|
1725
|
+
user_agent_header="user-agent",
|
|
1726
|
+
accept_header_value="application/json",
|
|
1727
|
+
http_headers=http_headers,
|
|
1728
|
+
security=self.sdk_configuration.security,
|
|
1729
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1730
|
+
request, False, False, "json", models.AaveWithdrawRequest
|
|
1731
|
+
),
|
|
1732
|
+
timeout_ms=timeout_ms,
|
|
1733
|
+
)
|
|
1734
|
+
|
|
1735
|
+
if retries == UNSET:
|
|
1736
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1737
|
+
retries = self.sdk_configuration.retry_config
|
|
1738
|
+
|
|
1739
|
+
retry_config = None
|
|
1740
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1741
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1742
|
+
|
|
1743
|
+
http_res = self.do_request(
|
|
1744
|
+
hook_ctx=HookContext(
|
|
1745
|
+
base_url=base_url or "",
|
|
1746
|
+
operation_id="aave_withdraw",
|
|
1747
|
+
oauth2_scopes=[],
|
|
1748
|
+
security_source=self.sdk_configuration.security,
|
|
1749
|
+
),
|
|
1750
|
+
request=req,
|
|
1751
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1752
|
+
retry_config=retry_config,
|
|
1753
|
+
)
|
|
1754
|
+
|
|
1755
|
+
response_data: Any = None
|
|
1756
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1757
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1758
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1759
|
+
response_data = utils.unmarshal_json(
|
|
1760
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1761
|
+
)
|
|
1762
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1763
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1764
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1765
|
+
raise errors.APIError(
|
|
1766
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1767
|
+
)
|
|
1768
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1769
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1770
|
+
raise errors.APIError(
|
|
1771
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1772
|
+
)
|
|
1773
|
+
|
|
1774
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1775
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
1776
|
+
raise errors.APIError(
|
|
1777
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1778
|
+
http_res.status_code,
|
|
1779
|
+
http_res_text,
|
|
1780
|
+
http_res,
|
|
1781
|
+
)
|
|
1782
|
+
|
|
1783
|
+
async def withdraw_async(
|
|
1784
|
+
self,
|
|
1785
|
+
*,
|
|
1786
|
+
token: models.TokenEnum,
|
|
1787
|
+
amount: Union[
|
|
1788
|
+
models.AaveWithdrawRequestAmount, models.AaveWithdrawRequestAmountTypedDict
|
|
1789
|
+
],
|
|
1790
|
+
recipient: str,
|
|
1791
|
+
chain: models.Chain,
|
|
1792
|
+
sender: str,
|
|
1793
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
1794
|
+
server_url: Optional[str] = None,
|
|
1795
|
+
timeout_ms: Optional[int] = None,
|
|
1796
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
1797
|
+
) -> models.UnsignedTransaction:
|
|
1798
|
+
r"""Unstake
|
|
1799
|
+
|
|
1800
|
+
This endpoint facilitates the withdrawal of collateral from the Aave protocol.
|
|
1801
|
+
|
|
1802
|
+
Users can withdraw a portion or all of their collateral, which may increase the risk
|
|
1803
|
+
of liquidation if there are outstanding borrows. The withdrawal process also
|
|
1804
|
+
includes the collection of any interest earned on the collateral. It is important
|
|
1805
|
+
for users to carefully consider their outstanding debts and the potential impact on
|
|
1806
|
+
their liquidation threshold before proceeding with a withdrawal. This endpoint is
|
|
1807
|
+
designed to provide a seamless and efficient way to manage your collateral within
|
|
1808
|
+
the Aave ecosystem.
|
|
1809
|
+
|
|
1810
|
+
:param token: A class representing the token. This class is used to represent the token in the system. Notice individual endpoints' documentation where per chain tokens are presented.
|
|
1811
|
+
:param amount: The amount of the asset to withdraw
|
|
1812
|
+
:param recipient: The address of the recipient of the withdrawn funds.
|
|
1813
|
+
:param chain: The chain to use.
|
|
1814
|
+
:param sender: The address of the transaction sender.
|
|
1815
|
+
:param retries: Override the default retry configuration for this method
|
|
1816
|
+
:param server_url: Override the default server URL for this method
|
|
1817
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
1818
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
1819
|
+
"""
|
|
1820
|
+
base_url = None
|
|
1821
|
+
url_variables = None
|
|
1822
|
+
if timeout_ms is None:
|
|
1823
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
1824
|
+
|
|
1825
|
+
if server_url is not None:
|
|
1826
|
+
base_url = server_url
|
|
1827
|
+
else:
|
|
1828
|
+
base_url = self._get_url(base_url, url_variables)
|
|
1829
|
+
|
|
1830
|
+
request = models.AaveWithdrawRequest(
|
|
1831
|
+
token=token,
|
|
1832
|
+
amount=amount,
|
|
1833
|
+
recipient=recipient,
|
|
1834
|
+
chain=chain,
|
|
1835
|
+
sender=sender,
|
|
1836
|
+
)
|
|
1837
|
+
|
|
1838
|
+
req = self._build_request_async(
|
|
1839
|
+
method="POST",
|
|
1840
|
+
path="/v0/aave/withdraw",
|
|
1841
|
+
base_url=base_url,
|
|
1842
|
+
url_variables=url_variables,
|
|
1843
|
+
request=request,
|
|
1844
|
+
request_body_required=True,
|
|
1845
|
+
request_has_path_params=False,
|
|
1846
|
+
request_has_query_params=True,
|
|
1847
|
+
user_agent_header="user-agent",
|
|
1848
|
+
accept_header_value="application/json",
|
|
1849
|
+
http_headers=http_headers,
|
|
1850
|
+
security=self.sdk_configuration.security,
|
|
1851
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
1852
|
+
request, False, False, "json", models.AaveWithdrawRequest
|
|
1853
|
+
),
|
|
1854
|
+
timeout_ms=timeout_ms,
|
|
1855
|
+
)
|
|
1856
|
+
|
|
1857
|
+
if retries == UNSET:
|
|
1858
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
1859
|
+
retries = self.sdk_configuration.retry_config
|
|
1860
|
+
|
|
1861
|
+
retry_config = None
|
|
1862
|
+
if isinstance(retries, utils.RetryConfig):
|
|
1863
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
1864
|
+
|
|
1865
|
+
http_res = await self.do_request_async(
|
|
1866
|
+
hook_ctx=HookContext(
|
|
1867
|
+
base_url=base_url or "",
|
|
1868
|
+
operation_id="aave_withdraw",
|
|
1869
|
+
oauth2_scopes=[],
|
|
1870
|
+
security_source=self.sdk_configuration.security,
|
|
1871
|
+
),
|
|
1872
|
+
request=req,
|
|
1873
|
+
error_status_codes=["422", "4XX", "5XX"],
|
|
1874
|
+
retry_config=retry_config,
|
|
1875
|
+
)
|
|
1876
|
+
|
|
1877
|
+
response_data: Any = None
|
|
1878
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
1879
|
+
return utils.unmarshal_json(http_res.text, models.UnsignedTransaction)
|
|
1880
|
+
if utils.match_response(http_res, "422", "application/json"):
|
|
1881
|
+
response_data = utils.unmarshal_json(
|
|
1882
|
+
http_res.text, errors.HTTPValidationErrorData
|
|
1883
|
+
)
|
|
1884
|
+
raise errors.HTTPValidationError(data=response_data)
|
|
1885
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
1886
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1887
|
+
raise errors.APIError(
|
|
1888
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1889
|
+
)
|
|
1890
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
1891
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1892
|
+
raise errors.APIError(
|
|
1893
|
+
"API error occurred", http_res.status_code, http_res_text, http_res
|
|
1894
|
+
)
|
|
1895
|
+
|
|
1896
|
+
content_type = http_res.headers.get("Content-Type")
|
|
1897
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
1898
|
+
raise errors.APIError(
|
|
1899
|
+
f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
|
|
1900
|
+
http_res.status_code,
|
|
1901
|
+
http_res_text,
|
|
1902
|
+
http_res,
|
|
1903
|
+
)
|