compass_api_sdk 2.0.21rc1__py3-none-any.whl → 2.2.1rc3__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.
Files changed (36) hide show
  1. compass_api_sdk/_version.py +2 -2
  2. compass_api_sdk/earn.py +360 -114
  3. compass_api_sdk/gas_sponsorship.py +38 -26
  4. compass_api_sdk/models/__init__.py +65 -9
  5. compass_api_sdk/models/aaveposition.py +80 -25
  6. compass_api_sdk/models/approvetransferrequest.py +2 -2
  7. compass_api_sdk/models/batchedsafeoperationsresponse_input.py +4 -4
  8. compass_api_sdk/models/batchedsafeoperationsresponse_output.py +4 -4
  9. compass_api_sdk/models/compass_api_backend_v2_models_earn_read_response_positions_vaultposition.py +72 -18
  10. compass_api_sdk/models/compass_api_backend_v2_models_safe_transact_response_batched_safe_operations_eip712domain.py +6 -6
  11. compass_api_sdk/models/depositevent.py +61 -0
  12. compass_api_sdk/models/earnmanageparams.py +8 -6
  13. compass_api_sdk/models/earnmanagerequest.py +6 -4
  14. compass_api_sdk/models/earnpositionsresponse.py +31 -22
  15. compass_api_sdk/models/fee.py +8 -7
  16. compass_api_sdk/models/pendledepositevent.py +49 -0
  17. compass_api_sdk/models/pendlemarketinfo.py +138 -0
  18. compass_api_sdk/models/pendlemarketsresponse.py +30 -0
  19. compass_api_sdk/models/pendleptposition.py +111 -0
  20. compass_api_sdk/models/pendleptvenue.py +78 -0
  21. compass_api_sdk/models/pendlewithdrawalevent.py +54 -0
  22. compass_api_sdk/models/positionpnl.py +52 -0
  23. compass_api_sdk/models/safetxmessage.py +6 -6
  24. compass_api_sdk/models/sponsorgasrequest.py +2 -2
  25. compass_api_sdk/models/v2_earn_pendle_marketsop.py +105 -0
  26. compass_api_sdk/models/v2_earn_positionsop.py +5 -30
  27. compass_api_sdk/models/v2_earn_vaultsop.py +3 -3
  28. compass_api_sdk/models/withdrawalevent.py +61 -0
  29. compass_api_sdk/types/basemodel.py +41 -3
  30. compass_api_sdk/utils/__init__.py +0 -3
  31. compass_api_sdk/utils/enums.py +60 -0
  32. compass_api_sdk/utils/requestbodies.py +3 -3
  33. compass_api_sdk/utils/serializers.py +0 -20
  34. {compass_api_sdk-2.0.21rc1.dist-info → compass_api_sdk-2.2.1rc3.dist-info}/METADATA +3 -2
  35. {compass_api_sdk-2.0.21rc1.dist-info → compass_api_sdk-2.2.1rc3.dist-info}/RECORD +36 -26
  36. {compass_api_sdk-2.0.21rc1.dist-info → compass_api_sdk-2.2.1rc3.dist-info}/WHEEL +0 -0
