Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions examples/basic_spot_deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from hyperliquid.utils import constants
import example_utils

TOKEN_ID = 1169
IS_MAINNET = False

def main():

_, _, exchange = example_utils.setup(constants.MAINNET_API_URL if IS_MAINNET else constants.TESTNET_API_URL, skip_ws=True)

user_and_wei = [["0xffffffffffffffffffffffffffffffffffffffff","0"]]
existing_token_and_wei = []

response = exchange.spot_deploy(TOKEN_ID, user_and_wei, existing_token_and_wei)

print(response)

if __name__ == "__main__":
main()
26 changes: 26 additions & 0 deletions hyperliquid/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,3 +575,29 @@ def multi_sig(self, multi_sig_user, inner_action, signatures, nonce, vault_addre
signature,
nonce,
)

def spot_deploy(self, token_id, user_and_wei: List[Tuple[str, int]], existing_token_and_wei: List[Tuple[str, int]]):
spot_deploy_action = {
"type": "spotDeploy",
"userGenesis":{
"token": token_id,
"userAndWei": [(address.lower(), amount) for address, amount in user_and_wei],
"existingTokenAndWei": [(address.lower(), amount) for address, amount in existing_token_and_wei]
}
}

timestamp = get_timestamp_ms()

signature = sign_l1_action(
self.wallet,
spot_deploy_action,
None,
timestamp,
self.base_url == MAINNET_API_URL,
)

return self._post_action(
spot_deploy_action,
signature,
timestamp,
)