Skip to content

Commit 719c002

Browse files
committed
add deployer freeze functionality to client and spot deploy
1 parent 793a2cd commit 719c002

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

examples/spot_deploy.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
from hyperliquid.utils import constants
1010

11+
# Set to True to enable freeze functionality for the deployed token
12+
# See step 2-a below for more details on freezing.
13+
ENABLE_FREEZE_PRIVILEGE = False
14+
DUMMY_USER = "0x0000000000000000000000000000000000000001"
15+
1116

1217
def main():
1318
address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True)
@@ -36,7 +41,7 @@ def main():
3641
user_genesis_result = exchange.spot_deploy_user_genesis(
3742
token,
3843
[
39-
("0x0000000000000000000000000000000000000001", "100000000000000"),
44+
(DUMMY_USER, "100000000000000"),
4045
("0xffffffffffffffffffffffffffffffffffffffff", "100000000000000"),
4146
],
4247
[],
@@ -49,6 +54,20 @@ def main():
4954
user_genesis_result = exchange.spot_deploy_user_genesis(token, [], [(1, "100000000000000")])
5055
print(user_genesis_result)
5156

57+
if ENABLE_FREEZE_PRIVILEGE:
58+
# Step 2-a: Enables the deployer to freeze/unfreeze users. Freezing a user means
59+
# that user cannot trade, send, or receive this token.
60+
enable_freeze_privilege_result = exchange.spot_deploy_enable_freeze_privilege(token)
61+
print(enable_freeze_privilege_result)
62+
63+
# Freeze user for token
64+
freeze_user_result = exchange.spot_deploy_freeze_user(token, DUMMY_USER, True)
65+
print(freeze_user_result)
66+
67+
# Unfreeze user for token
68+
unfreeze_user_result = exchange.spot_deploy_freeze_user(token, DUMMY_USER, False)
69+
print(unfreeze_user_result)
70+
5271
# Step 3: Genesis
5372
#
5473
# Finalize genesis. The max supply of 300000000000000 wei needs to match the total

hyperliquid/exchange.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,71 @@ def spot_deploy_user_genesis(
623623
timestamp,
624624
)
625625

626+
def spot_deploy_enable_freeze_privilege(self, token: int) -> Any:
627+
timestamp = get_timestamp_ms()
628+
action = {
629+
"type": "spotDeploy",
630+
"enableFreezePrivilege": {
631+
"token": token,
632+
},
633+
}
634+
signature = sign_l1_action(
635+
self.wallet,
636+
action,
637+
None,
638+
timestamp,
639+
self.base_url == MAINNET_API_URL,
640+
)
641+
return self._post_action(
642+
action,
643+
signature,
644+
timestamp,
645+
)
646+
647+
def spot_deploy_freeze_user(self, token: int, user: str, freeze: bool) -> Any:
648+
timestamp = get_timestamp_ms()
649+
action = {
650+
"type": "spotDeploy",
651+
"freezeUser": {
652+
"token": token,
653+
"user": user.lower(),
654+
"freeze": freeze,
655+
},
656+
}
657+
signature = sign_l1_action(
658+
self.wallet,
659+
action,
660+
None,
661+
timestamp,
662+
self.base_url == MAINNET_API_URL,
663+
)
664+
return self._post_action(
665+
action,
666+
signature,
667+
timestamp,
668+
)
669+
670+
def spot_deploy_revoke_freeze_privilege(self, token: int) -> Any:
671+
timestamp = get_timestamp_ms()
672+
action = {
673+
"type": "spotDeploy",
674+
"revokeFreezePrivilege": {
675+
"token": token,
676+
},
677+
}
678+
signature = sign_l1_action(
679+
self.wallet,
680+
action,
681+
None,
682+
timestamp,
683+
self.base_url == MAINNET_API_URL,
684+
)
685+
return self._post_action(
686+
action,
687+
signature,
688+
timestamp,
689+
)
690+
626691
def spot_deploy_genesis(self, token: int, max_supply: str, no_hyperliquidity: bool) -> Any:
627692
timestamp = get_timestamp_ms()
628693
genesis = {

0 commit comments

Comments
 (0)