@@ -0,0 +1,111 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .pendledepositevent import PendleDepositEvent, PendleDepositEventTypedDict
5
+ from .pendlewithdrawalevent import PendleWithdrawalEvent, PendleWithdrawalEventTypedDict
6
+ from .positionpnl import PositionPnL, PositionPnLTypedDict
7
+ from compass_api_sdk.types import (
8
+ BaseModel,
9
+ Nullable,
10
+ OptionalNullable,
11
+ UNSET,
12
+ UNSET_SENTINEL,
13
+ )
14
+ from compass_api_sdk.utils import validate_const
15
+ import pydantic
16
+ from pydantic import model_serializer
17
+ from pydantic.functional_validators import AfterValidator
18
+ from typing import List, Literal, Optional
19
+ from typing_extensions import Annotated, NotRequired, TypedDict
20
+
21
+
22
+ class PendlePTPositionTypedDict(TypedDict):
23
+ r"""Pendle Principal Token position."""
24
+
25
+ market_address: str
26
+ r"""The Pendle market address."""
27
+ pt_address: str
28
+ r"""The PT (Principal Token) contract address."""
29
+ underlying_symbol: str
30
+ r"""Symbol of the underlying asset (e.g., rsETH, weETH)."""
31
+ pt_balance: str
32
+ r"""The user's PT token balance."""
33
+ expiry: int
34
+ r"""Market expiry timestamp (Unix seconds)."""
35
+ current_pt_to_sy_rate: str
36
+ r"""Current PT-to-SY exchange rate (SY received per PT if sold now)."""
37
+ type: Literal["PENDLE_PT"]
38
+ r"""The market type discriminator."""
39
+ pnl: NotRequired[Nullable[PositionPnLTypedDict]]
40
+ r"""PnL metrics (in SY terms) for this position."""
41
+ deposits: NotRequired[List[PendleDepositEventTypedDict]]
42
+ r"""All buy PT events for this position."""
43
+ withdrawals: NotRequired[List[PendleWithdrawalEventTypedDict]]
44
+ r"""All sell/redeem PT events for this position."""
45
+
46
+
47
+ class PendlePTPosition(BaseModel):
48
+ r"""Pendle Principal Token position."""
49
+
50
+ market_address: str
51
+ r"""The Pendle market address."""
52
+
53
+ pt_address: str
54
+ r"""The PT (Principal Token) contract address."""
55
+
56
+ underlying_symbol: str
57
+ r"""Symbol of the underlying asset (e.g., rsETH, weETH)."""
58
+
59
+ pt_balance: str
60
+ r"""The user's PT token balance."""
61
+
62
+ expiry: int
63
+ r"""Market expiry timestamp (Unix seconds)."""
64
+
65
+ current_pt_to_sy_rate: str
66
+ r"""Current PT-to-SY exchange rate (SY received per PT if sold now)."""
67
+
68
+ TYPE: Annotated[
69
+ Annotated[Literal["PENDLE_PT"], AfterValidator(validate_const("PENDLE_PT"))],
70
+ pydantic.Field(alias="type"),
71
+ ] = "PENDLE_PT"
72
+ r"""The market type discriminator."""
73
+
74
+ pnl: OptionalNullable[PositionPnL] = UNSET
75
+ r"""PnL metrics (in SY terms) for this position."""
76
+
77
+ deposits: Optional[List[PendleDepositEvent]] = None
78
+ r"""All buy PT events for this position."""
79
+
80
+ withdrawals: Optional[List[PendleWithdrawalEvent]] = None
81
+ r"""All sell/redeem PT events for this position."""
82
+
83
+ @model_serializer(mode="wrap")
84
+ def serialize_model(self, handler):
85
+ optional_fields = ["pnl", "deposits", "withdrawals"]
86
+ nullable_fields = ["pnl"]
87
+ null_default_fields = []
88
+
89
+ serialized = handler(self)
90
+
91
+ m = {}
92
+
93
+ for n, f in type(self).model_fields.items():
94
+ k = f.alias or n
95
+ val = serialized.get(k)
96
+ serialized.pop(k, None)
97
+
98
+ optional_nullable = k in optional_fields and k in nullable_fields
99
+ is_set = (
100
+ self.__pydantic_fields_set__.intersection({n})
101
+ or k in null_default_fields
102
+ ) # pylint: disable=no-member
103
+
104
+ if val is not None and val != UNSET_SENTINEL:
105
+ m[k] = val
106
+ elif val != UNSET_SENTINEL and (
107
+ not k in optional_fields or (optional_nullable and is_set)
108
+ ):
109
+ m[k] = val
110
+
111
+ return m
@@ -0,0 +1,78 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from compass_api_sdk.types import (
5
+ BaseModel,
6
+ Nullable,
7
+ OptionalNullable,
8
+ UNSET,
9
+ UNSET_SENTINEL,
10
+ )
11
+ from compass_api_sdk.utils import validate_const
12
+ import pydantic
13
+ from pydantic import model_serializer
14
+ from pydantic.functional_validators import AfterValidator
15
+ from typing import Literal, Optional
16
+ from typing_extensions import Annotated, NotRequired, TypedDict
17
+
18
+
19
+ class PendlePTVenueTypedDict(TypedDict):
20
+ r"""Venue for Pendle Principal Token (PT) positions."""
21
+
22
+ market_address: str
23
+ r"""The Pendle market address identifying which PT to trade."""
24
+ type: Literal["PENDLE_PT"]
25
+ r"""The venue type discriminator."""
26
+ token: NotRequired[Nullable[str]]
27
+ r"""The token to exchange for PT (only used for DEPOSIT/buy). For WITHDRAW/sell, this field must not be provided - withdrawals always return the underlying asset to ensure accurate yield fee calculation."""
28
+ max_slippage_percent: NotRequired[float]
29
+ r"""Maximum slippage allowed in percent (e.g., 1 means 1% slippage)."""
30
+
31
+
32
+ class PendlePTVenue(BaseModel):
33
+ r"""Venue for Pendle Principal Token (PT) positions."""
34
+
35
+ market_address: str
36
+ r"""The Pendle market address identifying which PT to trade."""
37
+
38
+ TYPE: Annotated[
39
+ Annotated[Literal["PENDLE_PT"], AfterValidator(validate_const("PENDLE_PT"))],
40
+ pydantic.Field(alias="type"),
41
+ ] = "PENDLE_PT"
42
+ r"""The venue type discriminator."""
43
+
44
+ token: OptionalNullable[str] = UNSET
45
+ r"""The token to exchange for PT (only used for DEPOSIT/buy). For WITHDRAW/sell, this field must not be provided - withdrawals always return the underlying asset to ensure accurate yield fee calculation."""
46
+
47
+ max_slippage_percent: Optional[float] = None
48
+ r"""Maximum slippage allowed in percent (e.g., 1 means 1% slippage)."""
49
+
50
+ @model_serializer(mode="wrap")
51
+ def serialize_model(self, handler):
52
+ optional_fields = ["token", "max_slippage_percent"]
53
+ nullable_fields = ["token"]
54
+ null_default_fields = []
55
+
56
+ serialized = handler(self)
57
+
58
+ m = {}
59
+
60
+ for n, f in type(self).model_fields.items():
61
+ k = f.alias or n
62
+ val = serialized.get(k)
63
+ serialized.pop(k, None)
64
+
65
+ optional_nullable = k in optional_fields and k in nullable_fields
66
+ is_set = (
67
+ self.__pydantic_fields_set__.intersection({n})
68
+ or k in null_default_fields
69
+ ) # pylint: disable=no-member
70
+
71
+ if val is not None and val != UNSET_SENTINEL:
72
+ m[k] = val
73
+ elif val != UNSET_SENTINEL and (
74
+ not k in optional_fields or (optional_nullable and is_set)
75
+ ):
76
+ m[k] = val
77
+
78
+ return m
@@ -0,0 +1,54 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from compass_api_sdk.types import BaseModel
5
+ from typing_extensions import TypedDict
6
+
7
+
8
+ class PendleWithdrawalEventTypedDict(TypedDict):
9
+ r"""Pendle PT withdrawal event with cost basis at time of withdrawal."""
10
+
11
+ block_number: int
12
+ r"""Block number when withdrawal occurred"""
13
+ transaction_hash: str
14
+ r"""Transaction hash of the withdrawal"""
15
+ input_amount: str
16
+ r"""PT tokens sold/redeemed"""
17
+ input_symbol: str
18
+ r"""Symbol (PT)"""
19
+ output_amount: str
20
+ r"""Amount received (SY or token)"""
21
+ output_symbol: str
22
+ r"""Symbol of token received"""
23
+ realized_pnl: str
24
+ r"""Profit/loss: output value - cost basis consumed"""
25
+ cost_per_unit: str
26
+ r"""Cost basis per PT at withdrawal (SY received per PT sold)"""
27
+
28
+
29
+ class PendleWithdrawalEvent(BaseModel):
30
+ r"""Pendle PT withdrawal event with cost basis at time of withdrawal."""
31
+
32
+ block_number: int
33
+ r"""Block number when withdrawal occurred"""
34
+
35
+ transaction_hash: str
36
+ r"""Transaction hash of the withdrawal"""
37
+
38
+ input_amount: str
39
+ r"""PT tokens sold/redeemed"""
40
+
41
+ input_symbol: str
42
+ r"""Symbol (PT)"""
43
+
44
+ output_amount: str
45
+ r"""Amount received (SY or token)"""
46
+
47
+ output_symbol: str
48
+ r"""Symbol of token received"""
49
+
50
+ realized_pnl: str
51
+ r"""Profit/loss: output value - cost basis consumed"""
52
+
53
+ cost_per_unit: str
54
+ r"""Cost basis per PT at withdrawal (SY received per PT sold)"""
@@ -0,0 +1,52 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from compass_api_sdk.types import BaseModel
5
+ from typing_extensions import TypedDict
6
+
7
+
8
+ class PositionPnLTypedDict(TypedDict):
9
+ r"""Simplified PnL metrics for API response.
10
+
11
+ Historical events (deposits/withdrawals) are now at the position level, not inside
12
+ PnL.
13
+ """
14
+
15
+ total_deposited: str
16
+ r"""Total assets deposited over all time"""
17
+ current_value: str
18
+ r"""Current position value in underlying"""
19
+ unrealized_pnl: str
20
+ r"""current_value - cost_basis_remaining"""
21
+ realized_pnl: str
22
+ r"""Sum of profits/losses from all withdrawals"""
23
+ total_pnl: str
24
+ r"""unrealized_pnl + realized_pnl"""
25
+ total_pnl_percent: str
26
+ r"""(total_pnl / total_deposited) * 100"""
27
+
28
+
29
+ class PositionPnL(BaseModel):
30
+ r"""Simplified PnL metrics for API response.
31
+
32
+ Historical events (deposits/withdrawals) are now at the position level, not inside
33
+ PnL.
34
+ """
35
+
36
+ total_deposited: str
37
+ r"""Total assets deposited over all time"""
38
+
39
+ current_value: str
40
+ r"""Current position value in underlying"""
41
+
42
+ unrealized_pnl: str
43
+ r"""current_value - cost_basis_remaining"""
44
+
45
+ realized_pnl: str
46
+ r"""Sum of profits/losses from all withdrawals"""
47
+
48
+ total_pnl: str
49
+ r"""unrealized_pnl + realized_pnl"""
50
+
51
+ total_pnl_percent: str
52
+ r"""(total_pnl / total_deposited) * 100"""
@@ -8,7 +8,7 @@ from typing_extensions import Annotated, TypedDict
8
8
 
