-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtransfers.py
More file actions
65 lines (47 loc) · 1.77 KB
/
transfers.py
File metadata and controls
65 lines (47 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""
Transfers Example
Transfer USD and spot assets between accounts and wallets.
Requirements:
pip install hyperliquid-sdk
Usage:
export PRIVATE_KEY="0x..."
python transfers.py
"""
import os
import sys
from hyperliquid_sdk import HyperliquidSDK
PRIVATE_KEY = os.environ.get("PRIVATE_KEY")
if not PRIVATE_KEY:
print("Error: Set PRIVATE_KEY environment variable")
print(" export PRIVATE_KEY='0xYourPrivateKey'")
sys.exit(1)
def main():
print("Hyperliquid Transfers Example")
print("=" * 50)
sdk = HyperliquidSDK(private_key=PRIVATE_KEY)
print(f"Wallet: {sdk.address}")
# Transfer USD to another address
# result = sdk.transfer_usd("0x1234567890123456789012345678901234567890", 10.0)
# print(f"USD transfer: {result}")
# Transfer spot asset to another address
# result = sdk.transfer_spot("PURR", "0x1234567890123456789012345678901234567890", 100.0)
# print(f"Spot transfer: {result}")
# Transfer from spot wallet to perp wallet (internal)
# result = sdk.transfer_spot_to_perp(100.0)
# print(f"Spot to perp: {result}")
# Transfer from perp wallet to spot wallet (internal)
# result = sdk.transfer_perp_to_spot(100.0)
# print(f"Perp to spot: {result}")
# Send asset (generalized transfer)
# result = sdk.send_asset("USDC", "100.0", "0x1234567890123456789012345678901234567890")
# print(f"Send asset: {result}")
print()
print("Transfer methods available:")
print(" sdk.transfer_usd(destination, amount)")
print(" sdk.transfer_spot(token, destination, amount)")
print(" sdk.transfer_spot_to_perp(amount)")
print(" sdk.transfer_perp_to_spot(amount)")
print(" sdk.send_asset(token, amount, destination)")
if __name__ == "__main__":
main()