Пример #1
0
 public virtual async Task <ExchangeWithdrawalResponse> WithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
 {
     // *NOTE* do not wrap in CacheMethodCall
     await new SynchronizationContextRemover();
     withdrawalRequest.Currency = NormalizeMarketSymbol(withdrawalRequest.Currency);
     return(await OnWithdrawAsync(withdrawalRequest));
 }
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };
            string symbol  = NormalizeSymbol(withdrawalRequest.Symbol);
            var    payload = GetNoncePayload();
            JArray array   = await MakeJsonRequestAsync <JArray>("/payment-methods", null, GetNoncePayload(), "GET");

            if (array != null)
            {
                var rc = array.Where(t => t.Value <string>("currency") == symbol).FirstOrDefault();

                payload             = GetNoncePayload();
                payload["amount"]   = withdrawalRequest.Amount;
                payload["currency"] = symbol;
                payload["method"]   = rc.Value <string>("id");
                if (!String.IsNullOrEmpty(withdrawalRequest.AddressTag))
                {
                    payload["tag"] = withdrawalRequest.AddressTag;
                }
                // "status": 0,  "message": "Your transaction is pending. Please confirm it via email.",  "payoutId": "65",  "balance": []...
                JToken token = MakeJsonRequest <JToken>("/withdrawals/make", null, payload, "POST");
                response.Id      = token["payoutId"].ToStringInvariant();
                response.Message = token["message"].ToStringInvariant();
                response.Success = token["status"].ConvertInvariant <int>().Equals(0);
            }
            return(response);
        }
Пример #3
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse withdraw = new ExchangeWithdrawalResponse()
            {
                Success = false
            };
            var payload = await OnGetNoncePayloadAsync();

            payload["amount"]        = withdrawalRequest.Amount;
            payload["currency_code"] = withdrawalRequest.Symbol;
            payload["address"]       = withdrawalRequest.Address;
            if (!string.IsNullOrEmpty(withdrawalRequest.AddressTag))
            {
                payload["paymentId"] = withdrawalRequest.AddressTag;
            }
            //{ "id": "d2ce578f-647d-4fa0-b1aa-4a27e5ee597b"}   that's all folks!
            JToken token = await MakeJsonRequestAsync <JToken>("/payment/payout", null, payload, "POST");

            if (token != null && token["id"] != null)
            {
                withdraw.Success = true;
                withdraw.Id      = token["id"].ToStringInvariant();
            }
            return(withdraw);
        }
Пример #4
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest request)
        {
            var nonce = await GenerateNonceAsync();

            var payload = new Dictionary <string, object>
            {
                { "nonce", nonce },
                { "amount", request.Amount },
                { "currency", request.Currency },
                { "crypto_address", request.Address },
                { "add_network_fee_to_total", !request.TakeFeeFromAmount },
            };

            if (!string.IsNullOrEmpty(request.AddressTag))
            {
                payload.Add("destination_tag", request.AddressTag);
            }

            var result = await MakeJsonRequestAsync <WithdrawalResult>("/withdrawals/crypto", null, payload, "POST");

            var feeParsed = decimal.TryParse(result.Fee, out var fee);

            return(new ExchangeWithdrawalResponse
            {
                Id = result.Id,
                Fee = feeParsed ? fee : (decimal?)null
            });
        }
        public override ExchangeWithdrawalResponse Withdraw(ExchangeWithdrawalRequest withdrawalRequest)
        {
            Dictionary <string, object> payload = GetNoncePayload();

            payload["asset"]   = withdrawalRequest.Asset;
            payload["address"] = withdrawalRequest.ToAddress;
            payload["amount"]  = withdrawalRequest.Amount;

            if (!string.IsNullOrWhiteSpace(withdrawalRequest.Name))
            {
                payload["name"] = withdrawalRequest.Name;
            }

            if (!string.IsNullOrWhiteSpace(withdrawalRequest.AddressTag))
            {
                payload["addressTag"] = withdrawalRequest.AddressTag;
            }

            // yes, .html ...
            JToken response = MakeJsonRequest <JToken>("/withdraw.html", WithdrawalUrlPrivate, payload, "POST");

            CheckError(response);
            ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse
            {
                Id      = response["id"].ToStringInvariant(),
                Message = response["msg"].ToStringInvariant(),
            };

            if (response["success"] == null || !response["success"].ConvertInvariant <bool>())
            {
                throw new APIException(response["msg"].ToStringInvariant());
            }

            return(withdrawalResponse);
        }
