deltadefi 0.0.6__py3-none-any.whl → 0.0.8__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.

Potentially problematic release.


This version of deltadefi might be problematic. Click here for more details.

@@ -16,6 +16,7 @@ from deltadefi.responses import (
16
16
  SubmitDepositTransactionResponse,
17
17
  SubmitWithdrawalTransactionResponse,
18
18
  )
19
+ from deltadefi.responses.accounts import GetOperationKeyResponse
19
20
 
20
21
 
21
22
  class Accounts(API):
@@ -28,6 +29,17 @@ class Accounts(API):
28
29
  def __init__(self, api_key=None, base_url=None, **kwargs):
29
30
  super().__init__(api_key=api_key, base_url=base_url, **kwargs)
30
31
 
32
+ def get_operation_key(self, **kwargs) -> GetOperationKeyResponse:
33
+ """
34
+ Get the encrypted operation key.
35
+
36
+ Returns:
37
+ A GetOperationKeyResponse object containing the encrypted operation key and its hash.
38
+ """
39
+
40
+ url_path = "/operation-key"
41
+ return self.send_request("GET", self.group_url_path + url_path, kwargs)
42
+
31
43
  def create_new_api_key(self, **kwargs) -> CreateNewAPIKeyResponse:
32
44
  """
33
45
  Create a new API key.
@@ -1,10 +1,11 @@
1
1
  # flake8: noqa: E501
2
- from sidan_gin import HDWallet
2
+ from sidan_gin import Wallet
3
3
 
4
4
  from deltadefi.clients.accounts import Accounts
5
5
  from deltadefi.clients.app import App
6
6
  from deltadefi.clients.market import Market
7
7
  from deltadefi.clients.order import Order
8
+ from deltadefi.models.models import OrderSide, OrderType
8
9
  from deltadefi.responses import PostOrderResponse
9
10
 
10
11
 
@@ -17,7 +18,7 @@ class ApiClient:
17
18
  self,
18
19
  network: str = "preprod",
19
20
  api_key: str = None,
20
- wallet: HDWallet = None,
21
+ wallet: Wallet = None,
21
22
  base_url: str = None,
22
23
  ):
23
24
  """
@@ -25,31 +26,39 @@ class ApiClient:
25
26
 
26
27
  Args:
27
28
  config: An instance of ApiConfig containing the API configuration.
28
- wallet: An instance of HDWallet for signing transactions.
29
+ wallet: An instance of Wallet for signing transactions.
29
30
  base_url: Optional; The base URL for the API. Defaults to "https://api-dev.deltadefi.io".
30
31
  """
31
32
  if network == "mainnet":
32
33
  self.network_id = 1
33
- base_url = "https://api-dev.deltadefi.io" # TODO: input production link once available
34
+ self.base_url = "https://api-dev.deltadefi.io" # TODO: input production link once available
34
35
  else:
35
36
  self.network_id = 0
36
- base_url = "https://api-dev.deltadefi.io"
37
+ self.base_url = "https://api-staging.deltadefi.io"
38
+
39
+ if base_url:
40
+ self.base_url = base_url
37
41
 
38
42
  self.api_key = api_key
39
43
  self.wallet = wallet
40
- self.base_url = base_url
41
44
 
42
45
  self.accounts = Accounts(base_url=base_url, api_key=api_key)
43
46
  self.app = App(base_url=base_url, api_key=api_key)
44
47
  self.order = Order(base_url=base_url, api_key=api_key)
45
48
  self.market = Market(base_url=base_url, api_key=api_key)
46
49
 
47
- async def post_order(self, **kwargs) -> PostOrderResponse:
50
+ def post_order(
51
+ self, symbol: str, side: OrderSide, type: OrderType, quantity: int, **kwargs
52
+ ) -> PostOrderResponse:
48
53
  """
49
- Post an order to the DeltaDeFi API.
54
+ Post an order to the DeltaDeFi API. It includes building the transaction, signing it with the wallet, and submitting it.
50
55
 
51
56
  Args:
52
- data: A PostOrderRequest object containing the order details.
57
+ symbol: The trading pair symbol (e.g., "BTC-USD").
58
+ side: The side of the order (e.g., "buy" or "sell").
59
+ type: The type of the order (e.g., "limit" or "market").
60
+ quantity: The quantity of the asset to be traded.
61
+ **kwargs: Additional parameters for the order, such as price, limit_slippage, etc.
53
62
 
