Skip to content

Commit 88a3f6b

Browse files
committed
nit
1 parent 793a2cd commit 88a3f6b

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

examples/deployer_freeze.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Example script to freeze a user from trading, sending, and receiving a token.
2+
#
3+
# IMPORTANT: Replace any arguments for the exchange calls below to match your deployment requirements.
4+
5+
import example_utils
6+
7+
from hyperliquid.utils import constants
8+
9+
10+
def main():
11+
address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True)
12+
13+
# Freezing and unfreezing a user for token index 1. This assumes that the deployer
14+
# enabled deployer freeze privileges for this token before genesis.
15+
token = 1
16+
target_user = "0x0000000000000000000000000000000000000001"
17+
freeze_user_result = exchange.spot_deploy_freeze_user(token, target_user, True)
18+
print(freeze_user_result)
19+
20+
unfreeze_user_result = exchange.spot_deploy_freeze_user(token, target_user, False)
21+
print(unfreeze_user_result)
22+
23+
# Revoke freeze privilege. Revoking the freeze privilege for a token is permanent.
24+
revoke_freeze_privilege_result = exchange.spot_deploy_revoke_freeze_privilege(token)
25+
print(revoke_freeze_privilege_result)

examples/spot_deploy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ def main():
4949
user_genesis_result = exchange.spot_deploy_user_genesis(token, [], [(1, "100000000000000")])
5050
print(user_genesis_result)
5151

52+
# Step 2-a: Enable Deployer Freeze Functionality
53+
#
54+
# Enables the deployer to freeze/unfreeze users so that they cannot transfer or trade this token.
55+
enable_freeze_privilege_result = exchange.spot_deploy_enable_freeze_privilege(token)
56+
print(enable_freeze_privilege_result)
57+
5258
# Step 3: Genesis
5359
#
5460
# 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)