9
9
 
10
10
  class SafeTxMessageTypedDict(TypedDict):
11
- r"""The message data for a Safe transaction."""
11
+ r"""The message data for the transaction."""
12
12
 
13
13
  to: str
14
14
  r"""Destination address"""
@@ -19,7 +19,7 @@ class SafeTxMessageTypedDict(TypedDict):
19
19
  operation: OperationType
20
20
  r"""Safe operation types."""
21
21
  safe_tx_gas: str
22
- r"""Gas for the Safe transaction"""
22
+ r"""Gas for the transaction"""
23
23
  base_gas: str
24
24
  r"""Base gas costs"""
25
25
  gas_price: str
@@ -29,11 +29,11 @@ class SafeTxMessageTypedDict(TypedDict):
29
29
  refund_receiver: str
30
30
  r"""Address to receive gas refund"""
31
31
  nonce: str
32
- r"""Safe transaction nonce"""
32
+ r"""Transaction nonce"""
33
33
 
34
34
 
35
35
  class SafeTxMessage(BaseModel):
36
- r"""The message data for a Safe transaction."""
36
+ r"""The message data for the transaction."""
37
37
 
38
38
  to: str
39
39
  r"""Destination address"""
@@ -48,7 +48,7 @@ class SafeTxMessage(BaseModel):
48
48
  r"""Safe operation types."""