Пример #6
0
        //Withdraw  14
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            if (string.IsNullOrWhiteSpace(withdrawalRequest.Currency))
            {
                throw new APIException("Symbol empty");
            }
            if (string.IsNullOrWhiteSpace(withdrawalRequest.Address))
            {
                throw new APIException("Address empty");
            }

            Dictionary <string, object> payload = new Dictionary <string, object>
            {
                { "account", withdrawalRequest.Address },
                { "amount", withdrawalRequest.Amount },
                { "api_key", PublicApiKey.ToUnsecureString() },
                { "assetCode", withdrawalRequest.Currency },
                { "fee", withdrawalRequest.TakeFeeFromAmount }
            };

            JObject resp = await MakeJsonRequestAsync <JObject>("/withdraw.do", null, payload, "POST");

            CheckResponseToken(resp);

            return(ParseWithdrawalResponse(resp));
        }
Пример #7
0
        /// <summary>
        /// Function to withdraw from Bitsamp exchange. At the moment only XRP is supported.
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            string baseurl = null;
            string url;

            switch (withdrawalRequest.Symbol)
            {
            case "BTC":
                // use old API for Bitcoin withdraw
                baseurl = "https://www.bitstamp.net/api/";
                url     = "/bitcoin_withdrawal/";
                break;

            default:
                // this will work for some currencies and fail for others, caller must be aware of the supported currencies
                url = "/" + withdrawalRequest.Symbol.ToLowerInvariant() + "_withdrawal/";
                break;
            }

            Dictionary <string, object> payload = await OnGetNoncePayloadAsync();

            payload["address"]         = withdrawalRequest.Address.ToStringInvariant();
            payload["amount"]          = withdrawalRequest.Amount.ToStringInvariant();
            payload["destination_tag"] = withdrawalRequest.AddressTag.ToStringInvariant();

            JObject responseObject = await MakeJsonRequestAsync <JObject>(url, baseurl, payload, "POST");

            CheckJsonResponse(responseObject);
            return(new ExchangeWithdrawalResponse
            {
                Id = responseObject["id"].ToStringInvariant(),
                Message = responseObject["message"].ToStringInvariant(),
                Success = responseObject["success"].ConvertInvariant <bool>()
            });
        }
Пример #8
0
        /// <summary>
        /// Bitbank does not support withdrawing to arbitrary address (for security reason).
        /// We must first register address from its web form.
        /// So we will call two methods here.
        /// 1. Get address from already registered account. (fail if does not exist)
        /// 2. Withdraw to that address.
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            var asset    = withdrawalRequest.Currency.ToLowerInvariant();
            var payload1 = await GetNoncePayloadAsync();

            payload1.Add("asset", asset);
            JToken token1 = await MakeJsonRequestAsync <JToken>($"/user/withdrawal_account", baseUrl : BaseUrlPrivate, payload : payload1);

            if (!token1["accounts"].ToArray().Any(a => a["address"].ToStringInvariant() == withdrawalRequest.Address))
            {
                throw new APIException($"Could not withdraw to address {withdrawalRequest.Address}! You must register the address from web form first.");
            }

            var uuid = token1["uuid"].ToStringInvariant();

            var payload2 = await GetNoncePayloadAsync();

            payload2.Add("asset", asset);
            payload2.Add("amount", withdrawalRequest.Amount);
            payload2.Add("uuid", uuid);
            JToken token2 = await MakeJsonRequestAsync <JToken>($"/user/request_withdrawal", baseUrl : BaseUrlPrivate, payload : payload2, requestMethod : "POST");

            var resp = new ExchangeWithdrawalResponse
            {
                Id = token2["txid"].ToStringInvariant()
            };
            var status = token2["status"].ToStringInvariant();

            resp.Success = status != "REJECTED" && status != "CANCELED";
            resp.Message = "{" + $"label:{token2["label"]}, fee:{token2["fee"]}" + "}";
            return(resp);
        }
