@method @name grvt#transfer @description transfer currency internally between wallets on the same account @see https://api-docs.grvt.io/trading_api/#transfer_1 @param {string} code unified currency codeåå @param {float} amount amount to transfer @param {string} fromAccount account to transfer from @
(Object code, Object amount, Object fromAccount2, Object toAccount2, Object... optionalArgs)
| 2071 | * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure} |
| 2072 | */ |
| 2073 | public java.util.concurrent.CompletableFuture<Object> transfer(Object code, Object amount, Object fromAccount2, Object toAccount2, Object... optionalArgs) |
| 2074 | { |
| 2075 | final Object fromAccount3 = fromAccount2; |
| 2076 | final Object toAccount3 = toAccount2; |
| 2077 | return java.util.concurrent.CompletableFuture.supplyAsync(() -> { |
| 2078 | Object fromAccount = fromAccount3; |
| 2079 | Object toAccount = toAccount3; |
| 2080 | Object parameters = Helpers.getArg(optionalArgs, 0, new java.util.HashMap<String, Object>() {{}}); |
| 2081 | (this.loadMarketsAndSignIn()).join(); |
| 2082 | Object currency = this.currency(code); |
| 2083 | Object defaultFromAccountId = this.safeString(this.options, "userMainAccountId"); |
| 2084 | if (Helpers.isTrue(Helpers.isTrue(this.inArray(fromAccount, new java.util.ArrayList<Object>(java.util.Arrays.asList("trading", "funding")))) && Helpers.isTrue(this.inArray(toAccount, new java.util.ArrayList<Object>(java.util.Arrays.asList("trading", "funding")))))) |
| 2085 | { |
| 2086 | Object tradingAccountId = null; |
| 2087 | var tradingAccountIdparametersVariable = this.handleOptionAndParams(parameters, "transfer", "tradingAccountId"); |
| 2088 | tradingAccountId = ((java.util.List<Object>) tradingAccountIdparametersVariable).get(0); |
| 2089 | parameters = ((java.util.List<Object>) tradingAccountIdparametersVariable).get(1); |
| 2090 | Object fundingAccountId = null; |
| 2091 | var fundingAccountIdparametersVariable = this.handleOptionAndParams(parameters, "transfer", "fundingAccountId"); |
| 2092 | fundingAccountId = ((java.util.List<Object>) fundingAccountIdparametersVariable).get(0); |
| 2093 | parameters = ((java.util.List<Object>) fundingAccountIdparametersVariable).get(1); |
| 2094 | if (Helpers.isTrue(Helpers.isTrue(Helpers.isEqual(tradingAccountId, null)) || Helpers.isTrue(Helpers.isEqual(fundingAccountId, null)))) |
| 2095 | { |
| 2096 | throw new ArgumentsRequired((String)Helpers.add(this.id, " transfer(): you should set (in the options or params) \"tradingAccountId\" and \"fundingAccountId\" (you can use \"0\" as a main funding account id)")) ; |
| 2097 | } |
| 2098 | fromAccount = ((Helpers.isTrue((Helpers.isEqual(fromAccount, "trading"))))) ? tradingAccountId : fundingAccountId; |
| 2099 | toAccount = ((Helpers.isTrue((Helpers.isEqual(toAccount, "trading"))))) ? tradingAccountId : fundingAccountId; |
| 2100 | } |
| 2101 | final Object finalParameters = parameters; |
| 2102 | final Object finalFromAccount = fromAccount; |
| 2103 | final Object finalToAccount = toAccount; |
| 2104 | Object request = new java.util.HashMap<String, Object>() {{ |
| 2105 | put( "from_account_id", GrvtCore.this.safeString(finalParameters, "from_account_id", defaultFromAccountId) ); |
| 2106 | put( "from_sub_account_id", GrvtCore.this.safeString(finalParameters, "from_sub_account_id", finalFromAccount) ); |
| 2107 | put( "to_account_id", GrvtCore.this.safeString(finalParameters, "to_account_id", defaultFromAccountId) ); |
| 2108 | put( "to_sub_account_id", GrvtCore.this.safeString(finalParameters, "to_sub_account_id", finalToAccount) ); |
| 2109 | put( "currency", Helpers.GetValue(currency, "id") ); |
| 2110 | put( "num_tokens", GrvtCore.this.currencyToPrecision(code, amount) ); |
| 2111 | put( "signature", GrvtCore.this.defaultSignature() ); |
| 2112 | put( "transfer_type", "STANDARD" ); |
| 2113 | put( "transfer_metadata", null ); |
| 2114 | }}; |
| 2115 | request = this.createSignedRequest(request, "EIP712_TRANSFER_TYPE", currency); |
| 2116 | Object response = null; |
| 2117 | try |
| 2118 | { |
| 2119 | response = (this.privateTradingPostFullV1Transfer(this.extend(request, parameters))).join(); |
| 2120 | } catch(Exception error) |
| 2121 | { |
| 2122 | Object msg = this.exceptionMessage(error); |
| 2123 | Object isFromFundingAccount = Helpers.isEqual(fromAccount, "funding"); |
| 2124 | if (Helpers.isTrue(Helpers.isTrue(isFromFundingAccount) && Helpers.isTrue(Helpers.getIndexOf(msg, "You are not authorized")))) |
| 2125 | { |
| 2126 | throw new PermissionDenied((String)Helpers.add(Helpers.add(this.id, " transfer() failed. Ensure you use funding api-keys when trying to transfer from Funding accounts: "), msg)) ; |
| 2127 | } |
| 2128 | throw error; |
| 2129 | } |
| 2130 | // |
nothing calls this directly
no test coverage detected