Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/source/user-guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ You can build the expected EIP-712 typed data for each execute via :mod:`nado_pr
>>> order = OrderParams(amount=to_x18(20000), priceX18=to_pow_10(1, 17), expiration=order_expiration, nonce=order_nonce, sender=sender, appendix=appendix)
>>> order_typed_data = build_eip712_typed_data(NadoExecuteType.PLACE_ORDER, order.dict(), verifying_contract, chain_id)

**Market Order Example:**


``place_market_order`` is synchronous and returns an ``ExecuteResponse`` directly. Do not await the call. The ``sender`` field must be a ``SubaccountParams`` instance, not a plain wallet address string.

.. code-block:: python

>>> from nado_protocol.engine_client.types import PlaceMarketOrderParams
>>> from nado_protocol.utils.execute import MarketOrderParams
>>> from nado_protocol.utils.subaccount import SubaccountParams
>>> # ``client`` is an initialized NadoClient instance.
>>> sender = SubaccountParams(subaccount_owner="0xYourWalletAddress", subaccount_name="default")
>>> market_order = MarketOrderParams(sender=sender, amount=1)
>>> params = PlaceMarketOrderParams(product_id=1, market_order=market_order)
>>> response = client.market.place_market_order(params)

**Other Execute Types Example:**

.. code-block:: python
Expand Down
2 changes: 2 additions & 0 deletions nado_protocol/client/apis/market/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ def place_market_order(self, params: PlaceMarketOrderParams) -> ExecuteResponse:
"""
Places a market order through the engine.

This method is synchronous. Do not use ``await`` with the return value.

Args:
params (PlaceMarketOrderParams): Parameters required to place a market order.

Expand Down
4 changes: 4 additions & 0 deletions nado_protocol/utils/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ class MarketOrderParams(BaseParams):
"""
Class for defining the parameters of a market order.

The ``sender`` field inherited from ``BaseParams`` must be a
``SubaccountParams`` instance. A plain wallet address string is not valid
for this parameter.

Attributes:
amount (int): The amount of the asset to be bought or sold in the order. Positive for a `long` position and negative for a `short`.

Expand Down