diff --git a/examples/basic_spot_deploy.py b/examples/basic_spot_deploy.py new file mode 100644 index 0000000..1a03de7 --- /dev/null +++ b/examples/basic_spot_deploy.py @@ -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() \ No newline at end of file diff --git a/hyperliquid/exchange.py b/hyperliquid/exchange.py index f0c5d47..74c73c8 100644 --- a/hyperliquid/exchange.py +++ b/hyperliquid/exchange.py @@ -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, + ) \ No newline at end of file