nado-protocol 0.1.5__tar.gz → 0.1.7__tar.gz
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.
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/PKG-INFO +1 -1
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/types/query.py +10 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/indexer_client/types/models.py +1 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/indexer_client/types/query.py +3 -1
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/__init__.py +2 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/math.py +26 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/order.py +23 -29
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/pyproject.toml +1 -1
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/README.md +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/base.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/market/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/market/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/market/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/perp/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/perp/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/rewards/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/rewards/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/rewards/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/spot/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/spot/base.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/spot/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/spot/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/subaccount/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/subaccount/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/subaccount/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/context.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/Endpoint.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/FQuerier.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IAirdrop.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IClearinghouse.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IEndpoint.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IFoundationRewardsAirdrop.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IPerpEngine.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IProductEngine.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/ISpotEngine.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IStaking.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/MockERC20.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/deployments/deployment.testing.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/deployments/deployment.testnet.json +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/eip712/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/eip712/domain.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/eip712/sign.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/eip712/types.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/loader.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/types.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/types/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/types/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/types/models.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/engine_client/types/stream.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/indexer_client/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/indexer_client/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/indexer_client/types/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/trigger_client/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/trigger_client/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/trigger_client/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/trigger_client/types/__init__.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/trigger_client/types/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/trigger_client/types/models.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/trigger_client/types/query.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/backend.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/bytes32.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/enum.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/exceptions.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/execute.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/expiration.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/interest.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/model.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/nonce.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/subaccount.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/time.py +0 -0
- {nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/utils/twap.py +0 -0
|
@@ -179,11 +179,21 @@ class QueryMaxOrderSizeParams(SpotLeverageSerializerMixin):
|
|
|
179
179
|
product_id: int
|
|
180
180
|
price_x18: str
|
|
181
181
|
direction: MaxOrderSizeDirection
|
|
182
|
+
reduce_only: Optional[bool]
|
|
183
|
+
isolated: Optional[bool]
|
|
182
184
|
|
|
183
185
|
@validator("direction")
|
|
184
186
|
def direction_to_str(cls, v: MaxOrderSizeDirection) -> str:
|
|
185
187
|
return v.value
|
|
186
188
|
|
|
189
|
+
@validator("reduce_only")
|
|
190
|
+
def reduce_only_to_str(cls, v: Optional[bool]) -> Optional[str]:
|
|
191
|
+
return str(v).lower() if v is not None else v
|
|
192
|
+
|
|
193
|
+
@validator("isolated")
|
|
194
|
+
def isolated_to_str(cls, v: Optional[bool]) -> Optional[str]:
|
|
195
|
+
return str(v).lower() if v is not None else v
|
|
196
|
+
|
|
187
197
|
|
|
188
198
|
class QueryMaxWithdrawableParams(SpotLeverageSerializerMixin):
|
|
189
199
|
"""
|
|
@@ -75,6 +75,7 @@ class IndexerSubaccountHistoricalOrdersParams(IndexerBaseParams):
|
|
|
75
75
|
|
|
76
76
|
subaccount: str
|
|
77
77
|
product_ids: Optional[list[int]]
|
|
78
|
+
trigger_types: Optional[list[str]]
|
|
78
79
|
isolated: Optional[bool]
|
|
79
80
|
|
|
80
81
|
|
|
@@ -133,7 +134,8 @@ class IndexerSubaccountSummaryParams(NadoBaseModel):
|
|
|
133
134
|
"""
|
|
134
135
|
|
|
135
136
|
subaccount: str
|
|
136
|
-
timestamp: Optional[int]
|
|
137
|
+
timestamp: Optional[int] = None
|
|
138
|
+
active: Optional[bool] = None
|
|
137
139
|
|
|
138
140
|
|
|
139
141
|
class IndexerProductSnapshotsParams(IndexerBaseParams):
|
|
@@ -17,6 +17,19 @@ def to_pow_10(x: int, pow: int) -> int:
|
|
|
17
17
|
return x * 10**pow
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
def to_x6(x: float) -> int:
|
|
21
|
+
"""
|
|
22
|
+
Converts a float to a fixed point of 1e6.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
x (float): Float value to convert.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
int: Fixed point value represented as an integer.
|
|
29
|
+
"""
|
|
30
|
+
return int(Decimal(str(x)) * Decimal(10**6))
|
|
31
|
+
|
|
32
|
+
|
|
20
33
|
def to_x18(x: float) -> int:
|
|
21
34
|
"""
|
|
22
35
|
Converts a float to a fixed point of 1e18.
|
|
@@ -45,6 +58,19 @@ def from_pow_10(x: int, pow: int) -> float:
|
|
|
45
58
|
return float(x) / 10**pow
|
|
46
59
|
|
|
47
60
|
|
|
61
|
+
def from_x6(x: int) -> float:
|
|
62
|
+
"""
|
|
63
|
+
Reverts integer from power of 10^6 format.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
x (int): Converted value.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
float: Original value.
|
|
70
|
+
"""
|
|
71
|
+
return from_pow_10(x, 6)
|
|
72
|
+
|
|
73
|
+
|
|
48
74
|
def from_x18(x: int) -> float:
|
|
49
75
|
"""
|
|
50
76
|
Reverts integer from power of 10^18 format.
|
|
@@ -4,13 +4,13 @@ from nado_protocol.utils.expiration import OrderType
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
# Order appendix version
|
|
7
|
-
APPENDIX_VERSION =
|
|
7
|
+
APPENDIX_VERSION = 1
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class AppendixBitFields:
|
|
11
11
|
# | value | reserved | trigger | reduce only | order type| isolated | version |
|
|
12
|
-
# |
|
|
13
|
-
# | 127..
|
|
12
|
+
# | 64 bits | 50 bits | 2 bits | 1 bit | 2 bits | 1 bit | 8 bits |
|
|
13
|
+
# | 127..64 | 63..14 | 13..12 | 11 | 10..9 | 8 | 7..0 |
|
|
14
14
|
|
|
15
15
|
# Bit positions (from LSB to MSB)
|
|
16
16
|
VERSION_BITS = 8 # bits 7..0
|
|
@@ -18,8 +18,8 @@ class AppendixBitFields:
|
|
|
18
18
|
ORDER_TYPE_BITS = 2 # bits 10..9
|
|
19
19
|
REDUCE_ONLY_BITS = 1 # bit 11
|
|
20
20
|
TRIGGER_TYPE_BITS = 2 # bits 13..12
|
|
21
|
-
RESERVED_BITS =
|
|
22
|
-
VALUE_BITS =
|
|
21
|
+
RESERVED_BITS = 50 # bits 63..14
|
|
22
|
+
VALUE_BITS = 64 # bits 127..64 (for isolated margin or TWAP data)
|
|
23
23
|
|
|
24
24
|
# Bit masks
|
|
25
25
|
VERSION_MASK = (1 << VERSION_BITS) - 1
|
|
@@ -37,7 +37,7 @@ class AppendixBitFields:
|
|
|
37
37
|
REDUCE_ONLY_SHIFT = 11
|
|
38
38
|
TRIGGER_TYPE_SHIFT = 12
|
|
39
39
|
RESERVED_SHIFT = 14
|
|
40
|
-
VALUE_SHIFT =
|
|
40
|
+
VALUE_SHIFT = 64
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
class OrderAppendixTriggerType(IntEnum):
|
|
@@ -51,22 +51,19 @@ class OrderAppendixTriggerType(IntEnum):
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
class TWAPBitFields:
|
|
54
|
-
"""Bit field definitions for TWAP value packing within the
|
|
54
|
+
"""Bit field definitions for TWAP value packing within the 64-bit value field."""
|
|
55
55
|
|
|
56
|
-
# Bit layout (MSB → LSB): | times (32 bits) | slippage_x6 (32 bits) |
|
|
56
|
+
# Bit layout (MSB → LSB): | times (32 bits) | slippage_x6 (32 bits) |
|
|
57
57
|
TIMES_BITS = 32
|
|
58
58
|
SLIPPAGE_BITS = 32
|
|
59
|
-
RESERVED_BITS = 32
|
|
60
59
|
|
|
61
60
|
# Bit masks
|
|
62
61
|
TIMES_MASK = (1 << TIMES_BITS) - 1
|
|
63
62
|
SLIPPAGE_MASK = (1 << SLIPPAGE_BITS) - 1
|
|
64
|
-
RESERVED_MASK = (1 << RESERVED_BITS) - 1
|
|
65
63
|
|
|
66
|
-
# Bit shift positions (within the
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
TIMES_SHIFT = 64
|
|
64
|
+
# Bit shift positions (within the 64-bit value field)
|
|
65
|
+
SLIPPAGE_SHIFT = 0
|
|
66
|
+
TIMES_SHIFT = 32
|
|
70
67
|
|
|
71
68
|
# Slippage scaling factor (6 decimal places)
|
|
72
69
|
SLIPPAGE_SCALE = 1_000_000
|
|
@@ -74,30 +71,27 @@ class TWAPBitFields:
|
|
|
74
71
|
|
|
75
72
|
def pack_twap_appendix_value(times: int, slippage_frac: float) -> int:
|
|
76
73
|
"""
|
|
77
|
-
Packs TWAP order fields into a
|
|
74
|
+
Packs TWAP order fields into a 64-bit integer for the appendix.
|
|
78
75
|
|
|
79
76
|
Bit layout (MSB → LSB):
|
|
80
|
-
| times | slippage_x6 |
|
|
81
|
-
|
|
82
|
-
|
|
|
83
|
-
| 32 bits | 32 bits |
|
|
77
|
+
| times | slippage_x6 |
|
|
78
|
+
|-----------|-------------|
|
|
79
|
+
| 63..32 | 31..0 |
|
|
80
|
+
| 32 bits | 32 bits |
|
|
84
81
|
"""
|
|
85
82
|
slippage_x6 = int(slippage_frac * TWAPBitFields.SLIPPAGE_SCALE)
|
|
86
|
-
reserved = 0 # reserved 32-bit field (currently unused)
|
|
87
83
|
|
|
88
|
-
return (
|
|
89
|
-
(
|
|
90
|
-
| ((slippage_x6 & TWAPBitFields.SLIPPAGE_MASK) << TWAPBitFields.SLIPPAGE_SHIFT)
|
|
91
|
-
| ((reserved & TWAPBitFields.RESERVED_MASK) << TWAPBitFields.RESERVED_SHIFT)
|
|
84
|
+
return ((times & TWAPBitFields.TIMES_MASK) << TWAPBitFields.TIMES_SHIFT) | (
|
|
85
|
+
(slippage_x6 & TWAPBitFields.SLIPPAGE_MASK) << TWAPBitFields.SLIPPAGE_SHIFT
|
|
92
86
|
)
|
|
93
87
|
|
|
94
88
|
|
|
95
89
|
def unpack_twap_appendix_value(value: int) -> tuple[int, float]:
|
|
96
90
|
"""
|
|
97
|
-
Unpacks a
|
|
91
|
+
Unpacks a 64-bit integer into TWAP order fields.
|
|
98
92
|
|
|
99
93
|
Args:
|
|
100
|
-
value (int): The
|
|
94
|
+
value (int): The 64-bit value to unpack.
|
|
101
95
|
|
|
102
96
|
Returns:
|
|
103
97
|
tuple[int, float]: Number of TWAP executions and slippage fraction.
|
|
@@ -185,9 +179,9 @@ def build_appendix(
|
|
|
185
179
|
trigger_value & AppendixBitFields.TRIGGER_TYPE_MASK
|
|
186
180
|
) << AppendixBitFields.TRIGGER_TYPE_SHIFT
|
|
187
181
|
|
|
188
|
-
# Handle upper bits (127..
|
|
182
|
+
# Handle upper bits (127..64) based on order type
|
|
189
183
|
if isolated and isolated_margin is not None:
|
|
190
|
-
# Isolated margin (bits 127..
|
|
184
|
+
# Isolated margin (bits 127..64)
|
|
191
185
|
appendix |= (
|
|
192
186
|
isolated_margin & AppendixBitFields.VALUE_MASK
|
|
193
187
|
) << AppendixBitFields.VALUE_SHIFT
|
|
@@ -195,7 +189,7 @@ def build_appendix(
|
|
|
195
189
|
OrderAppendixTriggerType.TWAP,
|
|
196
190
|
OrderAppendixTriggerType.TWAP_CUSTOM_AMOUNTS,
|
|
197
191
|
]:
|
|
198
|
-
# TWAP value (bits 127..
|
|
192
|
+
# TWAP value (bits 127..64) - 64 bits
|
|
199
193
|
# These are guaranteed to be non-None due to validation above
|
|
200
194
|
assert twap_times is not None
|
|
201
195
|
assert twap_slippage_frac is not None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/client/apis/subaccount/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IClearinghouse.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{nado_protocol-0.1.5 → nado_protocol-0.1.7}/nado_protocol/contracts/abis/IProductEngine.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|