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

Method transfer

python/ccxt/apex.py:1374–1504  ·  view source on GitHub ↗

transfer currency internally between wallets on the same account :param str code: unified currency code :param float amount: amount to transfer :param str fromAccount: account to transfer from :param str toAccount: account to transfer to :param dict [

(self, code: str, amount: float, fromAccount: str, toAccount: str, params={})

Source from the content-addressed store, hash-verified

1372 return self.parse_order(data, market)
1373
1374 def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
1375 """
1376 transfer currency internally between wallets on the same account
1377 :param str code: unified currency code
1378 :param float amount: amount to transfer
1379 :param str fromAccount: account to transfer from
1380 :param str toAccount: account to transfer to
1381 :param dict [params]: extra parameters specific to the exchange API endpoint
1382 :param str [params.transferId]: UUID, which is unique across the platform
1383 :returns dict: a `transfer structure <https://docs.ccxt.com/?id=transfer-structure>`
1384 """
1385 self.load_markets()
1386 configResponse = self.publicGetV3Symbols(params)
1387 configData = self.safe_dict(configResponse, 'data', {})
1388 contractConfig = self.safe_dict(configData, 'contractConfig', {})
1389 contractAssets = self.safe_list(contractConfig, 'assets', [])
1390 spotConfig = self.safe_dict(configData, 'spotConfig', {})
1391 spotAssets = self.safe_list(spotConfig, 'assets', [])
1392 globalConfig = self.safe_dict(spotConfig, 'global', {})
1393 receiverAddress = self.safe_string(globalConfig, 'contractAssetPoolEthAddress', '')
1394 receiverZkAccountId = self.safe_string(globalConfig, 'contractAssetPoolZkAccountId', '')
1395 receiverSubAccountId = self.safe_string(globalConfig, 'contractAssetPoolSubAccount', '')
1396 receiverAccountId = self.safe_string(globalConfig, 'contractAssetPoolAccountId', '')
1397 accountResponse = self.privateGetV3Account(params)
1398 accountData = self.safe_dict(accountResponse, 'data', {})
1399 spotAccount = self.safe_dict(accountData, 'spotAccount', {})
1400 zkAccountId = self.safe_string(spotAccount, 'zkAccountId', '')
1401 subAccountId = self.safe_string(spotAccount, 'defaultSubAccountId', '0')
1402 subAccounts = self.safe_list(spotAccount, 'subAccounts', [])
1403 nonce = '0'
1404 if len(subAccounts) > 0:
1405 nonce = self.safe_string(subAccounts[0], 'nonce', '0')
1406 finalNonce = nonce # java req
1407 ethAddress = self.safe_string(accountData, 'ethereumAddress', '')
1408 accountId = self.safe_string(accountData, 'id', '')
1409 currency = {}
1410 assets = []
1411 if fromAccount is not None and fromAccount.lower() == 'contract':
1412 assets = contractAssets
1413 else:
1414 assets = spotAssets
1415 for i in range(0, len(assets)):
1416 if self.safe_string(assets[i], 'token', '') == code:
1417 currency = assets[i]
1418 tokenId = self.safe_string(currency, 'tokenId', '')
1419 decimalsNum = self.safe_number(currency, 'decimals', 0)
1420 mathPowResult = (math.pow(10, decimalsNum))
1421 amountNumber = self.parse_to_int(amount * mathPowResult)
1422 timestampSeconds = self.parse_to_int(self.milliseconds() / 1000)
1423 clientOrderId = self.safe_string_n(params, ['clientId', 'clientOrderId', 'client_order_id'])
1424 if clientOrderId is None:
1425 clientOrderId = self.generate_random_client_id_omni(self.safe_string(self.options, 'accountId'))
1426 finalClientOrderId = clientOrderId # java req
1427 params = self.omit(params, ['clientId', 'clientOrderId', 'client_order_id'])
1428 if fromAccount is not None and fromAccount.lower() == 'contract':
1429 formattedUint32 = '4294967295'
1430 zkSignAccountId = Precise.string_mod(accountId, formattedUint32)
1431 expireTime = timestampSeconds + 3600 * 24 * 28

Callers

nothing calls this directly

Calls 15

get_seedsMethod · 0.95
parse_transferMethod · 0.95
safe_dictMethod · 0.80
safe_listMethod · 0.80
safe_stringMethod · 0.80
safe_numberMethod · 0.80
parse_to_intMethod · 0.80
safe_string_nMethod · 0.80
string_modMethod · 0.80
remove0x_prefixMethod · 0.80

Tested by

no test coverage detected