MCPcopy Create free account
hub / github.com/ccxt/ccxt / transfer

Method transfer

python/ccxt/hyperliquid.py:3728–3826  ·  view source on GitHub ↗

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={})

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

format_vault_addressMethod · 0.95
sign_l1_actionMethod · 0.95
parse_transferMethod · 0.95
NotSupportedClass · 0.90
safe_boolMethod · 0.80
in_arrayMethod · 0.80
safe_string_2Method · 0.80
check_addressMethod · 0.80
parse_to_intMethod · 0.80
string_mulMethod · 0.80

Tested by

no test coverage detected