MCPcopy
hub / github.com/ccxt/ccxt / withdraw

Method withdraw

java/lib/src/main/java/io/github/ccxt/exchanges/OkxCore.java:5994–6059  ·  view source on GitHub ↗

@method @name okx#withdraw @description make a withdrawal @see https://www.okx.com/docs-v5/en/#funding-account-rest-api-withdrawal @param {string} code unified currency code @param {float} amount the amount to withdraw @param {string} address the address to withdraw to @param {string} tag @param {ob

(Object code, Object amount, Object address2, Object... optionalArgs)

Source from the content-addressed store, hash-verified

5992 * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
5993 */
5994 public java.util.concurrent.CompletableFuture<Object> withdraw(Object code, Object amount, Object address2, Object... optionalArgs)
5995 {
5996 final Object address3 = address2;
5997 return java.util.concurrent.CompletableFuture.supplyAsync(() -> {
5998 Object address = address3;
5999 Object tag = Helpers.getArg(optionalArgs, 0, null);
6000 Object parameters = Helpers.getArg(optionalArgs, 1, new java.util.HashMap<String, Object>() {{}});
6001 var tagparametersVariable = this.handleWithdrawTagAndParams(tag, parameters);
6002 tag = ((java.util.List<Object>) tagparametersVariable).get(0);
6003 parameters = ((java.util.List<Object>) tagparametersVariable).get(1);
6004 this.checkAddress(address);
6005 (this.loadMarkets()).join();
6006 Object currency = this.currency(code);
6007 if (Helpers.isTrue(Helpers.isTrue((!Helpers.isEqual(tag, null))) && Helpers.isTrue((Helpers.isGreaterThan(((String)tag).length(), 0)))))
6008 {
6009 address = Helpers.add(Helpers.add(address, ":"), tag);
6010 }
6011 final Object finalAddress = address;
6012 Object request = new java.util.HashMap<String, Object>() {{
6013 put( "ccy", Helpers.GetValue(currency, "id") );
6014 put( "toAddr", finalAddress );
6015 put( "dest", "4" );
6016 put( "amt", OkxCore.this.numberToString(amount) );
6017 }};
6018 Object network = this.safeString(parameters, "network"); // this line allows the user to specify either ERC20 or ETH
6019 if (Helpers.isTrue(!Helpers.isEqual(network, null)))
6020 {
6021 Object networks = this.safeDict(this.options, "networks", new java.util.HashMap<String, Object>() {{}});
6022 network = this.safeString(networks, ((String)network).toUpperCase(), network); // handle ETH>ERC20 alias
6023 Helpers.addElementToObject(request, "chain", Helpers.add(Helpers.add(Helpers.GetValue(currency, "id"), "-"), network));
6024 parameters = this.omit(parameters, "network");
6025 }
6026 Object fee = this.safeString(parameters, "fee");
6027 if (Helpers.isTrue(Helpers.isEqual(fee, null)))
6028 {
6029 Object currencies = (this.fetchCurrenciesAsync()).join();
6030 this.currencies = this.mapToSafeMap(this.deepExtend(this.currencies, currencies));
6031 Object targetNetwork = this.safeDict(Helpers.GetValue(currency, "networks"), this.networkIdToCode(network, Helpers.GetValue(currency, "code")), new java.util.HashMap<String, Object>() {{}});
6032 fee = this.safeString(targetNetwork, "fee");
6033 if (Helpers.isTrue(Helpers.isEqual(fee, null)))
6034 {
6035 throw new ArgumentsRequired((String)Helpers.add(this.id, " withdraw() requires a \"fee\" string parameter, network transaction fee must be ≥ 0. Withdrawals to OKCoin or OKX are fee-free, please set \"0\". Withdrawing to external digital asset address requires network transaction fee.")) ;
6036 }
6037 }
6038 Helpers.addElementToObject(request, "fee", this.numberToString(fee)); // withdrawals to OKCoin or OKX are fee-free, please set 0
6039 Object query = this.omit(parameters, new java.util.ArrayList<Object>(java.util.Arrays.asList("fee")));
6040 Object response = (this.privatePostAssetWithdrawal(this.extend(request, query))).join();
6041 //
6042 // {
6043 // "code": "0",
6044 // "msg": "",
6045 // "data": [
6046 // {
6047 // "amt": "0.1",
6048 // "wdId": "67485",
6049 // "ccy": "BTC"
6050 // }
6051 // ]

Callers

nothing calls this directly

Calls 15

getArgMethod · 0.95
isTrueMethod · 0.95
isEqualMethod · 0.95
isGreaterThanMethod · 0.95
addMethod · 0.95
GetValueMethod · 0.95
addElementToObjectMethod · 0.95
parseTransactionMethod · 0.95
getMethod · 0.45
checkAddressMethod · 0.45

Tested by

no test coverage detected