nado-protocol 0.1.1__py3-none-any.whl → 0.1.3__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.
- nado_protocol/client/__init__.py +11 -2
- nado_protocol/client/apis/market/execute.py +10 -26
- nado_protocol/client/apis/market/query.py +2 -2
- nado_protocol/client/apis/rewards/execute.py +27 -27
- nado_protocol/client/apis/rewards/query.py +5 -4
- nado_protocol/client/apis/subaccount/query.py +1 -1
- nado_protocol/client/context.py +0 -2
- nado_protocol/contracts/__init__.py +41 -33
- nado_protocol/contracts/abis/Endpoint.json +151 -228
- nado_protocol/contracts/abis/FQuerier.json +91 -508
- nado_protocol/contracts/abis/IAirdrop.json +76 -0
- nado_protocol/contracts/abis/IClearinghouse.json +277 -390
- nado_protocol/contracts/abis/IEndpoint.json +42 -80
- nado_protocol/contracts/abis/IPerpEngine.json +69 -422
- nado_protocol/contracts/abis/IProductEngine.json +87 -205
- nado_protocol/contracts/abis/ISpotEngine.json +173 -362
- nado_protocol/contracts/abis/MockERC20.json +1 -1
- nado_protocol/contracts/deployments/{deployment.test.json → deployment.testing.json} +2 -5
- nado_protocol/contracts/deployments/deployment.testnet.json +15 -0
- nado_protocol/contracts/eip712/types.py +15 -20
- nado_protocol/contracts/types.py +15 -13
- nado_protocol/engine_client/execute.py +18 -39
- nado_protocol/engine_client/query.py +1 -1
- nado_protocol/engine_client/types/__init__.py +4 -8
- nado_protocol/engine_client/types/execute.py +37 -103
- nado_protocol/engine_client/types/models.py +3 -59
- nado_protocol/engine_client/types/query.py +3 -6
- nado_protocol/indexer_client/query.py +4 -9
- nado_protocol/indexer_client/types/__init__.py +4 -5
- nado_protocol/indexer_client/types/models.py +16 -23
- nado_protocol/indexer_client/types/query.py +12 -11
- nado_protocol/trigger_client/execute.py +1 -1
- nado_protocol/trigger_client/types/execute.py +3 -1
- nado_protocol/utils/__init__.py +18 -1
- nado_protocol/utils/backend.py +5 -2
- nado_protocol/utils/exceptions.py +3 -3
- nado_protocol/utils/execute.py +26 -67
- nado_protocol/utils/expiration.py +7 -28
- nado_protocol/utils/nonce.py +0 -4
- nado_protocol/utils/order.py +356 -0
- {nado_protocol-0.1.1.dist-info → nado_protocol-0.1.3.dist-info}/METADATA +4 -2
- nado_protocol-0.1.3.dist-info/RECORD +78 -0
- {nado_protocol-0.1.1.dist-info → nado_protocol-0.1.3.dist-info}/entry_points.txt +0 -1
- nado_protocol/contracts/abis/IERC20.json +0 -185
- nado_protocol/contracts/abis/IOffchainBook.json +0 -536
- nado_protocol/contracts/abis/IVrtxAirdrop.json +0 -138
- nado_protocol-0.1.1.dist-info/RECORD +0 -78
- {nado_protocol-0.1.1.dist-info → nado_protocol-0.1.3.dist-info}/WHEEL +0 -0
|
@@ -15,20 +15,6 @@ class EngineStatus(StrEnum):
|
|
|
15
15
|
FAILED = "failed"
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
class MintLp(NadoBaseModel):
|
|
19
|
-
product_id: int
|
|
20
|
-
subaccount: str
|
|
21
|
-
amount_base: str
|
|
22
|
-
quote_amount_low: str
|
|
23
|
-
quote_amount_high: str
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class BurnLp(NadoBaseModel):
|
|
27
|
-
product_id: int
|
|
28
|
-
subaccount: str
|
|
29
|
-
amount_lp: str
|
|
30
|
-
|
|
31
|
-
|
|
32
18
|
class ApplyDelta(NadoBaseModel):
|
|
33
19
|
product_id: int
|
|
34
20
|
subaccount: str
|
|
@@ -36,14 +22,6 @@ class ApplyDelta(NadoBaseModel):
|
|
|
36
22
|
v_quote_delta: str
|
|
37
23
|
|
|
38
24
|
|
|
39
|
-
class MintLpTx(NadoBaseModel):
|
|
40
|
-
mint_lp: MintLp
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
class BurnLpTx(NadoBaseModel):
|
|
44
|
-
burn_lp: BurnLp
|
|
45
|
-
|
|
46
|
-
|
|
47
25
|
class ApplyDeltaTx(NadoBaseModel):
|
|
48
26
|
apply_delta: ApplyDelta
|
|
49
27
|
|
|
@@ -54,26 +32,15 @@ class SubaccountHealth(NadoBaseModel):
|
|
|
54
32
|
health: str
|
|
55
33
|
|
|
56
34
|
|
|
57
|
-
class SpotLpBalance(NadoBaseModel):
|
|
58
|
-
amount: str
|
|
59
|
-
|
|
60
|
-
|
|
61
35
|
class SpotBalance(NadoBaseModel):
|
|
62
36
|
amount: str
|
|
63
|
-
last_cumulative_multiplier_x18: str
|
|
64
37
|
|
|
65
38
|
|
|
66
39
|
class SpotProductBalance(NadoBaseModel):
|
|
67
40
|
product_id: int
|
|
68
|
-
lp_balance: SpotLpBalance
|
|
69
41
|
balance: SpotBalance
|
|
70
42
|
|
|
71
43
|
|
|
72
|
-
class PerpLpBalance(NadoBaseModel):
|
|
73
|
-
amount: str
|
|
74
|
-
last_cumulative_funding_x18: str
|
|
75
|
-
|
|
76
|
-
|
|
77
44
|
class PerpBalance(NadoBaseModel):
|
|
78
45
|
amount: str
|
|
79
46
|
v_quote_balance: str
|
|
@@ -82,7 +49,6 @@ class PerpBalance(NadoBaseModel):
|
|
|
82
49
|
|
|
83
50
|
class PerpProductBalance(NadoBaseModel):
|
|
84
51
|
product_id: int
|
|
85
|
-
lp_balance: PerpLpBalance
|
|
86
52
|
balance: PerpBalance
|
|
87
53
|
|
|
88
54
|
|
|
@@ -91,7 +57,7 @@ class ProductRisk(NadoBaseModel):
|
|
|
91
57
|
short_weight_initial_x18: str
|
|
92
58
|
long_weight_maintenance_x18: str
|
|
93
59
|
short_weight_maintenance_x18: str
|
|
94
|
-
|
|
60
|
+
price_x18: str
|
|
95
61
|
|
|
96
62
|
|
|
97
63
|
class ProductBookInfo(NadoBaseModel):
|
|
@@ -99,7 +65,6 @@ class ProductBookInfo(NadoBaseModel):
|
|
|
99
65
|
price_increment_x18: str
|
|
100
66
|
min_size: str
|
|
101
67
|
collected_fees: str
|
|
102
|
-
lp_spread_x18: str
|
|
103
68
|
|
|
104
69
|
|
|
105
70
|
class BaseProduct(NadoBaseModel):
|
|
@@ -109,16 +74,14 @@ class BaseProduct(NadoBaseModel):
|
|
|
109
74
|
book_info: ProductBookInfo
|
|
110
75
|
|
|
111
76
|
|
|
112
|
-
class BaseProductLpState(NadoBaseModel):
|
|
113
|
-
supply: str
|
|
114
|
-
|
|
115
|
-
|
|
116
77
|
class SpotProductConfig(NadoBaseModel):
|
|
117
78
|
token: str
|
|
118
79
|
interest_inflection_util_x18: str
|
|
119
80
|
interest_floor_x18: str
|
|
120
81
|
interest_small_cap_x18: str
|
|
121
82
|
interest_large_cap_x18: str
|
|
83
|
+
withdraw_fee_x18: str
|
|
84
|
+
min_deposit_rate_x18: str
|
|
122
85
|
|
|
123
86
|
|
|
124
87
|
class SpotProductState(NadoBaseModel):
|
|
@@ -128,20 +91,9 @@ class SpotProductState(NadoBaseModel):
|
|
|
128
91
|
total_borrows_normalized: str
|
|
129
92
|
|
|
130
93
|
|
|
131
|
-
class SpotProductLpAmount(NadoBaseModel):
|
|
132
|
-
amount: str
|
|
133
|
-
last_cumulative_multiplier_x18: str
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
class SpotProductLpState(BaseProductLpState):
|
|
137
|
-
quote: SpotProductLpAmount
|
|
138
|
-
base: SpotProductLpAmount
|
|
139
|
-
|
|
140
|
-
|
|
141
94
|
class SpotProduct(BaseProduct):
|
|
142
95
|
config: SpotProductConfig
|
|
143
96
|
state: SpotProductState
|
|
144
|
-
lp_state: SpotProductLpState
|
|
145
97
|
|
|
146
98
|
|
|
147
99
|
class PerpProductState(NadoBaseModel):
|
|
@@ -151,16 +103,8 @@ class PerpProductState(NadoBaseModel):
|
|
|
151
103
|
open_interest: str
|
|
152
104
|
|
|
153
105
|
|
|
154
|
-
class PerpProductLpState(BaseProductLpState):
|
|
155
|
-
last_cumulative_funding_x18: str
|
|
156
|
-
cumulative_funding_per_lp_x18: str
|
|
157
|
-
base: str
|
|
158
|
-
quote: str
|
|
159
|
-
|
|
160
|
-
|
|
161
106
|
class PerpProduct(BaseProduct):
|
|
162
107
|
state: PerpProductState
|
|
163
|
-
lp_state: PerpProductLpState
|
|
164
108
|
|
|
165
109
|
|
|
166
110
|
class MaxOrderSizeDirection(StrEnum):
|
|
@@ -5,12 +5,10 @@ from nado_protocol.utils.model import NadoBaseModel
|
|
|
5
5
|
from nado_protocol.engine_client.types.models import (
|
|
6
6
|
ApplyDeltaTx,
|
|
7
7
|
Asset,
|
|
8
|
-
BurnLpTx,
|
|
9
8
|
EngineStatus,
|
|
10
9
|
IsolatedPosition,
|
|
11
10
|
MarketPair,
|
|
12
11
|
MaxOrderSizeDirection,
|
|
13
|
-
MintLpTx,
|
|
14
12
|
ProductSymbol,
|
|
15
13
|
ResponseStatus,
|
|
16
14
|
SpotApr,
|
|
@@ -42,7 +40,7 @@ class EngineQueryType(StrEnum):
|
|
|
42
40
|
MARKET_PRICE = "market_price"
|
|
43
41
|
MAX_ORDER_SIZE = "max_order_size"
|
|
44
42
|
MAX_WITHDRAWABLE = "max_withdrawable"
|
|
45
|
-
|
|
43
|
+
MAX_NLP_MINTABLE = "max_nlp_mintable"
|
|
46
44
|
SUBACCOUNT_INFO = "subaccount_info"
|
|
47
45
|
SUBACCOUNT_ORDERS = "subaccount_orders"
|
|
48
46
|
ORDERS = "orders"
|
|
@@ -93,7 +91,7 @@ class QueryIsolatedPositionsParams(NadoBaseModel):
|
|
|
93
91
|
subaccount: str
|
|
94
92
|
|
|
95
93
|
|
|
96
|
-
QuerySubaccountInfoTx = Union[
|
|
94
|
+
QuerySubaccountInfoTx = Union[ApplyDeltaTx]
|
|
97
95
|
|
|
98
96
|
|
|
99
97
|
class QuerySubaccountInfoParams(NadoBaseModel):
|
|
@@ -202,7 +200,7 @@ class QueryMaxLpMintableParams(SpotLeverageSerializerMixin):
|
|
|
202
200
|
Parameters for querying the maximum liquidity that can be minted by a specified sender for a specific product.
|
|
203
201
|
"""
|
|
204
202
|
|
|
205
|
-
type = EngineQueryType.
|
|
203
|
+
type = EngineQueryType.MAX_NLP_MINTABLE.value
|
|
206
204
|
sender: str
|
|
207
205
|
product_id: int
|
|
208
206
|
|
|
@@ -264,7 +262,6 @@ class ContractsData(NadoBaseModel):
|
|
|
264
262
|
|
|
265
263
|
chain_id: str
|
|
266
264
|
endpoint_addr: str
|
|
267
|
-
book_addrs: list[str]
|
|
268
265
|
|
|
269
266
|
|
|
270
267
|
class NoncesData(NadoBaseModel):
|
|
@@ -2,7 +2,7 @@ from typing import Optional, Union
|
|
|
2
2
|
import requests
|
|
3
3
|
from functools import singledispatchmethod
|
|
4
4
|
from nado_protocol.indexer_client.types import IndexerClientOpts
|
|
5
|
-
from nado_protocol.indexer_client.types.models import MarketType
|
|
5
|
+
from nado_protocol.indexer_client.types.models import MarketType
|
|
6
6
|
from nado_protocol.indexer_client.types.query import (
|
|
7
7
|
IndexerCandlesticksParams,
|
|
8
8
|
IndexerCandlesticksData,
|
|
@@ -44,7 +44,7 @@ from nado_protocol.indexer_client.types.query import (
|
|
|
44
44
|
IndexerTokenRewardsParams,
|
|
45
45
|
IndexerUsdcPriceParams,
|
|
46
46
|
IndexerUsdcPriceData,
|
|
47
|
-
|
|
47
|
+
IndexerTokenMerkleProofsParams,
|
|
48
48
|
IndexerFoundationRewardsMerkleProofsParams,
|
|
49
49
|
IndexerMerkleProofsData,
|
|
50
50
|
IndexerInterestAndFundingParams,
|
|
@@ -413,9 +413,9 @@ class IndexerQueryClient:
|
|
|
413
413
|
IndexerUsdcPriceData,
|
|
414
414
|
)
|
|
415
415
|
|
|
416
|
-
def
|
|
416
|
+
def get_token_merkle_proofs(self, address: str) -> IndexerMerkleProofsData:
|
|
417
417
|
return ensure_data_type(
|
|
418
|
-
self.query(
|
|
418
|
+
self.query(IndexerTokenMerkleProofsParams(address=address)).data,
|
|
419
419
|
IndexerMerkleProofsData,
|
|
420
420
|
)
|
|
421
421
|
|
|
@@ -459,8 +459,3 @@ class IndexerQueryClient:
|
|
|
459
459
|
if max_trade_id is not None:
|
|
460
460
|
url += f"&max_trade_id={max_trade_id}"
|
|
461
461
|
return ensure_data_type(self._query_v2(url), list)
|
|
462
|
-
|
|
463
|
-
def get_vrtx_token_info(self, query_type: VrtxTokenQueryType) -> float:
|
|
464
|
-
return ensure_data_type(
|
|
465
|
-
self._query_v2(f"{self.url_v2}/vrtx?q={str(query_type)}"), float
|
|
466
|
-
)
|
|
@@ -86,10 +86,10 @@ __all__ = [
|
|
|
86
86
|
"IndexerWithdrawCollateralTx",
|
|
87
87
|
"IndexerLiquidateSubaccountTxData",
|
|
88
88
|
"IndexerLiquidateSubaccountTx",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
89
|
+
"IndexerMintNlpTxData",
|
|
90
|
+
"IndexerMintNlpTx",
|
|
91
|
+
"IndexerBurnNlpTxData",
|
|
92
|
+
"IndexerBurnNlpTx",
|
|
93
93
|
"IndexerTxData",
|
|
94
94
|
"IndexerTx",
|
|
95
95
|
"IndexerSpotProductBalanceData",
|
|
@@ -115,7 +115,6 @@ __all__ = [
|
|
|
115
115
|
"IndexerTickerInfo",
|
|
116
116
|
"IndexerPerpContractInfo",
|
|
117
117
|
"IndexerTradeInfo",
|
|
118
|
-
"VrtxTokenQueryType",
|
|
119
118
|
"IndexerTickersData",
|
|
120
119
|
"IndexerPerpContractsData",
|
|
121
120
|
"IndexerHistoricalTradesData",
|
|
@@ -20,8 +20,8 @@ class IndexerEventType(StrEnum):
|
|
|
20
20
|
MATCH_ORDERS = "match_orders"
|
|
21
21
|
MATCH_ORDER_A_M_M = "match_order_a_m_m"
|
|
22
22
|
SWAP_AMM = "swap_a_m_m"
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
MINT_NLP = "mint_nlp"
|
|
24
|
+
BURN_NLP = "burn_nlp"
|
|
25
25
|
MANUAL_ASSERT = "manual_assert"
|
|
26
26
|
LINK_SIGNER = "link_signer"
|
|
27
27
|
TRANSFER_QUOTE = "transfer_quote"
|
|
@@ -118,36 +118,32 @@ class IndexerLiquidateSubaccountTx(NadoBaseModel):
|
|
|
118
118
|
liquidate_subaccount: IndexerLiquidateSubaccountTxData
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
class
|
|
121
|
+
class IndexerMintNlpTxData(NadoBaseModel):
|
|
122
122
|
sender: str
|
|
123
|
-
|
|
124
|
-
amount_base: str
|
|
125
|
-
quote_amount_low: str
|
|
126
|
-
quote_amount_high: str
|
|
123
|
+
quote_amount: str
|
|
127
124
|
nonce: int
|
|
128
125
|
|
|
129
126
|
|
|
130
|
-
class
|
|
131
|
-
|
|
127
|
+
class IndexerMintNlpTx(NadoBaseModel):
|
|
128
|
+
mint_nlp: IndexerMintNlpTxData
|
|
132
129
|
|
|
133
130
|
|
|
134
|
-
class
|
|
131
|
+
class IndexerBurnNlpTxData(NadoBaseModel):
|
|
135
132
|
sender: str
|
|
136
|
-
|
|
137
|
-
amount: str
|
|
133
|
+
nlp_amount: str
|
|
138
134
|
nonce: int
|
|
139
135
|
|
|
140
136
|
|
|
141
|
-
class
|
|
142
|
-
|
|
137
|
+
class IndexerBurnNlpTx(NadoBaseModel):
|
|
138
|
+
burn_nlp: IndexerBurnNlpTxData
|
|
143
139
|
|
|
144
140
|
|
|
145
141
|
IndexerTxData = Union[
|
|
146
142
|
IndexerMatchOrdersTx,
|
|
147
143
|
IndexerWithdrawCollateralTx,
|
|
148
144
|
IndexerLiquidateSubaccountTx,
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
IndexerMintNlpTx,
|
|
146
|
+
IndexerBurnNlpTx,
|
|
151
147
|
]
|
|
152
148
|
|
|
153
149
|
|
|
@@ -186,8 +182,6 @@ class IndexerEventTrackedData(NadoBaseModel):
|
|
|
186
182
|
net_funding_cumulative: str
|
|
187
183
|
net_entry_unrealized: str
|
|
188
184
|
net_entry_cumulative: str
|
|
189
|
-
net_entry_lp_unrealized: str
|
|
190
|
-
net_entry_lp_cumulative: str
|
|
191
185
|
|
|
192
186
|
|
|
193
187
|
class IndexerEvent(IndexerBaseModel, IndexerEventTrackedData):
|
|
@@ -303,6 +297,10 @@ class IndexerLiquidatableAccount(NadoBaseModel):
|
|
|
303
297
|
class IndexerSubaccount(NadoBaseModel):
|
|
304
298
|
id: str
|
|
305
299
|
subaccount: str
|
|
300
|
+
address: str
|
|
301
|
+
subaccount_name: str
|
|
302
|
+
created_at: str
|
|
303
|
+
isolated: bool
|
|
306
304
|
|
|
307
305
|
|
|
308
306
|
class IndexerMerkleProof(NadoBaseModel):
|
|
@@ -357,8 +355,3 @@ class IndexerTradeInfo(NadoBaseModel):
|
|
|
357
355
|
class MarketType(StrEnum):
|
|
358
356
|
SPOT = "spot"
|
|
359
357
|
PERP = "perp"
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
class VrtxTokenQueryType(StrEnum):
|
|
363
|
-
TOTAL_SUPPLY = "total_supply"
|
|
364
|
-
CIRCULATING_SUPPLY = "circulating_supply"
|
|
@@ -49,7 +49,8 @@ class IndexerQueryType(StrEnum):
|
|
|
49
49
|
REFERRAL_CODE = "referral_code"
|
|
50
50
|
SUBACCOUNTS = "subaccounts"
|
|
51
51
|
USDC_PRICE = "usdc_price"
|
|
52
|
-
|
|
52
|
+
# TODO: revise once this endpoint is live
|
|
53
|
+
TOKEN_MERKLE_PROOFS = "token_merkle_proofs"
|
|
53
54
|
FOUNDATION_REWARDS_MERKLE_PROOFS = "foundation_rewards_merkle_proofs"
|
|
54
55
|
INTEREST_AND_FUNDING = "interest_and_funding"
|
|
55
56
|
|
|
@@ -262,9 +263,9 @@ class IndexerUsdcPriceParams(NadoBaseModel):
|
|
|
262
263
|
pass
|
|
263
264
|
|
|
264
265
|
|
|
265
|
-
class
|
|
266
|
+
class IndexerTokenMerkleProofsParams(NadoBaseModel):
|
|
266
267
|
"""
|
|
267
|
-
Parameters for querying
|
|
268
|
+
Parameters for querying token merkle proofs.
|
|
268
269
|
"""
|
|
269
270
|
|
|
270
271
|
address: str
|
|
@@ -308,7 +309,7 @@ IndexerParams = Union[
|
|
|
308
309
|
IndexerSubaccountsParams,
|
|
309
310
|
IndexerUsdcPriceParams,
|
|
310
311
|
IndexerMarketSnapshotsParams,
|
|
311
|
-
|
|
312
|
+
IndexerTokenMerkleProofsParams,
|
|
312
313
|
IndexerFoundationRewardsMerkleProofsParams,
|
|
313
314
|
IndexerInterestAndFundingParams,
|
|
314
315
|
]
|
|
@@ -460,12 +461,12 @@ class IndexerUsdcPriceRequest(NadoBaseModel):
|
|
|
460
461
|
usdc_price: IndexerUsdcPriceParams
|
|
461
462
|
|
|
462
463
|
|
|
463
|
-
class
|
|
464
|
+
class IndexerTokenMerkleProofsRequest(NadoBaseModel):
|
|
464
465
|
"""
|
|
465
|
-
Request object for querying
|
|
466
|
+
Request object for querying token merkle proofs.
|
|
466
467
|
"""
|
|
467
468
|
|
|
468
|
-
|
|
469
|
+
token_merkle_proofs: IndexerTokenMerkleProofsParams
|
|
469
470
|
|
|
470
471
|
|
|
471
472
|
class IndexerFoundationRewardsMerkleProofsRequest(NadoBaseModel):
|
|
@@ -502,7 +503,7 @@ IndexerRequest = Union[
|
|
|
502
503
|
IndexerSubaccountsRequest,
|
|
503
504
|
IndexerUsdcPriceRequest,
|
|
504
505
|
IndexerMarketSnapshotsRequest,
|
|
505
|
-
|
|
506
|
+
IndexerTokenMerkleProofsRequest,
|
|
506
507
|
IndexerFoundationRewardsMerkleProofsRequest,
|
|
507
508
|
IndexerInterestAndFundingRequest,
|
|
508
509
|
]
|
|
@@ -794,9 +795,9 @@ def to_indexer_request(params: IndexerParams) -> IndexerRequest:
|
|
|
794
795
|
IndexerUsdcPriceRequest,
|
|
795
796
|
IndexerQueryType.USDC_PRICE.value,
|
|
796
797
|
),
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
IndexerQueryType.
|
|
798
|
+
IndexerTokenMerkleProofsParams: (
|
|
799
|
+
IndexerTokenMerkleProofsRequest,
|
|
800
|
+
IndexerQueryType.TOKEN_MERKLE_PROOFS.value,
|
|
800
801
|
),
|
|
801
802
|
IndexerFoundationRewardsMerkleProofsParams: (
|
|
802
803
|
IndexerFoundationRewardsMerkleProofsRequest,
|
|
@@ -89,7 +89,7 @@ class TriggerExecuteClient(NadoBaseExecute):
|
|
|
89
89
|
|
|
90
90
|
def place_trigger_order(self, params: PlaceTriggerOrderParams) -> ExecuteResponse:
|
|
91
91
|
params = PlaceTriggerOrderParams.parse_obj(params)
|
|
92
|
-
params.order = self.prepare_execute_params(params.order, True
|
|
92
|
+
params.order = self.prepare_execute_params(params.order, True)
|
|
93
93
|
params.signature = params.signature or self._sign(
|
|
94
94
|
NadoExecuteType.PLACE_ORDER, params.order.dict(), params.product_id
|
|
95
95
|
)
|
|
@@ -46,7 +46,9 @@ class PlaceTriggerOrderRequest(NadoBaseModel):
|
|
|
46
46
|
raise ValueError("Missing `signature")
|
|
47
47
|
if isinstance(v.order.sender, bytes):
|
|
48
48
|
v.order.serialize_dict(["sender"], bytes32_to_hex)
|
|
49
|
-
v.order.serialize_dict(
|
|
49
|
+
v.order.serialize_dict(
|
|
50
|
+
["nonce", "priceX18", "amount", "expiration", "appendix"], str
|
|
51
|
+
)
|
|
50
52
|
return v
|
|
51
53
|
|
|
52
54
|
|
nado_protocol/utils/__init__.py
CHANGED
|
@@ -5,6 +5,7 @@ from nado_protocol.utils.expiration import *
|
|
|
5
5
|
from nado_protocol.utils.math import *
|
|
6
6
|
from nado_protocol.utils.nonce import *
|
|
7
7
|
from nado_protocol.utils.exceptions import *
|
|
8
|
+
from nado_protocol.utils.order import *
|
|
8
9
|
|
|
9
10
|
__all__ = [
|
|
10
11
|
"NadoBackendURL",
|
|
@@ -24,7 +25,6 @@ __all__ = [
|
|
|
24
25
|
"OrderType",
|
|
25
26
|
"get_expiration_timestamp",
|
|
26
27
|
"gen_order_nonce",
|
|
27
|
-
"decode_expiration",
|
|
28
28
|
"to_pow_10",
|
|
29
29
|
"to_x18",
|
|
30
30
|
"from_pow_10",
|
|
@@ -34,4 +34,21 @@ __all__ = [
|
|
|
34
34
|
"BadStatusCodeException",
|
|
35
35
|
"MissingSignerException",
|
|
36
36
|
"InvalidProductId",
|
|
37
|
+
# Order appendix utilities
|
|
38
|
+
"OrderAppendixTriggerType",
|
|
39
|
+
"APPENDIX_VERSION",
|
|
40
|
+
"AppendixBitFields",
|
|
41
|
+
"TWAPBitFields",
|
|
42
|
+
"gen_order_verifying_contract",
|
|
43
|
+
"pack_twap_appendix_value",
|
|
44
|
+
"unpack_twap_appendix_value",
|
|
45
|
+
"build_appendix",
|
|
46
|
+
"order_reduce_only",
|
|
47
|
+
"order_is_trigger_order",
|
|
48
|
+
"order_is_isolated",
|
|
49
|
+
"order_isolated_margin",
|
|
50
|
+
"order_version",
|
|
51
|
+
"order_trigger_type",
|
|
52
|
+
"order_twap_data",
|
|
53
|
+
"order_execution_type",
|
|
37
54
|
]
|
nado_protocol/utils/backend.py
CHANGED
|
@@ -13,6 +13,11 @@ class NadoBackendURL(StrEnum):
|
|
|
13
13
|
DEVNET_INDEXER = "http://localhost:8000"
|
|
14
14
|
DEVNET_TRIGGER = "http://localhost:8080"
|
|
15
15
|
|
|
16
|
+
# testnets
|
|
17
|
+
TESTNET_GATEWAY = "https://gateway.test.nado-backend.xyz/v1"
|
|
18
|
+
TESTNET_INDEXER = "https://archive.test.nado-backend.xyz/v1"
|
|
19
|
+
TESTNET_TRIGGER = "https://trigger.test.nado-backend.xyz/v1"
|
|
20
|
+
|
|
16
21
|
|
|
17
22
|
PrivateKey = str
|
|
18
23
|
Signer = Union[LocalAccount, PrivateKey]
|
|
@@ -29,7 +34,6 @@ class NadoClientOpts(BaseModel):
|
|
|
29
34
|
linked_signer (Optional[Signer]): An optional signer linked the main subaccount to perform executes on it's behalf.
|
|
30
35
|
chain_id (Optional[int]): An optional network chain ID.
|
|
31
36
|
endpoint_addr (Optional[str]): Nado's endpoint address used for verifying executes.
|
|
32
|
-
book_addrs (Optional[list[str]]): Nado's book addresses used for verifying order placement.
|
|
33
37
|
|
|
34
38
|
Notes:
|
|
35
39
|
- The class also includes several methods for validating and sanitizing the input values.
|
|
@@ -41,7 +45,6 @@ class NadoClientOpts(BaseModel):
|
|
|
41
45
|
linked_signer: Optional[Signer] = None
|
|
42
46
|
chain_id: Optional[int] = None
|
|
43
47
|
endpoint_addr: Optional[str] = None
|
|
44
|
-
book_addrs: Optional[list[str]] = None
|
|
45
48
|
|
|
46
49
|
class Config:
|
|
47
50
|
arbitrary_types_allowed = True
|
|
@@ -38,12 +38,12 @@ class InvalidProductId(Exception):
|
|
|
38
38
|
super().__init__(self.message)
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
class
|
|
42
|
-
"""Raised when providing invalid
|
|
41
|
+
class InvalidTokenClaimParams(Exception):
|
|
42
|
+
"""Raised when providing invalid token claim parameters."""
|
|
43
43
|
|
|
44
44
|
def __init__(
|
|
45
45
|
self,
|
|
46
|
-
message="Invalid
|
|
46
|
+
message="Invalid token params. Either `amount` or `claim_all` must be provided",
|
|
47
47
|
):
|
|
48
48
|
self.message = message
|
|
49
49
|
super().__init__(self.message)
|