Пример #9
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            /*
             *      "currencySymbol": "string",
             *      "quantity": "number (double)",
             *      "cryptoAddress": "string",
             *      "cryptoAddressTag": "string",
             *      "clientWithdrawalId": "string (uuid)"
             */

            string url     = "/withdrawals";
            var    payload = await GetNoncePayloadAsync();

            payload.Add("currencySymbol", withdrawalRequest.Currency);
            payload.Add("quantity", withdrawalRequest.Amount);
            payload.Add("cryptoAddress", withdrawalRequest.Address);
            if (withdrawalRequest.AddressTag != null)
            {
                payload.Add("cryptoAddressTag", withdrawalRequest.AddressTag);
            }


            JToken result = await MakeJsonRequestAsync <JToken>(url, null, payload, "POST");

            /*
             *      {
             *        "id": "string (uuid)",
             *        "currencySymbol": "string",
             *        "quantity": "number (double)",
             *        "cryptoAddress": "string",
             *        "cryptoAddressTag": "string",
             *        "txCost": "number (double)",
             *        "txId": "string",
             *        "status": "string",
             *        "createdAt": "string (date-time)",
             *        "completedAt": "string (date-time)",
             *        "clientWithdrawalId": "string (uuid)",
             *        "accountId": "string (uuid)"
             *      }
             */
            ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse
            {
                Id      = result["id"].ToStringInvariant(),
                Message = result["status"].ToStringInvariant(),
                Fee     = result.Value <decimal?>("txCost")
            };

            return(withdrawalResponse);
        }
Пример #10
0
        /// <summary>
        /// Function to withdraw from Bitsamp exchange. At the moment only XRP is supported.
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        public override ExchangeWithdrawalResponse Withdraw(ExchangeWithdrawalRequest withdrawalRequest)
        {
            string baseurl = null;
            string url     = "";

            switch (withdrawalRequest.Symbol)
            {
            case "XRP":
                url = "/xrp_withdrawal/";
                break;

            case "BCH":
                url = "/bch_withdrawal/";
                break;

            case "LTC":
                url = "/ltc_withdrawal/";
                break;

            case "ETH":
                url = "/eth_withdrawal/";
                break;

            case "BTC":
                baseurl = "https://www.bitstamp.net/api/";
                url     = "/bitcoin_withdrawal/";

                break;

            default:
                throw new NotImplementedException();
            }

            Dictionary <string, object> payload = GetNoncePayload();

            payload["address"]         = withdrawalRequest.Address.ToStringInvariant();
            payload["amount"]          = withdrawalRequest.Amount.ToStringInvariant();
            payload["destination_tag"] = withdrawalRequest.AddressTag.ToStringInvariant();

            JObject responseObject = MakeJsonRequest <JObject>(url, baseurl, payload, "POST");

            CheckError(responseObject);
            return(new ExchangeWithdrawalResponse()
            {
                Id = responseObject["id"].ToStringInvariant(),
                Message = responseObject["message"].ToStringInvariant(),
                Success = (bool)responseObject["success"]
            });
        }
Пример #11
0
        /// <summary>
        /// Kucoin doesn't support withdraws to Cryptonight currency addresses (No Address Tag paramater)
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = true
            };
            var payload = await GetNoncePayloadAsync();

            payload["address"] = withdrawalRequest.Address;
            payload["amount"]  = withdrawalRequest.Amount;

            JToken token = await MakeJsonRequestAsync <JToken>("/account/" + withdrawalRequest.Currency + "/withdraw/apply", null, payload, "POST");

            // no data is returned. Check error will throw exception on failure
            return(response);
        }
Пример #12
0
        /// <summary>
        /// Warning: Use with discretion
        /// <rant> Yobit trading seems fine, their API is stable, but their deposits/withdraws are *VERY* problematic.
        /// I'm being kind. Waited as much as two-weeks for deposts to show up on Exchange, even though they were confirmed on the blockchain.
        /// </rant>
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };
            var payload = await GetNoncePayloadAsync();

            payload.Add("method", "WithdrawCoinsToAddress");
            payload.Add("coinName", withdrawalRequest.Currency);
            payload.Add("amount", withdrawalRequest.Amount);
            payload.Add("address", withdrawalRequest.Address);
            await MakeJsonRequestAsync <JToken>("/", PrivateURL, payload, "POST");

            response.Success = true;
            return(response);
        }
