Skip to content

Commit bdaa8d4

Browse files
committed
add spot deploy functionality and example
1 parent 04253d0 commit bdaa8d4

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

hyperliquid/exchange.py

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,131 @@ def convert_to_multi_sig_user(self, authorized_users: List[str], threshold: int)
573573
timestamp,
574574
)
575575

576+
def spot_deploy_register_token(
577+
self, token_name: str, sz_decimals: int, wei_decimals: int, max_gas: int, full_name: str
578+
) -> Any:
579+
timestamp = get_timestamp_ms()
580+
action = {
581+
"type": "spotDeploy",
582+
"registerToken2": {
583+
"spec": {"name": token_name, "szDecimals": sz_decimals, "weiDecimals": wei_decimals},
584+
"maxGas": max_gas,
585+
"fullName": full_name,
586+
},
587+
}
588+
signature = sign_l1_action(
589+
self.wallet,
590+
action,
591+
None,
592+
timestamp,
593+
self.base_url == MAINNET_API_URL,
594+
)
595+
return self._post_action(
596+
action,
597+
signature,
598+
timestamp,
599+
)
600+
601+
def spot_deploy_user_genesis(
602+
self, token: int, user_and_wei: List[Tuple[str, str]], existing_token_and_wei: List[Tuple[int, str]]
603+
) -> Any:
604+
timestamp = get_timestamp_ms()
605+
action = {
606+
"type": "spotDeploy",
607+
"userGenesis": {
608+
"token": token,
609+
"userAndWei": [(user.lower(), wei) for (user, wei) in user_and_wei],
610+
"existingTokenAndWei": existing_token_and_wei,
611+
},
612+
}
613+
signature = sign_l1_action(
614+
self.wallet,
615+
action,
616+
None,
617+
timestamp,
618+
self.base_url == MAINNET_API_URL,
619+
)
620+
return self._post_action(
621+
action,
622+
signature,
623+
timestamp,
624+
)
625+
626+
def spot_deploy_genesis(self, token: int, max_supply: str, no_hyperliquidity: bool) -> Any:
627+
timestamp = get_timestamp_ms()
628+
genesis = {
629+
"token": token,
630+
"maxSupply": max_supply,
631+
}
632+
if no_hyperliquidity:
633+
genesis["noHyperliquidity"] = True
634+
action = {
635+
"type": "spotDeploy",
636+
"genesis": genesis,
637+
}
638+
signature = sign_l1_action(
639+
self.wallet,
640+
action,
641+
None,
642+
timestamp,
643+
self.base_url == MAINNET_API_URL,
644+
)
645+
return self._post_action(
646+
action,
647+
signature,
648+
timestamp,
649+
)
650+
651+
def spot_deploy_register_spot(self, base_token: int, quote_token: int) -> Any:
652+
timestamp = get_timestamp_ms()
653+
action = {
654+
"type": "spotDeploy",
655+
"registerSpot": {
656+
"tokens": [base_token, quote_token],
657+
},
658+
}
659+
signature = sign_l1_action(
660+
self.wallet,
661+
action,
662+
None,
663+
timestamp,
664+
self.base_url == MAINNET_API_URL,
665+
)
666+
return self._post_action(
667+
action,
668+
signature,
669+
timestamp,
670+
)
671+
672+
def spot_deploy_register_hyperliquidity(
673+
self, spot: int, start_px: float, order_sz: float, n_orders: int, n_seeded_levels: Optional[int]
674+
) -> Any:
675+
timestamp = get_timestamp_ms()
676+
register_hyperliquidity = {
677+
"spot": spot,
678+
"startPx": str(start_px),
679+
"orderSz": str(order_sz),
680+
"nOrders": n_orders,
681+
}
682+
if n_seeded_levels is not None:
683+
register_hyperliquidity["nSeededLevels"] = n_seeded_levels
684+
action = {
685+
"type": "spotDeploy",
686+
"registerHyperliquidity": register_hyperliquidity,
687+
}
688+
signature = sign_l1_action(
689+
self.wallet,
690+
action,
691+
None,
692+
timestamp,
693+
self.base_url == MAINNET_API_URL,
694+
)
695+
return self._post_action(
696+
action,
697+
signature,
698+
timestamp,
699+
)
700+
576701
def multi_sig(self, multi_sig_user, inner_action, signatures, nonce, vault_address=None):
577702
multi_sig_user = multi_sig_user.lower()
578703
multi_sig_action = {

0 commit comments

Comments
 (0)