protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest) { ExchangeWithdrawalResponse withdraw = new ExchangeWithdrawalResponse() { Success = false }; var payload = await GetNoncePayloadAsync(); payload["amount"] = withdrawalRequest.Amount; payload["currency_code"] = withdrawalRequest.Currency; 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; }
/// <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 internal 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.Symbol + "&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; }
/// <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); }
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); }
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); }
public override ExchangeWithdrawalResponse Withdraw(ExchangeWithdrawalRequest withdrawalRequest) { // Example: https://bittrex.com/api/v1.1/account/withdraw?apikey=API_KEY¤cy=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); }
/// <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); }
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); }