ExchangeSharp/API/Exchanges/Binance/ExchangeBinanceAPI.cs
/// <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>
A withdrawal request. Fee is automatically subtracted from the amount.
A withdrawal request . Fee is automatically subtracted from the amount .
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"; 
            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 ( string . IsNullOrWhiteSpace ( withdrawalRequest . Currency ) ) { throw new ArgumentException ( " " ) ; } else if ( string . IsNullOrWhiteSpace ( withdrawalRequest . Address ) ) { throw new ArgumentException ( " " ) ; } else if ( withdrawalRequest . Amount <= 0 ) { throw new ArgumentException ( " " ) ; } Dictionary < string , object > payload = await GetNoncePayloadAsync ( ) ; payload [ " " ] = withdrawalRequest . Currency ; payload [ " " ] = withdrawalRequest . Address ; payload [ " " ] = withdrawalRequest . Amount ; payload [ " " ] = withdrawalRequest . Description ?? " " ; if ( ! string . IsNullOrWhiteSpace ( withdrawalRequest . AddressTag ) ) { payload [ " " ] = withdrawalRequest . AddressTag ; } JToken response = await MakeJsonRequestAsync < JToken > ( " " , WithdrawalUrlPrivate , payload , " " ) ; ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse { Id = response [ " " ] . ToStringInvariant ( ) , Message = response [ " " ] . ToStringInvariant ( ) , } ; return withdrawalResponse ; }
A withdrawal request.
A withdrawal request .
// Contrary to what the API docs say, name is required
Withdrawal response from Binance
Withdrawal response from Binance
withdrawalRequest
ExchangeWithdrawalRequest
The withdrawal request.
The withdrawal request .