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

Method withdraw

python/ccxt/hyperliquid.py:3844–3904  ·  view source on GitHub ↗

make a withdrawal(only support USDC) https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault

(self, code: str, amount: float, address: str, tag: Str = None, params={})

Source from the content-addressed store, hash-verified

3842 }
3843
3844 def withdraw(self, code: str, amount: float, address: str, tag: Str = None, params={}) -> Transaction:
3845 """
3846 make a withdrawal(only support USDC)
3847
3848 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#initiate-a-withdrawal-request
3849 https://hyperliquid.gitbook.io/hyperliquid-docs/for-developers/api/exchange-endpoint#deposit-or-withdraw-from-a-vault
3850
3851 :param str code: unified currency code
3852 :param float amount: the amount to withdraw
3853 :param str address: the address to withdraw to
3854 :param str tag:
3855 :param dict [params]: extra parameters specific to the exchange API endpoint
3856 :param str [params.vaultAddress]: vault address withdraw from
3857 :returns dict: a `transaction structure <https://docs.ccxt.com/?id=transaction-structure>`
3858 """
3859 self.check_required_credentials()
3860 self.load_markets()
3861 self.check_address(address)
3862 if code is not None:
3863 code = code.upper()
3864 if code != 'USDC':
3865 raise NotSupported(self.id + ' withdraw() only support USDC')
3866 vaultAddress = None
3867 vaultAddress, params = self.handle_option_and_params(params, 'withdraw', 'vaultAddress')
3868 vaultAddress = self.format_vault_address(vaultAddress)
3869 params = self.omit(params, 'vaultAddress')
3870 nonce = self.milliseconds()
3871 action = {}
3872 sig: dict
3873 if vaultAddress is not None:
3874 action = {
3875 'type': 'vaultTransfer',
3876 'vaultAddress': '0x' + vaultAddress,
3877 'isDeposit': False,
3878 'usd': amount,
3879 }
3880 sig = self.sign_l1_action(action, nonce)
3881 else:
3882 isSandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
3883 payload = {
3884 'hyperliquidChain': 'Testnet' if isSandboxMode else 'Mainnet',
3885 'destination': address,
3886 'amount': str(amount),
3887 'time': nonce,
3888 }
3889 sig = self.build_withdraw_sig(payload)
3890 action = {
3891 'hyperliquidChain': payload['hyperliquidChain'],
3892 'signatureChainId': '0x66eee', # check self out
3893 'destination': address,
3894 'amount': str(amount),
3895 'time': nonce,
3896 'type': 'withdraw3',
3897 }
3898 request = {
3899 'action': action,
3900 'nonce': nonce,
3901 'signature': sig,

Callers

nothing calls this directly

Calls 13

format_vault_addressMethod · 0.95
sign_l1_actionMethod · 0.95
build_withdraw_sigMethod · 0.95
parse_transactionMethod · 0.95
NotSupportedClass · 0.90
check_addressMethod · 0.80
safe_boolMethod · 0.80
privatePostExchangeMethod · 0.65
load_marketsMethod · 0.45
omitMethod · 0.45

Tested by

no test coverage detected