49
49
 
50
50
  safe_tx_gas: Annotated[str, pydantic.Field(alias="safeTxGas")]
51
- r"""Gas for the Safe transaction"""
51
+ r"""Gas for the transaction"""
52
52
 
53
53
  base_gas: Annotated[str, pydantic.Field(alias="baseGas")]
54
54
  r"""Base gas costs"""
@@ -63,4 +63,4 @@ class SafeTxMessage(BaseModel):
63
63
  r"""Address to receive gas refund"""
64
64
 
65
65
  nonce: str
66
- r"""Safe transaction nonce"""
66
+ r"""Transaction nonce"""
@@ -43,7 +43,7 @@ r"""The EIP-712 typed data that was signed."""
43
43
 
44
44
  class SponsorGasRequestTypedDict(TypedDict):
45
45
  owner: str
46
- r"""The owner of the smart account's address."""
46
+ r"""The wallet address that owns the Earn Account."""
47
47
  chain: Chain
48
48
  r"""The chain to use."""
49
49
  eip_712: SponsorGasRequestEip712TypedDict
@@ -56,7 +56,7 @@ class SponsorGasRequestTypedDict(TypedDict):
56
56
 
57
57
  class SponsorGasRequest(BaseModel):
58
58
  owner: str
59
- r"""The owner of the smart account's address."""
59
+ r"""The wallet address that owns the Earn Account."""
60
60
 
