compass_api_sdk 1.1.0__py3-none-any.whl → 1.1.1rc0__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/_version.py +3 -3
- compass_api_sdk/basesdk.py +11 -1
- compass_api_sdk/erc_4626_vaults.py +0 -16
- compass_api_sdk/errors/__init__.py +15 -3
- compass_api_sdk/errors/apierror.py +2 -0
- compass_api_sdk/errors/compassapierror.py +11 -7
- compass_api_sdk/errors/httpvalidationerror.py +4 -2
- compass_api_sdk/errors/no_response_error.py +5 -1
- compass_api_sdk/errors/responsevalidationerror.py +2 -0
- compass_api_sdk/models/__init__.py +14 -1
- compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_vaults_vaultstate.py +44 -5
- compass_api_sdk/models/multicallauthorizationrequest.py +0 -4
- compass_api_sdk/morpho.py +0 -16
- compass_api_sdk/sdk.py +15 -2
- compass_api_sdk/utils/__init__.py +15 -3
- compass_api_sdk/utils/eventstreaming.py +10 -0
- {compass_api_sdk-1.1.0.dist-info → compass_api_sdk-1.1.1rc0.dist-info}/METADATA +3 -2
- {compass_api_sdk-1.1.0.dist-info → compass_api_sdk-1.1.1rc0.dist-info}/RECORD +19 -19
- {compass_api_sdk-1.1.0.dist-info → compass_api_sdk-1.1.1rc0.dist-info}/WHEEL +1 -1
compass_api_sdk/_version.py
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import importlib.metadata
|
|
4
4
|
|
|
5
5
|
__title__: str = "compass_api_sdk"
|
|
6
|
-
__version__: str = "1.1.
|
|
6
|
+
__version__: str = "1.1.1-rc0"
|
|
7
7
|
__openapi_doc_version__: str = "0.0.1"
|
|
8
|
-
__gen_version__: str = "2.
|
|
9
|
-
__user_agent__: str = "speakeasy-sdk/python 1.1.
|
|
8
|
+
__gen_version__: str = "2.701.8"
|
|
9
|
+
__user_agent__: str = "speakeasy-sdk/python 1.1.1-rc0 2.701.8 0.0.1 compass_api_sdk"
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
if __package__ is not None:
|
compass_api_sdk/basesdk.py
CHANGED
|
@@ -15,9 +15,19 @@ from urllib.parse import parse_qs, urlparse
|
|
|
15
15
|
|
|
16
16
|
class BaseSDK:
|
|
17
17
|
sdk_configuration: SDKConfiguration
|
|
18
|
+
parent_ref: Optional[object] = None
|
|
19
|
+
"""
|
|
20
|
+
Reference to the root SDK instance, if any. This will prevent it from
|
|
21
|
+
being garbage collected while there are active streams.
|
|
22
|
+
"""
|
|
18
23
|
|
|
19
|
-
def __init__(
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
sdk_config: SDKConfiguration,
|
|
27
|
+
parent_ref: Optional[object] = None,
|
|
28
|
+
) -> None:
|
|
20
29
|
self.sdk_configuration = sdk_config
|
|
30
|
+
self.parent_ref = parent_ref
|
|
21
31
|
|
|
22
32
|
def _get_url(self, base_url, url_variables):
|
|
23
33
|
sdk_url, sdk_variables = self.sdk_configuration.get_server_details()
|
|
@@ -453,14 +453,6 @@ class ERC4626Vaults(BaseSDK):
|
|
|
453
453
|
The passive yield earned on token deposits is represented by the increased value of
|
|
454
454
|
the shares received upon depositing tokens. Trade in these shares for the tokens you
|
|
455
455
|
deposited plus any accrued yield.
|
|
456
|
-
<Info>
|
|
457
|
-
**Required Allowances**
|
|
458
|
-
|
|
459
|
-
In order to make this transaction, token allowances need to be set for the following contracts.
|
|
460
|
-
|
|
461
|
-
- `<vault address>`
|
|
462
|
-
</Info>
|
|
463
|
-
|
|
464
456
|
|
|
465
457
|
:param vault_address: The vault address you are withdrawing from.
|
|
466
458
|
:param amount: The amount of tokens to withdraw from the vault. If set to 'ALL', your total deposited token amount will be withdrawn.
|
|
@@ -567,14 +559,6 @@ class ERC4626Vaults(BaseSDK):
|
|
|
567
559
|
The passive yield earned on token deposits is represented by the increased value of
|
|
568
560
|
the shares received upon depositing tokens. Trade in these shares for the tokens you
|
|
569
561
|
deposited plus any accrued yield.
|
|
570
|
-
<Info>
|
|
571
|
-
**Required Allowances**
|
|
572
|
-
|
|
573
|
-
In order to make this transaction, token allowances need to be set for the following contracts.
|
|
574
|
-
|
|
575
|
-
- `<vault address>`
|
|
576
|
-
</Info>
|
|
577
|
-
|
|
578
562
|
|
|
579
563
|
:param vault_address: The vault address you are withdrawing from.
|
|
580
564
|
:param amount: The amount of tokens to withdraw from the vault. If set to 'ALL', your total deposited token amount will be withdrawn.
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
+
from .compassapierror import CompassAPIError
|
|
3
4
|
from typing import TYPE_CHECKING
|
|
4
5
|
from importlib import import_module
|
|
5
6
|
import builtins
|
|
7
|
+
import sys
|
|
6
8
|
|
|
7
9
|
if TYPE_CHECKING:
|
|
8
10
|
from .apierror import APIError
|
|
9
|
-
from .compassapierror import CompassAPIError
|
|
10
11
|
from .httpvalidationerror import HTTPValidationError, HTTPValidationErrorData
|
|
11
12
|
from .no_response_error import NoResponseError
|
|
12
13
|
from .responsevalidationerror import ResponseValidationError
|
|
@@ -22,7 +23,6 @@ __all__ = [
|
|
|
22
23
|
|
|
23
24
|
_dynamic_imports: dict[str, str] = {
|
|
24
25
|
"APIError": ".apierror",
|
|
25
|
-
"CompassAPIError": ".compassapierror",
|
|
26
26
|
"HTTPValidationError": ".httpvalidationerror",
|
|
27
27
|
"HTTPValidationErrorData": ".httpvalidationerror",
|
|
28
28
|
"NoResponseError": ".no_response_error",
|
|
@@ -30,6 +30,18 @@ _dynamic_imports: dict[str, str] = {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
def dynamic_import(modname, retries=3):
|
|
34
|
+
for attempt in range(retries):
|
|
35
|
+
try:
|
|
36
|
+
return import_module(modname, __package__)
|
|
37
|
+
except KeyError:
|
|
38
|
+
# Clear any half-initialized module and retry
|
|
39
|
+
sys.modules.pop(modname, None)
|
|
40
|
+
if attempt == retries - 1:
|
|
41
|
+
break
|
|
42
|
+
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
|
43
|
+
|
|
44
|
+
|
|
33
45
|
def __getattr__(attr_name: str) -> object:
|
|
34
46
|
module_name = _dynamic_imports.get(attr_name)
|
|
35
47
|
if module_name is None:
|
|
@@ -38,7 +50,7 @@ def __getattr__(attr_name: str) -> object:
|
|
|
38
50
|
)
|
|
39
51
|
|
|
40
52
|
try:
|
|
41
|
-
module =
|
|
53
|
+
module = dynamic_import(module_name)
|
|
42
54
|
result = getattr(module, attr_name)
|
|
43
55
|
return result
|
|
44
56
|
except ImportError as e:
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import httpx
|
|
4
4
|
from typing import Optional
|
|
5
|
+
from dataclasses import dataclass
|
|
5
6
|
|
|
6
7
|
from compass_api_sdk.errors import CompassAPIError
|
|
7
8
|
|
|
8
9
|
MAX_MESSAGE_LEN = 10_000
|
|
9
10
|
|
|
10
11
|
|
|
12
|
+
@dataclass(frozen=True)
|
|
11
13
|
class APIError(CompassAPIError):
|
|
12
14
|
"""The fallback error class if no more specific error class is matched."""
|
|
13
15
|
|
|
@@ -2,25 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
import httpx
|
|
4
4
|
from typing import Optional
|
|
5
|
+
from dataclasses import dataclass, field
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
@dataclass(frozen=True)
|
|
7
9
|
class CompassAPIError(Exception):
|
|
8
10
|
"""The base class for all HTTP error responses."""
|
|
9
11
|
|
|
10
12
|
message: str
|
|
11
13
|
status_code: int
|
|
12
14
|
body: str
|
|
13
|
-
headers: httpx.Headers
|
|
14
|
-
raw_response: httpx.Response
|
|
15
|
+
headers: httpx.Headers = field(hash=False)
|
|
16
|
+
raw_response: httpx.Response = field(hash=False)
|
|
15
17
|
|
|
16
18
|
def __init__(
|
|
17
19
|
self, message: str, raw_response: httpx.Response, body: Optional[str] = None
|
|
18
20
|
):
|
|
19
|
-
self
|
|
20
|
-
self
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
object.__setattr__(self, "message", message)
|
|
22
|
+
object.__setattr__(self, "status_code", raw_response.status_code)
|
|
23
|
+
object.__setattr__(
|
|
24
|
+
self, "body", body if body is not None else raw_response.text
|
|
25
|
+
)
|
|
26
|
+
object.__setattr__(self, "headers", raw_response.headers)
|
|
27
|
+
object.__setattr__(self, "raw_response", raw_response)
|
|
24
28
|
|
|
25
29
|
def __str__(self):
|
|
26
30
|
return self.message
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
from compass_api_sdk.errors import CompassAPIError
|
|
5
5
|
from compass_api_sdk.models import validationerror as models_validationerror
|
|
6
6
|
from compass_api_sdk.types import BaseModel
|
|
7
|
+
from dataclasses import dataclass, field
|
|
7
8
|
import httpx
|
|
8
9
|
from typing import List, Optional
|
|
9
10
|
|
|
@@ -12,8 +13,9 @@ class HTTPValidationErrorData(BaseModel):
|
|
|
12
13
|
detail: Optional[List[models_validationerror.ValidationError]] = None
|
|
13
14
|
|
|
14
15
|
|
|
16
|
+
@dataclass(frozen=True)
|
|
15
17
|
class HTTPValidationError(CompassAPIError):
|
|
16
|
-
data: HTTPValidationErrorData
|
|
18
|
+
data: HTTPValidationErrorData = field(hash=False)
|
|
17
19
|
|
|
18
20
|
def __init__(
|
|
19
21
|
self,
|
|
@@ -23,4 +25,4 @@ class HTTPValidationError(CompassAPIError):
|
|
|
23
25
|
):
|
|
24
26
|
message = body or raw_response.text
|
|
25
27
|
super().__init__(message, raw_response, body)
|
|
26
|
-
self
|
|
28
|
+
object.__setattr__(self, "data", data)
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(frozen=True)
|
|
3
7
|
class NoResponseError(Exception):
|
|
4
8
|
"""Error raised when no HTTP response is received from the server."""
|
|
5
9
|
|
|
6
10
|
message: str
|
|
7
11
|
|
|
8
12
|
def __init__(self, message: str = "No response received"):
|
|
9
|
-
self
|
|
13
|
+
object.__setattr__(self, "message", message)
|
|
10
14
|
super().__init__(message)
|
|
11
15
|
|
|
12
16
|
def __str__(self):
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import httpx
|
|
4
4
|
from typing import Optional
|
|
5
|
+
from dataclasses import dataclass
|
|
5
6
|
|
|
6
7
|
from compass_api_sdk.errors import CompassAPIError
|
|
7
8
|
|
|
8
9
|
|
|
10
|
+
@dataclass(frozen=True)
|
|
9
11
|
class ResponseValidationError(CompassAPIError):
|
|
10
12
|
"""Error raised when there is a type mismatch between the response data and the expected Pydantic model."""
|
|
11
13
|
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
from importlib import import_module
|
|
5
5
|
import builtins
|
|
6
|
+
import sys
|
|
6
7
|
|
|
7
8
|
if TYPE_CHECKING:
|
|
8
9
|
from .aaveavgrateresponse import AaveAvgRateResponse, AaveAvgRateResponseTypedDict
|
|
@@ -2806,6 +2807,18 @@ _dynamic_imports: dict[str, str] = {
|
|
|
2806
2807
|
}
|
|
2807
2808
|
|
|
2808
2809
|
|
|
2810
|
+
def dynamic_import(modname, retries=3):
|
|
2811
|
+
for attempt in range(retries):
|
|
2812
|
+
try:
|
|
2813
|
+
return import_module(modname, __package__)
|
|
2814
|
+
except KeyError:
|
|
2815
|
+
# Clear any half-initialized module and retry
|
|
2816
|
+
sys.modules.pop(modname, None)
|
|
2817
|
+
if attempt == retries - 1:
|
|
2818
|
+
break
|
|
2819
|
+
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
|
2820
|
+
|
|
2821
|
+
|
|
2809
2822
|
def __getattr__(attr_name: str) -> object:
|
|
2810
2823
|
module_name = _dynamic_imports.get(attr_name)
|
|
2811
2824
|
if module_name is None:
|
|
@@ -2814,7 +2827,7 @@ def __getattr__(attr_name: str) -> object:
|
|
|
2814
2827
|
)
|
|
2815
2828
|
|
|
2816
2829
|
try:
|
|
2817
|
-
module =
|
|
2830
|
+
module = dynamic_import(module_name)
|
|
2818
2831
|
result = getattr(module, attr_name)
|
|
2819
2832
|
return result
|
|
2820
2833
|
except ImportError as e:
|
compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_vaults_vaultstate.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
from compass_api_sdk.types import
|
|
4
|
+
from compass_api_sdk.types import (
|
|
5
|
+
BaseModel,
|
|
6
|
+
Nullable,
|
|
7
|
+
OptionalNullable,
|
|
8
|
+
UNSET,
|
|
9
|
+
UNSET_SENTINEL,
|
|
10
|
+
)
|
|
5
11
|
import pydantic
|
|
6
|
-
from
|
|
12
|
+
from pydantic import model_serializer
|
|
13
|
+
from typing_extensions import Annotated, NotRequired, TypedDict
|
|
7
14
|
|
|
8
15
|
|
|
9
16
|
class CompassAPIBackendModelsMorphoReadResponseGetVaultsVaultStateTypedDict(TypedDict):
|
|
@@ -11,9 +18,9 @@ class CompassAPIBackendModelsMorphoReadResponseGetVaultsVaultStateTypedDict(Type
|
|
|
11
18
|
apy: float
|
|
12
19
|
net_apy: float
|
|
13
20
|
total_assets: int
|
|
14
|
-
total_assets_usd: float
|
|
15
21
|
fee: float
|
|
16
22
|
timelock: int
|
|
23
|
+
total_assets_usd: NotRequired[Nullable[float]]
|
|
17
24
|
|
|
18
25
|
|
|
19
26
|
class CompassAPIBackendModelsMorphoReadResponseGetVaultsVaultState(BaseModel):
|
|
@@ -25,8 +32,40 @@ class CompassAPIBackendModelsMorphoReadResponseGetVaultsVaultState(BaseModel):
|
|
|
25
32
|
|
|
26
33
|
total_assets: Annotated[int, pydantic.Field(alias="totalAssets")]
|
|
27
34
|
|
|
28
|
-
total_assets_usd: Annotated[float, pydantic.Field(alias="totalAssetsUsd")]
|
|
29
|
-
|
|
30
35
|
fee: float
|
|
31
36
|
|
|
32
37
|
timelock: int
|
|
38
|
+
|
|
39
|
+
total_assets_usd: Annotated[
|
|
40
|
+
OptionalNullable[float], pydantic.Field(alias="totalAssetsUsd")
|
|
41
|
+
] = UNSET
|
|
42
|
+
|
|
43
|
+
@model_serializer(mode="wrap")
|
|
44
|
+
def serialize_model(self, handler):
|
|
45
|
+
optional_fields = ["totalAssetsUsd"]
|
|
46
|
+
nullable_fields = ["totalAssetsUsd"]
|
|
47
|
+
null_default_fields = []
|
|
48
|
+
|
|
49
|
+
serialized = handler(self)
|
|
50
|
+
|
|
51
|
+
m = {}
|
|
52
|
+
|
|
53
|
+
for n, f in type(self).model_fields.items():
|
|
54
|
+
k = f.alias or n
|
|
55
|
+
val = serialized.get(k)
|
|
56
|
+
serialized.pop(k, None)
|
|
57
|
+
|
|
58
|
+
optional_nullable = k in optional_fields and k in nullable_fields
|
|
59
|
+
is_set = (
|
|
60
|
+
self.__pydantic_fields_set__.intersection({n})
|
|
61
|
+
or k in null_default_fields
|
|
62
|
+
) # pylint: disable=no-member
|
|
63
|
+
|
|
64
|
+
if val is not None and val != UNSET_SENTINEL:
|
|
65
|
+
m[k] = val
|
|
66
|
+
elif val != UNSET_SENTINEL and (
|
|
67
|
+
not k in optional_fields or (optional_nullable and is_set)
|
|
68
|
+
):
|
|
69
|
+
m[k] = val
|
|
70
|
+
|
|
71
|
+
return m
|
|
@@ -18,8 +18,6 @@ class MulticallAuthorizationRequestTypedDict(TypedDict):
|
|
|
18
18
|
This model is used to authorize a sender address to perform multicall operations,
|
|
19
19
|
allowing it to call multiple functions on multiple contracts in a single
|
|
20
20
|
transaction.
|
|
21
|
-
|
|
22
|
-
Only needs to be done once per an EOA.
|
|
23
21
|
"""
|
|
24
22
|
|
|
25
23
|
chain: MulticallAuthorizationRequestChain
|
|
@@ -33,8 +31,6 @@ class MulticallAuthorizationRequest(BaseModel):
|
|
|
33
31
|
This model is used to authorize a sender address to perform multicall operations,
|
|
34
32
|
allowing it to call multiple functions on multiple contracts in a single
|
|
35
33
|
transaction.
|
|
36
|
-
|
|
37
|
-
Only needs to be done once per an EOA.
|
|
38
34
|
"""
|
|
39
35
|
|
|
40
36
|
chain: MulticallAuthorizationRequestChain
|
compass_api_sdk/morpho.py
CHANGED
|
@@ -1449,14 +1449,6 @@ class Morpho(BaseSDK):
|
|
|
1449
1449
|
exposure for all deposited assets so users don't need to make these decisions
|
|
1450
1450
|
themselves. Users maintain full control over their assets, can monitor the vault's
|
|
1451
1451
|
state at any time, and withdraw their liquidity at their discretion.
|
|
1452
|
-
<Info>
|
|
1453
|
-
**Required Allowances**
|
|
1454
|
-
|
|
1455
|
-
In order to make this transaction, token allowances need to be set for the following contracts.
|
|
1456
|
-
|
|
1457
|
-
- `<vault-contract-address>`
|
|
1458
|
-
</Info>
|
|
1459
|
-
|
|
1460
1452
|
|
|
1461
1453
|
:param vault_address: The vault address you are withdrawing from.
|
|
1462
1454
|
:param amount: The amount of tokens to withdraw from the vault. If set to 'ALL', your total deposited token amount will be withdrawn.
|
|
@@ -1569,14 +1561,6 @@ class Morpho(BaseSDK):
|
|
|
1569
1561
|
exposure for all deposited assets so users don't need to make these decisions
|
|
1570
1562
|
themselves. Users maintain full control over their assets, can monitor the vault's
|
|
1571
1563
|
state at any time, and withdraw their liquidity at their discretion.
|
|
1572
|
-
<Info>
|
|
1573
|
-
**Required Allowances**
|
|
1574
|
-
|
|
1575
|
-
In order to make this transaction, token allowances need to be set for the following contracts.
|
|
1576
|
-
|
|
1577
|
-
- `<vault-contract-address>`
|
|
1578
|
-
</Info>
|
|
1579
|
-
|
|
1580
1564
|
|
|
1581
1565
|
:param vault_address: The vault address you are withdrawing from.
|
|
1582
1566
|
:param amount: The amount of tokens to withdraw from the vault. If set to 'ALL', your total deposited token amount will be withdrawn.
|
compass_api_sdk/sdk.py
CHANGED
|
@@ -10,6 +10,7 @@ from compass_api_sdk._hooks import SDKHooks
|
|
|
10
10
|
from compass_api_sdk.types import OptionalNullable, UNSET
|
|
11
11
|
import httpx
|
|
12
12
|
import importlib
|
|
13
|
+
import sys
|
|
13
14
|
from typing import Any, Callable, Dict, Optional, TYPE_CHECKING, Union, cast
|
|
14
15
|
import weakref
|
|
15
16
|
|
|
@@ -136,6 +137,7 @@ class CompassAPI(BaseSDK):
|
|
|
136
137
|
timeout_ms=timeout_ms,
|
|
137
138
|
debug_logger=debug_logger,
|
|
138
139
|
),
|
|
140
|
+
parent_ref=self,
|
|
139
141
|
)
|
|
140
142
|
|
|
141
143
|
hooks = SDKHooks()
|
|
@@ -160,13 +162,24 @@ class CompassAPI(BaseSDK):
|
|
|
160
162
|
self.sdk_configuration.async_client_supplied,
|
|
161
163
|
)
|
|
162
164
|
|
|
165
|
+
def dynamic_import(self, modname, retries=3):
|
|
166
|
+
for attempt in range(retries):
|
|
167
|
+
try:
|
|
168
|
+
return importlib.import_module(modname)
|
|
169
|
+
except KeyError:
|
|
170
|
+
# Clear any half-initialized module and retry
|
|
171
|
+
sys.modules.pop(modname, None)
|
|
172
|
+
if attempt == retries - 1:
|
|
173
|
+
break
|
|
174
|
+
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
|
175
|
+
|
|
163
176
|
def __getattr__(self, name: str):
|
|
164
177
|
if name in self._sub_sdk_map:
|
|
165
178
|
module_path, class_name = self._sub_sdk_map[name]
|
|
166
179
|
try:
|
|
167
|
-
module =
|
|
180
|
+
module = self.dynamic_import(module_path)
|
|
168
181
|
klass = getattr(module, class_name)
|
|
169
|
-
instance = klass(self.sdk_configuration)
|
|
182
|
+
instance = klass(self.sdk_configuration, parent_ref=self)
|
|
170
183
|
setattr(self, name, instance)
|
|
171
184
|
return instance
|
|
172
185
|
except ImportError as e:
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
from importlib import import_module
|
|
5
5
|
import builtins
|
|
6
|
+
import sys
|
|
6
7
|
|
|
7
8
|
if TYPE_CHECKING:
|
|
8
9
|
from .annotations import get_discriminator
|
|
@@ -159,6 +160,18 @@ _dynamic_imports: dict[str, str] = {
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
|
|
163
|
+
def dynamic_import(modname, retries=3):
|
|
164
|
+
for attempt in range(retries):
|
|
165
|
+
try:
|
|
166
|
+
return import_module(modname, __package__)
|
|
167
|
+
except KeyError:
|
|
168
|
+
# Clear any half-initialized module and retry
|
|
169
|
+
sys.modules.pop(modname, None)
|
|
170
|
+
if attempt == retries - 1:
|
|
171
|
+
break
|
|
172
|
+
raise KeyError(f"Failed to import module '{modname}' after {retries} attempts")
|
|
173
|
+
|
|
174
|
+
|
|
162
175
|
def __getattr__(attr_name: str) -> object:
|
|
163
176
|
module_name = _dynamic_imports.get(attr_name)
|
|
164
177
|
if module_name is None:
|
|
@@ -167,9 +180,8 @@ def __getattr__(attr_name: str) -> object:
|
|
|
167
180
|
)
|
|
168
181
|
|
|
169
182
|
try:
|
|
170
|
-
module =
|
|
171
|
-
|
|
172
|
-
return result
|
|
183
|
+
module = dynamic_import(module_name)
|
|
184
|
+
return getattr(module, attr_name)
|
|
173
185
|
except ImportError as e:
|
|
174
186
|
raise ImportError(
|
|
175
187
|
f"Failed to import {attr_name} from {module_name}: {e}"
|
|
@@ -17,6 +17,9 @@ T = TypeVar("T")
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
class EventStream(Generic[T]):
|
|
20
|
+
# Holds a reference to the SDK client to avoid it being garbage collected
|
|
21
|
+
# and cause termination of the underlying httpx client.
|
|
22
|
+
client_ref: Optional[object]
|
|
20
23
|
response: httpx.Response
|
|
21
24
|
generator: Generator[T, None, None]
|
|
22
25
|
|
|
@@ -25,9 +28,11 @@ class EventStream(Generic[T]):
|
|
|
25
28
|
response: httpx.Response,
|
|
26
29
|
decoder: Callable[[str], T],
|
|
27
30
|
sentinel: Optional[str] = None,
|
|
31
|
+
client_ref: Optional[object] = None,
|
|
28
32
|
):
|
|
29
33
|
self.response = response
|
|
30
34
|
self.generator = stream_events(response, decoder, sentinel)
|
|
35
|
+
self.client_ref = client_ref
|
|
31
36
|
|
|
32
37
|
def __iter__(self):
|
|
33
38
|
return self
|
|
@@ -43,6 +48,9 @@ class EventStream(Generic[T]):
|
|
|
43
48
|
|
|
44
49
|
|
|
45
50
|
class EventStreamAsync(Generic[T]):
|
|
51
|
+
# Holds a reference to the SDK client to avoid it being garbage collected
|
|
52
|
+
# and cause termination of the underlying httpx client.
|
|
53
|
+
client_ref: Optional[object]
|
|
46
54
|
response: httpx.Response
|
|
47
55
|
generator: AsyncGenerator[T, None]
|
|
48
56
|
|
|
@@ -51,9 +59,11 @@ class EventStreamAsync(Generic[T]):
|
|
|
51
59
|
response: httpx.Response,
|
|
52
60
|
decoder: Callable[[str], T],
|
|
53
61
|
sentinel: Optional[str] = None,
|
|
62
|
+
client_ref: Optional[object] = None,
|
|
54
63
|
):
|
|
55
64
|
self.response = response
|
|
56
65
|
self.generator = stream_events_async(response, decoder, sentinel)
|
|
66
|
+
self.client_ref = client_ref
|
|
57
67
|
|
|
58
68
|
def __aiter__(self):
|
|
59
69
|
return self
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: compass_api_sdk
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.1rc0
|
|
4
4
|
Summary: Compass API SDK.
|
|
5
5
|
Author: royalnine
|
|
6
6
|
Requires-Python: >=3.9.2
|
|
@@ -9,6 +9,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.11
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.12
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
13
|
Requires-Dist: httpcore (>=1.0.9)
|
|
13
14
|
Requires-Dist: httpx (>=0.28.1)
|
|
14
15
|
Requires-Dist: pydantic (>=2.11.2)
|
|
@@ -2,20 +2,20 @@ compass_api_sdk/__init__.py,sha256=w2u919V3Tzv4zEPQ-OYJ79gQ_4_SyW7GOFFoHtqXDFA,4
|
|
|
2
2
|
compass_api_sdk/_hooks/__init__.py,sha256=p5J13DeYuISQyQWirjJAObHIf2VtIlOtFqnIpvjjVwk,118
|
|
3
3
|
compass_api_sdk/_hooks/sdkhooks.py,sha256=eVxHB2Q_JG6zZx5xn74i208ij-fpTHqq2jod6fbghRQ,2503
|
|
4
4
|
compass_api_sdk/_hooks/types.py,sha256=4qXm6dEntJOC2QeOdTklcc53oFzTU3HBb1xGdZ-kBXY,3059
|
|
5
|
-
compass_api_sdk/_version.py,sha256=
|
|
5
|
+
compass_api_sdk/_version.py,sha256=EVcqWOMQ0yMMLBuckoCq7histop5FrHWXx9m-YLXG0A,480
|
|
6
6
|
compass_api_sdk/aave_v3.py,sha256=ELmjKLULQBr_FuyrQiynCl2J4VybHVM52HN8pULHio4,126496
|
|
7
7
|
compass_api_sdk/aerodrome_slipstream.py,sha256=wJ7fIDjWkn7h3sg1-_rzvttgl3IuZVWkgKQ8V5tIJLg,81001
|
|
8
|
-
compass_api_sdk/basesdk.py,sha256=
|
|
9
|
-
compass_api_sdk/erc_4626_vaults.py,sha256=
|
|
10
|
-
compass_api_sdk/errors/__init__.py,sha256=
|
|
11
|
-
compass_api_sdk/errors/apierror.py,sha256=
|
|
12
|
-
compass_api_sdk/errors/compassapierror.py,sha256=
|
|
13
|
-
compass_api_sdk/errors/httpvalidationerror.py,sha256=
|
|
14
|
-
compass_api_sdk/errors/no_response_error.py,sha256=
|
|
15
|
-
compass_api_sdk/errors/responsevalidationerror.py,sha256=
|
|
8
|
+
compass_api_sdk/basesdk.py,sha256=oB3y9BXwZfnqTN9IsqjdUVXirXeNnV5vUsqBioB5YPE,12139
|
|
9
|
+
compass_api_sdk/erc_4626_vaults.py,sha256=H8yK7PEFw-YNV1Otrj11Pj9VuMGS4id8eHE7hzUnUiE,26877
|
|
10
|
+
compass_api_sdk/errors/__init__.py,sha256=y-htW-36pm1idwtw1qFDBAfi-aCYFEE66ZPw8n_Hddc,2095
|
|
11
|
+
compass_api_sdk/errors/apierror.py,sha256=o6woYOzRGF7Cy-uD7oSi6IqOhjsN-lWI0DmhTYnSa2Q,1293
|
|
12
|
+
compass_api_sdk/errors/compassapierror.py,sha256=g43KQCQ_mG8TkfuaWsNlvXqzWR1A98KRg0B8c4woq0g,954
|
|
13
|
+
compass_api_sdk/errors/httpvalidationerror.py,sha256=BiBwCyDSl33kQjbMNH8ny9vpYldFQMQVLpYDx5tcduA,908
|
|
14
|
+
compass_api_sdk/errors/no_response_error.py,sha256=Kb7hmMtDo72KrLSjUEDNeQxvzZiVxUjOZym8TPdZp5Y,462
|
|
15
|
+
compass_api_sdk/errors/responsevalidationerror.py,sha256=kW9RiQ5W1iQzn7hlszgYt1L5r-YkWpqVG-nHua9C0d4,760
|
|
16
16
|
compass_api_sdk/ethena.py,sha256=7FTFurIyrCzmsRjyLrOnabIS5zsq2qASgT9WMb_x0bM,35792
|
|
17
17
|
compass_api_sdk/httpclient.py,sha256=Eu73urOAiZQtdUIyOUnPccxCiBbWEKrXG-JrRG3SLM4,3946
|
|
18
|
-
compass_api_sdk/models/__init__.py,sha256=
|
|
18
|
+
compass_api_sdk/models/__init__.py,sha256=eTVTeVwCxU5o2YKMfpD1CydIP4dhPgZnW6sqCe8WJ8c,139897
|
|
19
19
|
compass_api_sdk/models/aaveavgrateresponse.py,sha256=q_MArkpvKD2WdjxV7fljIHfnCbBytjddcj4m6UUGkR0,1330
|
|
20
20
|
compass_api_sdk/models/aaveborrowparams.py,sha256=Sb_i4KtK1ZVGGzkt7WU391cJzCryRpPp2m6vg7Du9Z8,3309
|
|
21
21
|
compass_api_sdk/models/aaveborrowrequest.py,sha256=TLEE-DxLqgLT4joybOZ1ete5Edld7poYv6LXi7egIzM,3654
|
|
@@ -68,7 +68,7 @@ compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_marke
|
|
|
68
68
|
compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_markets_asset.py,sha256=pMWAh-oYo4YBmeVpoh2XoPn8PmFWSrvRH0Gg7sPT8xQ,488
|
|
69
69
|
compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_markets_marketstate.py,sha256=wour5BGvKGddpI_qfs7WHfDewE5-cLdRjq7L-QTAQLg,2133
|
|
70
70
|
compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_vaults_asset.py,sha256=zlxZwigsUocOnYo2Q43JLDSiFL6w26r-jaqcy4Ds2NU,562
|
|
71
|
-
compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_vaults_vaultstate.py,sha256=
|
|
71
|
+
compass_api_sdk/models/compass_api_backend_models_morpho_read_response_get_vaults_vaultstate.py,sha256=iMopQyIRuafNa9LuqPatW2PR76nJg0OX1cA_2iquVH0,1910
|
|
72
72
|
compass_api_sdk/models/compass_api_backend_models_pendle_read_response_market_userposition.py,sha256=jkWdF9C7npeeiZPgBWaJt9Hd8Ft9Sn745ZNZct6R_-A,2749
|
|
73
73
|
compass_api_sdk/models/compass_api_backend_models_pendle_read_response_positions_tokenbalance.py,sha256=dxEvdDEZmYokpmCAO3RXRQU81kR4Bmiv3eEqMKh0GTU,450
|
|
74
74
|
compass_api_sdk/models/compass_api_backend_models_vaults_read_response_vault_userposition.py,sha256=5sIxXYR_5VUzoYsm-cFwSr_F2Nv6uMJRjpZhEuPNo4g,976
|
|
@@ -111,7 +111,7 @@ compass_api_sdk/models/morphowithdrawcollateralrequest.py,sha256=5AUFjql-Y-AJwBn
|
|
|
111
111
|
compass_api_sdk/models/morphowithdrawparams.py,sha256=Tm_uYiD04bl7ZOxyfubRk0pmTup_EtNM8sb0lVHbLqA,2511
|
|
112
112
|
compass_api_sdk/models/morphowithdrawrequest.py,sha256=KugL2PTDreFqu3cZS84YIHrm7rPmXsEQyJrwG7INtI4,2862
|
|
113
113
|
compass_api_sdk/models/movement10percent.py,sha256=AyRUHYFSy-m6A242J1sgOro_bboM9TV0sdPWsY3vVbo,2312
|
|
114
|
-
compass_api_sdk/models/multicallauthorizationrequest.py,sha256=
|
|
114
|
+
compass_api_sdk/models/multicallauthorizationrequest.py,sha256=oh274KwZucbsk0pPiQ4HNpWC1ft7DrwDgqouXJgfV4g,1189
|
|
115
115
|
compass_api_sdk/models/multicallauthorizationresponse.py,sha256=3jjdz9Mz-tKjhBzZbVaJW51no58HSqcxfHJwuZsgnhg,914
|
|
116
116
|
compass_api_sdk/models/multicallexecuterequest.py,sha256=HhBKEiCEDTvGJn4v9YN9HcqQDePXm4bDIoiOWAaSYW0,2379
|
|
117
117
|
compass_api_sdk/models/odosswapparams.py,sha256=Bx-W3zu_KrYdvx_3yDyP_Fsct6FY0kAW1KJ-UUEMB5o,2524
|
|
@@ -239,10 +239,10 @@ compass_api_sdk/models/weeklyapys.py,sha256=AaGjDD4NeGsZQBwdRW1G09Pmx17pLPe2oUA9
|
|
|
239
239
|
compass_api_sdk/models/wrapethparams.py,sha256=nw1fZiDrj5wZnI25Vmg0DcNI01k-uhot68lG1_H7xrY,1223
|
|
240
240
|
compass_api_sdk/models/wrapethrequest.py,sha256=H34yarBnpAAIswgme5p7tXmz3ZxKssccDXQUbRRibUQ,1553
|
|
241
241
|
compass_api_sdk/models/yieldrange.py,sha256=WEpZR24JddnCS1_13y2P1CdD0lBi6dPktysCNu3TUic,324
|
|
242
|
-
compass_api_sdk/morpho.py,sha256=
|
|
242
|
+
compass_api_sdk/morpho.py,sha256=6uk_9PgXOniSbAcRQdr8JaMqcBLGCU2EW03sCnrUMZ0,110574
|
|
243
243
|
compass_api_sdk/pendle.py,sha256=gpEo4DpvbLxIRN8U1EZAlKPFfe1mfgSradsFZmeH754,65368
|
|
244
244
|
compass_api_sdk/py.typed,sha256=zrp19r0G21lr2yRiMC0f8MFkQFGj9wMpSbboePMg8KM,59
|
|
245
|
-
compass_api_sdk/sdk.py,sha256=
|
|
245
|
+
compass_api_sdk/sdk.py,sha256=cOMvjqj6heqmwDfHlzzKQmw_wfTqwK1OyEhpdK5Nfyo,8608
|
|
246
246
|
compass_api_sdk/sdkconfiguration.py,sha256=5nec4ViMLCsNWBd3DyEv8zWqU5Z77YZfzwX69jkdSnM,1607
|
|
247
247
|
compass_api_sdk/sky.py,sha256=0JTj3XYSIe2rwBg4Kx1qOPKZhVXRp-Kbsfes-Jh38TA,44005
|
|
248
248
|
compass_api_sdk/smart_account.py,sha256=l1ZsrQv4Mak1SlnPWbo1OuyNm9VPOZxD_YigugsG2ao,8742
|
|
@@ -253,11 +253,11 @@ compass_api_sdk/types/__init__.py,sha256=RArOwSgeeTIva6h-4ttjXwMUeCkz10nAFBL9D-Q
|
|
|
253
253
|
compass_api_sdk/types/basemodel.py,sha256=L79WXvTECbSqaJzs8D3ud_KdIWkU7Cx2wbohDAktE9E,1127
|
|
254
254
|
compass_api_sdk/uniswap_v3.py,sha256=8vuGP0Y1zWDNeeWA_DA-lhYk14WcUtswsyZPY_28bzU,103587
|
|
255
255
|
compass_api_sdk/universal.py,sha256=uC40KvJuWzmN_azkL4Sajlo4EFJCymHSDsRcQvNV6vg,64457
|
|
256
|
-
compass_api_sdk/utils/__init__.py,sha256=
|
|
256
|
+
compass_api_sdk/utils/__init__.py,sha256=88uXYJ3d7C29IuuhPMgWfu4i00tNl555vaqrLA61hds,5766
|
|
257
257
|
compass_api_sdk/utils/annotations.py,sha256=aR7mZG34FzgRdew7WZPYEu9QGBerpuKxCF4sek5Z_5Y,1699
|
|
258
258
|
compass_api_sdk/utils/datetimes.py,sha256=oppAA5e3V35pQov1-FNLKxAaNF1_XWi-bQtyjjql3H8,855
|
|
259
259
|
compass_api_sdk/utils/enums.py,sha256=REU6ydF8gsVL3xaeGX4sMNyiL3q5P9h29-f6Sa6luAE,2633
|
|
260
|
-
compass_api_sdk/utils/eventstreaming.py,sha256=
|
|
260
|
+
compass_api_sdk/utils/eventstreaming.py,sha256=SgFqMcUOYKlrTQ4gAp_dNcKLvDXukeiEMNU3DP8mXk8,6692
|
|
261
261
|
compass_api_sdk/utils/forms.py,sha256=EJdnrfIkuwpDtekyHutla0HjI_FypTYcmYNyPKEu_W0,6874
|
|
262
262
|
compass_api_sdk/utils/headers.py,sha256=cPxWSmUILrefTGDzTH1Hdj7_Hlsj-EY6K5Tyc4iH4dk,3663
|
|
263
263
|
compass_api_sdk/utils/logger.py,sha256=9nUtlKHo3RFsIVyMw5jq3wEKZMVwHnZMSc6xLp-otC0,520
|
|
@@ -270,6 +270,6 @@ compass_api_sdk/utils/serializers.py,sha256=Hndks5M_rJXVub_N5lu0gKZQUoEmWrn6PN7R
|
|
|
270
270
|
compass_api_sdk/utils/unmarshal_json_response.py,sha256=GI4Cw4JB6H2qNkqbOuBiUcxtEOJhRm2bz3qfer9KmoE,591
|
|
271
271
|
compass_api_sdk/utils/url.py,sha256=BgGPgcTA6MRK4bF8fjP2dUopN3NzEzxWMXPBVg8NQUA,5254
|
|
272
272
|
compass_api_sdk/utils/values.py,sha256=CcaCXEa3xHhkUDROyXZocN8f0bdITftv9Y0P9lTf0YM,3517
|
|
273
|
-
compass_api_sdk-1.1.
|
|
274
|
-
compass_api_sdk-1.1.
|
|
275
|
-
compass_api_sdk-1.1.
|
|
273
|
+
compass_api_sdk-1.1.1rc0.dist-info/METADATA,sha256=1i7jmAZXaQXVGWMY04bEjjFJ3XDSVzGsvx1s8QrPPJ0,31523
|
|
274
|
+
compass_api_sdk-1.1.1rc0.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
|
|
275
|
+
compass_api_sdk-1.1.1rc0.dist-info/RECORD,,
|