Skip to content

Commit f1209dc

Browse files
committed
feat: post only order + cancel all
1 parent a7e78f7 commit f1209dc

File tree

4 files changed

+45
-4
lines changed

4 files changed

+45
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "deltadefi"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "Python SDK for DeltaDeFi protocol."
55
readme = "README.md"
66
requires-python = ">3.11,<4.0.0"

src/deltadefi/clients/orders.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from deltadefi.api import API
22
from deltadefi.models.models import OrderSide, OrderType
33
from deltadefi.responses import (
4+
BuildCancelAllOrdersTransactionResponse,
45
BuildCancelOrderTransactionResponse,
56
BuildPlaceOrderTransactionResponse,
7+
SubmitCancelAllOrdersTransactionResponse,
68
SubmitPlaceOrderTransactionResponse,
79
)
810
from deltadefi.utils import check_required_parameter, check_required_parameters
@@ -86,14 +88,28 @@ def build_cancel_order_transaction(
8688
url_path = f"/{order_id}/build"
8789
return self.send_request("DELETE", self.group_url_path + url_path, **kwargs)
8890

91+
def build_cancel_all_orders_transaction(
92+
self, **kwargs
93+
) -> BuildCancelAllOrdersTransactionResponse:
94+
"""
95+
Build a cancel all orders transaction.
96+
97+
Returns:
98+
A BuildCancelAllOrdersTransactionResponse object containing the built cancel all orders transaction.
99+
"""
100+
101+
url_path = "/cancel-all/build"
102+
return self.send_request("DELETE", self.group_url_path + url_path, **kwargs)
103+
89104
def submit_place_order_transaction(
90105
self, order_id: str, signed_tx: str, **kwargs
91106
) -> SubmitPlaceOrderTransactionResponse:
92107
"""
93108
Submit a place order transaction.
94109
95110
Args:
96-
data: A SubmitPlaceOrderTransactionRequest object containing the order details.
111+
order_id: The ID of the order to be placed.
112+
signed_tx: The signed transaction hex string for placing the order.
97113
98114
Returns:
99115
A SubmitPlaceOrderTransactionResponse object containing the submitted order transaction.
@@ -109,10 +125,25 @@ def submit_cancel_order_transaction(self, signed_tx: str, **kwargs):
109125
Submit a cancel order transaction.
110126
111127
Args:
112-
data: A SubmitCancelOrderTransactionRequest object containing the cancel order details.
128+
signed_tx: The signed transaction hex string for canceling the order.
113129
"""
114130
check_required_parameter(signed_tx, "signed_tx")
115131
payload = {"signed_tx": signed_tx, **kwargs}
116132

117133
path_url = "/submit"
118134
return self.send_request("DELETE", self.group_url_path + path_url, payload)
135+
136+
def submit_cancel_all_orders_transaction(
137+
self, signed_txs: list[str], **kwargs
138+
) -> SubmitCancelAllOrdersTransactionResponse:
139+
"""
140+
Submit a cancel all orders transaction.
141+
142+
Args:
143+
signed_txs: A list of signed transaction hex strings for canceling all orders.
144+
"""
145+
check_required_parameter(signed_txs, "signed_txs")
146+
payload = {"signed_txs": signed_txs, **kwargs}
147+
148+
path_url = "/cancel-all/submit"
149+
return self.send_request("DELETE", self.group_url_path + path_url, payload)

src/deltadefi/responses/responses.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,13 @@ class PostOrderResponse(SubmitPlaceOrderTransactionResponse):
6161
@dataclass
6262
class BuildCancelOrderTransactionResponse(TypedDict):
6363
tx_hex: str
64+
65+
66+
@dataclass
67+
class BuildCancelAllOrdersTransactionResponse(TypedDict):
68+
tx_hexes: list[str]
69+
70+
71+
@dataclass
72+
class SubmitCancelAllOrdersTransactionResponse(TypedDict):
73+
cancelled_order_ids: list[str]

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)