54
63
  Returns:
55
64
  A PostOrderResponse object containing the response from the API.
@@ -57,10 +66,19 @@ class ApiClient:
57
66
  Raises:
58
67
  ValueError: If the wallet is not initialized.
59
68
  """
69
+ print(
70
+ f"post_order: symbol={symbol}, side={side}, type={type}, quantity={quantity}, kwargs={kwargs}"
71
+ )
60
72
  if not hasattr(self, "wallet") or self.wallet is None:
61
73
  raise ValueError("Wallet is not initialized")
62
74
 
63
- build_res = "" # TODO: import wallet build order
75
+ build_res = self.order.build_place_order_transaction(
76
+ symbol, side, type, quantity, **kwargs
77
+ )
78
+ print(f"build_res: {build_res}")
64
79
  signed_tx = self.wallet.sign_tx(build_res["tx_hex"])
65
- submit_res = signed_tx + "" # TODO: import wallet submit tx
80
+ submit_res = self.order.submit_place_order_transaction(
81
+ build_res["order_id"], signed_tx, **kwargs
82
+ )
83
+ print(f"submit_res: {submit_res}")
66
84
  return submit_res
@@ -31,7 +31,11 @@ class Order(API):
31
31
  Build a place order transaction.
32
32
 
33
33
  Args:
34
- data: A BuildPlaceOrderTransactionRequest object containing the order details.
34
+ symbol: The trading pair symbol (e.g., "BTC-USD").
35
+ side: The side of the order (e.g., "buy" or "sell").
36
+ type: The type of the order (e.g., "limit" or "market").
37
+ quantity: The quantity of the asset to be traded.
38
+ **kwargs: Additional parameters for the order, such as price, limit_slippage, etc.
35
39
 
36
40
  Returns:
37
41
  A BuildPlaceOrderTransactionResponse object containing the built order transaction.
@@ -1,5 +1,5 @@
1
1
  from dataclasses import dataclass
2
- from typing import List
2
+ from typing import List, TypedDict
3
3
 
4
4
  from deltadefi.models.models import (
5
5
  AssetBalance,
@@ -10,17 +10,23 @@ from deltadefi.models.models import (
10
10
 
11
11
 
12
12
  @dataclass
13
- class CreateNewAPIKeyResponse:
13
+ class CreateNewAPIKeyResponse(TypedDict):
14
14
  api_key: str
15
15
 
16
16
 
17
17
  @dataclass
18
- class BuildDepositTransactionResponse:
18
+ class GetOperationKeyResponse(TypedDict):
19
+ encrypted_operation_key: str
20
+ operation_key_hash: str
21
+
22
+
23
+ @dataclass
24
+ class BuildDepositTransactionResponse(TypedDict):
19
25
  tx_hex: str
20
26
 
21
27
 
22
28
  @dataclass
23
- class SubmitDepositTransactionResponse:
29
+ class SubmitDepositTransactionResponse(TypedDict):
24
30
  tx_hash: str
25
31
 
26
32
 
@@ -35,22 +41,22 @@ class GetWithdrawalRecordsResponse(List[WithdrawalRecord]):
35
41
 
36
42
 
37
43
  @dataclass
38
- class GetOrderRecordResponse:
44
+ class GetOrderRecordResponse(TypedDict):
39
45
  orders: List[OrderJSON]
40
46
 
41
47
 
42
48
  @dataclass
43
- class BuildWithdrawalTransactionResponse:
49
+ class BuildWithdrawalTransactionResponse(TypedDict):
44
50
  tx_hex: str
45
51
 
46
52
 
47
53
  @dataclass
48
- class SubmitWithdrawalTransactionResponse:
54
+ class SubmitWithdrawalTransactionResponse(TypedDict):
49
55
  tx_hash: str
50
56
 
51
57
 
52
58
  @dataclass
53
- class GetAccountInfoResponse:
59
+ class GetAccountInfoResponse(TypedDict):
54
60
  api_key: str
55
61
  api_limit: int
56
62
  created_at: str
@@ -1,33 +1,33 @@
1
1
  from dataclasses import dataclass
2
- from typing import List
2
+ from typing import List, TypedDict
3
3
 
4
4
  from deltadefi.models import OrderJSON
5
5
 
6
6
 
7
7
  @dataclass
8
- class GetTermsAndConditionResponse:
8
+ class GetTermsAndConditionResponse(TypedDict):
9
9
  value: str
10
10
 
11
11
 
12
12
  @dataclass
13
- class MarketDepth:
13
+ class MarketDepth(TypedDict):
14
14
  price: float
15
15
  quantity: float
16
16
 
17
17
 
18
18
  @dataclass
19
- class GetMarketDepthResponse:
19
+ class GetMarketDepthResponse(TypedDict):
20
20
  bids: List[MarketDepth]
21
21
  asks: List[MarketDepth]
22
22
 
23
23
 
24
24
  @dataclass
25
- class GetMarketPriceResponse:
25
+ class GetMarketPriceResponse(TypedDict):
26
26
  price: float
27
27
 
28
28
 
29
29
  @dataclass
30
- class Trade:
30
+ class Trade(TypedDict):
31
31
  time: str
32
32
  symbol: str
33
33
  open: float
@@ -43,13 +43,13 @@ class GetAggregatedPriceResponse(List[Trade]):
43
43
 
44
44
 
45
45
  @dataclass
46
- class BuildPlaceOrderTransactionResponse:
46
+ class BuildPlaceOrderTransactionResponse(TypedDict):
47
47
  order_id: str
48
48
  tx_hex: str
49
49
 
50
50
 
51
51
  @dataclass
52
- class SubmitPlaceOrderTransactionResponse:
52
+ class SubmitPlaceOrderTransactionResponse(TypedDict):
53
53
  order: OrderJSON
54
54
 
55
55
 
@@ -59,10 +59,10 @@ class PostOrderResponse(SubmitPlaceOrderTransactionResponse):
59
59
 
60
60
 
61
61
  @dataclass
62
- class BuildCancelOrderTransactionResponse:
62
+ class BuildCancelOrderTransactionResponse(TypedDict):
63
63
  tx_hex: str
64
64
 
65
65
 
66
66
  @dataclass
67
- class SubmitCancelOrderTransactionResponse:
67
+ class SubmitCancelOrderTransactionResponse(TypedDict):
68
68
  tx_hash: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: deltadefi
3
- Version: 0.0.6
3
+ Version: 0.0.8
4
4
  Summary: Python SDK for DeltaDeFi protocol.
5
5
  License: Apache-2.0
6
6
  Keywords: cardano
@@ -16,10 +16,11 @@ Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Requires-Dist: certifi (==2024.8.30)
18
18
  Requires-Dist: charset-normalizer (==3.4.0)
19
+ Requires-Dist: dotenv (>=0.9.9,<0.10.0)
19
20
  Requires-Dist: idna (==3.10)
20
21
  Requires-Dist: pycardano (>=0.12.3,<0.13.0)
21
22
  Requires-Dist: requests (>=2.25,<3.0)
22
- Requires-Dist: sidan-gin (==0.1.1)
23
+ Requires-Dist: sidan-gin (==0.1.6)
23
24
  Requires-Dist: urllib3 (==2.2.3)
24
25
  Project-URL: Documentation, https://github.com/deltadefi-protocol/python-sdk
25
26
  Project-URL: Homepage, https://github.com/deltadefi-protocol/python-sdk
@@ -101,6 +102,16 @@ submit_order_response = api.order.submit_place_order_transaction(signed_tx="<sig
101
102
  print(submit_order_response)
102
103
  ```
103
104
 
105
+ ## Development
106
+
107
+ ### Tests
108
+
109
+ Testing sdk:
110
+
111
+ ```sh
112
+ DELTADEFI_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx make test
113
+ ```
114
+
104
115
  ## License
105
116
 
106
117
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>
@@ -4,11 +4,11 @@ deltadefi/api_resources/__init__.py,sha256=_SGHTpaQTIBvh9Rm868IT5pXpvvGBPqz3bxkY
4
4
  deltadefi/api_resources/auth.py,sha256=Mpl4Dbh_d_gGhwLo2CtBSKxZ21DC74x-qjVhlczZCDE,278
5
5
  deltadefi/api_resources/validation.py,sha256=vz-hovpLy9SMOIFGcBHC8vWZH8CJRlQP8rcbbTSM-PM,1375
6
6
  deltadefi/clients/__init__.py,sha256=AoK_kj_UKpxtCa3_if3yeHFAzHli9Mg-tsrUKOX7eH8,38
7
- deltadefi/clients/accounts.py,sha256=I3Yh82iHVK932u2Luvewbxk_KJ-WVLYqH048XBFgrsQ,5347
7
+ deltadefi/clients/accounts.py,sha256=i4Xjfb4KQH3VqrBbjZ4ovKJSf2nO2VzZm1KptHM5B4M,5781
8
8
  deltadefi/clients/app.py,sha256=TOgRlP83p91r7oS4ez8Gfm8soQzFHrJAmOHZJoGZ4SM,712
9
- deltadefi/clients/clients.py,sha256=Yzxkpf9-PA6LdYiJtmap1DrE3U5Sd4VNDGjexZxVbcs,2197
9
+ deltadefi/clients/clients.py,sha256=_ABwPM0dwzG9oEHY_oby3UOYJRZVNJOvaobvz2FcDDg,3064
10
10
  deltadefi/clients/market.py,sha256=v8hK06oXC73qS3IjvWDempHq_-9T6OW2pckIcDR7P2M,2580
11
- deltadefi/clients/order.py,sha256=kuv2mPnQeE-P66fylZEp9vXuqyhM26_MxKreY-VkoWo,3850
11
+ deltadefi/clients/order.py,sha256=grOcB_2Lr4yI3lrsctlGQd1JZwk_bV0K43jE3e2IRC4,4113
12
12
  deltadefi/constants/__init__.py,sha256=7LkrzfLTJsCCUl5IgZYrl-AbY_cf1fftcLklgnBYDTs,40
13
13
  deltadefi/constants/constants.py,sha256=9Ksb8_4t78KJpHVUnRArKlvgQk-CzcYsLRmA5qUnMwc,168
14
14
  deltadefi/error.py,sha256=Pq55p7FQbVn1GTih7NQBI7ZcVUUrlkaFKn-SwZUxBA8,1650
@@ -17,8 +17,8 @@ deltadefi/lib/utils.py,sha256=zuQFAKQphbGxDdPzBURw4A2n3AkRSbzmjMLHPLm9Ed4,1035
17
17
  deltadefi/models/__init__.py,sha256=oDJj6Y4gXN6C7Oz_t2fq8hej-D0G9OqfXjL4Jaeq8z8,37
18
18
  deltadefi/models/models.py,sha256=vnNFFPMQcOOSKhONHNHXJIx4wddV4IKeBszykiqWCwk,1182
19
19
  deltadefi/responses/__init__.py,sha256=JKSIUQu6qI_XhbAR2mVMCKNvR6x_vFZdyLGOuQTVrVY,64
20
- deltadefi/responses/accounts.py,sha256=aVQq1CqebIQz0YuNphFlA2fGBgvmf8FpboJzToEiY2g,939
21
- deltadefi/responses/responses.py,sha256=etlx83GgZC2noLKo8GKrmDo3Xhwup-g8Ob29f0WYA4I,993
22
- deltadefi-0.0.6.dist-info/METADATA,sha256=63Xkio2msUWQkRKcqLU5u7sjRzYNoV-RUFxd7r6jhHY,3081
23
- deltadefi-0.0.6.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
24
- deltadefi-0.0.6.dist-info/RECORD,,
20
+ deltadefi/responses/accounts.py,sha256=At-feMwjxHBM4vVdQMY1m_rrdCTtOTRLVc-c0-1I5Hg,1143
21
+ deltadefi/responses/responses.py,sha256=8vzUbgrW6jQjGH4Hkd9iIT0PyaeADQpPW3EBT-DxRjs,1103
22
+ deltadefi-0.0.8.dist-info/METADATA,sha256=7PNRQiT0tynSBdNhEv51dLN8A3646m6nNRxMUbZx5To,3234
23
+ deltadefi-0.0.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
24
+ deltadefi-0.0.8.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.2
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any