silhouette-python-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.
- silhouette_python_sdk-0.1.0/LICENSE.md +21 -0
- silhouette_python_sdk-0.1.0/PKG-INFO +291 -0
- silhouette_python_sdk-0.1.0/README.md +263 -0
- silhouette_python_sdk-0.1.0/pyproject.toml +191 -0
- silhouette_python_sdk-0.1.0/silhouette/__init__.py +88 -0
- silhouette_python_sdk-0.1.0/silhouette/abi/silhouette.json +1 -0
- silhouette_python_sdk-0.1.0/silhouette/api/__init__.py +5 -0
- silhouette_python_sdk-0.1.0/silhouette/api/auth.py +282 -0
- silhouette_python_sdk-0.1.0/silhouette/api/client.py +442 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/__init__.py +30 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/api.py +31 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/exchange.py +130 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/info.py +110 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/utils/__init__.py +22 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/utils/constants.py +4 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/utils/error.py +4 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/utils/signing.py +5 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/utils/types.py +4 -0
- silhouette_python_sdk-0.1.0/silhouette/hyperliquid/websocket_manager.py +34 -0
- silhouette_python_sdk-0.1.0/silhouette/py.typed +0 -0
- silhouette_python_sdk-0.1.0/silhouette/utils/__init__.py +8 -0
- silhouette_python_sdk-0.1.0/silhouette/utils/conversions.py +96 -0
- silhouette_python_sdk-0.1.0/silhouette/utils/types.py +369 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Hyperliquid Labs Pte. Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
18
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
19
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
20
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
21
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: silhouette-python-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for trading on Silhouette - the shield exchange on Hyperliquid
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: silhouette,trading,privacy,exchange,hyperliquid,defi,crypto,sdk
|
|
7
|
+
Author: Silhouette
|
|
8
|
+
Author-email: aidan@silhouette.exchange
|
|
9
|
+
Requires-Python: >=3.10,<4
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Dist: hyperliquid-python-sdk (>=0.20.0,<1.0.0)
|
|
21
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
22
|
+
Requires-Dist: siwe (>=4.4.0,<5.0.0)
|
|
23
|
+
Requires-Dist: typing_extensions (>=4.9.0) ; python_version < "3.11"
|
|
24
|
+
Project-URL: Homepage, https://github.com/silhouette-exchange/silhouette-python-sdk
|
|
25
|
+
Project-URL: Repository, https://github.com/silhouette-exchange/silhouette-python-sdk
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# silhouette-python-sdk
|
|
29
|
+
|
|
30
|
+
<div align="center">
|
|
31
|
+
|
|
32
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot)
|
|
33
|
+
[](https://github.com/astral-sh/ruff)
|
|
34
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/blob/main/.pre-commit-config.yaml)
|
|
35
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/releases)
|
|
36
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/blob/main/LICENSE.md)
|
|
37
|
+
|
|
38
|
+
Python SDK for trading on Silhouette - the shielded exchange on Hyperliquid.
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
## Overview
|
|
43
|
+
|
|
44
|
+
This package provides:
|
|
45
|
+
- **Drop-in replacement** for the official Hyperliquid Python SDK with enhanced convenience methods
|
|
46
|
+
- **Silhouette API integration** for trading on the shielded exchange
|
|
47
|
+
- **Type-safe** interfaces with comprehensive TypedDict definitions
|
|
48
|
+
- **Enhanced functionality** including balance checking, deposit automation, and withdrawal polling
|
|
49
|
+
|
|
50
|
+
**IMPORTANT**: This package replaces `hyperliquid-python-sdk`. Do not install both packages together. The official Hyperliquid SDK is included as a dependency.
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install silhouette-python-sdk
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Quick Start
|
|
59
|
+
|
|
60
|
+
### Using Enhanced Hyperliquid SDK
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
# IMPORTANT: Always import silhouette FIRST
|
|
64
|
+
import silhouette
|
|
65
|
+
|
|
66
|
+
# Then use standard hyperliquid imports to get enhanced versions
|
|
67
|
+
from hyperliquid.info import Info
|
|
68
|
+
from hyperliquid.exchange import Exchange
|
|
69
|
+
from hyperliquid.utils.constants import TESTNET_API_URL
|
|
70
|
+
|
|
71
|
+
# Enhanced Info client with get_balance() and await_withdrawal_completion()
|
|
72
|
+
info = Info(base_url=TESTNET_API_URL, skip_ws=True)
|
|
73
|
+
|
|
74
|
+
# Check spot balances
|
|
75
|
+
spot_state = info.spot_user_state("0x1615330FAee0776a643CC0075AD2008418e067Db")
|
|
76
|
+
print(spot_state)
|
|
77
|
+
|
|
78
|
+
# Get specific token balance (convenience method)
|
|
79
|
+
usdc_balance = info.get_balance("0x1615330FAee0776a643CC0075AD2008418e067Db", "USDC")
|
|
80
|
+
print(f"USDC Balance: {usdc_balance}")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Using Silhouette API
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from silhouette import SilhouetteApiClient
|
|
87
|
+
|
|
88
|
+
# Initialize client with auto-authentication
|
|
89
|
+
client = SilhouetteApiClient(
|
|
90
|
+
base_url="https://api-alpha.silhouette.exchange:8081",
|
|
91
|
+
private_key="your_private_key_here",
|
|
92
|
+
auto_auth=True,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Check balances
|
|
96
|
+
balances = client.user.get_balances()
|
|
97
|
+
print(balances)
|
|
98
|
+
|
|
99
|
+
# Place an order
|
|
100
|
+
order = client.order.create_order(
|
|
101
|
+
side="buy",
|
|
102
|
+
orderType="limit",
|
|
103
|
+
baseToken="HYPE",
|
|
104
|
+
quoteToken="USDC",
|
|
105
|
+
amount="1.0",
|
|
106
|
+
price="0.001",
|
|
107
|
+
)
|
|
108
|
+
print(f"Order placed: {order['orderId']}")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Enhanced Features
|
|
112
|
+
|
|
113
|
+
### Hyperliquid SDK Enhancements
|
|
114
|
+
|
|
115
|
+
The enhanced Hyperliquid SDK includes these convenience methods:
|
|
116
|
+
|
|
117
|
+
**Info class:**
|
|
118
|
+
- `get_balance(wallet_address: str, token_symbol: str) -> float` - Get user's balance for a specific token
|
|
119
|
+
- `await_withdrawal_completion(wallet_address: str, pre_withdrawal_balance: float, token_symbol: str, timeout: int) -> bool` - Poll balance until withdrawal completes
|
|
120
|
+
|
|
121
|
+
**Exchange class:**
|
|
122
|
+
- `deposit_to_silhouette(contract_address: str, token_symbol: str, amount: str, converter: TokenConverter) -> dict` - Deposit tokens from Hyperliquid to Silhouette contract
|
|
123
|
+
|
|
124
|
+
All other Hyperliquid SDK methods work exactly as documented in the [official Hyperliquid SDK](https://github.com/hyperliquid-dex/hyperliquid-python-sdk).
|
|
125
|
+
|
|
126
|
+
### Silhouette API Client
|
|
127
|
+
|
|
128
|
+
The `SilhouetteApiClient` provides access to the Silhouette shielded exchange:
|
|
129
|
+
|
|
130
|
+
- User operations: balances, withdrawal initiation
|
|
131
|
+
- Order management: create, cancel, query orders
|
|
132
|
+
- Trade execution with privacy guarantees
|
|
133
|
+
- Automatic authentication and session management
|
|
134
|
+
|
|
135
|
+
## Configuration
|
|
136
|
+
|
|
137
|
+
Create `examples/config.json` from the example template:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
cp examples/config.json.example examples/config.json
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Then configure:
|
|
144
|
+
- `account_address`: Your wallet's public address
|
|
145
|
+
- `secret_key`: Your wallet's private key (or use `keystore_path` for a keystore file)
|
|
146
|
+
- `use_testnet`: Set to `true` for testnet, `false` for mainnet
|
|
147
|
+
|
|
148
|
+
### [Optional] Using an API Wallet
|
|
149
|
+
|
|
150
|
+
Generate and authorise a new API private key on <https://app.hyperliquid.xyz/API>, and set the API wallet's private key as the `secret_key` in `examples/config.json`. Note that you must still set the public key of the main wallet (not the API wallet) as the `account_address`.
|
|
151
|
+
|
|
152
|
+
## Usage Examples
|
|
153
|
+
|
|
154
|
+
See [examples/](examples/) for complete examples:
|
|
155
|
+
|
|
156
|
+
- **[silhouette_full_workflow.py](examples/silhouette_full_workflow.py)** - Complete workflow: deposit, trade, withdraw
|
|
157
|
+
- **[basic_order.py](examples/basic_order.py)** - Place and manage orders on Hyperliquid
|
|
158
|
+
- **[basic_spot_order.py](examples/basic_spot_order.py)** - Spot trading examples
|
|
159
|
+
- **[basic_adding.py](examples/basic_adding.py)** - Deposit funds to Hyperliquid
|
|
160
|
+
|
|
161
|
+
Run any example after configuring your credentials:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
python examples/silhouette_full_workflow.py
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
### Prerequisites
|
|
170
|
+
|
|
171
|
+
- Python 3.10 or higher
|
|
172
|
+
- [Poetry](https://python-poetry.org/) for dependency management
|
|
173
|
+
|
|
174
|
+
### Setup
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Install Poetry (if not already installed)
|
|
178
|
+
curl -sSL https://install.python-poetry.org | python3 -
|
|
179
|
+
|
|
180
|
+
# Install dependencies
|
|
181
|
+
make install
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Development Workflow
|
|
185
|
+
|
|
186
|
+
#### Code Quality and Linting
|
|
187
|
+
|
|
188
|
+
This project uses [ruff](https://docs.astral.sh/ruff/) for linting and formatting, with pre-commit hooks for automated checks.
|
|
189
|
+
|
|
190
|
+
**Normal development workflow:**
|
|
191
|
+
1. Make your changes
|
|
192
|
+
2. Run `git add .` to stage changes
|
|
193
|
+
3. Run `git commit` - pre-commit hooks will run automatically
|
|
194
|
+
|
|
195
|
+
**If pre-commit hooks fail:**
|
|
196
|
+
1. `make check` - See all linting issues
|
|
197
|
+
2. `make fix` - Auto-fix safe issues
|
|
198
|
+
3. `make format` - Format code
|
|
199
|
+
4. `make test` - Run tests
|
|
200
|
+
5. Stage changes and commit again
|
|
201
|
+
|
|
202
|
+
#### Available Make Commands
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
make build # Builds as a tarball and a wheel
|
|
206
|
+
make check # Run ruff check without fixes
|
|
207
|
+
make check-safety # Run safety checks on dependencies
|
|
208
|
+
make cleanup # Cleanup project
|
|
209
|
+
make fix # Run ruff check with fixes
|
|
210
|
+
make fix-unsafe # Run ruff check with unsafe fixes
|
|
211
|
+
make format # Run ruff format
|
|
212
|
+
make install # Install dependencies from poetry.lock
|
|
213
|
+
make install-types # Find and install additional types for mypy
|
|
214
|
+
make lockfile-update # Update poetry.lock
|
|
215
|
+
make lockfile-update-full # Fully regenerate poetry.lock
|
|
216
|
+
make poetry-download # Download and install poetry
|
|
217
|
+
make pre-commit # Run all pre-commit hooks
|
|
218
|
+
make publish # Publish the package to PyPI
|
|
219
|
+
make test # Run tests with pytest
|
|
220
|
+
make update-dev-deps # Update development dependencies to latest versions
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Run `make` without arguments to see this list of commands.
|
|
224
|
+
|
|
225
|
+
### Running Tests
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Run all tests
|
|
229
|
+
make test
|
|
230
|
+
|
|
231
|
+
# Run specific test file
|
|
232
|
+
poetry run pytest tests/hyperliquid/info_test.py -v
|
|
233
|
+
|
|
234
|
+
# Run with coverage report
|
|
235
|
+
poetry run pytest --cov=silhouette --cov-report=html
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Project Structure
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
silhouette-python-sdk/
|
|
242
|
+
├── silhouette/
|
|
243
|
+
│ ├── api/ # Silhouette API client
|
|
244
|
+
│ │ ├── client.py # Main API client
|
|
245
|
+
│ │ └── auth.py # Authentication
|
|
246
|
+
│ ├── hyperliquid/ # Enhanced Hyperliquid SDK wrappers
|
|
247
|
+
│ │ ├── info.py # Enhanced Info class
|
|
248
|
+
│ │ ├── exchange.py # Enhanced Exchange class
|
|
249
|
+
│ │ └── utils/ # Re-exported utilities
|
|
250
|
+
│ └── utils/
|
|
251
|
+
│ ├── conversions.py # Token conversion utilities
|
|
252
|
+
│ └── types.py # Type definitions
|
|
253
|
+
├── tests/ # Test suite
|
|
254
|
+
│ ├── api/ # API client tests
|
|
255
|
+
│ ├── hyperliquid/ # Hyperliquid wrapper tests
|
|
256
|
+
│ └── utils/ # Utility tests
|
|
257
|
+
└── examples/ # Usage examples
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Releases
|
|
261
|
+
|
|
262
|
+
See [GitHub Releases](https://github.com/silhouette-exchange/silhouette-python-sdk/releases) for available versions.
|
|
263
|
+
|
|
264
|
+
We follow [Semantic Versioning](https://semver.org/) and use [Release Drafter](https://github.com/marketplace/actions/release-drafter) for automated release notes.
|
|
265
|
+
|
|
266
|
+
### Building and Releasing
|
|
267
|
+
|
|
268
|
+
1. Bump version: `poetry version <major|minor|patch>`
|
|
269
|
+
2. Commit changes: `git commit -am "Bump version to X.Y.Z"`
|
|
270
|
+
3. Create GitHub release
|
|
271
|
+
4. Publish: `make publish`
|
|
272
|
+
|
|
273
|
+
## Licence
|
|
274
|
+
|
|
275
|
+
This project is licensed under the terms of the MIT licence. See [LICENSE](LICENSE.md) for more details.
|
|
276
|
+
|
|
277
|
+
```bibtex
|
|
278
|
+
@misc{silhouette-python-sdk,
|
|
279
|
+
author = {Silhouette},
|
|
280
|
+
title = {Python SDK for trading on Silhouette - the shielded exchange on Hyperliquid},
|
|
281
|
+
year = {2025},
|
|
282
|
+
publisher = {GitHub},
|
|
283
|
+
journal = {GitHub repository},
|
|
284
|
+
howpublished = {\url{https://github.com/silhouette-exchange/silhouette-python-sdk}}
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Credits
|
|
289
|
+
|
|
290
|
+
This project was generated with [`python-package-template`](https://github.com/TezRomacH/python-package-template).
|
|
291
|
+
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# silhouette-python-sdk
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot)
|
|
6
|
+
[](https://github.com/astral-sh/ruff)
|
|
7
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/blob/main/.pre-commit-config.yaml)
|
|
8
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/releases)
|
|
9
|
+
[](https://github.com/silhouette-exchange/silhouette-python-sdk/blob/main/LICENSE.md)
|
|
10
|
+
|
|
11
|
+
Python SDK for trading on Silhouette - the shielded exchange on Hyperliquid.
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
## Overview
|
|
16
|
+
|
|
17
|
+
This package provides:
|
|
18
|
+
- **Drop-in replacement** for the official Hyperliquid Python SDK with enhanced convenience methods
|
|
19
|
+
- **Silhouette API integration** for trading on the shielded exchange
|
|
20
|
+
- **Type-safe** interfaces with comprehensive TypedDict definitions
|
|
21
|
+
- **Enhanced functionality** including balance checking, deposit automation, and withdrawal polling
|
|
22
|
+
|
|
23
|
+
**IMPORTANT**: This package replaces `hyperliquid-python-sdk`. Do not install both packages together. The official Hyperliquid SDK is included as a dependency.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install silhouette-python-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### Using Enhanced Hyperliquid SDK
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
# IMPORTANT: Always import silhouette FIRST
|
|
37
|
+
import silhouette
|
|
38
|
+
|
|
39
|
+
# Then use standard hyperliquid imports to get enhanced versions
|
|
40
|
+
from hyperliquid.info import Info
|
|
41
|
+
from hyperliquid.exchange import Exchange
|
|
42
|
+
from hyperliquid.utils.constants import TESTNET_API_URL
|
|
43
|
+
|
|
44
|
+
# Enhanced Info client with get_balance() and await_withdrawal_completion()
|
|
45
|
+
info = Info(base_url=TESTNET_API_URL, skip_ws=True)
|
|
46
|
+
|
|
47
|
+
# Check spot balances
|
|
48
|
+
spot_state = info.spot_user_state("0x1615330FAee0776a643CC0075AD2008418e067Db")
|
|
49
|
+
print(spot_state)
|
|
50
|
+
|
|
51
|
+
# Get specific token balance (convenience method)
|
|
52
|
+
usdc_balance = info.get_balance("0x1615330FAee0776a643CC0075AD2008418e067Db", "USDC")
|
|
53
|
+
print(f"USDC Balance: {usdc_balance}")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Using Silhouette API
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from silhouette import SilhouetteApiClient
|
|
60
|
+
|
|
61
|
+
# Initialize client with auto-authentication
|
|
62
|
+
client = SilhouetteApiClient(
|
|
63
|
+
base_url="https://api-alpha.silhouette.exchange:8081",
|
|
64
|
+
private_key="your_private_key_here",
|
|
65
|
+
auto_auth=True,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Check balances
|
|
69
|
+
balances = client.user.get_balances()
|
|
70
|
+
print(balances)
|
|
71
|
+
|
|
72
|
+
# Place an order
|
|
73
|
+
order = client.order.create_order(
|
|
74
|
+
side="buy",
|
|
75
|
+
orderType="limit",
|
|
76
|
+
baseToken="HYPE",
|
|
77
|
+
quoteToken="USDC",
|
|
78
|
+
amount="1.0",
|
|
79
|
+
price="0.001",
|
|
80
|
+
)
|
|
81
|
+
print(f"Order placed: {order['orderId']}")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Enhanced Features
|
|
85
|
+
|
|
86
|
+
### Hyperliquid SDK Enhancements
|
|
87
|
+
|
|
88
|
+
The enhanced Hyperliquid SDK includes these convenience methods:
|
|
89
|
+
|
|
90
|
+
**Info class:**
|
|
91
|
+
- `get_balance(wallet_address: str, token_symbol: str) -> float` - Get user's balance for a specific token
|
|
92
|
+
- `await_withdrawal_completion(wallet_address: str, pre_withdrawal_balance: float, token_symbol: str, timeout: int) -> bool` - Poll balance until withdrawal completes
|
|
93
|
+
|
|
94
|
+
**Exchange class:**
|
|
95
|
+
- `deposit_to_silhouette(contract_address: str, token_symbol: str, amount: str, converter: TokenConverter) -> dict` - Deposit tokens from Hyperliquid to Silhouette contract
|
|
96
|
+
|
|
97
|
+
All other Hyperliquid SDK methods work exactly as documented in the [official Hyperliquid SDK](https://github.com/hyperliquid-dex/hyperliquid-python-sdk).
|
|
98
|
+
|
|
99
|
+
### Silhouette API Client
|
|
100
|
+
|
|
101
|
+
The `SilhouetteApiClient` provides access to the Silhouette shielded exchange:
|
|
102
|
+
|
|
103
|
+
- User operations: balances, withdrawal initiation
|
|
104
|
+
- Order management: create, cancel, query orders
|
|
105
|
+
- Trade execution with privacy guarantees
|
|
106
|
+
- Automatic authentication and session management
|
|
107
|
+
|
|
108
|
+
## Configuration
|
|
109
|
+
|
|
110
|
+
Create `examples/config.json` from the example template:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
cp examples/config.json.example examples/config.json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Then configure:
|
|
117
|
+
- `account_address`: Your wallet's public address
|
|
118
|
+
- `secret_key`: Your wallet's private key (or use `keystore_path` for a keystore file)
|
|
119
|
+
- `use_testnet`: Set to `true` for testnet, `false` for mainnet
|
|
120
|
+
|
|
121
|
+
### [Optional] Using an API Wallet
|
|
122
|
+
|
|
123
|
+
Generate and authorise a new API private key on <https://app.hyperliquid.xyz/API>, and set the API wallet's private key as the `secret_key` in `examples/config.json`. Note that you must still set the public key of the main wallet (not the API wallet) as the `account_address`.
|
|
124
|
+
|
|
125
|
+
## Usage Examples
|
|
126
|
+
|
|
127
|
+
See [examples/](examples/) for complete examples:
|
|
128
|
+
|
|
129
|
+
- **[silhouette_full_workflow.py](examples/silhouette_full_workflow.py)** - Complete workflow: deposit, trade, withdraw
|
|
130
|
+
- **[basic_order.py](examples/basic_order.py)** - Place and manage orders on Hyperliquid
|
|
131
|
+
- **[basic_spot_order.py](examples/basic_spot_order.py)** - Spot trading examples
|
|
132
|
+
- **[basic_adding.py](examples/basic_adding.py)** - Deposit funds to Hyperliquid
|
|
133
|
+
|
|
134
|
+
Run any example after configuring your credentials:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
python examples/silhouette_full_workflow.py
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
### Prerequisites
|
|
143
|
+
|
|
144
|
+
- Python 3.10 or higher
|
|
145
|
+
- [Poetry](https://python-poetry.org/) for dependency management
|
|
146
|
+
|
|
147
|
+
### Setup
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Install Poetry (if not already installed)
|
|
151
|
+
curl -sSL https://install.python-poetry.org | python3 -
|
|
152
|
+
|
|
153
|
+
# Install dependencies
|
|
154
|
+
make install
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Development Workflow
|
|
158
|
+
|
|
159
|
+
#### Code Quality and Linting
|
|
160
|
+
|
|
161
|
+
This project uses [ruff](https://docs.astral.sh/ruff/) for linting and formatting, with pre-commit hooks for automated checks.
|
|
162
|
+
|
|
163
|
+
**Normal development workflow:**
|
|
164
|
+
1. Make your changes
|
|
165
|
+
2. Run `git add .` to stage changes
|
|
166
|
+
3. Run `git commit` - pre-commit hooks will run automatically
|
|
167
|
+
|
|
168
|
+
**If pre-commit hooks fail:**
|
|
169
|
+
1. `make check` - See all linting issues
|
|
170
|
+
2. `make fix` - Auto-fix safe issues
|
|
171
|
+
3. `make format` - Format code
|
|
172
|
+
4. `make test` - Run tests
|
|
173
|
+
5. Stage changes and commit again
|
|
174
|
+
|
|
175
|
+
#### Available Make Commands
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
make build # Builds as a tarball and a wheel
|
|
179
|
+
make check # Run ruff check without fixes
|
|
180
|
+
make check-safety # Run safety checks on dependencies
|
|
181
|
+
make cleanup # Cleanup project
|
|
182
|
+
make fix # Run ruff check with fixes
|
|
183
|
+
make fix-unsafe # Run ruff check with unsafe fixes
|
|
184
|
+
make format # Run ruff format
|
|
185
|
+
make install # Install dependencies from poetry.lock
|
|
186
|
+
make install-types # Find and install additional types for mypy
|
|
187
|
+
make lockfile-update # Update poetry.lock
|
|
188
|
+
make lockfile-update-full # Fully regenerate poetry.lock
|
|
189
|
+
make poetry-download # Download and install poetry
|
|
190
|
+
make pre-commit # Run all pre-commit hooks
|
|
191
|
+
make publish # Publish the package to PyPI
|
|
192
|
+
make test # Run tests with pytest
|
|
193
|
+
make update-dev-deps # Update development dependencies to latest versions
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Run `make` without arguments to see this list of commands.
|
|
197
|
+
|
|
198
|
+
### Running Tests
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Run all tests
|
|
202
|
+
make test
|
|
203
|
+
|
|
204
|
+
# Run specific test file
|
|
205
|
+
poetry run pytest tests/hyperliquid/info_test.py -v
|
|
206
|
+
|
|
207
|
+
# Run with coverage report
|
|
208
|
+
poetry run pytest --cov=silhouette --cov-report=html
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Project Structure
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
silhouette-python-sdk/
|
|
215
|
+
├── silhouette/
|
|
216
|
+
│ ├── api/ # Silhouette API client
|
|
217
|
+
│ │ ├── client.py # Main API client
|
|
218
|
+
│ │ └── auth.py # Authentication
|
|
219
|
+
│ ├── hyperliquid/ # Enhanced Hyperliquid SDK wrappers
|
|
220
|
+
│ │ ├── info.py # Enhanced Info class
|
|
221
|
+
│ │ ├── exchange.py # Enhanced Exchange class
|
|
222
|
+
│ │ └── utils/ # Re-exported utilities
|
|
223
|
+
│ └── utils/
|
|
224
|
+
│ ├── conversions.py # Token conversion utilities
|
|
225
|
+
│ └── types.py # Type definitions
|
|
226
|
+
├── tests/ # Test suite
|
|
227
|
+
│ ├── api/ # API client tests
|
|
228
|
+
│ ├── hyperliquid/ # Hyperliquid wrapper tests
|
|
229
|
+
│ └── utils/ # Utility tests
|
|
230
|
+
└── examples/ # Usage examples
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Releases
|
|
234
|
+
|
|
235
|
+
See [GitHub Releases](https://github.com/silhouette-exchange/silhouette-python-sdk/releases) for available versions.
|
|
236
|
+
|
|
237
|
+
We follow [Semantic Versioning](https://semver.org/) and use [Release Drafter](https://github.com/marketplace/actions/release-drafter) for automated release notes.
|
|
238
|
+
|
|
239
|
+
### Building and Releasing
|
|
240
|
+
|
|
241
|
+
1. Bump version: `poetry version <major|minor|patch>`
|
|
242
|
+
2. Commit changes: `git commit -am "Bump version to X.Y.Z"`
|
|
243
|
+
3. Create GitHub release
|
|
244
|
+
4. Publish: `make publish`
|
|
245
|
+
|
|
246
|
+
## Licence
|
|
247
|
+
|
|
248
|
+
This project is licensed under the terms of the MIT licence. See [LICENSE](LICENSE.md) for more details.
|
|
249
|
+
|
|
250
|
+
```bibtex
|
|
251
|
+
@misc{silhouette-python-sdk,
|
|
252
|
+
author = {Silhouette},
|
|
253
|
+
title = {Python SDK for trading on Silhouette - the shielded exchange on Hyperliquid},
|
|
254
|
+
year = {2025},
|
|
255
|
+
publisher = {GitHub},
|
|
256
|
+
journal = {GitHub repository},
|
|
257
|
+
howpublished = {\url{https://github.com/silhouette-exchange/silhouette-python-sdk}}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Credits
|
|
262
|
+
|
|
263
|
+
This project was generated with [`python-package-template`](https://github.com/TezRomacH/python-package-template).
|