nado-protocol 0.1.0__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/__init__.py +0 -0
- nado_protocol/client/__init__.py +200 -0
- nado_protocol/client/apis/__init__.py +26 -0
- nado_protocol/client/apis/base.py +42 -0
- nado_protocol/client/apis/market/__init__.py +23 -0
- nado_protocol/client/apis/market/execute.py +192 -0
- nado_protocol/client/apis/market/query.py +310 -0
- nado_protocol/client/apis/perp/__init__.py +18 -0
- nado_protocol/client/apis/perp/query.py +30 -0
- nado_protocol/client/apis/rewards/__init__.py +6 -0
- nado_protocol/client/apis/rewards/execute.py +131 -0
- nado_protocol/client/apis/rewards/query.py +12 -0
- nado_protocol/client/apis/spot/__init__.py +23 -0
- nado_protocol/client/apis/spot/base.py +32 -0
- nado_protocol/client/apis/spot/execute.py +117 -0
- nado_protocol/client/apis/spot/query.py +79 -0
- nado_protocol/client/apis/subaccount/__init__.py +24 -0
- nado_protocol/client/apis/subaccount/execute.py +54 -0
- nado_protocol/client/apis/subaccount/query.py +145 -0
- nado_protocol/client/context.py +90 -0
- nado_protocol/contracts/__init__.py +377 -0
- nado_protocol/contracts/abis/Endpoint.json +636 -0
- nado_protocol/contracts/abis/FQuerier.json +1909 -0
- nado_protocol/contracts/abis/IClearinghouse.json +876 -0
- nado_protocol/contracts/abis/IERC20.json +185 -0
- nado_protocol/contracts/abis/IEndpoint.json +250 -0
- nado_protocol/contracts/abis/IFoundationRewardsAirdrop.json +76 -0
- nado_protocol/contracts/abis/IOffchainBook.json +536 -0
- nado_protocol/contracts/abis/IPerpEngine.json +931 -0
- nado_protocol/contracts/abis/IProductEngine.json +352 -0
- nado_protocol/contracts/abis/ISpotEngine.json +813 -0
- nado_protocol/contracts/abis/IStaking.json +288 -0
- nado_protocol/contracts/abis/IVrtxAirdrop.json +138 -0
- nado_protocol/contracts/abis/MockERC20.json +311 -0
- nado_protocol/contracts/deployments/deployment.test.json +18 -0
- nado_protocol/contracts/eip712/__init__.py +16 -0
- nado_protocol/contracts/eip712/domain.py +36 -0
- nado_protocol/contracts/eip712/sign.py +79 -0
- nado_protocol/contracts/eip712/types.py +154 -0
- nado_protocol/contracts/loader.py +55 -0
- nado_protocol/contracts/types.py +141 -0
- nado_protocol/engine_client/__init__.py +35 -0
- nado_protocol/engine_client/execute.py +416 -0
- nado_protocol/engine_client/query.py +481 -0
- nado_protocol/engine_client/types/__init__.py +113 -0
- nado_protocol/engine_client/types/execute.py +680 -0
- nado_protocol/engine_client/types/models.py +247 -0
- nado_protocol/engine_client/types/query.py +516 -0
- nado_protocol/engine_client/types/stream.py +6 -0
- nado_protocol/indexer_client/__init__.py +28 -0
- nado_protocol/indexer_client/query.py +466 -0
- nado_protocol/indexer_client/types/__init__.py +122 -0
- nado_protocol/indexer_client/types/models.py +364 -0
- nado_protocol/indexer_client/types/query.py +819 -0
- nado_protocol/trigger_client/__init__.py +17 -0
- nado_protocol/trigger_client/execute.py +118 -0
- nado_protocol/trigger_client/query.py +61 -0
- nado_protocol/trigger_client/types/__init__.py +7 -0
- nado_protocol/trigger_client/types/execute.py +89 -0
- nado_protocol/trigger_client/types/models.py +44 -0
- nado_protocol/trigger_client/types/query.py +77 -0
- nado_protocol/utils/__init__.py +37 -0
- nado_protocol/utils/backend.py +111 -0
- nado_protocol/utils/bytes32.py +159 -0
- nado_protocol/utils/enum.py +6 -0
- nado_protocol/utils/exceptions.py +58 -0
- nado_protocol/utils/execute.py +403 -0
- nado_protocol/utils/expiration.py +45 -0
- nado_protocol/utils/interest.py +66 -0
- nado_protocol/utils/math.py +67 -0
- nado_protocol/utils/model.py +79 -0
- nado_protocol/utils/nonce.py +33 -0
- nado_protocol/utils/subaccount.py +18 -0
- nado_protocol/utils/time.py +21 -0
- nado_protocol-0.1.0.dist-info/METADATA +157 -0
- nado_protocol-0.1.0.dist-info/RECORD +78 -0
- nado_protocol-0.1.0.dist-info/WHEEL +4 -0
- nado_protocol-0.1.0.dist-info/entry_points.txt +11 -0
|
File without changes
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from nado_protocol.client.apis.market import MarketAPI
|
|
3
|
+
from nado_protocol.client.apis.perp import PerpAPI
|
|
4
|
+
from nado_protocol.client.apis.spot import SpotAPI
|
|
5
|
+
from nado_protocol.client.apis.subaccount import SubaccountAPI
|
|
6
|
+
from nado_protocol.client.apis.rewards import RewardsAPI
|
|
7
|
+
from nado_protocol.client.context import (
|
|
8
|
+
NadoClientContext,
|
|
9
|
+
NadoClientContextOpts,
|
|
10
|
+
create_nado_client_context,
|
|
11
|
+
)
|
|
12
|
+
from nado_protocol.contracts import NadoContractsContext
|
|
13
|
+
from nado_protocol.contracts.loader import load_deployment
|
|
14
|
+
from nado_protocol.contracts.types import NadoNetwork
|
|
15
|
+
from nado_protocol.utils.backend import NadoBackendURL, Signer
|
|
16
|
+
from nado_protocol.utils.enum import StrEnum
|
|
17
|
+
from nado_protocol.client.context import *
|
|
18
|
+
|
|
19
|
+
from pydantic import parse_obj_as
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class NadoClientMode(StrEnum):
|
|
23
|
+
"""
|
|
24
|
+
NadoClientMode is an enumeration representing the operational modes of the NadoClient.
|
|
25
|
+
|
|
26
|
+
Attributes:
|
|
27
|
+
DEVNET: For local development.
|
|
28
|
+
|
|
29
|
+
TESTING: For running tests.
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
# dev
|
|
33
|
+
DEVNET = "devnet"
|
|
34
|
+
TESTING = "testing"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class NadoClient:
|
|
38
|
+
"""
|
|
39
|
+
The primary client interface for interacting with Nado Protocol.
|
|
40
|
+
|
|
41
|
+
This client consolidates the functionality of various aspects of Nado such as spot, market,
|
|
42
|
+
subaccount, and perpetual (perp) operations.
|
|
43
|
+
|
|
44
|
+
To initialize an instance of this client, use the `create_nado_client` utility.
|
|
45
|
+
|
|
46
|
+
Attributes:
|
|
47
|
+
- context (NadoClientContext): The client context containing configuration for interacting with Nado.
|
|
48
|
+
- market (MarketAPI): Sub-client for executing and querying market operations.
|
|
49
|
+
- subaccount (SubaccountAPI): Sub-client for executing and querying subaccount operations.
|
|
50
|
+
- spot (SpotAPI): Sub-client for executing and querying spot operations.
|
|
51
|
+
- perp (PerpAPI): Sub-client for executing and querying perpetual operations.
|
|
52
|
+
- rewards (RewardsAPI): Sub-client for executing and querying rewards operations (e.g: staking, claiming, etc).
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
context: NadoClientContext
|
|
56
|
+
market: MarketAPI
|
|
57
|
+
subaccount: SubaccountAPI
|
|
58
|
+
spot: SpotAPI
|
|
59
|
+
perp: PerpAPI
|
|
60
|
+
rewards: RewardsAPI
|
|
61
|
+
|
|
62
|
+
def __init__(self, context: NadoClientContext):
|
|
63
|
+
"""
|
|
64
|
+
Initialize a new instance of the NadoClient.
|
|
65
|
+
|
|
66
|
+
This constructor should not be called directly. Instead, use the `create_nado_client` utility to
|
|
67
|
+
create a new NadoClient. This is because the `create_nado_client` utility includes important
|
|
68
|
+
additional setup steps that aren't included in this constructor.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
context (NadoClientContext): The client context.
|
|
72
|
+
|
|
73
|
+
Note:
|
|
74
|
+
Use `create_nado_client` for creating instances.
|
|
75
|
+
"""
|
|
76
|
+
self.context = context
|
|
77
|
+
self.market = MarketAPI(context)
|
|
78
|
+
self.subaccount = SubaccountAPI(context)
|
|
79
|
+
self.spot = SpotAPI(context)
|
|
80
|
+
self.perp = PerpAPI(context)
|
|
81
|
+
self.rewards = RewardsAPI(context)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def create_nado_client(
|
|
85
|
+
mode: NadoClientMode,
|
|
86
|
+
signer: Optional[Signer] = None,
|
|
87
|
+
context_opts: Optional[NadoClientContextOpts] = None,
|
|
88
|
+
) -> NadoClient:
|
|
89
|
+
"""
|
|
90
|
+
Create a new NadoClient based on the given mode and signer.
|
|
91
|
+
|
|
92
|
+
This function will create a new NadoClientContext based on the provided mode, and then
|
|
93
|
+
initialize a new NadoClient with that context.
|
|
94
|
+
|
|
95
|
+
If `context_opts` are provided, they will be used to create the client context. Otherwise,
|
|
96
|
+
default context options for the given mode will be used.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
mode (NadoClientMode): The mode in which to operate the client. Can be one of the following:
|
|
100
|
+
NadoClientMode.DEVNET: For local development.
|
|
101
|
+
|
|
102
|
+
signer (Signer, optional): An instance of LocalAccount or a private key string for signing transactions.
|
|
103
|
+
|
|
104
|
+
context_opts (NadoClientContextOpts, optional): Options for creating the client context.
|
|
105
|
+
If not provided, default options for the given mode will be used.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
NadoClient: The created NadoClient instance.
|
|
109
|
+
"""
|
|
110
|
+
logging.info(f"Initializing default {mode} context")
|
|
111
|
+
(
|
|
112
|
+
engine_endpoint_url,
|
|
113
|
+
indexer_endpoint_url,
|
|
114
|
+
trigger_endpoint_url,
|
|
115
|
+
network_name,
|
|
116
|
+
) = client_mode_to_setup(mode)
|
|
117
|
+
try:
|
|
118
|
+
network = NadoNetwork(network_name)
|
|
119
|
+
deployment = load_deployment(network)
|
|
120
|
+
rpc_node_url = deployment.node_url
|
|
121
|
+
contracts_context = NadoContractsContext(
|
|
122
|
+
network=network,
|
|
123
|
+
endpoint_addr=deployment.endpoint_addr,
|
|
124
|
+
querier_addr=deployment.querier_addr,
|
|
125
|
+
perp_engine_addr=deployment.perp_engine_addr,
|
|
126
|
+
spot_engine_addr=deployment.spot_engine_addr,
|
|
127
|
+
clearinghouse_addr=deployment.clearinghouse_addr,
|
|
128
|
+
vrtx_airdrop_addr=deployment.vrtx_airdrop_addr,
|
|
129
|
+
vrtx_staking_addr=deployment.vrtx_staking_addr,
|
|
130
|
+
foundation_rewards_airdrop_addr=deployment.foundation_rewards_airdrop_addr,
|
|
131
|
+
)
|
|
132
|
+
except Exception as e:
|
|
133
|
+
logging.warning(
|
|
134
|
+
f"Failed to load contracts for mode {mode} with error: {e}, using provided defaults."
|
|
135
|
+
)
|
|
136
|
+
assert context_opts is not None and context_opts.rpc_node_url is not None
|
|
137
|
+
assert context_opts is not None and context_opts.contracts_context is not None
|
|
138
|
+
|
|
139
|
+
rpc_node_url = context_opts.rpc_node_url
|
|
140
|
+
contracts_context = context_opts.contracts_context
|
|
141
|
+
|
|
142
|
+
if context_opts:
|
|
143
|
+
parsed_context_opts: NadoClientContextOpts = NadoClientContextOpts.parse_obj(
|
|
144
|
+
context_opts
|
|
145
|
+
)
|
|
146
|
+
engine_endpoint_url = (
|
|
147
|
+
parsed_context_opts.engine_endpoint_url or engine_endpoint_url
|
|
148
|
+
)
|
|
149
|
+
indexer_endpoint_url = (
|
|
150
|
+
parsed_context_opts.indexer_endpoint_url or indexer_endpoint_url
|
|
151
|
+
)
|
|
152
|
+
trigger_endpoint_url = (
|
|
153
|
+
parsed_context_opts.trigger_endpoint_url or trigger_endpoint_url
|
|
154
|
+
)
|
|
155
|
+
rpc_node_url = parsed_context_opts.rpc_node_url or rpc_node_url
|
|
156
|
+
contracts_context = parsed_context_opts.contracts_context or contracts_context
|
|
157
|
+
|
|
158
|
+
context = create_nado_client_context(
|
|
159
|
+
NadoClientContextOpts(
|
|
160
|
+
rpc_node_url=rpc_node_url,
|
|
161
|
+
engine_endpoint_url=parse_obj_as(AnyUrl, engine_endpoint_url),
|
|
162
|
+
indexer_endpoint_url=parse_obj_as(AnyUrl, indexer_endpoint_url),
|
|
163
|
+
trigger_endpoint_url=parse_obj_as(AnyUrl, trigger_endpoint_url),
|
|
164
|
+
contracts_context=contracts_context,
|
|
165
|
+
),
|
|
166
|
+
signer,
|
|
167
|
+
)
|
|
168
|
+
return NadoClient(context)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def client_mode_to_setup(
|
|
172
|
+
client_mode: NadoClientMode,
|
|
173
|
+
) -> tuple[str, str, str, str]:
|
|
174
|
+
try:
|
|
175
|
+
return {
|
|
176
|
+
NadoClientMode.DEVNET: (
|
|
177
|
+
NadoBackendURL.DEVNET_GATEWAY.value,
|
|
178
|
+
NadoBackendURL.DEVNET_INDEXER.value,
|
|
179
|
+
NadoBackendURL.DEVNET_TRIGGER.value,
|
|
180
|
+
NadoNetwork.HARDHAT.value,
|
|
181
|
+
),
|
|
182
|
+
NadoClientMode.TESTING: (
|
|
183
|
+
NadoBackendURL.DEVNET_GATEWAY.value,
|
|
184
|
+
NadoBackendURL.DEVNET_INDEXER.value,
|
|
185
|
+
NadoBackendURL.DEVNET_TRIGGER.value,
|
|
186
|
+
NadoNetwork.TESTING.value,
|
|
187
|
+
),
|
|
188
|
+
}[client_mode]
|
|
189
|
+
except KeyError:
|
|
190
|
+
raise Exception(f"Mode provided `{client_mode}` not supported!")
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
__all__ = [
|
|
194
|
+
"NadoClient",
|
|
195
|
+
"NadoClientMode",
|
|
196
|
+
"create_nado_client",
|
|
197
|
+
"NadoClientContext",
|
|
198
|
+
"NadoClientContextOpts",
|
|
199
|
+
"create_nado_client_context",
|
|
200
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from nado_protocol.client.apis.base import *
|
|
2
|
+
from nado_protocol.client.apis.market import *
|
|
3
|
+
from nado_protocol.client.apis.perp import *
|
|
4
|
+
from nado_protocol.client.apis.spot import *
|
|
5
|
+
from nado_protocol.client.apis.spot.base import *
|
|
6
|
+
from nado_protocol.client.apis.subaccount import *
|
|
7
|
+
from nado_protocol.client.apis.rewards import *
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"NadoBaseAPI",
|
|
11
|
+
"MarketAPI",
|
|
12
|
+
"MarketExecuteAPI",
|
|
13
|
+
"MarketQueryAPI",
|
|
14
|
+
"SpotAPI",
|
|
15
|
+
"BaseSpotAPI",
|
|
16
|
+
"SpotExecuteAPI",
|
|
17
|
+
"SpotQueryAPI",
|
|
18
|
+
"SubaccountAPI",
|
|
19
|
+
"SubaccountExecuteAPI",
|
|
20
|
+
"SubaccountQueryAPI",
|
|
21
|
+
"PerpAPI",
|
|
22
|
+
"PerpQueryAPI",
|
|
23
|
+
"RewardsAPI",
|
|
24
|
+
"RewardsExecuteAPI",
|
|
25
|
+
"RewardsQueryAPI",
|
|
26
|
+
]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from nado_protocol.client.context import NadoClientContext
|
|
3
|
+
from nado_protocol.utils.exceptions import MissingSignerException
|
|
4
|
+
from eth_account.signers.local import LocalAccount
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class NadoBaseAPI:
|
|
8
|
+
"""
|
|
9
|
+
The base class for all Nado API classes, providing the foundation for API-specific classes in the Nado client.
|
|
10
|
+
|
|
11
|
+
NadoBaseAPI serves as a foundation for the hierarchical structure of the Nado API classes. This structure allows for better
|
|
12
|
+
organization and separation of concerns, with each API-specific subclass handling a different aspect of the Nado client's functionality.
|
|
13
|
+
|
|
14
|
+
Attributes:
|
|
15
|
+
context (NadoClientContext): The context in which the API operates, providing access to the client's state and services.
|
|
16
|
+
|
|
17
|
+
Note:
|
|
18
|
+
This class is not meant to be used directly. It provides base functionality for other API classes in the Nado client.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
context: NadoClientContext
|
|
22
|
+
|
|
23
|
+
def __init__(self, context: NadoClientContext):
|
|
24
|
+
"""
|
|
25
|
+
Initialize an instance of NadoBaseAPI.
|
|
26
|
+
|
|
27
|
+
NadoBaseAPI requires a context during instantiation, which should be an instance of NadoClientContext. This context
|
|
28
|
+
provides access to the state and services of the Nado client and allows the API to interact with these.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
context (NadoClientContext): The context in which this API operates. Provides access to the state and services
|
|
32
|
+
of the Nado client.
|
|
33
|
+
"""
|
|
34
|
+
self.context = context
|
|
35
|
+
|
|
36
|
+
def _get_signer(self, signer: Optional[LocalAccount]) -> LocalAccount:
|
|
37
|
+
signer = signer if signer else self.context.signer
|
|
38
|
+
if not signer:
|
|
39
|
+
raise MissingSignerException(
|
|
40
|
+
"A signer must be provided or set via the context."
|
|
41
|
+
)
|
|
42
|
+
return signer
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from nado_protocol.client.apis.market.execute import MarketExecuteAPI
|
|
2
|
+
from nado_protocol.client.apis.market.query import MarketQueryAPI
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class MarketAPI(MarketExecuteAPI, MarketQueryAPI):
|
|
6
|
+
"""
|
|
7
|
+
A unified interface for market operations in the Nado Protocol.
|
|
8
|
+
|
|
9
|
+
This class combines functionalities from both MarketExecuteAPI and MarketQueryAPI
|
|
10
|
+
into a single interface, providing a simpler and more consistent way to perform market operations.
|
|
11
|
+
It allows for both query (data retrieval) and execution (transaction) operations for market.
|
|
12
|
+
|
|
13
|
+
Inheritance:
|
|
14
|
+
MarketExecuteAPI: This provides functionalities to execute various operations related to market.
|
|
15
|
+
These include actions like placing an order, canceling an order, minting and burning LP tokens.
|
|
16
|
+
|
|
17
|
+
MarketQueryAPI: This provides functionalities to retrieve various kinds of information related to market.
|
|
18
|
+
These include operations like retrieving order books, historical orders, market matches, and others.
|
|
19
|
+
|
|
20
|
+
Attributes and Methods: Inherited from MarketExecuteAPI and MarketQueryAPI.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
pass
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
from nado_protocol.engine_client.types.execute import (
|
|
2
|
+
BurnLpParams,
|
|
3
|
+
CancelAndPlaceParams,
|
|
4
|
+
CancelOrdersParams,
|
|
5
|
+
CancelProductOrdersParams,
|
|
6
|
+
ExecuteResponse,
|
|
7
|
+
MintLpParams,
|
|
8
|
+
PlaceMarketOrderParams,
|
|
9
|
+
PlaceOrderParams,
|
|
10
|
+
PlaceIsolatedOrderParams,
|
|
11
|
+
)
|
|
12
|
+
from nado_protocol.client.apis.base import NadoBaseAPI
|
|
13
|
+
from nado_protocol.trigger_client.types.execute import (
|
|
14
|
+
PlaceTriggerOrderParams,
|
|
15
|
+
CancelTriggerOrdersParams,
|
|
16
|
+
CancelProductTriggerOrdersParams,
|
|
17
|
+
)
|
|
18
|
+
from nado_protocol.utils.exceptions import MissingTriggerClient
|
|
19
|
+
from nado_protocol.utils.subaccount import Subaccount
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class MarketExecuteAPI(NadoBaseAPI):
|
|
23
|
+
"""
|
|
24
|
+
Provides functionality to interact with the Nado's market execution APIs.
|
|
25
|
+
This class contains methods that allow clients to execute operations such as minting LP tokens, burning LP tokens,
|
|
26
|
+
placing and cancelling orders on the Nado market.
|
|
27
|
+
|
|
28
|
+
Attributes:
|
|
29
|
+
context (NadoClientContext): The context that provides connectivity configuration for NadoClient.
|
|
30
|
+
|
|
31
|
+
Note:
|
|
32
|
+
This class should not be instantiated directly, it is designed to be used through a NadoClient instance.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def mint_lp(self, params: MintLpParams) -> ExecuteResponse:
|
|
36
|
+
"""
|
|
37
|
+
Mint LP tokens through the engine.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
params (MintLpParams): Parameters required to mint LP tokens.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
ExecuteResponse: The response from the engine execution.
|
|
44
|
+
|
|
45
|
+
Raises:
|
|
46
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
47
|
+
"""
|
|
48
|
+
return self.context.engine_client.mint_lp(params)
|
|
49
|
+
|
|
50
|
+
def burn_lp(self, params: BurnLpParams) -> ExecuteResponse:
|
|
51
|
+
"""
|
|
52
|
+
Burn LP tokens through the engine.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
params (BurnLpParams): Parameters required to burn LP tokens.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
ExecuteResponse: The response from the engine execution.
|
|
59
|
+
|
|
60
|
+
Raises:
|
|
61
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
62
|
+
"""
|
|
63
|
+
return self.context.engine_client.burn_lp(params)
|
|
64
|
+
|
|
65
|
+
def place_order(self, params: PlaceOrderParams) -> ExecuteResponse:
|
|
66
|
+
"""
|
|
67
|
+
Places an order through the engine.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
params (PlaceOrderParams): Parameters required to place an order.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
ExecuteResponse: The response from the engine execution.
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
77
|
+
"""
|
|
78
|
+
return self.context.engine_client.place_order(params)
|
|
79
|
+
|
|
80
|
+
def place_isolated_order(self, params: PlaceIsolatedOrderParams) -> ExecuteResponse:
|
|
81
|
+
"""
|
|
82
|
+
Places an isolated order through the engine.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
params (PlaceIsolatedOrderParams): Parameters required to place an isolated order.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
ExecuteResponse: The response from the engine execution.
|
|
89
|
+
|
|
90
|
+
Raises:
|
|
91
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
92
|
+
"""
|
|
93
|
+
return self.context.engine_client.place_isolated_order(params)
|
|
94
|
+
|
|
95
|
+
def place_market_order(self, params: PlaceMarketOrderParams) -> ExecuteResponse:
|
|
96
|
+
"""
|
|
97
|
+
Places a market order through the engine.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
params (PlaceMarketOrderParams): Parameters required to place a market order.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
ExecuteResponse: The response from the engine execution.
|
|
104
|
+
|
|
105
|
+
Raises:
|
|
106
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
107
|
+
"""
|
|
108
|
+
return self.context.engine_client.place_market_order(params)
|
|
109
|
+
|
|
110
|
+
def cancel_orders(self, params: CancelOrdersParams) -> ExecuteResponse:
|
|
111
|
+
"""
|
|
112
|
+
Cancels orders through the engine.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
params (CancelOrdersParams): Parameters required to cancel orders.
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
ExecuteResponse: The response from the engine execution containing information about the canceled product orders.
|
|
119
|
+
|
|
120
|
+
Raises:
|
|
121
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
122
|
+
"""
|
|
123
|
+
return self.context.engine_client.cancel_orders(params)
|
|
124
|
+
|
|
125
|
+
def cancel_product_orders(
|
|
126
|
+
self, params: CancelProductOrdersParams
|
|
127
|
+
) -> ExecuteResponse:
|
|
128
|
+
"""
|
|
129
|
+
Cancels all orders for provided products through the engine.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
params (CancelProductOrdersParams): Parameters required to cancel product orders.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
ExecuteResponse: The response from the engine execution containing information about the canceled product orders.
|
|
136
|
+
|
|
137
|
+
Raises:
|
|
138
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
139
|
+
"""
|
|
140
|
+
return self.context.engine_client.cancel_product_orders(params)
|
|
141
|
+
|
|
142
|
+
def cancel_and_place(self, params: CancelAndPlaceParams) -> ExecuteResponse:
|
|
143
|
+
"""
|
|
144
|
+
Cancels orders and places a new one through the engine on the same request.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
params (CancelAndPlaceParams): Parameters required to cancel orders and place a new one.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
ExecuteResponse: The response from the engine execution.
|
|
151
|
+
|
|
152
|
+
Raises:
|
|
153
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
154
|
+
"""
|
|
155
|
+
return self.context.engine_client.cancel_and_place(params)
|
|
156
|
+
|
|
157
|
+
def close_position(
|
|
158
|
+
self, subaccount: Subaccount, product_id: int
|
|
159
|
+
) -> ExecuteResponse:
|
|
160
|
+
"""
|
|
161
|
+
Places an order through the engine to close a position for the provided `product_id`.
|
|
162
|
+
|
|
163
|
+
Attributes:
|
|
164
|
+
subaccount (Subaccount): The subaccount to close position for.
|
|
165
|
+
product_id (int): The ID of the product to close position for.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
ExecuteResponse: The response from the engine execution.
|
|
169
|
+
|
|
170
|
+
Raises:
|
|
171
|
+
Exception: If there is an error during the execution or the response status is not "success".
|
|
172
|
+
"""
|
|
173
|
+
return self.context.engine_client.close_position(subaccount, product_id)
|
|
174
|
+
|
|
175
|
+
def place_trigger_order(self, params: PlaceTriggerOrderParams) -> ExecuteResponse:
|
|
176
|
+
if self.context.trigger_client is None:
|
|
177
|
+
raise MissingTriggerClient()
|
|
178
|
+
return self.context.trigger_client.place_trigger_order(params)
|
|
179
|
+
|
|
180
|
+
def cancel_trigger_orders(
|
|
181
|
+
self, params: CancelTriggerOrdersParams
|
|
182
|
+
) -> ExecuteResponse:
|
|
183
|
+
if self.context.trigger_client is None:
|
|
184
|
+
raise MissingTriggerClient()
|
|
185
|
+
return self.context.trigger_client.cancel_trigger_orders(params)
|
|
186
|
+
|
|
187
|
+
def cancel_trigger_product_orders(
|
|
188
|
+
self, params: CancelProductTriggerOrdersParams
|
|
189
|
+
) -> ExecuteResponse:
|
|
190
|
+
if self.context.trigger_client is None:
|
|
191
|
+
raise MissingTriggerClient()
|
|
192
|
+
return self.context.trigger_client.cancel_product_trigger_orders(params)
|