Пример #13
0
        /// <summary>
        /// Warning: Use with discretion
        /// <rant> Yobit trading seems fine, their API is stable, but their deposits/withdraws are *VERY* problematic.
        /// I'm being kind. Waited as much as two-weeks for deposts to show up on Exchange, even though they were confirmed on the blockchain.
        /// </rant>
        /// </summary>
        /// <param name="withdrawalRequest"></param>
        /// <returns></returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };
            var payload = GetNoncePayload();

            payload.Add("method", "WithdrawCoinsToAddress");
            payload.Add("coinName", withdrawalRequest.Symbol);
            payload.Add("amount", withdrawalRequest.Amount);
            payload.Add("address", withdrawalRequest.Address);
            JToken token = await MakeJsonRequestAsync <JToken>("/", PrivateURL, payload, "POST");

            CheckError(token);   // will throw exception on error
            response.Success = true;
            return(response);
        }
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };

            if (!String.IsNullOrEmpty(withdrawalRequest.AddressTag))
            {
                withdrawalRequest.AddressTag = "::" + withdrawalRequest.AddressTag;
            }

            // {"fault": null,"userId": 797,"userName": "******","id": 11285042,"state": "APPROVED","createDate": 1432197911364,"lastModifyDate": 1432197911802,"verificationType": "NONE","verificationData": null, "comment": null, "description": "Transfer from Livecoin", "amount": 0.002, "currency": "BTC", "accountTo": "B1099909", "acceptDate": null, "valueDate": null, "docDate": 1432197911364, "docNumber": 11111111, "correspondentDetails": null, "accountFrom": "B0000001", "outcome": false, "external": null, "externalKey": "1111111", "externalSystemId": 18, "externalServiceId": null, "wallet": "1111111" }
            JToken token = await MakeJsonRequestAsync <JToken>("/payment/out/coin?currency=" + withdrawalRequest.Currency + "&wallet=" + withdrawalRequest.Address + withdrawalRequest.AddressTag + "&amount=" + withdrawalRequest.Amount, BaseUrl, await GetNoncePayloadAsync(), "POST");

            response.Success = true;
            return(response);
        }
        protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse { Success = false };

            var payload = GetNoncePayload();
            payload.Add("Currency", withdrawalRequest.Symbol);
            payload.Add("Address", withdrawalRequest.Address);
            if (!string.IsNullOrEmpty(withdrawalRequest.AddressTag)) payload.Add("PaymentId", withdrawalRequest.AddressTag);
            payload.Add("Amount", withdrawalRequest.Amount);
            JToken token = await MakeJsonRequestAsync<JToken>("/SubmitWithdraw", null, payload, "POST");
            if (token["Success"].ConvertInvariant<bool>() == true)
            {
                response.Id = token["Data"].ConvertInvariant<int>().ToStringInvariant();
                response.Success = true;
            }
            return response;
        }
Пример #16
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest request)
        {
            var parameters = new Dictionary <string, object>
            {
                { "coin", request.Currency },
                { "size", request.Amount },
                { "address", request.Address },
                { "nonce", await GenerateNonceAsync() },
                { "password", request.Password },
                { "code", request.Code }
            };

            var result = await MakeJsonRequestAsync <JToken>("/wallet/withdrawals", null, parameters, "POST");

            return(new ExchangeWithdrawalResponse
            {
                Id = result["id"].ToString()
            });
        }
Пример #17
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            var payload = await GetNoncePayloadAsync();

            payload["address"]  = withdrawalRequest.Address;
            payload["amount"]   = withdrawalRequest.Amount;
            payload["currency"] = withdrawalRequest.Currency;
            if (withdrawalRequest.AddressTag != null)
            {
                payload["attr-tag"] = withdrawalRequest.AddressTag;
            }

            JToken result = await MakeJsonRequestAsync <JToken>("/dw/withdraw/api/create", PrivateUrlV1, payload, "POST");

            return(new ExchangeWithdrawalResponse
            {
                Id = result.Root["data"].ToStringInvariant(),
                Message = result.Root["status"].ToStringInvariant()
            });
        }
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            var payload = await GetNoncePayloadAsync();

            payload["currency"] = withdrawalRequest.Currency;
            payload["quantity"] = withdrawalRequest.Amount;
            payload["address"]  = withdrawalRequest.Address;
            if (!string.IsNullOrEmpty(withdrawalRequest.AddressTag))
            {
                payload["comments"] = withdrawalRequest.AddressTag;
            }

            await MakeJsonRequestAsync <JToken>("/account/withdraw", BaseUrl, payload);

            // Bleutrade doesn't return any info, just an empty string on success. The MakeJsonRequestAsync will throw an exception if there's an error
            return(new ExchangeWithdrawalResponse()
            {
                Success = true
            });
        }