61
61
  chain: Chain
62
62
  r"""The chain to use."""
@@ -0,0 +1,105 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from .chain import Chain
5
+ from compass_api_sdk.types import (
6
+ BaseModel,
7
+ Nullable,
8
+ OptionalNullable,
9
+ UNSET,
10
+ UNSET_SENTINEL,
11
+ )
12
+ from compass_api_sdk.utils import FieldMetadata, QueryParamMetadata
13
+ from enum import Enum
14
+ from pydantic import model_serializer
15
+ from typing import Optional
16
+ from typing_extensions import Annotated, NotRequired, TypedDict
17
+
18
+
19
+ class V2EarnPendleMarketsDirection(str, Enum):
20
+ r"""The direction to order the results by."""
21
+
22
+ ASC = "asc"
23
+ DESC = "desc"
24
+
25
+
26
+ class V2EarnPendleMarketsRequestTypedDict(TypedDict):
27
+ order_by: str
28
+ r"""The field to order the results by."""
29
+ direction: NotRequired[V2EarnPendleMarketsDirection]
30
+ r"""The direction to order the results by."""
31
+ offset: NotRequired[int]
32
+ r"""The offset of the first item to return."""
33
+ limit: NotRequired[int]
34
+ r"""The number of items to return."""
35
+ chain: NotRequired[Nullable[Chain]]
36
+ r"""Optional chain filter. If not provided, returns markets for all chains."""
37
+ underlying_symbol: NotRequired[Nullable[str]]
38
+ r"""Filter markets by underlying asset symbol (e.g., 'USDC', 'WETH')."""
39
+
40
+
41
+ class V2EarnPendleMarketsRequest(BaseModel):
42
+ order_by: Annotated[
43
+ str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True))
44
+ ]
45
+ r"""The field to order the results by."""
46
+
47
+ direction: Annotated[
48
+ Optional[V2EarnPendleMarketsDirection],
49
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
50
+ ] = None
51
+ r"""The direction to order the results by."""
52
+
53
+ offset: Annotated[
54
+ Optional[int],
55
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
56
+ ] = None
57
+ r"""The offset of the first item to return."""
58
+
59
+ limit: Annotated[
60
+ Optional[int],
61
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
62
+ ] = None
63
+ r"""The number of items to return."""
64
+
65
+ chain: Annotated[
66
+ OptionalNullable[Chain],
67
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
68
+ ] = UNSET
69
+ r"""Optional chain filter. If not provided, returns markets for all chains."""
70
+
71
+ underlying_symbol: Annotated[
72
+ OptionalNullable[str],
73
+ FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
74
+ ] = UNSET
75
+ r"""Filter markets by underlying asset symbol (e.g., 'USDC', 'WETH')."""
76
+
77
+ @model_serializer(mode="wrap")
78
+ def serialize_model(self, handler):
79
+ optional_fields = ["direction", "offset", "limit", "chain", "underlying_symbol"]
80
+ nullable_fields = ["chain", "underlying_symbol"]
81
+ null_default_fields = []
82
+
83
+ serialized = handler(self)
84
+
85
+ m = {}
86
+
87
+ for n, f in type(self).model_fields.items():
88
+ k = f.alias or n
89
+ val = serialized.get(k)
90
+ serialized.pop(k, None)
91
+
92
+ optional_nullable = k in optional_fields and k in nullable_fields
93
+ is_set = (
94
+ self.__pydantic_fields_set__.intersection({n})
95
+ or k in null_default_fields
96
+ ) # pylint: disable=no-member
97
+
98
+ if val is not None and val != UNSET_SENTINEL:
99
+ m[k] = val
100
+ elif val != UNSET_SENTINEL and (
101
+ not k in optional_fields or (optional_nullable and is_set)
102
+ ):
103
+ m[k] = val
104
+
105
+ return m
@@ -4,8 +4,7 @@ from __future__ import annotations
4
4
  from compass_api_sdk.types import BaseModel
