diff --git a/src/ExchangeSharpConsole/Options/DepositAddressOption.cs b/src/ExchangeSharpConsole/Options/DepositAddressOption.cs new file mode 100644 index 00000000..92ff2f2f --- /dev/null +++ b/src/ExchangeSharpConsole/Options/DepositAddressOption.cs @@ -0,0 +1,26 @@ +using CommandLine; +using ExchangeSharpConsole.Options.Interfaces; +using System; +using System.Threading.Tasks; + +namespace ExchangeSharpConsole.Options +{ + [Verb("deposit-address", HelpText = "Get a deposit address for given currency")] + public class DepositAddressOption : BaseOption, IOptionPerExchange, IOptionWithCurrency + { + public string ExchangeName { get; set; } + + public string Currency { get; set; } + + public override async Task RunCommand() + { + using var api = GetExchangeInstance(ExchangeName); + + Authenticate(api); + + var address = await api.GetDepositAddressAsync(Currency); + + Console.WriteLine($"Address: {address}"); + } + } +} diff --git a/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithAddress.cs b/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithAddress.cs new file mode 100644 index 00000000..cd061ea1 --- /dev/null +++ b/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithAddress.cs @@ -0,0 +1,13 @@ +using CommandLine; + +namespace ExchangeSharpConsole.Options.Interfaces +{ + public interface IOptionWithAddress + { + [Option('d', "address", Required = true, HelpText = "Crypto address")] + string Address { get; set; } + + [Option('t', "address-tag", Required = false, HelpText = "Tag describing the address")] + string Tag { get; set; } + } +} diff --git a/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithAmount.cs b/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithAmount.cs new file mode 100644 index 00000000..9b31bae1 --- /dev/null +++ b/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithAmount.cs @@ -0,0 +1,10 @@ +using CommandLine; + +namespace ExchangeSharpConsole.Options.Interfaces +{ + public interface IOptionWithCurrencyAmount : IOptionWithCurrency + { + [Option('a', "amount", Required = true, HelpText = "Amount of the currency.")] + decimal Amount { get; set; } + } +} diff --git a/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithCurrency.cs b/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithCurrency.cs new file mode 100644 index 00000000..53fed0d8 --- /dev/null +++ b/src/ExchangeSharpConsole/Options/Interfaces/IOptionWithCurrency.cs @@ -0,0 +1,10 @@ +using CommandLine; + +namespace ExchangeSharpConsole.Options.Interfaces +{ + public interface IOptionWithCurrency + { + [Option('c', "currency", Required = true, HelpText = "Currency, e.g. BTC.")] + string Currency { get; set; } + } +} diff --git a/src/ExchangeSharpConsole/Options/WithdrawOption.cs b/src/ExchangeSharpConsole/Options/WithdrawOption.cs new file mode 100644 index 00000000..86372eb9 --- /dev/null +++ b/src/ExchangeSharpConsole/Options/WithdrawOption.cs @@ -0,0 +1,39 @@ +using CommandLine; +using ExchangeSharp; +using ExchangeSharpConsole.Options.Interfaces; +using System; +using System.Threading.Tasks; + +namespace ExchangeSharpConsole.Options +{ + [Verb("withdraw", HelpText = "Withdraw given amount in given currency to target address")] + public class WithdrawOption : BaseOption, IOptionPerExchange, IOptionWithAddress, IOptionWithCurrencyAmount + { + public string ExchangeName { get; set; } + + public string Address { get; set; } + + public string Tag { get; set; } + + public decimal Amount { get; set; } + + public string Currency { get; set; } + + public override async Task RunCommand() + { + using var api = GetExchangeInstance(ExchangeName); + + Authenticate(api); + + var result = await api.WithdrawAsync(new ExchangeWithdrawalRequest + { + Address = Address, + AddressTag = Tag, + Amount = Amount, + Currency = Currency + }); + + Console.WriteLine($"Withdrawal successful: {result.Success}, id: {result.Id}, optional message: {result.Message}"); + } + } +} diff --git a/src/ExchangeSharpConsole/Program.cs b/src/ExchangeSharpConsole/Program.cs index 4b243e08..bea04a0f 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(DepositAddressOption), typeof(CurrenciesOption), typeof(ExampleOption), typeof(ExportOption), @@ -38,7 +39,8 @@ public partial class Program typeof(WebSocketsPositionsOption), typeof(WebSocketsTickersOption), typeof(WebSocketsTradesOption), - typeof(WebSocketsCandlesOption) + typeof(WebSocketsCandlesOption), + typeof(WithdrawOption) }; public Program()