diff --git a/examples/basic_spot_to_perp.py b/examples/basic_spot_to_perp.py index 95e9c34..c3a92cb 100644 --- a/examples/basic_spot_to_perp.py +++ b/examples/basic_spot_to_perp.py @@ -6,11 +6,11 @@ def main(): address, info, exchange = example_utils.setup(constants.TESTNET_API_URL, skip_ws=True) # Transfer 1.23 USDC from perp wallet to spot wallet - transfer_result = exchange.user_spot_transfer(1.23, False) + transfer_result = exchange.usd_class_transfer(1.23, False) print(transfer_result) # Transfer 1.23 USDC from spot wallet to perp wallet - transfer_result = exchange.user_spot_transfer(1.23, True) + transfer_result = exchange.usd_class_transfer(1.23, True) print(transfer_result) diff --git a/hyperliquid/exchange.py b/hyperliquid/exchange.py index 1f79295..d9f5f53 100644 --- a/hyperliquid/exchange.py +++ b/hyperliquid/exchange.py @@ -55,7 +55,7 @@ def _post_action(self, action, signature, nonce): "action": action, "nonce": nonce, "signature": signature, - "vaultAddress": self.vault_address, + "vaultAddress": self.vault_address if action["type"] != "usdClassTransfer" else None, } logging.debug(payload) return self.post("/exchange", payload) @@ -402,9 +402,13 @@ def create_sub_account(self, name: str) -> Any: def usd_class_transfer(self, amount: float, to_perp: bool) -> Any: timestamp = get_timestamp_ms() + str_amount = str(amount) + if self.vault_address: + str_amount += f" subaccount:{self.vault_address}" + action = { "type": "usdClassTransfer", - "amount": str(amount), + "amount": str_amount, "toPerp": to_perp, "nonce": timestamp, } diff --git a/pyproject.toml b/pyproject.toml index 76e0c11..5eddc7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "hyperliquid-python-sdk" -version = "0.7.0" +version = "0.7.1" description = "SDK for Hyperliquid API trading with Python." readme = "README.md" authors = ["Hyperliquid "]