deltadefi 0.0.1__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.

deltadefi/__init__.py ADDED
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ from .clients import ApiClient
@@ -0,0 +1,3 @@
1
+ # flake8: noqa
2
+ from .auth import *
3
+ from .validation import *
@@ -0,0 +1,16 @@
1
+ from dataclasses import dataclass
2
+ from typing import Optional
3
+
4
+
5
+ @dataclass
6
+ class AuthHeaders:
7
+ jwt: str
8
+ apiKey: str
9
+
10
+
11
+ class ApiHeaders:
12
+ __annotations__ = {
13
+ "Content-Type": str,
14
+ "Authorization": Optional[str],
15
+ "X-API-KEY": Optional[str],
16
+ }
@@ -0,0 +1,42 @@
1
+ # flake8: noqa
2
+ from dataclasses import dataclass
3
+ from typing import List
4
+
5
+ from sidan_gin import Asset
6
+
7
+ """
8
+ * DeltaDeFiOrderInfo is a type that represents the information of a DeltaDeFi order.
9
+ * @property {Asset[]} assetsToPay - The assets that are to be paid from orders in current transaction.
10
+ * @property {Asset[]} assetsToReturn - The assets that are to be received from orders in current transaction.
11
+ * @property {string} txFee - The transaction fee.
12
+ * @property {string} tradingFee - The trading fee.
13
+ """
14
+
15
+
16
+ @dataclass
17
+ class DeltaDeFiOrderInfo:
18
+ assetsToPay: List[Asset]
19
+ assetsToReturn: List[Asset]
20
+ txFee: str
21
+ tradingFee: str
22
+
23
+
24
+ """
25
+ * DeltaDeFiTxInfo is a type that represents the information of a DeltaDeFi transaction.
26
+ * @property {Asset[]} accountInput - The assets that are input from the account.
27
+ * @property {Asset[]} accountOutput - The assets that are output to the account.
28
+ * @property {Asset[]} dexInput - The assets that are input from the DEX.
29
+ * @property {Asset[]} dexOutput - The assets that are output to the DEX.
30
+ * @property {string} txFee - The transaction fee.
31
+ * @property {string} tradingFee - The trading fee.
32
+ """
33
+
34
+
35
+ @dataclass
36
+ class DeltaDeFiTxInfo:
37
+ accountInput: List[Asset]
38
+ accountOutput: List[Asset]
39
+ dexInput: List[DeltaDeFiOrderInfo]
40
+ dexOutput: List[DeltaDeFiOrderInfo]
41
+ txFee: str
42
+ tradingFee: str
@@ -0,0 +1,6 @@
1
+ # flake8: noqa
2
+ from .accounts import *
3
+ from .app import *
4
+ from .clients import *
5
+ from .markets import *
6
+ from .orders import *
@@ -0,0 +1,225 @@
1
+ import requests
2
+
3
+ from deltadefi.requests import (
4
+ BuildDepositTransactionRequest,
5
+ BuildWithdrawalTransactionRequest,
6
+ SignInRequest,
7
+ SubmitDepositTransactionRequest,
8
+ SubmitWithdrawalTransactionRequest,
9
+ )
10
+ from deltadefi.responses import (
11
+ BuildDepositTransactionResponse,
12
+ BuildWithdrawalTransactionResponse,
13
+ CreateNewAPIKeyResponse,
14
+ GetAccountBalanceResponse,
15
+ GetDepositRecordsResponse,
16
+ GetOrderRecordResponse,
17
+ GetTermsAndConditionResponse,
18
+ GetWithdrawalRecordsResponse,
19
+ SignInResponse,
20
+ SubmitDepositTransactionResponse,
21
+ SubmitWithdrawalTransactionResponse,
22
+ )
23
+
24
+
25
+ class Accounts:
26
+ """
27
+ Accounts client for interacting with the DeltaDeFi API.
28
+ """
29
+
30
+ def __init__(self, api_client):
31
+ """
32
+ Initialize the Accounts client.
33
+
34
+ Args:
35
+ api_client: An instance of the ApiClient.
36
+ """
37
+ self.api_client = api_client
38
+
39
+ def sign_in(self, data: SignInRequest) -> SignInResponse:
40
+ """
41
+ Sign in to the DeltaDeFi API.
42
+
43
+ Args:
44
+ data: A SignInRequest object containing the authentication key and wallet address.
45
+
46
+ Returns:
47
+ A SignInResponse object containing the sign-in response.
48
+ """
49
+ auth_key = data["auth_key"]
50
+ wallet_address = data["wallet_address"]
51
+ headers = {
52
+ "X-API-KEY": auth_key,
53
+ "Content-Type": "application/json",
54
+ }
55
+ response = requests.post(
56
+ f"{self.api_client.base_url}/accounts/signin",
57
+ json={"wallet_address": wallet_address},
58
+ headers=headers,
59
+ )
60
+ response.raise_for_status()
61
+ return response.json()
62
+
63
+ def createNewApiKey(self) -> CreateNewAPIKeyResponse:
64
+ """
65
+ Create a new API key.
66
+
67
+ Returns:
68
+ A CreateNewAPIKeyResponse object containing the new API key.
69
+ """
70
+ response = requests.get(
71
+ f"{self.api_client.base_url}/accounts/new-api-key",
72
+ headers=self.api_client.headers,
73
+ )
74
+ response.raise_for_status()
75
+ return response.json()
76
+
77
+ def getDepositRecords(self) -> GetDepositRecordsResponse:
78
+ """
79
+ Get deposit records.
80
+
81
+ Returns:
82
+ A GetDepositRecordsResponse object containing the deposit records.
83
+ """
84
+ response = requests.get(
85
+ f"{self.api_client.base_url}/accounts/deposit-records",
86
+ headers=self.api_client.headers,
87
+ )
88
+ response.raise_for_status()
89
+ return response.json()
90
+
91
+ def getWithdrawalRecords(self) -> GetWithdrawalRecordsResponse:
92
+ """
93
+ Get withdrawal records.
94
+
95
+ Returns:
96
+ A GetWithdrawalRecordsResponse object containing the withdrawal records.
97
+ """
98
+ response = requests.get(
99
+ f"{self.api_client.base_url}/accounts/withdrawal-records",
100
+ headers=self.api_client.headers,
101
+ )
102
+ response.raise_for_status()
103
+ return response.json()
104
+
105
+ def getOrderRecords(self) -> GetOrderRecordResponse:
106
+ """
107
+ Get order records.
108
+
109
+ Returns:
110
+ A GetOrderRecordResponse object containing the order records.
111
+ """
112
+ response = requests.get(
113
+ f"{self.api_client.base_url}/accounts/order-records",
114
+ headers=self.api_client.headers,
115
+ )
116
+ response.raise_for_status()
117
+ return response.json()
118
+
119
+ def getAccountBalance(self) -> GetAccountBalanceResponse:
120
+ """
121
+ Get account balance.
122
+
123
+ Returns:
124
+ A GetAccountBalanceResponse object containing the account balance.
125
+ """
126
+ response = requests.get(
127
+ f"{self.api_client.base_url}/accounts/balance",
128
+ headers=self.api_client.headers,
129
+ )
130
+ response.raise_for_status()
131
+ return response.json()
132
+
133
+ def buildDepositTransaction(
134
+ self, data: BuildDepositTransactionRequest
135
+ ) -> BuildDepositTransactionResponse:
136
+ """
137
+ Build a deposit transaction.
138
+
139
+ Args:
140
+ data: A BuildDepositTransactionRequest object containing the deposit transaction details.
141
+
142
+ Returns:
143
+ A BuildDepositTransactionResponse object containing the built deposit transaction.
144
+ """
145
+ response = requests.post(
146
+ f"{self.api_client.base_url}/accounts/deposit/build",
147
+ json=data,
148
+ headers=self.api_client.headers,
149
+ )
150
+ response.raise_for_status()
151
+ return response.json()
152
+
153
+ def buildWithdrawalTransaction(
154
+ self, data: BuildWithdrawalTransactionRequest
155
+ ) -> BuildWithdrawalTransactionResponse:
156
+ """
157
+ Build a withdrawal transaction.
158
+
159
+ Args:
160
+ data: A BuildWithdrawalTransactionRequest object containing the withdrawal transaction details.
161
+
162
+ Returns:
163
+ A BuildWithdrawalTransactionResponse object containing the built withdrawal transaction.
164
+ """
165
+ response = requests.post(
166
+ f"{self.api_client.base_url}/accounts/withdrawal/build",
167
+ json=data,
168
+ headers=self.api_client.headers,
169
+ )
170
+ response.raise_for_status()
171
+ return response.json()
172
+
173
+ def submitDepositTransaction(
174
+ self, data: SubmitDepositTransactionRequest
175
+ ) -> SubmitDepositTransactionResponse:
176
+ """
177
+ Submit a deposit transaction.
178
+
179
+ Args:
180
+ data: A SubmitDepositTransactionRequest object containing the deposit transaction details.
181
+
182
+ Returns:
183
+ A SubmitDepositTransactionResponse object containing the submitted deposit transaction.
184
+ """
185
+ response = requests.post(
186
+ f"{self.api_client.base_url}/accounts/deposit/submit",
187
+ json=data,
188
+ headers=self.api_client.headers,
189
+ )
190
+ response.raise_for_status()
191
+ return response.json()
192
+
193
+ def submitWithdrawalTransaction(
194
+ self, data: SubmitWithdrawalTransactionRequest
195
+ ) -> SubmitWithdrawalTransactionResponse:
196
+ """
197
+ Submit a withdrawal transaction.
198
+
199
+ Args:
200
+ data: A SubmitWithdrawalTransactionRequest object containing the withdrawal transaction details.
201
+
202
+ Returns:
203
+ A SubmitWithdrawalTransactionResponse object containing the submitted withdrawal transaction.
204
+ """
205
+ response = requests.post(
206
+ f"{self.api_client.base_url}/accounts/withdrawal/submit",
207
+ json=data,
208
+ headers=self.api_client.headers,
209
+ )
210
+ response.raise_for_status()
211
+ return response.json()
212
+
213
+ def getTermsAndCondition(self) -> GetTermsAndConditionResponse:
214
+ """
215
+ Get terms and conditions.
216
+
217
+ Returns:
218
+ A GetTermsAndConditionResponse object containing the terms and conditions.
219
+ """
220
+ response = requests.get(
221
+ f"{self.api_client.base_url}/accounts/terms-and-condition",
222
+ headers=self.api_client.headers,
223
+ )
224
+ response.raise_for_status()
225
+ return response.json()
@@ -0,0 +1,32 @@
1
+ import requests
2
+
3
+ from deltadefi.responses import GetTermsAndConditionResponse
4
+
5
+
6
+ class App:
7
+ """
8
+ App client for interacting with the DeltaDeFi API.
9
+ """
10
+
11
+ def __init__(self, api_client):
12
+ """
13
+ Initialize the App client.
14
+
15
+ Args:
16
+ api_client: An instance of the ApiClient.
17
+ """
18
+ self.api_client = api_client
19
+
20
+ def getTermsAndCondition(self) -> GetTermsAndConditionResponse:
21
+ """
22
+ Get terms and conditions.
23
+
24
+ Returns:
25
+ A GetTermsAndConditionResponse object containing the terms and conditions.
26
+ """
27
+ response = requests.get(
28
+ f"{self.api_client.base_url}/terms-and-conditions",
29
+ headers=self.api_client.headers,
30
+ )
31
+ response.raise_for_status()
32
+ return response.json()
@@ -0,0 +1,77 @@
1
+ # flake8: noqa: E501
2
+ from sidan_gin import HDWallet
3
+
4
+ from deltadefi.api_resources.auth import ApiHeaders
5
+ from deltadefi.clients.accounts import Accounts
6
+ from deltadefi.clients.markets import Markets
7
+ from deltadefi.clients.orders import Orders
8
+ from deltadefi.requests import PostOrderRequest
9
+ from deltadefi.responses import PostOrderResponse
10
+
11
+
12
+ class ApiClient:
13
+ """
14
+ ApiClient for interacting with the DeltaDeFi API.
15
+ """
16
+
17
+ def __init__(
18
+ self,
19
+ network: str = "preprod",
20
+ jwt: str = None,
21
+ api_key: str = None,
22
+ wallet: HDWallet = None,
23
+ base_url: str = None,
24
+ ):
25
+ """
26
+ Initialize the ApiClient.
27
+
28
+ Args:
29
+ config: An instance of ApiConfig containing the API configuration.
30
+ wallet: An instance of HDWallet for signing transactions.
31
+ base_url: Optional; The base URL for the API. Defaults to "https://api-dev.deltadefi.io".
32
+ """
33
+ self.base_url = base_url or "https://api-dev.deltadefi.io"
34
+ headers: ApiHeaders = {
35
+ "Content-Type": "application/json",
36
+ }
37
+
38
+ if network == "mainnet":
39
+ self.network_id = 1
40
+ base_url = "https://api-dev.deltadefi.io" # TODO: input production link once available
41
+ else:
42
+ self.network_id = 0
43
+ base_url = "https://api-dev.deltadefi.io"
44
+
45
+ if jwt is not None:
46
+ headers["Authorization"] = jwt
47
+
48
+ if api_key is not None:
49
+ headers["X-API-KEY"] = api_key
50
+
51
+ if wallet is not None:
52
+ self.wallet = wallet.signing_key
53
+
54
+ self.accounts = Accounts(self)
55
+ self.orders = Orders(self)
56
+ self.markets = Markets(self)
57
+
58
+ async def post_order(self, data: PostOrderRequest) -> PostOrderResponse:
59
+ """
60
+ Post an order to the DeltaDeFi API.
61
+
62
+ Args:
63
+ data: A PostOrderRequest object containing the order details.
64
+
65
+ Returns:
66
+ A PostOrderResponse object containing the response from the API.
67
+
68
+ Raises:
69
+ ValueError: If the wallet is not initialized.
70
+ """
71
+ if not hasattr(self, "wallet") or self.wallet is None:
72
+ raise ValueError("Wallet is not initialized")
73
+
74
+ build_res = "" # TODO: import wallet build order
75
+ signed_tx = self.wallet.sign_tx(build_res["tx_hex"])
76
+ submit_res = signed_tx + "" # TODO: import wallet submit tx
77
+ return submit_res
@@ -0,0 +1,82 @@
1
+ # flake8: noqa: E501
2
+
3
+ import requests
4
+
5
+ from deltadefi.requests import (
6
+ GetAggregatedPriceRequest,
7
+ GetMarketDepthRequest,
8
+ GetMarketPriceRequest,
9
+ )
10
+ from deltadefi.responses import (
11
+ GetAggregatedPriceResponse,
12
+ GetMarketDepthResponse,
13
+ GetMarketPriceResponse,
14
+ )
15
+
16
+
17
+ class Markets:
18
+ """
19
+ Markets client for interacting with the DeltaDeFi API.
20
+ """
21
+
22
+ def __init__(self, api_client):
23
+ """
24
+ Initialize the Markets client.
25
+
26
+ Args:
27
+ api_client: An instance of the ApiClient.
28
+ """
29
+ self.api_client = api_client
30
+
31
+ def getDepth(self, data: GetMarketDepthRequest) -> GetMarketDepthResponse:
32
+ """
33
+ Get market depth.
34
+
35
+ Args:
36
+ data: A GetMarketDepthRequest object containing the market pair.
37
+
38
+ Returns:
39
+ A GetMarketDepthResponse object containing the market depth.
40
+ """
41
+ response = requests.get(
42
+ f"{self.api_client.base_url}/market/depth?pair={data['pair']}",
43
+ headers=self.api_client.headers,
44
+ )
45
+ response.raise_for_status()
46
+ return response.json()
47
+
48
+ def getMarketPrice(self, data: GetMarketPriceRequest) -> GetMarketPriceResponse:
49
+ """
50
+ Get market price.
51
+
52
+ Args:
53
+ data: A GetMarketPriceRequest object containing the market pair.
54
+
55
+ Returns:
56
+ A GetMarketPriceResponse object containing the market price.
57
+ """
58
+ response = requests.get(
59
+ f"{self.api_client.base_url}/market/market-price?pair={data['pair']}",
60
+ headers=self.api_client.headers,
61
+ )
62
+ response.raise_for_status()
63
+ return response.json()
64
+
65
+ def getAggregatedPrice(
66
+ self, data: GetAggregatedPriceRequest
67
+ ) -> GetAggregatedPriceResponse:
68
+ """
69
+ Get aggregated price.
70
+
71
+ Args:
72
+ data: A GetAggregatedPriceRequest object containing the market pair, interval, start, and end time.
73
+
74
+ Returns:
75
+ A GetAggregatedPriceResponse object containing the aggregated price.
76
+ """
77
+ response = requests.get(
78
+ f"{self.api_client.base_url}/market/aggregate/{data['pair']}?interval={data['interval']}&start={data.get('start', '')}&end={data.get('end', '')}",
79
+ headers=self.api_client.headers,
80
+ )
81
+ response.raise_for_status()
82
+ return response.json()
@@ -0,0 +1,107 @@
1
+ import requests
2
+
3
+ from deltadefi.requests import (
4
+ BuildPlaceOrderTransactionRequest,
5
+ SubmitCancelOrderTransactionRequest,
6
+ SubmitPlaceOrderTransactionRequest,
7
+ )
8
+ from deltadefi.responses import (
9
+ BuildCancelOrderTransactionResponse,
10
+ BuildPlaceOrderTransactionResponse,
11
+ SubmitCancelOrderTransactionResponse,
12
+ SubmitPlaceOrderTransactionResponse,
13
+ )
14
+
15
+
16
+ class Orders:
17
+ """
18
+ Orders client for interacting with the DeltaDeFi API.
19
+ """
20
+
21
+ def __init__(self, api_client):
22
+ """
23
+ Initialize the Orders client.
24
+
25
+ Args:
26
+ api_client: An instance of the ApiClient.
27
+ """
28
+ self.api_client = api_client
29
+
30
+ def build_place_order_transaction(
31
+ self, data: BuildPlaceOrderTransactionRequest
32
+ ) -> BuildPlaceOrderTransactionResponse:
33
+ """
34
+ Build a place order transaction.
35
+
36
+ Args:
37
+ data: A BuildPlaceOrderTransactionRequest object containing the order details.
38
+
39
+ Returns:
40
+ A BuildPlaceOrderTransactionResponse object containing the built order transaction.
41
+ """
42
+ response = requests.post(
43
+ f"{self.api_client.base_url}/order/build",
44
+ json=data,
45
+ headers=self.api_client.headers,
46
+ )
47
+ response.raise_for_status()
48
+ return response.json()
49
+
50
+ def build_cancel_order_transaction(
51
+ self, order_id: str
52
+ ) -> BuildCancelOrderTransactionResponse:
53
+ """
54
+ Build a cancel order transaction.
55
+
56
+ Args:
57
+ order_id: The ID of the order to be canceled.
58
+
59
+ Returns:
60
+ A BuildCancelOrderTransactionResponse object containing the built cancel order transaction.
61
+ """
62
+ response = requests.delete(
63
+ f"{self.api_client.base_url}/order/{order_id}/build",
64
+ headers=self.api_client.headers,
65
+ )
66
+ response.raise_for_status()
67
+ return response.json()
68
+
69
+ def submit_place_order_transaction(
70
+ self, data: SubmitPlaceOrderTransactionRequest
71
+ ) -> SubmitPlaceOrderTransactionResponse:
72
+ """
73
+ Submit a place order transaction.
74
+
75
+ Args:
76
+ data: A SubmitPlaceOrderTransactionRequest object containing the order details.
77
+
78
+ Returns:
79
+ A SubmitPlaceOrderTransactionResponse object containing the submitted order transaction.
80
+ """
81
+ response = requests.post(
82
+ f"{self.api_client.base_url}/order/submit",
83
+ json=data,
84
+ headers=self.api_client.headers,
85
+ )
86
+ response.raise_for_status()
87
+ return response.json()
88
+
89
+ def submit_cancel_order_transaction(
90
+ self, data: SubmitCancelOrderTransactionRequest
91
+ ) -> SubmitCancelOrderTransactionResponse:
92
+ """
93
+ Submit a cancel order transaction.
94
+
95
+ Args:
96
+ data: A SubmitCancelOrderTransactionRequest object containing the cancel order details.
97
+
98
+ Returns:
99
+ A SubmitCancelOrderTransactionResponse object containing the submitted cancel order transaction.
100
+ """
101
+ response = requests.delete(
102
+ f"{self.api_client.base_url}/order/submit",
103
+ json=data,
104
+ headers=self.api_client.headers,
105
+ )
106
+ response.raise_for_status()
107
+ return response.json()
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ from .constants import *
@@ -0,0 +1,6 @@
1
+ from typing import Literal
2
+
3
+ TradingPair = Literal["ADAUSDX"]
4
+ TradingSide = Literal["buy", "sell"]
5
+ TradingType = Literal["limit", "market"]
6
+ TimeInForce = Literal["GTC"]
deltadefi/error.py ADDED
@@ -0,0 +1,63 @@
1
+ from __future__ import absolute_import, division, print_function
2
+
3
+
4
+ class deltadefi_sdkError(Exception):
5
+ def __init__(
6
+ self,
7
+ message=None,
8
+ http_body=None,
9
+ http_status=None,
10
+ json_body=None,
11
+ headers=None,
12
+ code=None,
13
+ ):
14
+ super(deltadefi_sdkError, self).__init__(message)
15
+
16
+ self._message = message
17
+ self.http_body = http_body
18
+ self.http_status = http_status
19
+ self.json_body = json_body
20
+ self.headers = headers or {}
21
+ self.code = code
22
+ self.request_id = self.headers.get("request-id", None)
23
+
24
+
25
+ class APIError(deltadefi_sdkError):
26
+ pass
27
+
28
+
29
+ class deltadefi_sdkErrorWithParamCode(deltadefi_sdkError):
30
+ def __repr__(self):
31
+ return "%s(message=%r, param=%r, code=%r, http_status=%r, " "request_id=%r)" % (
32
+ self.__class__.__name__,
33
+ self._message,
34
+ self.param,
35
+ self.code,
36
+ self.http_status,
37
+ self.request_id,
38
+ )
39
+
40
+
41
+ class InvalidRequestError(deltadefi_sdkErrorWithParamCode):
42
+ def __init__(
43
+ self,
44
+ message,
45
+ param,
46
+ code=None,
47
+ http_body=None,
48
+ http_status=None,
49
+ json_body=None,
50
+ headers=None,
51
+ ):
52
+ super(InvalidRequestError, self).__init__(
53
+ message, http_body, http_status, json_body, headers, code
54
+ )
55
+ self.param = param
56
+
57
+
58
+ class AuthenticationError(deltadefi_sdkError):
59
+ pass
60
+
61
+
62
+ class PermissionError(deltadefi_sdkError):
63
+ pass
@@ -0,0 +1,2 @@
1
+ # flake8: noqa
2
+ from .models import *
@@ -0,0 +1,70 @@
1
+ from dataclasses import dataclass
2
+ from typing import List, Literal
3
+
4
+ from sidan_gin import Asset
5
+
6
+ TradingSymbol = Literal["ADAUSDX"]
7
+
8
+ OrderStatus = Literal["building", "open", "closed", "failed"]
9
+
10
+ OrderSide = Literal["buy", "sell"]
11
+
12
+ OrderSides = {
13
+ "BuyOrder": "buy",
14
+ "SellOrder": "sell",
15
+ }
16
+
17
+ OrderType = Literal["market", "limit"]
18
+
19
+ OrderTypes = {
20
+ "MarketOrder": "market",
21
+ "LimitOrder": "limit",
22
+ }
23
+
24
+
25
+ @dataclass
26
+ class TransactionStatus:
27
+ building = "building"
28
+ held_for_order = "held_for_order"
29
+ submitted = "submitted"
30
+ submission_failed = "submission_failed"
31
+ confirmed = "confirmed"
32
+
33
+
34
+ @dataclass
35
+ class OrderJSON:
36
+ order_id: str
37
+ status: OrderStatus
38
+ symbol: TradingSymbol
39
+ orig_qty: str
40
+ executed_qty: str
41
+ side: OrderSide
42
+ price: str
43
+ type: OrderType
44
+ fee_amount: float
45
+ executed_price: float
46
+ slippage: str
47
+ create_time: int
48
+ update_time: int
49
+
50
+
51
+ @dataclass
52
+ class DepositRecord:
53
+ created_at: str
54
+ status: TransactionStatus
55
+ assets: List[Asset]
56
+ tx_hash: str
57
+
58
+
59
+ @dataclass
60
+ class WithdrawalRecord:
61
+ created_at: str
62
+ status: TransactionStatus
63
+ assets: List[Asset]
64
+
65
+
66
+ @dataclass
67
+ class AssetBalance:
68
+ asset: str
69
+ free: int
70
+ locked: int
@@ -0,0 +1,3 @@
1
+ # flake8: noqa
2
+ from .accounts import *
3
+ from .requests import *
@@ -0,0 +1,31 @@
1
+ from dataclasses import dataclass
2
+ from typing import List
3
+
4
+ from sidan_gin import Asset, UTxO
5
+
6
+
7
+ @dataclass
8
+ class SignInRequest:
9
+ wallet_address: str
10
+ auth_key: str
11
+
12
+
13
+ @dataclass
14
+ class BuildDepositTransactionRequest:
15
+ deposit_amount: List[Asset]
16
+ input_utxos: List[UTxO]
17
+
18
+
19
+ @dataclass
20
+ class BuildWithdrawalTransactionRequest:
21
+ withdrawal_amount: List[Asset]
22
+
23
+
24
+ @dataclass
25
+ class SubmitDepositTransactionRequest:
26
+ signed_tx: str
27
+
28
+
29
+ @dataclass
30
+ class SubmitWithdrawalTransactionRequest:
31
+ signed_txs: List[str]
@@ -0,0 +1,67 @@
1
+ from dataclasses import dataclass
2
+ from typing import Literal, Optional
3
+
4
+ from deltadefi.models import OrderSide, OrderType, TradingSymbol
5
+
6
+
7
+ @dataclass
8
+ class GetMarketDepthRequest:
9
+ pair: str
10
+
11
+
12
+ @dataclass
13
+ class GetMarketPriceRequest:
14
+ pair: str
15
+
16
+
17
+ Interval = Literal["15m", "30m", "1h", "1d", "1w", "1M"]
18
+
19
+
20
+ @dataclass
21
+ class GetAggregatedPriceRequest:
22
+ pair: str
23
+ interval: Interval
24
+ start: Optional[int]
25
+ end: Optional[int]
26
+
27
+
28
+ # class TradingSymbol(str):
29
+ # pass
30
+
31
+
32
+ # class OrderSide(str):
33
+ # pass
34
+
35
+
36
+ # class OrderType(str):
37
+ # pass
38
+
39
+
40
+ @dataclass
41
+ class BuildPlaceOrderTransactionRequest:
42
+ pair: TradingSymbol
43
+ side: OrderSide
44
+ type: OrderType
45
+ quantity: float
46
+ price: Optional[float]
47
+ basis_point: Optional[float]
48
+
49
+
50
+ class PostOrderRequest(BuildPlaceOrderTransactionRequest):
51
+ pass
52
+
53
+
54
+ @dataclass
55
+ class SubmitPlaceOrderTransactionRequest:
56
+ order_id: str
57
+ signed_tx: str
58
+
59
+
60
+ @dataclass
61
+ class BuildCancelOrderTransactionRequest:
62
+ order_id: str
63
+
64
+
65
+ @dataclass
66
+ class SubmitCancelOrderTransactionRequest:
67
+ signed_tx: str
@@ -0,0 +1,3 @@
1
+ # flake8: noqa
2
+ from .accounts import *
3
+ from .responses import *
@@ -0,0 +1,68 @@
1
+ from dataclasses import dataclass
2
+ from typing import List
3
+
4
+ from deltadefi.models.models import (
5
+ AssetBalance,
6
+ DepositRecord,
7
+ OrderJSON,
8
+ WithdrawalRecord,
9
+ )
10
+
11
+
12
+ @dataclass
13
+ class SignInResponse:
14
+ token: str
15
+ is_first_time: bool
16
+
17
+
18
+ @dataclass
19
+ class CreateNewAPIKeyResponse:
20
+ api_key: str
21
+
22
+
23
+ @dataclass
24
+ class BuildDepositTransactionResponse:
25
+ tx_hex: str
26
+
27
+
28
+ @dataclass
29
+ class SubmitDepositTransactionResponse:
30
+ tx_hash: str
31
+
32
+
33
+ @dataclass
34
+ class GetDepositRecordsResponse(List[DepositRecord]):
35
+ pass
36
+
37
+
38
+ @dataclass
39
+ class GetWithdrawalRecordsResponse(List[WithdrawalRecord]):
40
+ pass
41
+
42
+
43
+ @dataclass
44
+ class GetOrderRecordResponse:
45
+ orders: List[OrderJSON]
46
+
47
+
48
+ @dataclass
49
+ class BuildWithdrawalTransactionResponse:
50
+ tx_hex: str
51
+
52
+
53
+ @dataclass
54
+ class SubmitWithdrawalTransactionResponse:
55
+ tx_hash: str
56
+
57
+
58
+ @dataclass
59
+ class GetAccountInfoResponse:
60
+ api_key: str
61
+ api_limit: int
62
+ created_at: str
63
+ updated_at: str
64
+
65
+
66
+ @dataclass
67
+ class GetAccountBalanceResponse(List[AssetBalance]):
68
+ pass
@@ -0,0 +1,68 @@
1
+ from dataclasses import dataclass
2
+ from typing import List
3
+
4
+ from deltadefi.models import OrderJSON
5
+
6
+
7
+ @dataclass
8
+ class GetTermsAndConditionResponse:
9
+ value: str
10
+
11
+
12
+ @dataclass
13
+ class MarketDepth:
14
+ price: float
15
+ quantity: float
16
+
17
+
18
+ @dataclass
19
+ class GetMarketDepthResponse:
20
+ bids: List[MarketDepth]
21
+ asks: List[MarketDepth]
22
+
23
+
24
+ @dataclass
25
+ class GetMarketPriceResponse:
26
+ price: float
27
+
28
+
29
+ @dataclass
30
+ class Trade:
31
+ time: str
32
+ symbol: str
33
+ open: float
34
+ high: float
35
+ low: float
36
+ close: float
37
+ volume: float
38
+
39
+
40
+ @dataclass
41
+ class GetAggregatedPriceResponse(List[Trade]):
42
+ pass
43
+
44
+
45
+ @dataclass
46
+ class BuildPlaceOrderTransactionResponse:
47
+ order_id: str
48
+ tx_hex: str
49
+
50
+
51
+ @dataclass
52
+ class SubmitPlaceOrderTransactionResponse:
53
+ order: OrderJSON
54
+
55
+
56
+ @dataclass
57
+ class PostOrderResponse(SubmitPlaceOrderTransactionResponse):
58
+ pass
59
+
60
+
61
+ @dataclass
62
+ class BuildCancelOrderTransactionResponse:
63
+ tx_hex: str
64
+
65
+
66
+ @dataclass
67
+ class SubmitCancelOrderTransactionResponse:
68
+ tx_hash: str
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.3
2
+ Name: deltadefi
3
+ Version: 0.0.1
4
+ Summary: Python SDK for DeltaDeFi protocol.
5
+ License: Apache-2.0
6
+ Keywords: cardano
7
+ Author: HinsonSIDAN
8
+ Author-email: wongkahinhinson@gmail.com
9
+ Requires-Python: >3.11,<4.0.0
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Requires-Dist: certifi (==2024.8.30)
18
+ Requires-Dist: charset-normalizer (==3.4.0)
19
+ Requires-Dist: idna (==3.10)
20
+ Requires-Dist: pycardano (>=0.12.3,<0.13.0)
21
+ Requires-Dist: requests (>=2.25,<3.0)
22
+ Requires-Dist: sidan-gin (==0.1.1)
23
+ Requires-Dist: urllib3 (==2.2.3)
24
+ Project-URL: Documentation, https://github.com/deltadefi-protocol/python-sdk
25
+ Project-URL: Homepage, https://github.com/deltadefi-protocol/python-sdk
26
+ Description-Content-Type: text/markdown
27
+
28
+ # DeltaDeFi Python SDK
29
+
30
+ The DeltaDeFi Python SDK provides a convenient way to interact with the DeltaDeFi API. This SDK allows developers to easily integrate DeltaDeFi's features into their Python applications.
31
+
32
+ ## Installation
33
+
34
+ To install the SDK, use `pip`:
35
+
36
+ ```sh
37
+ pip install deltadefi-python-sdk
38
+ ```
39
+
40
+ ## Requirements
41
+
42
+ - Python 3.11 or higher
43
+
44
+ ## Usage
45
+
46
+ ### Initialization
47
+
48
+ To use the SDK, you need to initialize the ApiClient with your API configuration and wallet.
49
+
50
+ ```python
51
+ from deltadefi.api_resources.api_config import ApiConfig
52
+ from deltadefi.clients.clients import ApiClient
53
+ from sidan_gin import HDWallet
54
+
55
+ # Initialize API configuration
56
+ network="mainnet",
57
+ api_key="your_api_key",
58
+
59
+ # Initialize HDWallet
60
+ wallet = HDWallet("your_wallet_mnemonic")
61
+
62
+ # Initialize ApiClient
63
+ api_client = ApiClient(network=network, api_key=api_key, wallet=wallet)
64
+ ```
65
+
66
+ ### Accounts
67
+
68
+ The Accounts client allows you to interact with account-related endpoints.
69
+
70
+ ```python
71
+ from deltadefi.clients.accounts import Accounts
72
+
73
+ accounts_client = api_client.accounts
74
+
75
+ # Sign in
76
+ sign_in_request = SignInRequest(auth_key="your_auth_key", wallet_address="your_wallet_address")
77
+ sign_in_response = accounts_client.sign_in(sign_in_request)
78
+ print(sign_in_response)
79
+
80
+ # Get account balance
81
+ account_balance = accounts_client.get_account_balance()
82
+ print(account_balance)
83
+ ```
84
+
85
+ ### Markets
86
+
87
+ The Markets client allows you to interact with market-related endpoints.
88
+
89
+ ```python
90
+ from deltadefi.clients.markets import Markets
91
+
92
+ markets_client = api_client.markets
93
+
94
+ # Get market depth
95
+ market_depth_request = GetMarketDepthRequest(pair="BTC/USD")
96
+ market_depth_response = markets_client.getDepth(market_depth_request)
97
+ print(market_depth_response)
98
+
99
+ # Get market price
100
+ market_price_request = GetMarketPriceRequest(pair="BTC/USD")
101
+ market_price_response = markets_client.getMarketPrice(market_price_request)
102
+ print(market_price_response)
103
+ ```
104
+
105
+ ### Orders
106
+
107
+ The Orders client allows you to interact with order-related endpoints.
108
+
109
+ ```python
110
+ from deltadefi.clients.orders import Orders
111
+
112
+ orders_client = api_client.orders
113
+
114
+ # Build place order transaction
115
+ place_order_request = BuildPlaceOrderTransactionRequest(pair="BTC/USD", amount=1, price=50000)
116
+ place_order_response = orders_client.build_place_order_transaction(place_order_request)
117
+ print(place_order_response)
118
+
119
+ # Submit place order transaction
120
+ submit_order_request = SubmitPlaceOrderTransactionRequest(order_id="order_id")
121
+ submit_order_response = orders_client.submit_place_order_transaction(submit_order_request)
122
+ print(submit_order_response)
123
+ ```
124
+
125
+ ## License
126
+
127
+ 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
128
+
129
+ ```
130
+ http://www.apache.org/licenses/LICENSE-2.0
131
+ ```
132
+
@@ -0,0 +1,24 @@
1
+ deltadefi/__init__.py,sha256=_dbB-toNXZvwZxj5DnEY0nW5noDnDpF4QsJNEwGO_IA,46
2
+ deltadefi/api_resources/__init__.py,sha256=_SGHTpaQTIBvh9Rm868IT5pXpvvGBPqz3bxkY6YapZ4,61
3
+ deltadefi/api_resources/auth.py,sha256=Mpl4Dbh_d_gGhwLo2CtBSKxZ21DC74x-qjVhlczZCDE,278
4
+ deltadefi/api_resources/validation.py,sha256=vz-hovpLy9SMOIFGcBHC8vWZH8CJRlQP8rcbbTSM-PM,1375
5
+ deltadefi/clients/__init__.py,sha256=EsZ3uPvBHMmxzx29tAddhDd4Nk1tDZ6eFewLG1Hh6fs,126
6
+ deltadefi/clients/accounts.py,sha256=vWIVsftRA2TYgtmRxTqD2Ex1BYO2EFOkvbnSZyCGdpA,7044
7
+ deltadefi/clients/app.py,sha256=nt1jULimogIk70qR9De5r6NnL1O1ursmfnfIm6pmtJs,815
8
+ deltadefi/clients/clients.py,sha256=kFmGa2pgNgFrfKnYCt_aZb9brLCWi5GtQKVGydaHb3M,2446
9
+ deltadefi/clients/markets.py,sha256=byWzMenDJehTV3Ro5v9okXAGi3erdJ1c8iVuvBKNJDw,2388
10
+ deltadefi/clients/orders.py,sha256=c53D67Iu6-xb_ucsu3TK6HR5fKmHttz-JT6NhvlCYJA,3285
11
+ deltadefi/constants/__init__.py,sha256=7LkrzfLTJsCCUl5IgZYrl-AbY_cf1fftcLklgnBYDTs,40
12
+ deltadefi/constants/constants.py,sha256=9Ksb8_4t78KJpHVUnRArKlvgQk-CzcYsLRmA5qUnMwc,168
13
+ deltadefi/error.py,sha256=KIOHxGgv5Qa2IYUBByCE0uEM8fjBfyasVb2Acz3B77Y,1524
14
+ deltadefi/models/__init__.py,sha256=oDJj6Y4gXN6C7Oz_t2fq8hej-D0G9OqfXjL4Jaeq8z8,37
15
+ deltadefi/models/models.py,sha256=4vU2vVJpMDSPKYQH41JKC1raKf2kelEcAik45qUyopc,1228
16
+ deltadefi/requests/__init__.py,sha256=LmC-3pphj__BcvaPzFpJ1fvJDrCHtvstQ9y6zSW67JE,63
17
+ deltadefi/requests/accounts.py,sha256=zCzmNCLNW75Xcmy_JbVWtAJOqqLavDqZLmh-Ll-TQqU,521
18
+ deltadefi/requests/requests.py,sha256=3-LM2p-JHp8F8gGujtZcTAxb7um8C2WG9rgFap4hnSU,1062
19
+ deltadefi/responses/__init__.py,sha256=JKSIUQu6qI_XhbAR2mVMCKNvR6x_vFZdyLGOuQTVrVY,64
20
+ deltadefi/responses/accounts.py,sha256=6MvyAvrJ5Mc1hJ6BhQovtRiOsZZJzY_PsPpO5CNfe_c,1013
21
+ deltadefi/responses/responses.py,sha256=etlx83GgZC2noLKo8GKrmDo3Xhwup-g8Ob29f0WYA4I,993
22
+ deltadefi-0.0.1.dist-info/METADATA,sha256=A0iBWAGnqgwosUTeRsP529CDKpQOP6cW-3WqcyGk4Q8,3806
23
+ deltadefi-0.0.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
24
+ deltadefi-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.1.2
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any