MCPcopy Index your code
hub / github.com/ccxt/ccxt / withdraw

Method withdraw

java/lib/src/main/java/io/github/ccxt/exchanges/HtxCore.java:7525–7590  ·  view source on GitHub ↗

@method @name htx#withdraw @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec4cc41-7773-11ed-9966-0242ac110003 @description make a withdrawal @param {string} code unified currency code @param {float} amount the amount to withdraw @param {string} address the address to withdraw to @param {strin

(Object code, Object amount2, Object address, Object... optionalArgs)

Source from the content-addressed store, hash-verified

7523 * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
7524 */
7525 public java.util.concurrent.CompletableFuture<Object> withdraw(Object code, Object amount2, Object address, Object... optionalArgs)
7526 {
7527 final Object amount3 = amount2;
7528 return java.util.concurrent.CompletableFuture.supplyAsync(() -> {
7529 Object amount = amount3;
7530 Object tag = Helpers.getArg(optionalArgs, 0, null);
7531 Object parameters = Helpers.getArg(optionalArgs, 1, new java.util.HashMap<String, Object>() {{}});
7532 var tagparametersVariable = this.handleWithdrawTagAndParams(tag, parameters);
7533 tag = ((java.util.List<Object>) tagparametersVariable).get(0);
7534 parameters = ((java.util.List<Object>) tagparametersVariable).get(1);
7535 (this.loadMarkets()).join();
7536 this.checkAddress(address);
7537 Object currency = this.currency(code);
7538 Object request = new java.util.HashMap<String, Object>() {{
7539 put( "address", address );
7540 put( "currency", ((String)Helpers.GetValue(currency, "id")).toLowerCase() );
7541 }};
7542 if (Helpers.isTrue(!Helpers.isEqual(tag, null)))
7543 {
7544 Helpers.addElementToObject(request, "addr-tag", tag); // only for XRP?
7545 }
7546 Object networkCode = null;
7547 var networkCodeparametersVariable = this.handleNetworkCodeAndParams(parameters);
7548 networkCode = ((java.util.List<Object>) networkCodeparametersVariable).get(0);
7549 parameters = ((java.util.List<Object>) networkCodeparametersVariable).get(1);
7550 if (Helpers.isTrue(!Helpers.isEqual(networkCode, null)))
7551 {
7552 Helpers.addElementToObject(request, "chain", this.networkCodeToId(networkCode, code));
7553 }
7554 amount = Helpers.parseFloat(this.currencyToPrecision(code, amount, networkCode));
7555 Object withdrawOptions = this.safeValue(this.options, "withdraw", new java.util.HashMap<String, Object>() {{}});
7556 if (Helpers.isTrue(this.safeBool(withdrawOptions, "includeFee", false)))
7557 {
7558 Object fee = this.safeNumber(parameters, "fee");
7559 if (Helpers.isTrue(Helpers.isEqual(fee, null)))
7560 {
7561 Object currencies = (this.fetchCurrenciesAsync()).join();
7562 this.currencies = this.mapToSafeMap(this.deepExtend(this.currencies, currencies));
7563 Object targetNetwork = this.safeValue(Helpers.GetValue(currency, "networks"), networkCode, new java.util.HashMap<String, Object>() {{}});
7564 fee = this.safeNumber(targetNetwork, "fee");
7565 if (Helpers.isTrue(Helpers.isEqual(fee, null)))
7566 {
7567 throw new ArgumentsRequired((String)Helpers.add(this.id, " withdraw() function can not find withdraw fee for chosen network. You need to re-load markets with \"exchange.loadMarkets(true)\", or provide the \"fee\" parameter")) ;
7568 }
7569 }
7570 // fee needs to be deducted from whole amount
7571 Object feeString = this.currencyToPrecision(code, fee, networkCode);
7572 parameters = this.omit(parameters, "fee");
7573 Object amountString = this.numberToString(amount);
7574 Object amountSubtractedString = Precise.stringSub(amountString, feeString);
7575 Object amountSubtracted = Helpers.parseFloat(amountSubtractedString);
7576 Helpers.addElementToObject(request, "fee", Helpers.parseFloat(feeString));
7577 amount = Helpers.parseFloat(this.currencyToPrecision(code, amountSubtracted, networkCode));
7578 }
7579 Helpers.addElementToObject(request, "amount", amount);
7580 Object response = (this.spotPrivatePostV1DwWithdrawApiCreate(this.extend(request, parameters))).join();
7581 //
7582 // {

Callers

nothing calls this directly

Calls 15

getArgMethod · 0.95
GetValueMethod · 0.95
isTrueMethod · 0.95
isEqualMethod · 0.95
addElementToObjectMethod · 0.95
networkCodeToIdMethod · 0.95
parseFloatMethod · 0.95
addMethod · 0.95
stringSubMethod · 0.95
parseTransactionMethod · 0.95

Tested by

no test coverage detected