compass_api_sdk 0.7.1__py3-none-any.whl → 0.7.2__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/pendle.py CHANGED
@@ -4,7 +4,7 @@ from .basesdk import BaseSDK
4
4
  from compass_api_sdk import errors, models, utils
5
5
  from compass_api_sdk._hooks import HookContext
6
6
  from compass_api_sdk.types import OptionalNullable, UNSET
7
- from typing import Any, Mapping, Optional
7
+ from typing import Any, Mapping, Optional, Union
8
8
 
9
9
 
10
10
  class Pendle(BaseSDK):
@@ -847,3 +847,899 @@ class Pendle(BaseSDK):
847
847
  http_res_text,
848
848
  http_res,
849
849
  )
850
+
851
+ def buy_pt(
852
+ self,
853
+ *,
854
+ market_address: str,
855
+ amount: Union[
856
+ models.PendleBuyPtRequestAmount, models.PendleBuyPtRequestAmountTypedDict
857
+ ],
858
+ chain: models.Chain,
859
+ sender: str,
860
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
861
+ server_url: Optional[str] = None,
862
+ timeout_ms: Optional[int] = None,
863
+ http_headers: Optional[Mapping[str, str]] = None,
864
+ ) -> models.TxResponse:
865
+ r"""Buy Princpal Token (PT)
866
+
867
+ Buy Principal Token (PT) with market's Underlying Token.
868
+
869
+ :param market_address: The address of the market identifying which Principal Token (PT) you would like to buy.
870
+ :param amount: The amount of market's Underlying Token you would like to sell for market's Principal Token (PT).
871
+ :param chain: The chain to use.
872
+ :param sender: The address of the transaction sender.
873
+ :param retries: Override the default retry configuration for this method
874
+ :param server_url: Override the default server URL for this method
875
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
876
+ :param http_headers: Additional headers to set or replace on requests.
877
+ """
878
+ base_url = None
879
+ url_variables = None
880
+ if timeout_ms is None:
881
+ timeout_ms = self.sdk_configuration.timeout_ms
882
+
883
+ if server_url is not None:
884
+ base_url = server_url
885
+ else:
886
+ base_url = self._get_url(base_url, url_variables)
887
+
888
+ request = models.PendleBuyPtRequest(
889
+ market_address=market_address,
890
+ amount=amount,
891
+ chain=chain,
892
+ sender=sender,
893
+ )
894
+
895
+ req = self._build_request(
896
+ method="POST",
897
+ path="/v0/pendle/buy_pt",
898
+ base_url=base_url,
899
+ url_variables=url_variables,
900
+ request=request,
901
+ request_body_required=True,
902
+ request_has_path_params=False,
903
+ request_has_query_params=True,
904
+ user_agent_header="user-agent",
905
+ accept_header_value="application/json",
906
+ http_headers=http_headers,
907
+ security=self.sdk_configuration.security,
908
+ get_serialized_body=lambda: utils.serialize_request_body(
909
+ request, False, False, "json", models.PendleBuyPtRequest
910
+ ),
911
+ timeout_ms=timeout_ms,
912
+ )
913
+
914
+ if retries == UNSET:
915
+ if self.sdk_configuration.retry_config is not UNSET:
916
+ retries = self.sdk_configuration.retry_config
917
+
918
+ retry_config = None
919
+ if isinstance(retries, utils.RetryConfig):
920
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
921
+
922
+ http_res = self.do_request(
923
+ hook_ctx=HookContext(
924
+ config=self.sdk_configuration,
925
+ base_url=base_url or "",
926
+ operation_id="pendle_buy_pt",
927
+ oauth2_scopes=[],
928
+ security_source=self.sdk_configuration.security,
929
+ ),
930
+ request=req,
931
+ error_status_codes=["422", "4XX", "5XX"],
932
+ retry_config=retry_config,
933
+ )
934
+
935
+ response_data: Any = None
936
+ if utils.match_response(http_res, "200", "application/json"):
937
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
938
+ if utils.match_response(http_res, "422", "application/json"):
939
+ response_data = utils.unmarshal_json(
940
+ http_res.text, errors.HTTPValidationErrorData
941
+ )
942
+ raise errors.HTTPValidationError(data=response_data)
943
+ if utils.match_response(http_res, "4XX", "*"):
944
+ http_res_text = utils.stream_to_text(http_res)
945
+ raise errors.APIError(
946
+ "API error occurred", http_res.status_code, http_res_text, http_res
947
+ )
948
+ if utils.match_response(http_res, "5XX", "*"):
949
+ http_res_text = utils.stream_to_text(http_res)
950
+ raise errors.APIError(
951
+ "API error occurred", http_res.status_code, http_res_text, http_res
952
+ )
953
+
954
+ content_type = http_res.headers.get("Content-Type")
955
+ http_res_text = utils.stream_to_text(http_res)
956
+ raise errors.APIError(
957
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
958
+ http_res.status_code,
959
+ http_res_text,
960
+ http_res,
961
+ )
962
+
963
+ async def buy_pt_async(
964
+ self,
965
+ *,
966
+ market_address: str,
967
+ amount: Union[
968
+ models.PendleBuyPtRequestAmount, models.PendleBuyPtRequestAmountTypedDict
969
+ ],
970
+ chain: models.Chain,
971
+ sender: str,
972
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
973
+ server_url: Optional[str] = None,
974
+ timeout_ms: Optional[int] = None,
975
+ http_headers: Optional[Mapping[str, str]] = None,
976
+ ) -> models.TxResponse:
977
+ r"""Buy Princpal Token (PT)
978
+
979
+ Buy Principal Token (PT) with market's Underlying Token.
980
+
981
+ :param market_address: The address of the market identifying which Principal Token (PT) you would like to buy.
982
+ :param amount: The amount of market's Underlying Token you would like to sell for market's Principal Token (PT).
983
+ :param chain: The chain to use.
984
+ :param sender: The address of the transaction sender.
985
+ :param retries: Override the default retry configuration for this method
986
+ :param server_url: Override the default server URL for this method
987
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
988
+ :param http_headers: Additional headers to set or replace on requests.
989
+ """
990
+ base_url = None
991
+ url_variables = None
992
+ if timeout_ms is None:
993
+ timeout_ms = self.sdk_configuration.timeout_ms
994
+
995
+ if server_url is not None:
996
+ base_url = server_url
997
+ else:
998
+ base_url = self._get_url(base_url, url_variables)
999
+
1000
+ request = models.PendleBuyPtRequest(
1001
+ market_address=market_address,
1002
+ amount=amount,
1003
+ chain=chain,
1004
+ sender=sender,
1005
+ )
1006
+
1007
+ req = self._build_request_async(
1008
+ method="POST",
1009
+ path="/v0/pendle/buy_pt",
1010
+ base_url=base_url,
1011
+ url_variables=url_variables,
1012
+ request=request,
1013
+ request_body_required=True,
1014
+ request_has_path_params=False,
1015
+ request_has_query_params=True,
1016
+ user_agent_header="user-agent",
1017
+ accept_header_value="application/json",
1018
+ http_headers=http_headers,
1019
+ security=self.sdk_configuration.security,
1020
+ get_serialized_body=lambda: utils.serialize_request_body(
1021
+ request, False, False, "json", models.PendleBuyPtRequest
1022
+ ),
1023
+ timeout_ms=timeout_ms,
1024
+ )
1025
+
1026
+ if retries == UNSET:
1027
+ if self.sdk_configuration.retry_config is not UNSET:
1028
+ retries = self.sdk_configuration.retry_config
1029
+
1030
+ retry_config = None
1031
+ if isinstance(retries, utils.RetryConfig):
1032
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1033
+
1034
+ http_res = await self.do_request_async(
1035
+ hook_ctx=HookContext(
1036
+ config=self.sdk_configuration,
1037
+ base_url=base_url or "",
1038
+ operation_id="pendle_buy_pt",
1039
+ oauth2_scopes=[],
1040
+ security_source=self.sdk_configuration.security,
1041
+ ),
1042
+ request=req,
1043
+ error_status_codes=["422", "4XX", "5XX"],
1044
+ retry_config=retry_config,
1045
+ )
1046
+
1047
+ response_data: Any = None
1048
+ if utils.match_response(http_res, "200", "application/json"):
1049
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
1050
+ if utils.match_response(http_res, "422", "application/json"):
1051
+ response_data = utils.unmarshal_json(
1052
+ http_res.text, errors.HTTPValidationErrorData
1053
+ )
1054
+ raise errors.HTTPValidationError(data=response_data)
1055
+ if utils.match_response(http_res, "4XX", "*"):
1056
+ http_res_text = await utils.stream_to_text_async(http_res)
1057
+ raise errors.APIError(
1058
+ "API error occurred", http_res.status_code, http_res_text, http_res
1059
+ )
1060
+ if utils.match_response(http_res, "5XX", "*"):
1061
+ http_res_text = await utils.stream_to_text_async(http_res)
1062
+ raise errors.APIError(
1063
+ "API error occurred", http_res.status_code, http_res_text, http_res
1064
+ )
1065
+
1066
+ content_type = http_res.headers.get("Content-Type")
1067
+ http_res_text = await utils.stream_to_text_async(http_res)
1068
+ raise errors.APIError(
1069
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1070
+ http_res.status_code,
1071
+ http_res_text,
1072
+ http_res,
1073
+ )
1074
+
1075
+ def sell_pt(
1076
+ self,
1077
+ *,
1078
+ market_address: str,
1079
+ amount: Union[
1080
+ models.PendleSellPtRequestAmount, models.PendleSellPtRequestAmountTypedDict
1081
+ ],
1082
+ chain: models.Chain,
1083
+ sender: str,
1084
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1085
+ server_url: Optional[str] = None,
1086
+ timeout_ms: Optional[int] = None,
1087
+ http_headers: Optional[Mapping[str, str]] = None,
1088
+ ) -> models.TxResponse:
1089
+ r"""Sell Princpal Token (PT)
1090
+
1091
+ Sell Principal Token (PT) for the market's Underlying Token.
1092
+
1093
+ :param market_address: The address of the market identifying which Principal Token (PT) you would like to sell.
1094
+ :param amount: The amount of market's Principal Token (PT) you would like to sell for market's Underlying Token.
1095
+ :param chain: The chain to use.
1096
+ :param sender: The address of the transaction sender.
1097
+ :param retries: Override the default retry configuration for this method
1098
+ :param server_url: Override the default server URL for this method
1099
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1100
+ :param http_headers: Additional headers to set or replace on requests.
1101
+ """
1102
+ base_url = None
1103
+ url_variables = None
1104
+ if timeout_ms is None:
1105
+ timeout_ms = self.sdk_configuration.timeout_ms
1106
+
1107
+ if server_url is not None:
1108
+ base_url = server_url
1109
+ else:
1110
+ base_url = self._get_url(base_url, url_variables)
1111
+
1112
+ request = models.PendleSellPtRequest(
1113
+ market_address=market_address,
1114
+ amount=amount,
1115
+ chain=chain,
1116
+ sender=sender,
1117
+ )
1118
+
1119
+ req = self._build_request(
1120
+ method="POST",
1121
+ path="/v0/pendle/sell_pt",
1122
+ base_url=base_url,
1123
+ url_variables=url_variables,
1124
+ request=request,
1125
+ request_body_required=True,
1126
+ request_has_path_params=False,
1127
+ request_has_query_params=True,
1128
+ user_agent_header="user-agent",
1129
+ accept_header_value="application/json",
1130
+ http_headers=http_headers,
1131
+ security=self.sdk_configuration.security,
1132
+ get_serialized_body=lambda: utils.serialize_request_body(
1133
+ request, False, False, "json", models.PendleSellPtRequest
1134
+ ),
1135
+ timeout_ms=timeout_ms,
1136
+ )
1137
+
1138
+ if retries == UNSET:
1139
+ if self.sdk_configuration.retry_config is not UNSET:
1140
+ retries = self.sdk_configuration.retry_config
1141
+
1142
+ retry_config = None
1143
+ if isinstance(retries, utils.RetryConfig):
1144
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1145
+
1146
+ http_res = self.do_request(
1147
+ hook_ctx=HookContext(
1148
+ config=self.sdk_configuration,
1149
+ base_url=base_url or "",
1150
+ operation_id="pendle_sell_pt",
1151
+ oauth2_scopes=[],
1152
+ security_source=self.sdk_configuration.security,
1153
+ ),
1154
+ request=req,
1155
+ error_status_codes=["422", "4XX", "5XX"],
1156
+ retry_config=retry_config,
1157
+ )
1158
+
1159
+ response_data: Any = None
1160
+ if utils.match_response(http_res, "200", "application/json"):
1161
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
1162
+ if utils.match_response(http_res, "422", "application/json"):
1163
+ response_data = utils.unmarshal_json(
1164
+ http_res.text, errors.HTTPValidationErrorData
1165
+ )
1166
+ raise errors.HTTPValidationError(data=response_data)
1167
+ if utils.match_response(http_res, "4XX", "*"):
1168
+ http_res_text = utils.stream_to_text(http_res)
1169
+ raise errors.APIError(
1170
+ "API error occurred", http_res.status_code, http_res_text, http_res
1171
+ )
1172
+ if utils.match_response(http_res, "5XX", "*"):
1173
+ http_res_text = utils.stream_to_text(http_res)
1174
+ raise errors.APIError(
1175
+ "API error occurred", http_res.status_code, http_res_text, http_res
1176
+ )
1177
+
1178
+ content_type = http_res.headers.get("Content-Type")
1179
+ http_res_text = utils.stream_to_text(http_res)
1180
+ raise errors.APIError(
1181
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1182
+ http_res.status_code,
1183
+ http_res_text,
1184
+ http_res,
1185
+ )
1186
+
1187
+ async def sell_pt_async(
1188
+ self,
1189
+ *,
1190
+ market_address: str,
1191
+ amount: Union[
1192
+ models.PendleSellPtRequestAmount, models.PendleSellPtRequestAmountTypedDict
1193
+ ],
1194
+ chain: models.Chain,
1195
+ sender: str,
1196
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1197
+ server_url: Optional[str] = None,
1198
+ timeout_ms: Optional[int] = None,
1199
+ http_headers: Optional[Mapping[str, str]] = None,
1200
+ ) -> models.TxResponse:
1201
+ r"""Sell Princpal Token (PT)
1202
+
1203
+ Sell Principal Token (PT) for the market's Underlying Token.
1204
+
1205
+ :param market_address: The address of the market identifying which Principal Token (PT) you would like to sell.
1206
+ :param amount: The amount of market's Principal Token (PT) you would like to sell for market's Underlying Token.
1207
+ :param chain: The chain to use.
1208
+ :param sender: The address of the transaction sender.
1209
+ :param retries: Override the default retry configuration for this method
1210
+ :param server_url: Override the default server URL for this method
1211
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1212
+ :param http_headers: Additional headers to set or replace on requests.
1213
+ """
1214
+ base_url = None
1215
+ url_variables = None
1216
+ if timeout_ms is None:
1217
+ timeout_ms = self.sdk_configuration.timeout_ms
1218
+
1219
+ if server_url is not None:
1220
+ base_url = server_url
1221
+ else:
1222
+ base_url = self._get_url(base_url, url_variables)
1223
+
1224
+ request = models.PendleSellPtRequest(
1225
+ market_address=market_address,
1226
+ amount=amount,
1227
+ chain=chain,
1228
+ sender=sender,
1229
+ )
1230
+
1231
+ req = self._build_request_async(
1232
+ method="POST",
1233
+ path="/v0/pendle/sell_pt",
1234
+ base_url=base_url,
1235
+ url_variables=url_variables,
1236
+ request=request,
1237
+ request_body_required=True,
1238
+ request_has_path_params=False,
1239
+ request_has_query_params=True,
1240
+ user_agent_header="user-agent",
1241
+ accept_header_value="application/json",
1242
+ http_headers=http_headers,
1243
+ security=self.sdk_configuration.security,
1244
+ get_serialized_body=lambda: utils.serialize_request_body(
1245
+ request, False, False, "json", models.PendleSellPtRequest
1246
+ ),
1247
+ timeout_ms=timeout_ms,
1248
+ )
1249
+
1250
+ if retries == UNSET:
1251
+ if self.sdk_configuration.retry_config is not UNSET:
1252
+ retries = self.sdk_configuration.retry_config
1253
+
1254
+ retry_config = None
1255
+ if isinstance(retries, utils.RetryConfig):
1256
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1257
+
1258
+ http_res = await self.do_request_async(
1259
+ hook_ctx=HookContext(
1260
+ config=self.sdk_configuration,
1261
+ base_url=base_url or "",
1262
+ operation_id="pendle_sell_pt",
1263
+ oauth2_scopes=[],
1264
+ security_source=self.sdk_configuration.security,
1265
+ ),
1266
+ request=req,
1267
+ error_status_codes=["422", "4XX", "5XX"],
1268
+ retry_config=retry_config,
1269
+ )
1270
+
1271
+ response_data: Any = None
1272
+ if utils.match_response(http_res, "200", "application/json"):
1273
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
1274
+ if utils.match_response(http_res, "422", "application/json"):
1275
+ response_data = utils.unmarshal_json(
1276
+ http_res.text, errors.HTTPValidationErrorData
1277
+ )
1278
+ raise errors.HTTPValidationError(data=response_data)
1279
+ if utils.match_response(http_res, "4XX", "*"):
1280
+ http_res_text = await utils.stream_to_text_async(http_res)
1281
+ raise errors.APIError(
1282
+ "API error occurred", http_res.status_code, http_res_text, http_res
1283
+ )
1284
+ if utils.match_response(http_res, "5XX", "*"):
1285
+ http_res_text = await utils.stream_to_text_async(http_res)
1286
+ raise errors.APIError(
1287
+ "API error occurred", http_res.status_code, http_res_text, http_res
1288
+ )
1289
+
1290
+ content_type = http_res.headers.get("Content-Type")
1291
+ http_res_text = await utils.stream_to_text_async(http_res)
1292
+ raise errors.APIError(
1293
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1294
+ http_res.status_code,
1295
+ http_res_text,
1296
+ http_res,
1297
+ )
1298
+
1299
+ def buy_yt(
1300
+ self,
1301
+ *,
1302
+ market_address: str,
1303
+ amount: Union[
1304
+ models.PendleBuyYtRequestAmount, models.PendleBuyYtRequestAmountTypedDict
1305
+ ],
1306
+ chain: models.Chain,
1307
+ sender: str,
1308
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1309
+ server_url: Optional[str] = None,
1310
+ timeout_ms: Optional[int] = None,
1311
+ http_headers: Optional[Mapping[str, str]] = None,
1312
+ ) -> models.TxResponse:
1313
+ r"""Buy Yield Token (YT)
1314
+
1315
+ Buy Yield Token (YT) with market's Underlying Token.
1316
+
1317
+ :param market_address: The address of the market identifying which Yield Token (YT) you would like to buy.
1318
+ :param amount: The amount of market's Underlying Token you would like to sell for market's Yield Token (YT).
1319
+ :param chain: The chain to use.
1320
+ :param sender: The address of the transaction sender.
1321
+ :param retries: Override the default retry configuration for this method
1322
+ :param server_url: Override the default server URL for this method
1323
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1324
+ :param http_headers: Additional headers to set or replace on requests.
1325
+ """
1326
+ base_url = None
1327
+ url_variables = None
1328
+ if timeout_ms is None:
1329
+ timeout_ms = self.sdk_configuration.timeout_ms
1330
+
1331
+ if server_url is not None:
1332
+ base_url = server_url
1333
+ else:
1334
+ base_url = self._get_url(base_url, url_variables)
1335
+
1336
+ request = models.PendleBuyYtRequest(
1337
+ market_address=market_address,
1338
+ amount=amount,
1339
+ chain=chain,
1340
+ sender=sender,
1341
+ )
1342
+
1343
+ req = self._build_request(
1344
+ method="POST",
1345
+ path="/v0/pendle/buy_yt",
1346
+ base_url=base_url,
1347
+ url_variables=url_variables,
1348
+ request=request,
1349
+ request_body_required=True,
1350
+ request_has_path_params=False,
1351
+ request_has_query_params=True,
1352
+ user_agent_header="user-agent",
1353
+ accept_header_value="application/json",
1354
+ http_headers=http_headers,
1355
+ security=self.sdk_configuration.security,
1356
+ get_serialized_body=lambda: utils.serialize_request_body(
1357
+ request, False, False, "json", models.PendleBuyYtRequest
1358
+ ),
1359
+ timeout_ms=timeout_ms,
1360
+ )
1361
+
1362
+ if retries == UNSET:
1363
+ if self.sdk_configuration.retry_config is not UNSET:
1364
+ retries = self.sdk_configuration.retry_config
1365
+
1366
+ retry_config = None
1367
+ if isinstance(retries, utils.RetryConfig):
1368
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1369
+
1370
+ http_res = self.do_request(
1371
+ hook_ctx=HookContext(
1372
+ config=self.sdk_configuration,
1373
+ base_url=base_url or "",
1374
+ operation_id="pendle_buy_yt",
1375
+ oauth2_scopes=[],
1376
+ security_source=self.sdk_configuration.security,
1377
+ ),
1378
+ request=req,
1379
+ error_status_codes=["422", "4XX", "5XX"],
1380
+ retry_config=retry_config,
1381
+ )
1382
+
1383
+ response_data: Any = None
1384
+ if utils.match_response(http_res, "200", "application/json"):
1385
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
1386
+ if utils.match_response(http_res, "422", "application/json"):
1387
+ response_data = utils.unmarshal_json(
1388
+ http_res.text, errors.HTTPValidationErrorData
1389
+ )
1390
+ raise errors.HTTPValidationError(data=response_data)
1391
+ if utils.match_response(http_res, "4XX", "*"):
1392
+ http_res_text = utils.stream_to_text(http_res)
1393
+ raise errors.APIError(
1394
+ "API error occurred", http_res.status_code, http_res_text, http_res
1395
+ )
1396
+ if utils.match_response(http_res, "5XX", "*"):
1397
+ http_res_text = utils.stream_to_text(http_res)
1398
+ raise errors.APIError(
1399
+ "API error occurred", http_res.status_code, http_res_text, http_res
1400
+ )
1401
+
1402
+ content_type = http_res.headers.get("Content-Type")
1403
+ http_res_text = utils.stream_to_text(http_res)
1404
+ raise errors.APIError(
1405
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1406
+ http_res.status_code,
1407
+ http_res_text,
1408
+ http_res,
1409
+ )
1410
+
1411
+ async def buy_yt_async(
1412
+ self,
1413
+ *,
1414
+ market_address: str,
1415
+ amount: Union[
1416
+ models.PendleBuyYtRequestAmount, models.PendleBuyYtRequestAmountTypedDict
1417
+ ],
1418
+ chain: models.Chain,
1419
+ sender: str,
1420
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1421
+ server_url: Optional[str] = None,
1422
+ timeout_ms: Optional[int] = None,
1423
+ http_headers: Optional[Mapping[str, str]] = None,
1424
+ ) -> models.TxResponse:
1425
+ r"""Buy Yield Token (YT)
1426
+
1427
+ Buy Yield Token (YT) with market's Underlying Token.
1428
+
1429
+ :param market_address: The address of the market identifying which Yield Token (YT) you would like to buy.
1430
+ :param amount: The amount of market's Underlying Token you would like to sell for market's Yield Token (YT).
1431
+ :param chain: The chain to use.
1432
+ :param sender: The address of the transaction sender.
1433
+ :param retries: Override the default retry configuration for this method
1434
+ :param server_url: Override the default server URL for this method
1435
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1436
+ :param http_headers: Additional headers to set or replace on requests.
1437
+ """
1438
+ base_url = None
1439
+ url_variables = None
1440
+ if timeout_ms is None:
1441
+ timeout_ms = self.sdk_configuration.timeout_ms
1442
+
1443
+ if server_url is not None:
1444
+ base_url = server_url
1445
+ else:
1446
+ base_url = self._get_url(base_url, url_variables)
1447
+
1448
+ request = models.PendleBuyYtRequest(
1449
+ market_address=market_address,
1450
+ amount=amount,
1451
+ chain=chain,
1452
+ sender=sender,
1453
+ )
1454
+
1455
+ req = self._build_request_async(
1456
+ method="POST",
1457
+ path="/v0/pendle/buy_yt",
1458
+ base_url=base_url,
1459
+ url_variables=url_variables,
1460
+ request=request,
1461
+ request_body_required=True,
1462
+ request_has_path_params=False,
1463
+ request_has_query_params=True,
1464
+ user_agent_header="user-agent",
1465
+ accept_header_value="application/json",
1466
+ http_headers=http_headers,
1467
+ security=self.sdk_configuration.security,
1468
+ get_serialized_body=lambda: utils.serialize_request_body(
1469
+ request, False, False, "json", models.PendleBuyYtRequest
1470
+ ),
1471
+ timeout_ms=timeout_ms,
1472
+ )
1473
+
1474
+ if retries == UNSET:
1475
+ if self.sdk_configuration.retry_config is not UNSET:
1476
+ retries = self.sdk_configuration.retry_config
1477
+
1478
+ retry_config = None
1479
+ if isinstance(retries, utils.RetryConfig):
1480
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1481
+
1482
+ http_res = await self.do_request_async(
1483
+ hook_ctx=HookContext(
1484
+ config=self.sdk_configuration,
1485
+ base_url=base_url or "",
1486
+ operation_id="pendle_buy_yt",
1487
+ oauth2_scopes=[],
1488
+ security_source=self.sdk_configuration.security,
1489
+ ),
1490
+ request=req,
1491
+ error_status_codes=["422", "4XX", "5XX"],
1492
+ retry_config=retry_config,
1493
+ )
1494
+
1495
+ response_data: Any = None
1496
+ if utils.match_response(http_res, "200", "application/json"):
1497
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
1498
+ if utils.match_response(http_res, "422", "application/json"):
1499
+ response_data = utils.unmarshal_json(
1500
+ http_res.text, errors.HTTPValidationErrorData
1501
+ )
1502
+ raise errors.HTTPValidationError(data=response_data)
1503
+ if utils.match_response(http_res, "4XX", "*"):
1504
+ http_res_text = await utils.stream_to_text_async(http_res)
1505
+ raise errors.APIError(
1506
+ "API error occurred", http_res.status_code, http_res_text, http_res
1507
+ )
1508
+ if utils.match_response(http_res, "5XX", "*"):
1509
+ http_res_text = await utils.stream_to_text_async(http_res)
1510
+ raise errors.APIError(
1511
+ "API error occurred", http_res.status_code, http_res_text, http_res
1512
+ )
1513
+
1514
+ content_type = http_res.headers.get("Content-Type")
1515
+ http_res_text = await utils.stream_to_text_async(http_res)
1516
+ raise errors.APIError(
1517
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1518
+ http_res.status_code,
1519
+ http_res_text,
1520
+ http_res,
1521
+ )
1522
+
1523
+ def sell_yt(
1524
+ self,
1525
+ *,
1526
+ market_address: str,
1527
+ amount: Union[
1528
+ models.PendleSellYtRequestAmount, models.PendleSellYtRequestAmountTypedDict
1529
+ ],
1530
+ chain: models.Chain,
1531
+ sender: str,
1532
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1533
+ server_url: Optional[str] = None,
1534
+ timeout_ms: Optional[int] = None,
1535
+ http_headers: Optional[Mapping[str, str]] = None,
1536
+ ) -> models.TxResponse:
1537
+ r"""Sell Yield Token (YT)
1538
+
1539
+ Sell Yield Token (YT) for the market's Underlying Token.
1540
+
1541
+ :param market_address: The address of the market identifying which Yield Token (YT) you would like to sell.
1542
+ :param amount: The amount of market's Yield Token (YT) you would like to sell for market's Underlying Token.
1543
+ :param chain: The chain to use.
1544
+ :param sender: The address of the transaction sender.
1545
+ :param retries: Override the default retry configuration for this method
1546
+ :param server_url: Override the default server URL for this method
1547
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1548
+ :param http_headers: Additional headers to set or replace on requests.
1549
+ """
1550
+ base_url = None
1551
+ url_variables = None
1552
+ if timeout_ms is None:
1553
+ timeout_ms = self.sdk_configuration.timeout_ms
1554
+
1555
+ if server_url is not None:
1556
+ base_url = server_url
1557
+ else:
1558
+ base_url = self._get_url(base_url, url_variables)
1559
+
1560
+ request = models.PendleSellYtRequest(
1561
+ market_address=market_address,
1562
+ amount=amount,
1563
+ chain=chain,
1564
+ sender=sender,
1565
+ )
1566
+
1567
+ req = self._build_request(
1568
+ method="POST",
1569
+ path="/v0/pendle/sell_yt",
1570
+ base_url=base_url,
1571
+ url_variables=url_variables,
1572
+ request=request,
1573
+ request_body_required=True,
1574
+ request_has_path_params=False,
1575
+ request_has_query_params=True,
1576
+ user_agent_header="user-agent",
1577
+ accept_header_value="application/json",
1578
+ http_headers=http_headers,
1579
+ security=self.sdk_configuration.security,
1580
+ get_serialized_body=lambda: utils.serialize_request_body(
1581
+ request, False, False, "json", models.PendleSellYtRequest
1582
+ ),
1583
+ timeout_ms=timeout_ms,
1584
+ )
1585
+
1586
+ if retries == UNSET:
1587
+ if self.sdk_configuration.retry_config is not UNSET:
1588
+ retries = self.sdk_configuration.retry_config
1589
+
1590
+ retry_config = None
1591
+ if isinstance(retries, utils.RetryConfig):
1592
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1593
+
1594
+ http_res = self.do_request(
1595
+ hook_ctx=HookContext(
1596
+ config=self.sdk_configuration,
1597
+ base_url=base_url or "",
1598
+ operation_id="pendle_sell_yt",
1599
+ oauth2_scopes=[],
1600
+ security_source=self.sdk_configuration.security,
1601
+ ),
1602
+ request=req,
1603
+ error_status_codes=["422", "4XX", "5XX"],
1604
+ retry_config=retry_config,
1605
+ )
1606
+
1607
+ response_data: Any = None
1608
+ if utils.match_response(http_res, "200", "application/json"):
1609
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
1610
+ if utils.match_response(http_res, "422", "application/json"):
1611
+ response_data = utils.unmarshal_json(
1612
+ http_res.text, errors.HTTPValidationErrorData
1613
+ )
1614
+ raise errors.HTTPValidationError(data=response_data)
1615
+ if utils.match_response(http_res, "4XX", "*"):
1616
+ http_res_text = utils.stream_to_text(http_res)
1617
+ raise errors.APIError(
1618
+ "API error occurred", http_res.status_code, http_res_text, http_res
1619
+ )
1620
+ if utils.match_response(http_res, "5XX", "*"):
1621
+ http_res_text = utils.stream_to_text(http_res)
1622
+ raise errors.APIError(
1623
+ "API error occurred", http_res.status_code, http_res_text, http_res
1624
+ )
1625
+
1626
+ content_type = http_res.headers.get("Content-Type")
1627
+ http_res_text = utils.stream_to_text(http_res)
1628
+ raise errors.APIError(
1629
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1630
+ http_res.status_code,
1631
+ http_res_text,
1632
+ http_res,
1633
+ )
1634
+
1635
+ async def sell_yt_async(
1636
+ self,
1637
+ *,
1638
+ market_address: str,
1639
+ amount: Union[
1640
+ models.PendleSellYtRequestAmount, models.PendleSellYtRequestAmountTypedDict
1641
+ ],
1642
+ chain: models.Chain,
1643
+ sender: str,
1644
+ retries: OptionalNullable[utils.RetryConfig] = UNSET,
1645
+ server_url: Optional[str] = None,
1646
+ timeout_ms: Optional[int] = None,
1647
+ http_headers: Optional[Mapping[str, str]] = None,
1648
+ ) -> models.TxResponse:
1649
+ r"""Sell Yield Token (YT)
1650
+
1651
+ Sell Yield Token (YT) for the market's Underlying Token.
1652
+
1653
+ :param market_address: The address of the market identifying which Yield Token (YT) you would like to sell.
1654
+ :param amount: The amount of market's Yield Token (YT) you would like to sell for market's Underlying Token.
1655
+ :param chain: The chain to use.
1656
+ :param sender: The address of the transaction sender.
1657
+ :param retries: Override the default retry configuration for this method
1658
+ :param server_url: Override the default server URL for this method
1659
+ :param timeout_ms: Override the default request timeout configuration for this method in milliseconds
1660
+ :param http_headers: Additional headers to set or replace on requests.
1661
+ """
1662
+ base_url = None
1663
+ url_variables = None
1664
+ if timeout_ms is None:
1665
+ timeout_ms = self.sdk_configuration.timeout_ms
1666
+
1667
+ if server_url is not None:
1668
+ base_url = server_url
1669
+ else:
1670
+ base_url = self._get_url(base_url, url_variables)
1671
+
1672
+ request = models.PendleSellYtRequest(
1673
+ market_address=market_address,
1674
+ amount=amount,
1675
+ chain=chain,
1676
+ sender=sender,
1677
+ )
1678
+
1679
+ req = self._build_request_async(
1680
+ method="POST",
1681
+ path="/v0/pendle/sell_yt",
1682
+ base_url=base_url,
1683
+ url_variables=url_variables,
1684
+ request=request,
1685
+ request_body_required=True,
1686
+ request_has_path_params=False,
1687
+ request_has_query_params=True,
1688
+ user_agent_header="user-agent",
1689
+ accept_header_value="application/json",
1690
+ http_headers=http_headers,
1691
+ security=self.sdk_configuration.security,
1692
+ get_serialized_body=lambda: utils.serialize_request_body(
1693
+ request, False, False, "json", models.PendleSellYtRequest
1694
+ ),
1695
+ timeout_ms=timeout_ms,
1696
+ )
1697
+
1698
+ if retries == UNSET:
1699
+ if self.sdk_configuration.retry_config is not UNSET:
1700
+ retries = self.sdk_configuration.retry_config
1701
+
1702
+ retry_config = None
1703
+ if isinstance(retries, utils.RetryConfig):
1704
+ retry_config = (retries, ["429", "500", "502", "503", "504"])
1705
+
1706
+ http_res = await self.do_request_async(
1707
+ hook_ctx=HookContext(
1708
+ config=self.sdk_configuration,
1709
+ base_url=base_url or "",
1710
+ operation_id="pendle_sell_yt",
1711
+ oauth2_scopes=[],
1712
+ security_source=self.sdk_configuration.security,
1713
+ ),
1714
+ request=req,
1715
+ error_status_codes=["422", "4XX", "5XX"],
1716
+ retry_config=retry_config,
1717
+ )
1718
+
1719
+ response_data: Any = None
1720
+ if utils.match_response(http_res, "200", "application/json"):
1721
+ return utils.unmarshal_json(http_res.text, models.TxResponse)
1722
+ if utils.match_response(http_res, "422", "application/json"):
1723
+ response_data = utils.unmarshal_json(
1724
+ http_res.text, errors.HTTPValidationErrorData
1725
+ )
1726
+ raise errors.HTTPValidationError(data=response_data)
1727
+ if utils.match_response(http_res, "4XX", "*"):
1728
+ http_res_text = await utils.stream_to_text_async(http_res)
1729
+ raise errors.APIError(
1730
+ "API error occurred", http_res.status_code, http_res_text, http_res
1731
+ )
1732
+ if utils.match_response(http_res, "5XX", "*"):
1733
+ http_res_text = await utils.stream_to_text_async(http_res)
1734
+ raise errors.APIError(
1735
+ "API error occurred", http_res.status_code, http_res_text, http_res
1736
+ )
1737
+
1738
+ content_type = http_res.headers.get("Content-Type")
1739
+ http_res_text = await utils.stream_to_text_async(http_res)
1740
+ raise errors.APIError(
1741
+ f"Unexpected response received (code: {http_res.status_code}, type: {content_type})",
1742
+ http_res.status_code,
1743
+ http_res_text,
1744
+ http_res,
1745
+ )