ethereal-sdk 0.1.0__tar.gz

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.
Files changed (81) hide show
  1. ethereal_sdk-0.1.0/PKG-INFO +265 -0
  2. ethereal_sdk-0.1.0/README.md +236 -0
  3. ethereal_sdk-0.1.0/ethereal/__init__.py +9 -0
  4. ethereal_sdk-0.1.0/ethereal/async_rest_client.py +1116 -0
  5. ethereal_sdk-0.1.0/ethereal/async_ws_client.py +97 -0
  6. ethereal_sdk-0.1.0/ethereal/base_client.py +51 -0
  7. ethereal_sdk-0.1.0/ethereal/chain_client.py +464 -0
  8. ethereal_sdk-0.1.0/ethereal/constants.py +37 -0
  9. ethereal_sdk-0.1.0/ethereal/contracts/13374201/ExchangeGateway.json +5313 -0
  10. ethereal_sdk-0.1.0/ethereal/contracts/13374202/ExchangeGateway.json +5313 -0
  11. ethereal_sdk-0.1.0/ethereal/contracts/31337/ExchangeGateway.json +5313 -0
  12. ethereal_sdk-0.1.0/ethereal/contracts/5064014/ExchangeGateway.json +5313 -0
  13. ethereal_sdk-0.1.0/ethereal/contracts/common/ERC20.json +222 -0
  14. ethereal_sdk-0.1.0/ethereal/contracts/common/WUSDe.json +368 -0
  15. ethereal_sdk-0.1.0/ethereal/models/__init__.py +7 -0
  16. ethereal_sdk-0.1.0/ethereal/models/config.py +78 -0
  17. ethereal_sdk-0.1.0/ethereal/models/devnet/rest.py +3571 -0
  18. ethereal_sdk-0.1.0/ethereal/models/mainnet/rest.py +3571 -0
  19. ethereal_sdk-0.1.0/ethereal/models/rest.py +3571 -0
  20. ethereal_sdk-0.1.0/ethereal/models/testnet/rest.py +3571 -0
  21. ethereal_sdk-0.1.0/ethereal/py.typed +0 -0
  22. ethereal_sdk-0.1.0/ethereal/rest/__init__.py +0 -0
  23. ethereal_sdk-0.1.0/ethereal/rest/async_http_client.py +299 -0
  24. ethereal_sdk-0.1.0/ethereal/rest/funding.py +80 -0
  25. ethereal_sdk-0.1.0/ethereal/rest/http_client.py +316 -0
  26. ethereal_sdk-0.1.0/ethereal/rest/linked_signer.py +426 -0
  27. ethereal_sdk-0.1.0/ethereal/rest/order.py +481 -0
  28. ethereal_sdk-0.1.0/ethereal/rest/position.py +93 -0
  29. ethereal_sdk-0.1.0/ethereal/rest/product.py +76 -0
  30. ethereal_sdk-0.1.0/ethereal/rest/referral.py +55 -0
  31. ethereal_sdk-0.1.0/ethereal/rest/rpc.py +19 -0
  32. ethereal_sdk-0.1.0/ethereal/rest/subaccount.py +224 -0
  33. ethereal_sdk-0.1.0/ethereal/rest/token.py +292 -0
  34. ethereal_sdk-0.1.0/ethereal/rest/util.py +140 -0
  35. ethereal_sdk-0.1.0/ethereal/rest_client.py +147 -0
  36. ethereal_sdk-0.1.0/ethereal/rest_client.pyi +390 -0
  37. ethereal_sdk-0.1.0/ethereal/ws/__init__.py +0 -0
  38. ethereal_sdk-0.1.0/ethereal/ws/async_ws_base.py +91 -0
  39. ethereal_sdk-0.1.0/ethereal/ws/ws_base.py +129 -0
  40. ethereal_sdk-0.1.0/ethereal/ws_client.py +103 -0
  41. ethereal_sdk-0.1.0/ethereal_sdk.egg-info/PKG-INFO +265 -0
  42. ethereal_sdk-0.1.0/ethereal_sdk.egg-info/SOURCES.txt +79 -0
  43. ethereal_sdk-0.1.0/ethereal_sdk.egg-info/dependency_links.txt +1 -0
  44. ethereal_sdk-0.1.0/ethereal_sdk.egg-info/requires.txt +10 -0
  45. ethereal_sdk-0.1.0/ethereal_sdk.egg-info/top_level.txt +6 -0
  46. ethereal_sdk-0.1.0/examples/cli.py +50 -0
  47. ethereal_sdk-0.1.0/pyproject.toml +72 -0
  48. ethereal_sdk-0.1.0/scripts/check_test_account.py +116 -0
  49. ethereal_sdk-0.1.0/scripts/generate_docstrings.py +82 -0
  50. ethereal_sdk-0.1.0/scripts/generate_sync_client.py +309 -0
  51. ethereal_sdk-0.1.0/scripts/generate_types.py +255 -0
  52. ethereal_sdk-0.1.0/scripts/setup_test_account.py +137 -0
  53. ethereal_sdk-0.1.0/setup.cfg +4 -0
  54. ethereal_sdk-0.1.0/tests/__init__.py +0 -0
  55. ethereal_sdk-0.1.0/tests/conftest.py +277 -0
  56. ethereal_sdk-0.1.0/tests/helpers.py +10 -0
  57. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_info.py +84 -0
  58. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_info_account.py +104 -0
  59. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_orders.py +535 -0
  60. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_orders_oto_oco.py +412 -0
  61. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_position_liquidations.py +13 -0
  62. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_signers.py +279 -0
  63. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_subaccount_archive.py +113 -0
  64. ethereal_sdk-0.1.0/tests/rest/async/test_async_rest_token.py +294 -0
  65. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_info.py +41 -0
  66. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_info_account.py +85 -0
  67. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_orders.py +356 -0
  68. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_orders_oto_oco.py +404 -0
  69. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_position_liquidations.py +11 -0
  70. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_signers.py +233 -0
  71. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_subaccount_archive.py +87 -0
  72. ethereal_sdk-0.1.0/tests/rest/sync/test_sync_rest_token.py +277 -0
  73. ethereal_sdk-0.1.0/tests/test_async_clients.py +182 -0
  74. ethereal_sdk-0.1.0/tests/test_chain.py +97 -0
  75. ethereal_sdk-0.1.0/tests/test_clients.py +201 -0
  76. ethereal_sdk-0.1.0/tests/test_signing.py +356 -0
  77. ethereal_sdk-0.1.0/tests/test_util.py +151 -0
  78. ethereal_sdk-0.1.0/tests/ws/test_async_ws_base.py +26 -0
  79. ethereal_sdk-0.1.0/tests/ws/test_async_ws_client.py +34 -0
  80. ethereal_sdk-0.1.0/tests/ws/test_ws_base.py +26 -0
  81. ethereal_sdk-0.1.0/tests/ws/test_ws_client.py +34 -0
