nado-protocol 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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.0.dist-info → nado_protocol-0.1.2.dist-info}/METADATA +4 -2
- nado_protocol-0.1.2.dist-info/RECORD +78 -0
- {nado_protocol-0.1.0.dist-info → nado_protocol-0.1.2.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.0.dist-info/RECORD +0 -78
- {nado_protocol-0.1.0.dist-info → nado_protocol-0.1.2.dist-info}/WHEEL +0 -0
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
-
"nodeUrl": "http://0.0.0.0:8545",
|
|
3
2
|
"publicNodeUrl": "http://0.0.0.0:8545",
|
|
4
3
|
"explorerUrl": "",
|
|
5
4
|
"startBlock": 0,
|
|
6
5
|
"deployer": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
|
|
7
6
|
"quote": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
|
|
8
7
|
"querier": "0x4ed7c70F96B99c776995fB64377f0d4aB3B0e1C1",
|
|
9
|
-
"feeCalculator": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e",
|
|
10
8
|
"clearinghouse": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853",
|
|
11
|
-
"clearinghouseLiq": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
|
|
12
9
|
"endpoint": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318",
|
|
13
10
|
"spotEngine": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82",
|
|
14
11
|
"perpEngine": "0x0B306BF915C4d645ff596e518fAf3F9669b97016",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
12
|
+
"airdrop": "0x0000000000000000000000000000000000000000",
|
|
13
|
+
"staking": "0x0000000000000000000000000000000000000000",
|
|
17
14
|
"foundationRewardsAirdrop": "0x0000000000000000000000000000000000000000"
|
|
18
15
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"publicNodeUrl": "https://rpc-gel-sepolia.inkonchain.com",
|
|
3
|
+
"explorerUrl": "https://explorer-sepolia.inkonchain.com",
|
|
4
|
+
"startBlock": 27233833,
|
|
5
|
+
"deployer": "0x8177A1b5bFaAa10A4b1178c6D42aDaa4b75c8146",
|
|
6
|
+
"quote": "0x5F65358d61A9a281ea3BB930d05889ACa21E3f4f",
|
|
7
|
+
"querier": "0x5A62e748b2630560Ffe9E928780cF9Fe0e086A21",
|
|
8
|
+
"clearinghouse": "0x5E9b4336104069467E57E843033e62c79C667F8F",
|
|
9
|
+
"endpoint": "0xf8963f7860aF7DE9b94893EDb9A3b5c155e1Fc0c",
|
|
10
|
+
"spotEngine": "0x61AA7A636df5e72eBe34c70a340eB76ABB3A15bE",
|
|
11
|
+
"perpEngine": "0x3D6Ac7105cA399884739a8CC19cAdB4178844466",
|
|
12
|
+
"airdrop": "0x0000000000000000000000000000000000000000",
|
|
13
|
+
"staking": "0x0000000000000000000000000000000000000000",
|
|
14
|
+
"foundationRewardsAirdrop": "0x0000000000000000000000000000000000000000"
|
|
15
|
+
}
|
|
@@ -69,16 +69,7 @@ def get_nado_eip712_type(tx: NadoTxType) -> dict:
|
|
|
69
69
|
{"name": "amount", "type": "int128"},
|
|
70
70
|
{"name": "expiration", "type": "uint64"},
|
|
71
71
|
{"name": "nonce", "type": "uint64"},
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
NadoTxType.PLACE_ISOLATED_ORDER: {
|
|
75
|
-
"IsolatedOrder": [
|
|
76
|
-
{"name": "sender", "type": "bytes32"},
|
|
77
|
-
{"name": "priceX18", "type": "int128"},
|
|
78
|
-
{"name": "amount", "type": "int128"},
|
|
79
|
-
{"name": "expiration", "type": "uint64"},
|
|
80
|
-
{"name": "nonce", "type": "uint64"},
|
|
81
|
-
{"name": "margin", "type": "int128"},
|
|
72
|
+
{"name": "appendix", "type": "uint128"},
|
|
82
73
|
]
|
|
83
74
|
},
|
|
84
75
|
NadoTxType.CANCEL_ORDERS: {
|
|
@@ -114,21 +105,17 @@ def get_nado_eip712_type(tx: NadoTxType) -> dict:
|
|
|
114
105
|
{"name": "nonce", "type": "uint64"},
|
|
115
106
|
],
|
|
116
107
|
},
|
|
117
|
-
NadoTxType.
|
|
118
|
-
"
|
|
108
|
+
NadoTxType.MINT_NLP: {
|
|
109
|
+
"MintNlp": [
|
|
119
110
|
{"name": "sender", "type": "bytes32"},
|
|
120
|
-
{"name": "
|
|
121
|
-
{"name": "amountBase", "type": "uint128"},
|
|
122
|
-
{"name": "quoteAmountLow", "type": "uint128"},
|
|
123
|
-
{"name": "quoteAmountHigh", "type": "uint128"},
|
|
111
|
+
{"name": "quoteAmount", "type": "uint128"},
|
|
124
112
|
{"name": "nonce", "type": "uint64"},
|
|
125
113
|
]
|
|
126
114
|
},
|
|
127
|
-
NadoTxType.
|
|
128
|
-
"
|
|
115
|
+
NadoTxType.BURN_NLP: {
|
|
116
|
+
"BurnNlp": [
|
|
129
117
|
{"name": "sender", "type": "bytes32"},
|
|
130
|
-
{"name": "
|
|
131
|
-
{"name": "amount", "type": "uint128"},
|
|
118
|
+
{"name": "nlpAmount", "type": "uint128"},
|
|
132
119
|
{"name": "nonce", "type": "uint64"},
|
|
133
120
|
]
|
|
134
121
|
},
|
|
@@ -139,6 +126,14 @@ def get_nado_eip712_type(tx: NadoTxType) -> dict:
|
|
|
139
126
|
{"name": "nonce", "type": "uint64"},
|
|
140
127
|
]
|
|
141
128
|
},
|
|
129
|
+
NadoTxType.TRANSFER_QUOTE: {
|
|
130
|
+
"TransferQuote": [
|
|
131
|
+
{"name": "sender", "type": "bytes32"},
|
|
132
|
+
{"name": "recipient", "type": "bytes32"},
|
|
133
|
+
{"name": "amount", "type": "uint128"},
|
|
134
|
+
{"name": "nonce", "type": "uint64"},
|
|
135
|
+
]
|
|
136
|
+
},
|
|
142
137
|
NadoTxType.AUTHENTICATE_STREAM: {
|
|
143
138
|
"StreamAuthentication": [
|
|
144
139
|
{"name": "sender", "type": "bytes32"},
|
nado_protocol/contracts/types.py
CHANGED
|
@@ -11,8 +11,11 @@ class NadoNetwork(StrEnum):
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
# dev
|
|
14
|
-
HARDHAT = "localhost"
|
|
15
|
-
TESTING = "
|
|
14
|
+
HARDHAT = "localhost" # local hardhat node
|
|
15
|
+
TESTING = "testing" # for running local tests
|
|
16
|
+
|
|
17
|
+
# testnet
|
|
18
|
+
TESTNET = "testnet" # Ink Sepolia
|
|
16
19
|
|
|
17
20
|
|
|
18
21
|
class NadoAbiName(StrEnum):
|
|
@@ -24,12 +27,11 @@ class NadoAbiName(StrEnum):
|
|
|
24
27
|
FQUERIER = "FQuerier"
|
|
25
28
|
ICLEARINGHOUSE = "IClearinghouse"
|
|
26
29
|
IENDPOINT = "IEndpoint"
|
|
27
|
-
IOFFCHAIN_BOOK = "IOffchainBook"
|
|
28
30
|
IPERP_ENGINE = "IPerpEngine"
|
|
29
31
|
ISPOT_ENGINE = "ISpotEngine"
|
|
30
32
|
MOCK_ERC20 = "MockERC20"
|
|
31
33
|
ISTAKING = "IStaking"
|
|
32
|
-
|
|
34
|
+
IAIRDROP = "IAirdrop"
|
|
33
35
|
IFOUNDATION_REWARDS_AIRDROP = "IFoundationRewardsAirdrop"
|
|
34
36
|
|
|
35
37
|
|
|
@@ -52,9 +54,9 @@ class NadoDeployment(NadoBaseModel):
|
|
|
52
54
|
|
|
53
55
|
perp_engine_addr (str): The address of the perpetual engine contract.
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
airdrop_addr (str): The address of the airdrop contract.
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
staking_addr (str): The address of the staking contract.
|
|
58
60
|
|
|
59
61
|
foundation_rewards_airdrop_addr (str): The address of Foundation Rewards airdrop contract for the corresponding chain (e.g: Arb airdrop for Arbitrum).
|
|
60
62
|
"""
|
|
@@ -66,8 +68,8 @@ class NadoDeployment(NadoBaseModel):
|
|
|
66
68
|
endpoint_addr: str = Field(alias="endpoint")
|
|
67
69
|
spot_engine_addr: str = Field(alias="spotEngine")
|
|
68
70
|
perp_engine_addr: str = Field(alias="perpEngine")
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
airdrop_addr: str = Field(alias="airdrop")
|
|
72
|
+
staking_addr: str = Field(alias="staking")
|
|
71
73
|
foundation_rewards_airdrop_addr: str = Field(alias="foundationRewardsAirdrop")
|
|
72
74
|
|
|
73
75
|
|
|
@@ -91,13 +93,13 @@ class DepositCollateralParams(NadoBaseModel):
|
|
|
91
93
|
referral_code: Optional[str]
|
|
92
94
|
|
|
93
95
|
|
|
94
|
-
class
|
|
96
|
+
class ClaimTokensParams(NadoBaseModel):
|
|
95
97
|
epoch: int
|
|
96
98
|
amount: Optional[int]
|
|
97
99
|
claim_all: Optional[bool]
|
|
98
100
|
|
|
99
101
|
|
|
100
|
-
class
|
|
102
|
+
class ClaimTokensContractParams(NadoBaseModel):
|
|
101
103
|
epoch: int
|
|
102
104
|
amount_to_claim: int
|
|
103
105
|
total_claimable_amount: int
|
|
@@ -120,15 +122,15 @@ class NadoExecuteType(StrEnum):
|
|
|
120
122
|
"""
|
|
121
123
|
|
|
122
124
|
PLACE_ORDER = "place_order"
|
|
123
|
-
PLACE_ISOLATED_ORDER = "place_isolated_order"
|
|
124
125
|
CANCEL_ORDERS = "cancel_orders"
|
|
125
126
|
CANCEL_PRODUCT_ORDERS = "cancel_product_orders"
|
|
126
127
|
CANCEL_AND_PLACE = "cancel_and_place"
|
|
127
128
|
WITHDRAW_COLLATERAL = "withdraw_collateral"
|
|
128
129
|
LIQUIDATE_SUBACCOUNT = "liquidate_subaccount"
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
MINT_NLP = "mint_nlp"
|
|
131
|
+
BURN_NLP = "burn_nlp"
|
|
131
132
|
LINK_SIGNER = "link_signer"
|
|
133
|
+
TRANSFER_QUOTE = "transfer_quote"
|
|
132
134
|
|
|
133
135
|
|
|
134
136
|
NadoTxType = StrEnum(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import time
|
|
2
1
|
import requests
|
|
3
2
|
from functools import singledispatchmethod
|
|
4
3
|
|
|
@@ -8,7 +7,7 @@ from nado_protocol.engine_client.types import (
|
|
|
8
7
|
EngineClientOpts,
|
|
9
8
|
)
|
|
10
9
|
from nado_protocol.engine_client.types.execute import (
|
|
11
|
-
|
|
10
|
+
BurnNlpParams,
|
|
12
11
|
CancelAndPlaceParams,
|
|
13
12
|
CancelOrdersParams,
|
|
14
13
|
CancelProductOrdersParams,
|
|
@@ -17,9 +16,8 @@ from nado_protocol.engine_client.types.execute import (
|
|
|
17
16
|
ExecuteResponse,
|
|
18
17
|
LinkSignerParams,
|
|
19
18
|
LiquidateSubaccountParams,
|
|
20
|
-
|
|
19
|
+
MintNlpParams,
|
|
21
20
|
OrderParams,
|
|
22
|
-
PlaceIsolatedOrderParams,
|
|
23
21
|
PlaceMarketOrderParams,
|
|
24
22
|
PlaceOrderParams,
|
|
25
23
|
WithdrawCollateralParams,
|
|
@@ -38,6 +36,7 @@ from nado_protocol.utils.math import mul_x18, round_x18, to_x18
|
|
|
38
36
|
from nado_protocol.utils.model import NadoBaseModel, is_instance_of_union
|
|
39
37
|
from nado_protocol.utils.subaccount import Subaccount, SubaccountParams
|
|
40
38
|
from nado_protocol.utils.execute import NadoBaseExecute
|
|
39
|
+
from nado_protocol.utils.order import build_appendix
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
class EngineExecuteClient(NadoBaseExecute):
|
|
@@ -151,26 +150,6 @@ class EngineExecuteClient(NadoBaseExecute):
|
|
|
151
150
|
)
|
|
152
151
|
return self.execute(params)
|
|
153
152
|
|
|
154
|
-
def place_isolated_order(self, params: PlaceIsolatedOrderParams) -> ExecuteResponse:
|
|
155
|
-
"""
|
|
156
|
-
Execute a place isolated order operation.
|
|
157
|
-
|
|
158
|
-
Args:
|
|
159
|
-
params (PlaceIsolatedOrderParams): Parameters required for placing an isolated order.
|
|
160
|
-
The parameters include the isolated order details.
|
|
161
|
-
|
|
162
|
-
Returns:
|
|
163
|
-
ExecuteResponse: Response of the execution, including status and potential error message.
|
|
164
|
-
"""
|
|
165
|
-
params = PlaceIsolatedOrderParams.parse_obj(params)
|
|
166
|
-
params.isolated_order = self.prepare_execute_params(params.isolated_order, True)
|
|
167
|
-
params.signature = params.signature or self._sign(
|
|
168
|
-
NadoExecuteType.PLACE_ISOLATED_ORDER,
|
|
169
|
-
params.isolated_order.dict(),
|
|
170
|
-
params.product_id,
|
|
171
|
-
)
|
|
172
|
-
return self.execute(params)
|
|
173
|
-
|
|
174
153
|
def place_market_order(self, params: PlaceMarketOrderParams) -> ExecuteResponse:
|
|
175
154
|
"""
|
|
176
155
|
Places an FOK order using top of the book price with provided slippage.
|
|
@@ -198,8 +177,9 @@ class EngineExecuteClient(NadoBaseExecute):
|
|
|
198
177
|
amount=params.market_order.amount,
|
|
199
178
|
nonce=params.market_order.nonce,
|
|
200
179
|
priceX18=round_x18(market_price_x18, price_increment_x18),
|
|
201
|
-
expiration=get_expiration_timestamp(
|
|
202
|
-
|
|
180
|
+
expiration=get_expiration_timestamp(1000),
|
|
181
|
+
appendix=build_appendix(
|
|
182
|
+
OrderType.FOK, reduce_only=bool(params.reduce_only)
|
|
203
183
|
),
|
|
204
184
|
)
|
|
205
185
|
return self.place_order(
|
|
@@ -317,38 +297,38 @@ class EngineExecuteClient(NadoBaseExecute):
|
|
|
317
297
|
)
|
|
318
298
|
return self.execute(params)
|
|
319
299
|
|
|
320
|
-
def
|
|
300
|
+
def mint_nlp(self, params: MintNlpParams) -> ExecuteResponse:
|
|
321
301
|
"""
|
|
322
|
-
Execute a mint
|
|
302
|
+
Execute a mint NLP tokens operation.
|
|
323
303
|
|
|
324
304
|
Args:
|
|
325
|
-
params (
|
|
305
|
+
params (MintNlpParams): Parameters required for minting NLP tokens.
|
|
326
306
|
The parameters include the LP details.
|
|
327
307
|
|
|
328
308
|
Returns:
|
|
329
309
|
ExecuteResponse: Response of the execution, including status and potential error message.
|
|
330
310
|
"""
|
|
331
|
-
params = self.prepare_execute_params(
|
|
311
|
+
params = self.prepare_execute_params(MintNlpParams.parse_obj(params), False)
|
|
332
312
|
params.signature = params.signature or self._sign(
|
|
333
|
-
NadoExecuteType.
|
|
313
|
+
NadoExecuteType.MINT_NLP,
|
|
334
314
|
params.dict(),
|
|
335
315
|
)
|
|
336
316
|
return self.execute(params)
|
|
337
317
|
|
|
338
|
-
def
|
|
318
|
+
def burn_nlp(self, params: BurnNlpParams) -> ExecuteResponse:
|
|
339
319
|
"""
|
|
340
|
-
Execute a burn
|
|
320
|
+
Execute a burn NLP tokens operation.
|
|
341
321
|
|
|
342
322
|
Args:
|
|
343
|
-
params (
|
|
323
|
+
params (BurnNlpParams): Parameters required for burning LP tokens.
|
|
344
324
|
The parameters include the LP details.
|
|
345
325
|
|
|
346
326
|
Returns:
|
|
347
327
|
ExecuteResponse: Response of the execution, including status and potential error message.
|
|
348
328
|
"""
|
|
349
|
-
params = self.prepare_execute_params(
|
|
329
|
+
params = self.prepare_execute_params(BurnNlpParams.parse_obj(params), False)
|
|
350
330
|
params.signature = params.signature or self._sign(
|
|
351
|
-
NadoExecuteType.
|
|
331
|
+
NadoExecuteType.BURN_NLP,
|
|
352
332
|
params.dict(),
|
|
353
333
|
)
|
|
354
334
|
return self.execute(params)
|
|
@@ -408,9 +388,8 @@ class EngineExecuteClient(NadoBaseExecute):
|
|
|
408
388
|
closing_price_x18,
|
|
409
389
|
product.book_info.price_increment_x18,
|
|
410
390
|
),
|
|
411
|
-
expiration=get_expiration_timestamp(
|
|
412
|
-
|
|
413
|
-
),
|
|
391
|
+
expiration=get_expiration_timestamp(1000),
|
|
392
|
+
appendix=build_appendix(OrderType.FOK, reduce_only=True),
|
|
414
393
|
),
|
|
415
394
|
)
|
|
416
395
|
)
|
|
@@ -22,8 +22,8 @@ __all__ = [
|
|
|
22
22
|
"CancelAndPlaceParams",
|
|
23
23
|
"WithdrawCollateralParams",
|
|
24
24
|
"LiquidateSubaccountParams",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"MintNlpParams",
|
|
26
|
+
"BurnNlpParams",
|
|
27
27
|
"LinkSignerParams",
|
|
28
28
|
"ExecuteParams",
|
|
29
29
|
"TxRequest",
|
|
@@ -33,8 +33,8 @@ __all__ = [
|
|
|
33
33
|
"CancelAndPlaceRequest",
|
|
34
34
|
"WithdrawCollateralRequest",
|
|
35
35
|
"LiquidateSubaccountRequest",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
36
|
+
"MintNlpRequest",
|
|
37
|
+
"BurnNlpRequest",
|
|
38
38
|
"LinkSignerRequest",
|
|
39
39
|
"ExecuteRequest",
|
|
40
40
|
"ExecuteResponse",
|
|
@@ -75,11 +75,7 @@ __all__ = [
|
|
|
75
75
|
"QueryResponse",
|
|
76
76
|
"ResponseStatus",
|
|
77
77
|
"EngineStatus",
|
|
78
|
-
"MintLp",
|
|
79
|
-
"BurnLp",
|
|
80
78
|
"ApplyDelta",
|
|
81
|
-
"MintLpTx",
|
|
82
|
-
"BurnLpTx",
|
|
83
79
|
"ApplyDeltaTx",
|
|
84
80
|
"SubaccountHealth",
|
|
85
81
|
"SpotLpBalance",
|
|
@@ -4,7 +4,6 @@ from nado_protocol.contracts.types import NadoExecuteType
|
|
|
4
4
|
from nado_protocol.engine_client.types.models import ResponseStatus
|
|
5
5
|
from nado_protocol.utils.execute import (
|
|
6
6
|
BaseParamsSigned,
|
|
7
|
-
IsolatedOrderParams,
|
|
8
7
|
MarketOrderParams,
|
|
9
8
|
OrderParams,
|
|
10
9
|
SignatureParams,
|
|
@@ -45,29 +44,6 @@ class PlaceOrderParams(SignatureParams):
|
|
|
45
44
|
spot_leverage: Optional[bool]
|
|
46
45
|
|
|
47
46
|
|
|
48
|
-
class PlaceIsolatedOrderParams(SignatureParams):
|
|
49
|
-
"""
|
|
50
|
-
Class for defining the parameters needed to place an isolated order.
|
|
51
|
-
|
|
52
|
-
Attributes:
|
|
53
|
-
id (Optional[int]): An optional custom order id that is echoed back in subscription events e.g: fill orders, etc.
|
|
54
|
-
|
|
55
|
-
product_id (int): The id of the product for which the order is being placed.
|
|
56
|
-
|
|
57
|
-
isolated_order (IsolatedOrderParams): The parameters of the isolated order.
|
|
58
|
-
|
|
59
|
-
digest (Optional[str]): An optional hash of the order data.
|
|
60
|
-
|
|
61
|
-
borrow_margin (Optional[bool]): Whether the cross subaccount can borrow quote for the margin transfer into the isolated subaccount. If not provided, it defaults to true.
|
|
62
|
-
"""
|
|
63
|
-
|
|
64
|
-
id: Optional[int]
|
|
65
|
-
product_id: int
|
|
66
|
-
isolated_order: IsolatedOrderParams
|
|
67
|
-
digest: Optional[str]
|
|
68
|
-
borrow_margin: Optional[bool]
|
|
69
|
-
|
|
70
|
-
|
|
71
47
|
class PlaceMarketOrderParams(SignatureParams):
|
|
72
48
|
"""
|
|
73
49
|
Class for defining the parameters needed to place a market order.
|
|
@@ -190,43 +166,33 @@ class LiquidateSubaccountParams(BaseParamsSigned):
|
|
|
190
166
|
return subaccount_to_bytes32(v)
|
|
191
167
|
|
|
192
168
|
|
|
193
|
-
class
|
|
169
|
+
class MintNlpParams(BaseParamsSigned):
|
|
194
170
|
"""
|
|
195
|
-
Parameters required for minting
|
|
171
|
+
Parameters required for minting Nado Liquidity Provider (NLP) tokens for a specific product in a subaccount.
|
|
196
172
|
|
|
197
173
|
Attributes:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
amountBase (int): The amount of base to be consumed by minting LPs multiplied by 1e18.
|
|
201
|
-
|
|
202
|
-
quoteAmountLow (int): The minimum amount of quote to be consumed by minting LPs multiplied by 1e18.
|
|
203
|
-
|
|
204
|
-
quoteAmountHigh (int): The maximum amount of quote to be consumed by minting LPs multiplied by 1e18.
|
|
174
|
+
quoteAmount (int): The amount of quote to be consumed by minting NLP multiplied by 1e18.
|
|
205
175
|
|
|
206
176
|
spot_leverage (Optional[bool]): Indicates whether leverage is to be used. Defaults to True.
|
|
207
177
|
If set to False, the transaction fails if it causes a borrow on the subaccount.
|
|
208
178
|
"""
|
|
209
179
|
|
|
210
|
-
|
|
211
|
-
amountBase: int
|
|
212
|
-
quoteAmountLow: int
|
|
213
|
-
quoteAmountHigh: int
|
|
180
|
+
quoteAmount: int
|
|
214
181
|
spot_leverage: Optional[bool]
|
|
215
182
|
|
|
216
183
|
|
|
217
|
-
class
|
|
184
|
+
class BurnNlpParams(BaseParamsSigned):
|
|
218
185
|
"""
|
|
219
|
-
This class represents the parameters required to burn
|
|
220
|
-
|
|
186
|
+
This class represents the parameters required to burn Nado Liquidity Provider (NLP)
|
|
187
|
+
tokens for a specific subaccount.
|
|
221
188
|
|
|
222
189
|
Attributes:
|
|
223
190
|
productId (int): The ID of the product.
|
|
224
191
|
|
|
225
|
-
|
|
192
|
+
nlpAmount (int): Amount of NLP tokens to burn multiplied by 1e18.
|
|
226
193
|
"""
|
|
227
194
|
|
|
228
|
-
|
|
229
|
-
amount: int
|
|
195
|
+
nlpAmount: int
|
|
230
196
|
|
|
231
197
|
|
|
232
198
|
class LinkSignerParams(BaseParamsSigned):
|
|
@@ -249,13 +215,12 @@ class LinkSignerParams(BaseParamsSigned):
|
|
|
249
215
|
|
|
250
216
|
ExecuteParams = Union[
|
|
251
217
|
PlaceOrderParams,
|
|
252
|
-
PlaceIsolatedOrderParams,
|
|
253
218
|
CancelOrdersParams,
|
|
254
219
|
CancelProductOrdersParams,
|
|
255
220
|
WithdrawCollateralParams,
|
|
256
221
|
LiquidateSubaccountParams,
|
|
257
|
-
|
|
258
|
-
|
|
222
|
+
MintNlpParams,
|
|
223
|
+
BurnNlpParams,
|
|
259
224
|
LinkSignerParams,
|
|
260
225
|
CancelAndPlaceParams,
|
|
261
226
|
]
|
|
@@ -282,33 +247,8 @@ class PlaceOrderRequest(NadoBaseModel):
|
|
|
282
247
|
raise ValueError("Missing `signature")
|
|
283
248
|
if isinstance(v.order.sender, bytes):
|
|
284
249
|
v.order.serialize_dict(["sender"], bytes32_to_hex)
|
|
285
|
-
v.order.serialize_dict(
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
class PlaceIsolatedOrderRequest(NadoBaseModel):
|
|
290
|
-
"""
|
|
291
|
-
Parameters for a request to place an isolated order.
|
|
292
|
-
|
|
293
|
-
Attributes:
|
|
294
|
-
place_isolated_order (PlaceIsolatedOrderParams): The parameters for the isolated order to be placed.
|
|
295
|
-
|
|
296
|
-
Methods:
|
|
297
|
-
serialize: Validates and serializes the order parameters.
|
|
298
|
-
"""
|
|
299
|
-
|
|
300
|
-
place_isolated_order: PlaceIsolatedOrderParams
|
|
301
|
-
|
|
302
|
-
@validator("place_isolated_order")
|
|
303
|
-
def serialize(cls, v: PlaceIsolatedOrderParams) -> PlaceIsolatedOrderParams:
|
|
304
|
-
if v.isolated_order.nonce is None:
|
|
305
|
-
raise ValueError("Missing order `nonce`")
|
|
306
|
-
if v.signature is None:
|
|
307
|
-
raise ValueError("Missing `signature")
|
|
308
|
-
if isinstance(v.isolated_order.sender, bytes):
|
|
309
|
-
v.isolated_order.serialize_dict(["sender"], bytes32_to_hex)
|
|
310
|
-
v.isolated_order.serialize_dict(
|
|
311
|
-
["nonce", "priceX18", "amount", "expiration", "margin"], str
|
|
250
|
+
v.order.serialize_dict(
|
|
251
|
+
["nonce", "priceX18", "amount", "expiration", "appendix"], str
|
|
312
252
|
)
|
|
313
253
|
return v
|
|
314
254
|
|
|
@@ -500,51 +440,50 @@ class LiquidateSubaccountRequest(NadoBaseModel):
|
|
|
500
440
|
_validator = validator("liquidate_subaccount", allow_reuse=True)(to_tx_request)
|
|
501
441
|
|
|
502
442
|
|
|
503
|
-
class
|
|
443
|
+
class MintNlpRequest(NadoBaseModel):
|
|
504
444
|
"""
|
|
505
|
-
Parameters for a mint
|
|
445
|
+
Parameters for a mint NLP request.
|
|
506
446
|
|
|
507
447
|
Attributes:
|
|
508
|
-
|
|
448
|
+
mint_nlp (MintNlpParams): The parameters for minting liquidity.
|
|
509
449
|
|
|
510
450
|
Methods:
|
|
511
|
-
serialize: Validates and converts the '
|
|
512
|
-
attributes of 'mint_lp' to their proper serialized forms.
|
|
451
|
+
serialize: Validates and converts the 'quoteAmount' attribute of 'mint_nlp' to their proper serialized forms.
|
|
513
452
|
|
|
514
|
-
to_tx_request: Validates and converts '
|
|
453
|
+
to_tx_request: Validates and converts 'mint_nlp' into a transaction request.
|
|
515
454
|
"""
|
|
516
455
|
|
|
517
|
-
|
|
456
|
+
mint_nlp: MintNlpParams
|
|
518
457
|
|
|
519
|
-
@validator("
|
|
520
|
-
def serialize(cls, v:
|
|
521
|
-
v.serialize_dict(["
|
|
458
|
+
@validator("mint_nlp")
|
|
459
|
+
def serialize(cls, v: MintNlpParams) -> MintNlpParams:
|
|
460
|
+
v.serialize_dict(["quoteAmount"], str)
|
|
522
461
|
return v
|
|
523
462
|
|
|
524
|
-
_validator = validator("
|
|
463
|
+
_validator = validator("mint_nlp", allow_reuse=True)(to_tx_request)
|
|
525
464
|
|
|
526
465
|
|
|
527
|
-
class
|
|
466
|
+
class BurnNlpRequest(NadoBaseModel):
|
|
528
467
|
"""
|
|
529
|
-
Parameters for a burn
|
|
468
|
+
Parameters for a burn NLP request.
|
|
530
469
|
|
|
531
470
|
Attributes:
|
|
532
|
-
|
|
471
|
+
burn_nlp (BurnNlpParams): The parameters for burning liquidity.
|
|
533
472
|
|
|
534
473
|
Methods:
|
|
535
|
-
serialize: Validates and converts the '
|
|
474
|
+
serialize: Validates and converts the 'nlpAmount' attribute of 'burn_nlp' to its proper serialized form.
|
|
536
475
|
|
|
537
|
-
to_tx_request: Validates and converts '
|
|
476
|
+
to_tx_request: Validates and converts 'burn_nlp' into a transaction request.
|
|
538
477
|
"""
|
|
539
478
|
|
|
540
|
-
|
|
479
|
+
burn_nlp: BurnNlpParams
|
|
541
480
|
|
|
542
|
-
@validator("
|
|
543
|
-
def serialize(cls, v:
|
|
544
|
-
v.serialize_dict(["
|
|
481
|
+
@validator("burn_nlp")
|
|
482
|
+
def serialize(cls, v: BurnNlpParams) -> BurnNlpParams:
|
|
483
|
+
v.serialize_dict(["nlpAmount"], str)
|
|
545
484
|
return v
|
|
546
485
|
|
|
547
|
-
_validator = validator("
|
|
486
|
+
_validator = validator("burn_nlp", allow_reuse=True)(to_tx_request)
|
|
548
487
|
|
|
549
488
|
|
|
550
489
|
class LinkSignerRequest(NadoBaseModel):
|
|
@@ -572,14 +511,13 @@ class LinkSignerRequest(NadoBaseModel):
|
|
|
572
511
|
|
|
573
512
|
ExecuteRequest = Union[
|
|
574
513
|
PlaceOrderRequest,
|
|
575
|
-
PlaceIsolatedOrderRequest,
|
|
576
514
|
CancelOrdersRequest,
|
|
577
515
|
CancelProductOrdersRequest,
|
|
578
516
|
CancelAndPlaceRequest,
|
|
579
517
|
WithdrawCollateralRequest,
|
|
580
518
|
LiquidateSubaccountRequest,
|
|
581
|
-
|
|
582
|
-
|
|
519
|
+
MintNlpRequest,
|
|
520
|
+
BurnNlpRequest,
|
|
583
521
|
LinkSignerRequest,
|
|
584
522
|
]
|
|
585
523
|
|
|
@@ -647,10 +585,6 @@ def to_execute_request(params: ExecuteParams) -> ExecuteRequest:
|
|
|
647
585
|
"""
|
|
648
586
|
execute_request_mapping = {
|
|
649
587
|
PlaceOrderParams: (PlaceOrderRequest, NadoExecuteType.PLACE_ORDER.value),
|
|
650
|
-
PlaceIsolatedOrderParams: (
|
|
651
|
-
PlaceIsolatedOrderRequest,
|
|
652
|
-
NadoExecuteType.PLACE_ISOLATED_ORDER.value,
|
|
653
|
-
),
|
|
654
588
|
CancelOrdersParams: (
|
|
655
589
|
CancelOrdersRequest,
|
|
656
590
|
NadoExecuteType.CANCEL_ORDERS.value,
|
|
@@ -667,8 +601,8 @@ def to_execute_request(params: ExecuteParams) -> ExecuteRequest:
|
|
|
667
601
|
LiquidateSubaccountRequest,
|
|
668
602
|
NadoExecuteType.LIQUIDATE_SUBACCOUNT.value,
|
|
669
603
|
),
|
|
670
|
-
|
|
671
|
-
|
|
604
|
+
MintNlpParams: (MintNlpRequest, NadoExecuteType.MINT_NLP.value),
|
|
605
|
+
BurnNlpParams: (BurnNlpRequest, NadoExecuteType.BURN_NLP.value),
|
|
672
606
|
LinkSignerParams: (LinkSignerRequest, NadoExecuteType.LINK_SIGNER.value),
|
|
673
607
|
CancelAndPlaceParams: (
|
|
674
608
|
CancelAndPlaceRequest,
|