Skip to content

Commit 8d1260f

Browse files
committed
Add spot_deploy to Exchange and examples
1 parent 636d60e commit 8d1260f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

examples/basic_spot_deploy.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from hyperliquid.utils import constants
2+
import example_utils
3+
4+
TOKEN_ID = 1169
5+
IS_MAINNET = False
6+
7+
def main():
8+
9+
_, _, exchange = example_utils.setup(constants.MAINNET_API_URL if IS_MAINNET else constants.TESTNET_API_URL, skip_ws=True)
10+
11+
user_and_wei = [["0xffffffffffffffffffffffffffffffffffffffff","0"]]
12+
existing_token_and_wei = []
13+
14+
response = exchange.spot_deploy(TOKEN_ID, user_and_wei, existing_token_and_wei)
15+
16+
print(response)
17+
18+
if __name__ == "__main__":
19+
main()

hyperliquid/exchange.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,3 +575,29 @@ def multi_sig(self, multi_sig_user, inner_action, signatures, nonce, vault_addre
575575
signature,
576576
nonce,
577577
)
578+
579+
def spot_deploy(self, token_id, user_and_wei: List[Tuple[str, int]], existing_token_and_wei: List[Tuple[str, int]]):
580+
spot_deploy_action = {
581+
"type": "spotDeploy",
582+
"userGenesis":{
583+
"token": token_id,
584+
"userAndWei": [(address.lower(), amount) for address, amount in user_and_wei],
585+
"existingTokenAndWei": [(address.lower(), amount) for address, amount in existing_token_and_wei]
586+
}
587+
}
588+
589+
timestamp = get_timestamp_ms()
590+
591+
signature = sign_l1_action(
592+
self.wallet,
593+
spot_deploy_action,
594+
None,
595+
timestamp,
596+
self.base_url == MAINNET_API_URL,
597+
)
598+
599+
return self._post_action(
600+
spot_deploy_action,
601+
signature,
602+
timestamp,
603+
)

0 commit comments

Comments
 (0)