Пример #19
0
        /// <summary>A withdrawal request. Fee is automatically subtracted from the amount.</summary>
        /// <param name="withdrawalRequest">The withdrawal request.</param>
        /// <returns>Withdrawal response from Binance</returns>
        public override ExchangeWithdrawalResponse Withdraw(ExchangeWithdrawalRequest withdrawalRequest)
        {
            if (string.IsNullOrWhiteSpace(withdrawalRequest.Symbol))
            {
                throw new APIException("Symbol must be provided for Withdraw");
            }

            if (string.IsNullOrWhiteSpace(withdrawalRequest.Address))
            {
                throw new APIException("Address must be provided for Withdraw");
            }

            if (withdrawalRequest.Amount <= 0)
            {
                throw new APIException("Withdrawal amount must be positive and non-zero");
            }

            Dictionary <string, object> payload = GetNoncePayload();

            payload["asset"]   = withdrawalRequest.Symbol;
            payload["address"] = withdrawalRequest.Address;
            payload["amount"]  = withdrawalRequest.Amount;
            payload["name"]    = withdrawalRequest.Description ?? "apiwithdrawal"; // Contrary to what the API docs say, name is required

            if (!string.IsNullOrWhiteSpace(withdrawalRequest.AddressTag))
            {
                payload["addressTag"] = withdrawalRequest.AddressTag;
            }

            JToken response = MakeJsonRequest <JToken>("/withdraw.html", WithdrawalUrlPrivate, payload, "POST");

            CheckError(response);

            ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse
            {
                Id      = response["id"].ToStringInvariant(),
                Message = response["msg"].ToStringInvariant(),
            };

            return(withdrawalResponse);
        }
Пример #20
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            var response = new ExchangeWithdrawalResponse {
                Success = false
            };

            var payload = await GetNoncePayloadAsync();

            payload.Add("Currency", withdrawalRequest.Currency);
            payload.Add("Address", withdrawalRequest.Address);
            if (!string.IsNullOrEmpty(withdrawalRequest.AddressTag))
            {
                payload.Add("PaymentId", withdrawalRequest.AddressTag);
            }
            payload.Add("Amount", withdrawalRequest.Amount);
            var token = await MakeJsonRequestAsync <JToken>("/SubmitWithdraw", null, payload, "POST");

            response.Id      = token.ConvertInvariant <int>().ToStringInvariant();
            response.Success = true;
            return(response);
        }
Пример #21
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            ExchangeWithdrawalResponse response = new ExchangeWithdrawalResponse {
                Success = false
            };

            var payload = await GetNoncePayloadAsync();

            payload.Add("method", "withdraw");
            payload.Add("coin", withdrawalRequest.Currency);
            payload.Add("amount", withdrawalRequest.Amount);
            payload.Add("address", withdrawalRequest.Address);
            // ( [success] => 1 [error] => Array ([0] => Withdraw requested. ))
            JToken token = await MakeJsonRequestAsync <JToken>("/api", null, payload, "POST");

            if (token["success"].ConvertInvariant <int>() == 1)
            {
                response.Success = true;
            }
            return(response);
        }
Пример #22
0
        public override ExchangeWithdrawalResponse Withdraw(ExchangeWithdrawalRequest withdrawalRequest)
        {
            // Example: https://bittrex.com/api/v1.1/account/withdraw?apikey=API_KEY&currency=EAC&quantity=20.40&address=EAC_ADDRESS

            string url = $"/account/withdraw?currency={NormalizeSymbol(withdrawalRequest.Asset)}&quantity={withdrawalRequest.Amount}&address={withdrawalRequest.ToAddress}";

            if (!string.IsNullOrWhiteSpace(withdrawalRequest.AddressTag))
            {
                url += $"&paymentid{withdrawalRequest.AddressTag}";
            }

            JToken response = MakeJsonRequest <JToken>(url, null, GetNoncePayload());
            JToken result   = CheckError(response);

            ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse
            {
                Id      = result["uuid"].ToStringInvariant(),
                Message = result["msg"].ToStringInvariant()
            };

            return(withdrawalResponse);
        }