@@ -0,0 +1,265 @@
1
+ Metadata-Version: 2.4
2
+ Name: ethereal-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for interacting with the Ethereal API
5
+ Author: Meridian Labs
6
+ License: MIT
7
+ Project-URL: Homepage, https://meridianxyz.github.io/ethereal-py-sdk/
8
+ Project-URL: Documentation, https://meridianxyz.github.io/ethereal-py-sdk/
9
+ Project-URL: Source Code, https://pypi.org/project/ethereal-sdk/
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: eth-account>=0.13.5
22
+ Requires-Dist: pydantic>=2.11.2
23
+ Requires-Dist: python-dotenv>=1.0.1
24
+ Requires-Dist: python-socketio>=5.12.1
25
+ Requires-Dist: requests>=2.32.3
26
+ Requires-Dist: httpx>=0.27.0
27
+ Requires-Dist: web3>=7.9.0
28
+ Requires-Dist: uvloop>=0.21.0; sys_platform != "win32" and platform_python_implementation == "CPython"
29
+
30
+ # Ethereal Python SDK
31
+
32
+ A Python library for interacting with the Ethereal trading platform. This SDK provides tools for trading, managing positions, and accessing market data.
33
+
34
+ ## SDK Documentation
35
+
36
+ For full documentation, visit the [documentation site](https://meridianxyz.github.io/ethereal-py-sdk/).
37
+
38
+ View the source code on [PyPI](https://pypi.org/project/ethereal-sdk/).
39
+
40
+ ## Installation
41
+
42
+ ### Using uv (Recommended)
43
+
44
+ [uv](https://github.com/astral-sh/uv) is a fast Python package installer and resolver:
45
+
46
+ ```bash
47
+ # Install uv if you don't have it
48
+ curl -LsSf https://astral.sh/uv/install.sh | sh
49
+
50
+ # Install the SDK
51
+ uv add ethereal-sdk
52
+ ```
53
+
54
+ ### Using pip
55
+
56
+ ```bash
57
+ pip install ethereal-sdk
58
+ ```
59
+
60
+ uvloop installs automatically on CPython for macOS/Linux; Windows and other platforms fall back to asyncio.
61
+
62
+ ## Quick Start
63
+
64
+ The SDK provides two client types:
65
+
66
+ **AsyncRESTClient** (Recommended for new applications):
67
+
68
+ ```python
69
+ import asyncio
70
+ from decimal import Decimal
71
+ from ethereal import AsyncRESTClient
72
+
73
+ async def main():
74
+ client = await AsyncRESTClient.create({
75
+ "base_url": "https://api.etherealtest.net",
76
+ "chain_config": {
77
+ "rpc_url": "https://rpc.etherealtest.net",
78
+ "private_key": "your_private_key", # optional - required for trading
79
+ }
80
+ })
81
+
82
+ # Get market data
83
+ products = await client.list_products()
84
+ product_ids = [p.id for p in products]
85
+ prices = await client.list_market_prices(product_ids=product_ids)
86
+
87
+ # Place an order (requires private key)
88
+ await client.create_order(
89
+ order_type="LIMIT",
90
+ quantity=Decimal("1.0"),
91
+ side=0, # 0 for buy, 1 for sell
92
+ price=Decimal("100.0"),
93
+ ticker="BTCUSD"
94
+ )
95
+
96
+ await client.close()
97
+
98
+ asyncio.run(main())
99
+ ```
100
+
101
+ **RESTClient** (Synchronous):
102
+
103
+ ```python
104
+ from decimal import Decimal
105
+ from ethereal import RESTClient
106
+
107
+ client = RESTClient({
108
+ "base_url": "https://api.etherealtest.net",
109
+ "chain_config": {
110
+ "rpc_url": "https://rpc.etherealtest.net",
111
+ "private_key": "your_private_key", # optional - required for trading
112
+ }
113
+ })
114
+
115
+ # Get market data
116
+ products = client.list_products()
117
+
118
+ # Place an order (requires private key)
119
+ order = client.create_order(
120
+ order_type="LIMIT",
121
+ quantity=Decimal("1.0"),
122
+ side=0,
123
+ price=Decimal("100.0"),
124
+ ticker="BTCUSD"
125
+ )
126
+ ```
127
+
128
+ ## Main Features
129
+
130
+ ### Market Data
131
+
132
+ - List available trading products
133
+ - Get current market prices
134
+ - View market order book
135
+ - Track funding rates
136
+
137
+ ### Trading
138
+
139
+ - Place market and limit orders
140
+ - Cancel orders
141
+ - View order history
142
+ - Track trades and fills
143
+
144
+ ### Account Management
145
+
146
+ - Manage subaccounts
147
+ - View positions
148
+ - Track token balances
149
+ - Handle deposits and withdrawals
150
+
151
+ ### Websocket Support
152
+
153
+ - Real-time market data
154
+ - Live order book updates
155
+
156
+ ## Configuration
157
+
158
+ The SDK can be configured with these options:
159
+
160
+ - `private_key`: Your private key for authentication
161
+ - `base_url`: API endpoint (default: "https://api.etherealtest.net")
162
+ - `timeout`: Request timeout in seconds
163
+ - `verbose`: Enable debug logging
164
+ - `rate_limit_headers`: Enable rate limit headers
165
+
166
+ The SDK automatically enables uvloop on supported platforms and transparently falls back to the built-in asyncio loop elsewhere.
167
+
168
+ ## Examples
169
+
170
+ ### Get Market Data
171
+
172
+ ```python
173
+ async def get_market_data():
174
+ client = await AsyncRESTClient.create({"base_url": "https://api.ethereal.trade"})
175
+
176
+ # List all available products
177
+ products = await client.list_products()
178
+
179
+ # Get current prices
180
+ all_product_ids = [product.id for product in products]
181
+ prices = await client.list_market_prices(product_ids=all_product_ids)
182
+
183
+ # View market liquidity
184
+ products_by_ticker = await client.products_by_ticker()
185
+ btc_product_id = products_by_ticker['BTCUSD'].id
186
+ liquidity = await client.get_market_liquidity(product_id=btc_product_id)
187
+
188
+ await client.close()
189
+
190
+ asyncio.run(get_market_data())
191
+ ```
192
+
193
+ ### Manage Orders
194
+
195
+ ```python
196
+ async def manage_orders():
197
+ config = {
198
+ "base_url": "https://api.ethereal.trade",
199
+ "chain_config": {
200
+ "rpc_url": "https://rpc.ethereal.trade",
201
+ "private_key": "your_private_key"
202
+ }
203
+ }
204
+ client = await AsyncRESTClient.create(config)
205
+
206
+ # Place a limit order
207
+ order = await client.create_order(
208
+ order_type="LIMIT",
209
+ quantity=Decimal("1.0"),
210
+ side=0,
211
+ price=Decimal("100.0"),
212
+ ticker="BTCUSD"
213
+ )
214
+
215
+ # Cancel an order
216
+ subaccounts = await client.subaccounts()
217
+ await client.cancel_orders(
218
+ order_ids=["<uuid of order>"],
219
+ sender=client.chain.address,
220
+ subaccount=subaccounts[0].name
221
+ )
222
+
223
+ # View order history
224
+ subaccount_id = subaccounts[0].id
225
+ orders = await client.list_orders(subaccount_id=subaccount_id)
226
+
227
+ await client.close()
228
+
229
+ asyncio.run(manage_orders())
230
+ ```
231
+
232
+ ### Account Operations
233
+
234
+ ```python
235
+ async def account_operations():
236
+ config = {
237
+ "base_url": "https://api.ethereal.trade",
238
+ "chain_config": {
239
+ "rpc_url": "https://rpc.ethereal.trade",
240
+ "private_key": "your_private_key"
241
+ }
242
+ }
243
+ client = await AsyncRESTClient.create(config)
244
+
245
+ # List subaccounts
246
+ subaccounts = await client.subaccounts()
247
+
248
+ # View positions
249
+ positions = await client.list_positions(subaccount_id=subaccounts[0].id)
250
+
251
+ # Get token balances
252
+ balances = await client.get_subaccount_balances(subaccount_id=subaccounts[0].id)
253
+
254
+ await client.close()
255
+
256
+ asyncio.run(account_operations())
257
+ ```
258
+
259
+ ## Ethereal Documentation
260
+
261
+ For full documentation, visit our [documentation site](https://docs.ethereal.trade).
262
+
263
+ ## Support
264
+
265
+ For issues and questions, please refer to the project's issue tracker or documentation.
@@ -0,0 +1,236 @@
1
+ # Ethereal Python SDK
2
+
3
+ A Python library for interacting with the Ethereal trading platform. This SDK provides tools for trading, managing positions, and accessing market data.
4
+
5
+ ## SDK Documentation
6
+
7
+ For full documentation, visit the [documentation site](https://meridianxyz.github.io/ethereal-py-sdk/).
8
+
9
+ View the source code on [PyPI](https://pypi.org/project/ethereal-sdk/).
10
+
11
+ ## Installation
12
+
13
+ ### Using uv (Recommended)
14
+
15
+ [uv](https://github.com/astral-sh/uv) is a fast Python package installer and resolver:
16
+
17
+ ```bash
18
+ # Install uv if you don't have it
19
+ curl -LsSf https://astral.sh/uv/install.sh | sh
20
+
21
+ # Install the SDK
22
+ uv add ethereal-sdk
23
+ ```
24
+
25
+ ### Using pip
26
+
27
+ ```bash
28
+ pip install ethereal-sdk
29
+ ```
30
+
31
+ uvloop installs automatically on CPython for macOS/Linux; Windows and other platforms fall back to asyncio.
32
+
33
+ ## Quick Start
34
+
35
+ The SDK provides two client types:
36
+
37
+ **AsyncRESTClient** (Recommended for new applications):
38
+
39
+ ```python
40
+ import asyncio
41
+ from decimal import Decimal
42
+ from ethereal import AsyncRESTClient
43
+
44
+ async def main():
45
+ client = await AsyncRESTClient.create({
46
+ "base_url": "https://api.etherealtest.net",
47
+ "chain_config": {
48
+ "rpc_url": "https://rpc.etherealtest.net",
49
+ "private_key": "your_private_key", # optional - required for trading
50
+ }
51
+ })
52
+
53
+ # Get market data
54
+ products = await client.list_products()
55
+ product_ids = [p.id for p in products]
56
+ prices = await client.list_market_prices(product_ids=product_ids)
57
+
58
+ # Place an order (requires private key)
59
+ await client.create_order(
60
+ order_type="LIMIT",
61
+ quantity=Decimal("1.0"),
62
+ side=0, # 0 for buy, 1 for sell
63
+ price=Decimal("100.0"),
64
+ ticker="BTCUSD"
65
+ )
66
+
67
+ await client.close()
68
+
69
+ asyncio.run(main())
70
+ ```
71
+
72
+ **RESTClient** (Synchronous):
73
+
74
+ ```python
75
+ from decimal import Decimal
76
+ from ethereal import RESTClient
77
+
78
+ client = RESTClient({
79
+ "base_url": "https://api.etherealtest.net",
80
+ "chain_config": {
81
+ "rpc_url": "https://rpc.etherealtest.net",
82
+ "private_key": "your_private_key", # optional - required for trading
83
+ }
84
+ })
85
+
86
+ # Get market data
87
+ products = client.list_products()
88
+
89
+ # Place an order (requires private key)
90
+ order = client.create_order(
91
+ order_type="LIMIT",
92
+ quantity=Decimal("1.0"),
93
+ side=0,
94
+ price=Decimal("100.0"),
95
+ ticker="BTCUSD"
96
+ )
97
+ ```
98
+
99
+ ## Main Features
100
+
101
+ ### Market Data
102
+
103
+ - List available trading products
104
+ - Get current market prices
105
+ - View market order book
106
+ - Track funding rates
107
+
108
+ ### Trading
109
+
110
+ - Place market and limit orders
111
+ - Cancel orders
112
+ - View order history
113
+ - Track trades and fills
114
+
115
+ ### Account Management
116
+
117
+ - Manage subaccounts
118
+ - View positions
119
+ - Track token balances
120
+ - Handle deposits and withdrawals
121
+
122
+ ### Websocket Support
123
+
124
+ - Real-time market data
125
+ - Live order book updates
126
+
127
+ ## Configuration
128
+
129
+ The SDK can be configured with these options:
130
+
131
+ - `private_key`: Your private key for authentication
132
+ - `base_url`: API endpoint (default: "https://api.etherealtest.net")
133
+ - `timeout`: Request timeout in seconds
134
+ - `verbose`: Enable debug logging
135
+ - `rate_limit_headers`: Enable rate limit headers
136
+
137
+ The SDK automatically enables uvloop on supported platforms and transparently falls back to the built-in asyncio loop elsewhere.
138
+
139
+ ## Examples
140
+
141
+ ### Get Market Data
142
+
143
+ ```python
144
+ async def get_market_data():
145
+ client = await AsyncRESTClient.create({"base_url": "https://api.ethereal.trade"})
146
+
147
+ # List all available products
148
+ products = await client.list_products()
149
+
150
+ # Get current prices
151
+ all_product_ids = [product.id for product in products]
152
+ prices = await client.list_market_prices(product_ids=all_product_ids)
153
+
154
+ # View market liquidity
155
+ products_by_ticker = await client.products_by_ticker()
156
+ btc_product_id = products_by_ticker['BTCUSD'].id
157
+ liquidity = await client.get_market_liquidity(product_id=btc_product_id)
158
+
159
+ await client.close()
160
+
161
+ asyncio.run(get_market_data())
162
+ ```
163
+
164
+ ### Manage Orders
165
+
166
+ ```python
167
+ async def manage_orders():
168
+ config = {
169
+ "base_url": "https://api.ethereal.trade",
170
+ "chain_config": {
171
+ "rpc_url": "https://rpc.ethereal.trade",
172
+ "private_key": "your_private_key"
173
+ }
174
+ }
175
+ client = await AsyncRESTClient.create(config)
176
+
177
+ # Place a limit order
178
+ order = await client.create_order(
179
+ order_type="LIMIT",
180
+ quantity=Decimal("1.0"),
181
+ side=0,
182
+ price=Decimal("100.0"),
183
+ ticker="BTCUSD"
184
+ )
185
+
186
+ # Cancel an order
187
+ subaccounts = await client.subaccounts()
188
+ await client.cancel_orders(
189
+ order_ids=["<uuid of order>"],
190
+ sender=client.chain.address,
191
+ subaccount=subaccounts[0].name
192
+ )
193
+
194
+ # View order history
195
+ subaccount_id = subaccounts[0].id
196
+ orders = await client.list_orders(subaccount_id=subaccount_id)
197
+
198
+ await client.close()
199
+
200
+ asyncio.run(manage_orders())
201
+ ```
202
+
203
+ ### Account Operations
204
+
205
+ ```python
206
+ async def account_operations():
207
+ config = {
208
+ "base_url": "https://api.ethereal.trade",
209
+ "chain_config": {
210
+ "rpc_url": "https://rpc.ethereal.trade",
211
+ "private_key": "your_private_key"
212
+ }
213
+ }
214
+ client = await AsyncRESTClient.create(config)
215
+
216
+ # List subaccounts
217
+ subaccounts = await client.subaccounts()
218
+
219
+ # View positions
220
+ positions = await client.list_positions(subaccount_id=subaccounts[0].id)
221
+
222
+ # Get token balances
223
+ balances = await client.get_subaccount_balances(subaccount_id=subaccounts[0].id)
224
+
225
+ await client.close()
226
+
227
+ asyncio.run(account_operations())
228
+ ```
229
+
230
+ ## Ethereal Documentation
231
+
232
+ For full documentation, visit our [documentation site](https://docs.ethereal.trade).
233
+
234
+ ## Support
235
+
236
+ For issues and questions, please refer to the project's issue tracker or documentation.
@@ -0,0 +1,9 @@
1
+ from importlib.metadata import version
2
+
3
+ from ethereal.rest_client import RESTClient
4
+ from ethereal.async_rest_client import AsyncRESTClient
5
+ from ethereal.ws_client import WSClient
6
+ from ethereal.async_ws_client import AsyncWSClient
7
+
8
+ __version__ = version("ethereal-sdk")
9
+ __all__ = ["RESTClient", "AsyncRESTClient", "WSClient", "AsyncWSClient", "__version__"]