transfer currency internally between wallets on the same account https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#l1-usdc-transfer :param str code: unified currency code :param float amount: amount to transfer :param str
(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})
| 3726 | } |
| 3727 | |
| 3728 | def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry: |
| 3729 | """ |
| 3730 | transfer currency internally between wallets on the same account |
| 3731 | |
| 3732 | https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#l1-usdc-transfer |
| 3733 | |
| 3734 | :param str code: unified currency code |
| 3735 | :param float amount: amount to transfer |
| 3736 | :param str fromAccount: account to transfer from *spot, swap* |
| 3737 | :param str toAccount: account to transfer to *swap, spot or address* |
| 3738 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 3739 | :param str [params.vaultAddress]: the vault address for order |
| 3740 | :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>` |
| 3741 | """ |
| 3742 | self.check_required_credentials() |
| 3743 | self.load_markets() |
| 3744 | isSandboxMode = self.safe_bool(self.options, 'sandboxMode') |
| 3745 | nonce = self.milliseconds() |
| 3746 | if self.in_array(fromAccount, ['spot', 'swap', 'perp']): |
| 3747 | # handle swap <> spot account transfer |
| 3748 | if not self.in_array(toAccount, ['spot', 'swap', 'perp']): |
| 3749 | raise NotSupported(self.id + ' transfer() only support spot <> swap transfer') |
| 3750 | strAmount = self.number_to_string(amount) |
| 3751 | vaultAddress = self.safe_string_2(params, 'vaultAddress', 'subAccountAddress') |
| 3752 | if vaultAddress is not None: |
| 3753 | vaultAddress = self.format_vault_address(vaultAddress) |
| 3754 | strAmount = strAmount + ' subaccount:' + vaultAddress |
| 3755 | strAmountFinal = strAmount # java req |
| 3756 | toPerp = (toAccount == 'perp') or (toAccount == 'swap') |
| 3757 | transferPayload = { |
| 3758 | 'hyperliquidChain': 'Testnet' if isSandboxMode else 'Mainnet', |
| 3759 | 'amount': strAmountFinal, |
| 3760 | 'toPerp': toPerp, |
| 3761 | 'nonce': nonce, |
| 3762 | } |
| 3763 | transferSig = self.build_usd_class_send_sig(transferPayload) |
| 3764 | transferRequest = { |
| 3765 | 'action': { |
| 3766 | 'hyperliquidChain': transferPayload['hyperliquidChain'], |
| 3767 | 'signatureChainId': '0x66eee', |
| 3768 | 'type': 'usdClassTransfer', |
| 3769 | 'amount': strAmountFinal, |
| 3770 | 'toPerp': toPerp, |
| 3771 | 'nonce': nonce, |
| 3772 | }, |
| 3773 | 'nonce': nonce, |
| 3774 | 'signature': transferSig, |
| 3775 | } |
| 3776 | transferResponse = self.privatePostExchange(transferRequest) |
| 3777 | return transferResponse |
| 3778 | # transfer between main account and subaccount |
| 3779 | isDeposit = False |
| 3780 | subAccountAddress = None |
| 3781 | if fromAccount == 'main': |
| 3782 | subAccountAddress = toAccount |
| 3783 | isDeposit = True |
| 3784 | elif toAccount == 'main': |
| 3785 | subAccountAddress = fromAccount |
nothing calls this directly
no test coverage detected