@method @name apex#transfer @description transfer currency internally between wallets on the same account @param {string} code unified currency code @param {float} amount amount to transfer @param {string} fromAccount account to transfer from @param {string} toAccount account to transfer to @param {
(Object code, Object amount2, Object fromAccount2, Object toAccount, Object... optionalArgs)
| 1608 | * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure} |
| 1609 | */ |
| 1610 | public java.util.concurrent.CompletableFuture<Object> transfer(Object code, Object amount2, Object fromAccount2, Object toAccount, Object... optionalArgs) |
| 1611 | { |
| 1612 | final Object amount3 = amount2; |
| 1613 | final Object fromAccount3 = fromAccount2; |
| 1614 | return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 1615 | Object amount = amount3; |
| 1616 | Object fromAccount = fromAccount3; |
| 1617 | Object parameters = Helpers.getArg(optionalArgs, 0, new java.util.HashMap<String, Object>() {{}}); |
| 1618 | (this.loadMarkets()).join(); |
| 1619 | Object configResponse = (this.publicGetV3Symbols(parameters)).join(); |
| 1620 | Object configData = this.safeDict(configResponse, "data", new java.util.HashMap<String, Object>() {{}}); |
| 1621 | Object contractConfig = this.safeDict(configData, "contractConfig", new java.util.HashMap<String, Object>() {{}}); |
| 1622 | Object contractAssets = this.safeList(contractConfig, "assets", new java.util.ArrayList<Object>(java.util.Arrays.asList())); |
| 1623 | Object spotConfig = this.safeDict(configData, "spotConfig", new java.util.HashMap<String, Object>() {{}}); |
| 1624 | Object spotAssets = this.safeList(spotConfig, "assets", new java.util.ArrayList<Object>(java.util.Arrays.asList())); |
| 1625 | Object globalConfig = this.safeDict(spotConfig, "global", new java.util.HashMap<String, Object>() {{}}); |
| 1626 | Object receiverAddress = this.safeString(globalConfig, "contractAssetPoolEthAddress", ""); |
| 1627 | Object receiverZkAccountId = this.safeString(globalConfig, "contractAssetPoolZkAccountId", ""); |
| 1628 | Object receiverSubAccountId = this.safeString(globalConfig, "contractAssetPoolSubAccount", ""); |
| 1629 | Object receiverAccountId = this.safeString(globalConfig, "contractAssetPoolAccountId", ""); |
| 1630 | Object accountResponse = (this.privateGetV3Account(parameters)).join(); |
| 1631 | Object accountData = this.safeDict(accountResponse, "data", new java.util.HashMap<String, Object>() {{}}); |
| 1632 | Object spotAccount = this.safeDict(accountData, "spotAccount", new java.util.HashMap<String, Object>() {{}}); |
| 1633 | Object zkAccountId = this.safeString(spotAccount, "zkAccountId", ""); |
| 1634 | Object subAccountId = this.safeString(spotAccount, "defaultSubAccountId", "0"); |
| 1635 | Object subAccounts = this.safeList(spotAccount, "subAccounts", new java.util.ArrayList<Object>(java.util.Arrays.asList())); |
| 1636 | Object nonce = "0"; |
| 1637 | if (Helpers.isTrue(Helpers.isGreaterThan(Helpers.getArrayLength(subAccounts), 0))) |
| 1638 | { |
| 1639 | nonce = this.safeString(Helpers.GetValue(subAccounts, 0), "nonce", "0"); |
| 1640 | } |
| 1641 | Object finalNonce = nonce; // java req |
| 1642 | Object ethAddress = this.safeString(accountData, "ethereumAddress", ""); |
| 1643 | Object accountId = this.safeString(accountData, "id", ""); |
| 1644 | Object currency = new java.util.HashMap<String, Object>() {{}}; |
| 1645 | Object assets = new java.util.ArrayList<Object>(java.util.Arrays.asList()); |
| 1646 | if (Helpers.isTrue(Helpers.isTrue(!Helpers.isEqual(fromAccount, null)) && Helpers.isTrue(Helpers.isEqual(((String)fromAccount).toLowerCase(), "contract")))) |
| 1647 | { |
| 1648 | assets = contractAssets; |
| 1649 | } else |
| 1650 | { |
| 1651 | assets = spotAssets; |
| 1652 | } |
| 1653 | for (var i = 0; Helpers.isLessThan(i, Helpers.getArrayLength(assets)); i++) |
| 1654 | { |
| 1655 | if (Helpers.isTrue(Helpers.isEqual(this.safeString(Helpers.GetValue(assets, i), "token", ""), code))) |
| 1656 | { |
| 1657 | currency = Helpers.GetValue(assets, i); |
| 1658 | } |
| 1659 | } |
| 1660 | Object tokenId = this.safeString(currency, "tokenId", ""); |
| 1661 | Object decimalsNum = this.safeNumber(currency, "decimals", 0); |
| 1662 | Object mathPowResult = (Helpers.mathPow(Double.parseDouble(Helpers.toString(10)), Double.parseDouble(Helpers.toString(decimalsNum)))); |
| 1663 | Object amountNumber = this.parseToInt(Helpers.multiply(amount, mathPowResult)); |
| 1664 | Object timestampSeconds = this.parseToInt(Helpers.divide(this.milliseconds(), 1000)); |
| 1665 | Object clientOrderId = this.safeStringN(parameters, new java.util.ArrayList<Object>(java.util.Arrays.asList("clientId", "clientOrderId", "client_order_id"))); |
| 1666 | if (Helpers.isTrue(Helpers.isEqual(clientOrderId, null))) |
| 1667 | { |
nothing calls this directly
no test coverage detected