diff --git a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs index bfc789e36..7f45d5838 100644 --- a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs @@ -555,6 +555,31 @@ protected override async Task> OnGetAmountsAvailable return amounts; } + protected override async Task OnWithdrawAsync(ExchangeWithdrawalRequest request) + { + var nonce = await GetNoncePayloadAsync(); + var payload = new Dictionary + { + { "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("/withdrawals/crypto", null, payload, "POST"); + + return new ExchangeWithdrawalResponse + { + Id = result.Id + }; + } + protected override async Task OnPlaceOrderAsync(ExchangeOrderRequest order) { object nonce = await GenerateNonceAsync(); diff --git a/src/ExchangeSharp/API/Exchanges/Coinbase/Models/Response/WithdrawalResult.cs b/src/ExchangeSharp/API/Exchanges/Coinbase/Models/Response/WithdrawalResult.cs new file mode 100644 index 000000000..6aab8d5ef --- /dev/null +++ b/src/ExchangeSharp/API/Exchanges/Coinbase/Models/Response/WithdrawalResult.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace ExchangeSharp.Coinbase +{ + public class WithdrawalResult + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("amount")] + public string Amount { get; set; } + + [JsonProperty("currency")] + public string Currency { get; set; } + + [JsonProperty("fee")] + public string Fee { get; set; } + + [JsonProperty("subtotal")] + public string Subtotal { get; set; } + } +} diff --git a/src/ExchangeSharpConsole/Options/CurrenciesOption.cs b/src/ExchangeSharpConsole/Options/CurrenciesOption.cs new file mode 100644 index 000000000..4f8f64edf --- /dev/null +++ b/src/ExchangeSharpConsole/Options/CurrenciesOption.cs @@ -0,0 +1,28 @@ +using CommandLine; +using ExchangeSharpConsole.Options.Interfaces; +using Newtonsoft.Json; +using System; +using System.Threading.Tasks; + +namespace ExchangeSharpConsole.Options +{ + [Verb("currencies", HelpText = "Gets a list of currencies available on the exchange")] + public class CurrenciesOption : BaseOption, IOptionPerExchange + { + public string ExchangeName { get; set; } + + public override async Task RunCommand() + { + using var api = GetExchangeInstance(ExchangeName); + + Authenticate(api); + + var currencies = await api.GetCurrenciesAsync(); + + foreach (var c in currencies) + { + Console.WriteLine($"{c.Key}: {c.Value.FullName}, {c.Value.AltName}"); + } + } + } +} diff --git a/src/ExchangeSharpConsole/Program.cs b/src/ExchangeSharpConsole/Program.cs index e8d95ac3e..4b243e08b 100644 --- a/src/ExchangeSharpConsole/Program.cs +++ b/src/ExchangeSharpConsole/Program.cs @@ -18,6 +18,7 @@ public partial class Program typeof(CancelOrderOption), typeof(CandlesOption), typeof(ConvertOption), + typeof(CurrenciesOption), typeof(ExampleOption), typeof(ExportOption), typeof(InteractiveOption),