Пример #23
0
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            // If we have an address tag, verify that Polo lets you specify it as part of the withdrawal
            if (!string.IsNullOrWhiteSpace(withdrawalRequest.AddressTag))
            {
                if (!WithdrawalFieldCount.TryGetValue(withdrawalRequest.Currency, out int fieldCount) || fieldCount == 0)
                {
                    throw new APIException($"Coin {withdrawalRequest.Currency} has unknown withdrawal field count. Please manually verify the number of fields allowed during a withdrawal (Address + Tag = 2) and add it to PoloniexWithdrawalFields.csv before calling Withdraw");
                }
                else if (fieldCount == 1)
                {
                    throw new APIException($"Coin {withdrawalRequest.Currency} only allows an address to be specified and address tag {withdrawalRequest.AddressTag} was provided.");
                }
                else if (fieldCount > 2)
                {
                    throw new APIException("More than two fields on a withdrawal is unsupported.");
                }
            }

            var paramsList = new List <object> {
                "currency", NormalizeMarketSymbol(withdrawalRequest.Currency), "amount", withdrawalRequest.Amount, "address", withdrawalRequest.Address
            };

            if (!string.IsNullOrWhiteSpace(withdrawalRequest.AddressTag))
            {
                paramsList.Add("paymentId");
                paramsList.Add(withdrawalRequest.AddressTag);
            }

            JToken token = await MakePrivateAPIRequestAsync("withdraw", paramsList.ToArray());

            ExchangeWithdrawalResponse resp = new ExchangeWithdrawalResponse {
                Message = token["response"].ToStringInvariant()
            };

            return(resp);
        }
Пример #24
0
        /// <summary>A withdrawal request. Fee is automatically subtracted from the amount.</summary>
        /// <param name="withdrawalRequest">The withdrawal request.</param>
        /// <returns>Withdrawal response from Binance</returns>
        protected override async Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
        {
            if (string.IsNullOrWhiteSpace(withdrawalRequest.Currency))
            {
                throw new ArgumentException("Symbol must be provided for Withdraw");
            }
            else if (string.IsNullOrWhiteSpace(withdrawalRequest.Address))
            {
                throw new ArgumentException("Address must be provided for Withdraw");
            }
            else if (withdrawalRequest.Amount <= 0)
            {
                throw new ArgumentException("Withdrawal amount must be positive and non-zero");
            }

            Dictionary <string, object> payload = await GetNoncePayloadAsync();

            payload["asset"]   = withdrawalRequest.Currency;
            payload["address"] = withdrawalRequest.Address;
            payload["amount"]  = withdrawalRequest.Amount;
            payload["name"]    = withdrawalRequest.Description ?? "apiwithdrawal"; // Contrary to what the API docs say, name is required

            if (!string.IsNullOrWhiteSpace(withdrawalRequest.AddressTag))
            {
                payload["addressTag"] = withdrawalRequest.AddressTag;
            }

            JToken response = await MakeJsonRequestAsync <JToken>("/withdraw.html", WithdrawalUrlPrivate, payload, "POST");

            ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse
            {
                Id      = response["id"].ToStringInvariant(),
                Message = response["msg"].ToStringInvariant(),
            };

            return(withdrawalResponse);
        }
Пример #25
0
 /// <summary>
 /// A withdrawal request.
 /// </summary>
 /// <param name="withdrawalRequest">The withdrawal request.</param>
 public virtual ExchangeWithdrawalResponse Withdraw(ExchangeWithdrawalRequest withdrawalRequest) => throw new NotImplementedException();
Пример #26
0
 /// <summary>
 /// Asynchronous withdraws.
 /// </summary>
 /// <param name="withdrawalRequest">The withdrawal request.</param>
 public Task WithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest) => Task.Factory.StartNew(() => Withdraw(withdrawalRequest));
Пример #27
0
 /// <summary>
 /// Asynchronous withdraws request.
 /// </summary>
 /// <param name="withdrawalRequest">The withdrawal request.</param>
 public async Task <ExchangeWithdrawalResponse> WithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
 {
     await new SynchronizationContextRemover();
     return(await OnWithdrawAsync(withdrawalRequest));
 }
Пример #28
0
 /// <summary>
 /// A withdrawal request.
 /// </summary>
 /// <param name="withdrawalRequest">The withdrawal request.</param>
 public ExchangeWithdrawalResponse Withdraw(ExchangeWithdrawalRequest withdrawalRequest) => WithdrawAsync(withdrawalRequest).GetAwaiter().GetResult();
Пример #29
0
 protected virtual Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest) => throw new NotImplementedException();
Пример #30
0
 protected override Task <ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest)
 {
     throw new NotImplementedException("Huobi does not provide a withdraw API");
 }