5
5
  from compass_api_sdk.utils import FieldMetadata, QueryParamMetadata
6
6
  from enum import Enum
7
- from typing import Optional
8
- from typing_extensions import Annotated, NotRequired, TypedDict
7
+ from typing_extensions import Annotated, TypedDict
9
8
 
10
9
 
11
10
  class V2EarnPositionsChain(str, Enum):
@@ -16,14 +15,8 @@ class V2EarnPositionsChain(str, Enum):
16
15
 
17
16
  class V2EarnPositionsRequestTypedDict(TypedDict):
18
17
  chain: V2EarnPositionsChain
19
- user_address: str
20
- r"""The address of the user to get vault positions for."""
21
- offset: NotRequired[int]
22
- r"""The offset of the first item to return."""
23
- limit: NotRequired[int]
24
- r"""The number of items to return."""
25
- days: NotRequired[int]
26
- r"""How many days back from the current time to include in the blockchain scan."""
18
+ owner: str
19
+ r"""The address of the owner of the earn account to get positions for."""
27
20
 
28
21
 
29
22
  class V2EarnPositionsRequest(BaseModel):
@@ -32,25 +25,7 @@ class V2EarnPositionsRequest(BaseModel):
32
25
  FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
33
26
  ]
34
27
 
35
- user_address: Annotated[
28
+ owner: Annotated[
36
29
  str, FieldMetadata(query=QueryParamMetadata(style="form", explode=True))
37
30
  ]
38
- r"""The address of the user to get vault positions for."""
39
-
40
- offset: Annotated[
41
- Optional[int],
42
- FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
43
- ] = None
44
- r"""The offset of the first item to return."""
45
-
46
- limit: Annotated[
47
- Optional[int],
48
- FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
49
- ] = None
50
- r"""The number of items to return."""
51
-
52
- days: Annotated[
53
- Optional[int],
54
- FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
55
- ] = None
56
- r"""How many days back from the current time to include in the blockchain scan."""
31
+ r"""The address of the owner of the earn account to get positions for."""
@@ -16,7 +16,7 @@ from typing import Optional
16
16
  from typing_extensions import Annotated, NotRequired, TypedDict
17
17
 
18
18
 
19
- class Direction(str, Enum):
19
+ class V2EarnVaultsDirection(str, Enum):
20
20
  r"""The direction to order the results by."""
21
21
 
22
22
  ASC = "asc"
@@ -26,7 +26,7 @@ class Direction(str, Enum):
26
26
  class V2EarnVaultsRequestTypedDict(TypedDict):
27
27
  order_by: str
28
28
  r"""The field to order the results by."""
29
- direction: NotRequired[Direction]
29
+ direction: NotRequired[V2EarnVaultsDirection]
30
30
  r"""The direction to order the results by."""
31
31
  offset: NotRequired[int]
32
32
  r"""The offset of the first item to return."""
@@ -45,7 +45,7 @@ class V2EarnVaultsRequest(BaseModel):
45
45
  r"""The field to order the results by."""
46
46
 
47
47
  direction: Annotated[
48
- Optional[Direction],
48
+ Optional[V2EarnVaultsDirection],
49
49
  FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
50
50
  ] = None
51
51
  r"""The direction to order the results by."""
@@ -0,0 +1,61 @@
1
+ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
+
3
+ from __future__ import annotations
4
+ from compass_api_sdk.types import BaseModel
5
+ from typing_extensions import TypedDict
6
+
7
+
8
+ class WithdrawalEventTypedDict(TypedDict):
9
+ r"""Historical withdrawal event with realized PnL.
10
+
11
+ Uses generic input/output format:
12
+ - Vault: input=shares, output=underlying
13
+ - Aave: input=aTokens, output=underlying
14
+ - Pendle: input=PT, output=token (varies)
15
+ """
16
+
17
+ block_number: int
18
+ r"""Block number when withdrawal occurred"""
19
+ transaction_hash: str
20
+ r"""Transaction hash of the withdrawal"""
21
+ input_amount: str
22
+ r"""Units withdrawn (shares, aTokens, PT)"""
23
+ input_symbol: str
24
+ r"""Symbol of units withdrawn"""
25
+ output_amount: str
26
+ r"""Amount received (underlying or token)"""
27
+ output_symbol: str
28
+ r"""Symbol of token received"""
29
+ realized_pnl: str
30
+ r"""Profit/loss: output value - cost basis consumed"""
31
+
32
+
33
+ class WithdrawalEvent(BaseModel):
34
+ r"""Historical withdrawal event with realized PnL.
35
+
36
+ Uses generic input/output format:
37
+ - Vault: input=shares, output=underlying
38
+ - Aave: input=aTokens, output=underlying
39
+ - Pendle: input=PT, output=token (varies)
40
+ """
41
+
42
+ block_number: int
43
+ r"""Block number when withdrawal occurred"""
44
+
45
+ transaction_hash: str
46
+ r"""Transaction hash of the withdrawal"""
47
+
48
+ input_amount: str
49
+ r"""Units withdrawn (shares, aTokens, PT)"""
50
+
51
+ input_symbol: str
52
+ r"""Symbol of units withdrawn"""
53
+
54
+ output_amount: str
55
+ r"""Amount received (underlying or token)"""
56
+
57
+ output_symbol: str
58
+ r"""Symbol of token received"""
59
+
60
+ realized_pnl: str
61
+ r"""Profit/loss: output value - cost basis consumed"""
@@ -2,7 +2,8 @@
2
2
 
3
3
  from pydantic import ConfigDict, model_serializer
4
4
  from pydantic import BaseModel as PydanticBaseModel
5
- from typing import TYPE_CHECKING, Literal, Optional, TypeVar, Union
5
+ from pydantic_core import core_schema
6
+ from typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, Union
6
7
  from typing_extensions import TypeAliasType, TypeAlias
7
8
 
8
9
 
@@ -35,5 +36,42 @@ else:
35
36
  "OptionalNullable", Union[Optional[Nullable[T]], Unset], type_params=(T,)
36
37
  )
