Skip to content

Commit 866d18d

Browse files
committed
Version 0.10.0
1 parent a85725c commit 866d18d

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

examples/basic_evm_use_big_blocks.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import example_utils
2+
3+
from hyperliquid.utils import constants
4+
5+
6+
# This example shows how to switch an account to use big blocks on the EVM
7+
def main():
8+
address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True)
9+
10+
print(exchange.use_big_blocks(True))
11+
print(exchange.use_big_blocks(False))
12+
13+
14+
if __name__ == "__main__":
15+
main()

examples/basic_sub_account.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ def main():
1616
if sub_account["name"] == name:
1717
sub_account_user = sub_account["subAccountUser"]
1818

19-
print(exchange.sub_account_transfer(sub_account_user, True, 10))
19+
# Transfer 1 USD to the subaccount
20+
print(exchange.sub_account_transfer(sub_account_user, True, 1_000_000))
21+
# Transfer 1.23 HYPE to the subaccount (the token string assumes testnet, the address needs to be changed for mainnet)
22+
print(exchange.sub_account_spot_transfer(sub_account_user, True, "HYPE:0x7317beb7cceed72ef0b346074cc8e7ab", 1.23))
2023

2124

2225
if __name__ == "__main__":

hyperliquid/exchange.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,28 @@ def sub_account_transfer(self, sub_account_user: str, is_deposit: bool, usd: int
445445
timestamp,
446446
)
447447

448+
def sub_account_spot_transfer(self, sub_account_user: str, is_deposit: bool, token: str, amount: float) -> Any:
449+
timestamp = get_timestamp_ms()
450+
sub_account_transfer_action = {
451+
"type": "subAccountSpotTransfer",
452+
"subAccountUser": sub_account_user,
453+
"isDeposit": is_deposit,
454+
"token": token,
455+
"amount": str(amount),
456+
}
457+
signature = sign_l1_action(
458+
self.wallet,
459+
sub_account_transfer_action,
460+
None,
461+
timestamp,
462+
self.base_url == MAINNET_API_URL,
463+
)
464+
return self._post_action(
465+
sub_account_transfer_action,
466+
signature,
467+
timestamp,
468+
)
469+
448470
def vault_usd_transfer(self, vault_address: str, is_deposit: bool, usd: int) -> Any:
449471
timestamp = get_timestamp_ms()
450472
vault_transfer_action = {
@@ -575,3 +597,22 @@ def multi_sig(self, multi_sig_user, inner_action, signatures, nonce, vault_addre
575597
signature,
576598
nonce,
577599
)
600+
601+
def use_big_blocks(self, enable: bool) -> Any:
602+
timestamp = get_timestamp_ms()
603+
action = {
604+
"type": "evmUserModify",
605+
"usingBigBlocks": enable,
606+
}
607+
signature = sign_l1_action(
608+
self.wallet,
609+
action,
610+
None,
611+
timestamp,
612+
self.base_url == MAINNET_API_URL,
613+
)
614+
return self._post_action(
615+
action,
616+
signature,
617+
timestamp,
618+
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
55

66
[tool.poetry]
77
name = "hyperliquid-python-sdk"
8-
version = "0.9.0"
8+
version = "0.10.0"
99
description = "SDK for Hyperliquid API trading with Python."
1010
readme = "README.md"
1111
authors = ["Hyperliquid <[email protected]>"]

0 commit comments

Comments
 (0)