37
38
 
38
- UnrecognizedInt: TypeAlias = int
39
- UnrecognizedStr: TypeAlias = str
39
+
40
+ class UnrecognizedStr(str):
41
+ @classmethod
42
+ def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
43
+ # Make UnrecognizedStr only work in lax mode, not strict mode
44
+ # This makes it a "fallback" option when more specific types (like Literals) don't match
45
+ def validate_lax(v: Any) -> 'UnrecognizedStr':
46
+ if isinstance(v, cls):
47
+ return v
48
+ return cls(str(v))
49
+
50
+ # Use lax_or_strict_schema where strict always fails
51
+ # This forces Pydantic to prefer other union members in strict mode
52
+ # and only fall back to UnrecognizedStr in lax mode
53
+ return core_schema.lax_or_strict_schema(
54
+ lax_schema=core_schema.chain_schema([
55
+ core_schema.str_schema(),
56
+ core_schema.no_info_plain_validator_function(validate_lax)
57
+ ]),
58
+ strict_schema=core_schema.none_schema(), # Always fails in strict mode
59
+ )
60
+
61
+
62
+ class UnrecognizedInt(int):
63
+ @classmethod
64
+ def __get_pydantic_core_schema__(cls, _source_type: Any, _handler: Any) -> core_schema.CoreSchema:
65
+ # Make UnrecognizedInt only work in lax mode, not strict mode
66
+ # This makes it a "fallback" option when more specific types (like Literals) don't match
67
+ def validate_lax(v: Any) -> 'UnrecognizedInt':
68
+ if isinstance(v, cls):
69
+ return v
70
+ return cls(int(v))
71
+ return core_schema.lax_or_strict_schema(
72
+ lax_schema=core_schema.chain_schema([
73
+ core_schema.int_schema(),
74
+ core_schema.no_info_plain_validator_function(validate_lax)
75
+ ]),
76
+ strict_schema=core_schema.none_schema(), # Always fails in strict mode
77
+ )