From 625ce0551f9ba6a66464bc84ee8171d455b35f59 Mon Sep 17 00:00:00 2001 From: Tomas Bezouska Date: Mon, 29 Nov 2021 17:03:55 +0100 Subject: [PATCH] Withdrawal fee --- .../API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs | 2 ++ .../API/Exchanges/Bittrex/ExchangeBittrexAPI.cs | 3 ++- .../API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs | 4 +++- .../API/Exchanges/FTX/ExchangeFTXAPI.cs | 3 ++- .../API/Exchanges/Kraken/ExchangeKrakenAPI.cs | 3 ++- .../Model/ExchangeWithdrawalResponse.cs | 13 ++++++++----- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/ExchangeSharp/API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs b/src/ExchangeSharp/API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs index 15369fb08..c97edecde 100644 --- a/src/ExchangeSharp/API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs @@ -777,6 +777,8 @@ protected override async Task OnWithdrawAsync(Exchan resp.Id = result[0]["withdrawal_id"].ToStringInvariant(); resp.Message = result[0]["message"].ToStringInvariant(); + resp.Fee = result[0].Value("WITHDRAWAL_FEE"); + return resp; } diff --git a/src/ExchangeSharp/API/Exchanges/Bittrex/ExchangeBittrexAPI.cs b/src/ExchangeSharp/API/Exchanges/Bittrex/ExchangeBittrexAPI.cs index 306202061..7e5889997 100644 --- a/src/ExchangeSharp/API/Exchanges/Bittrex/ExchangeBittrexAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Bittrex/ExchangeBittrexAPI.cs @@ -546,7 +546,8 @@ protected override async Task OnWithdrawAsync(Exchan ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse { Id = result["id"].ToStringInvariant(), - Message = result["status"].ToStringInvariant() + Message = result["status"].ToStringInvariant(), + Fee = result.Value("txCost") }; return withdrawalResponse; diff --git a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs index ef9c6c0cd..8f255eb5c 100644 --- a/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs @@ -670,10 +670,12 @@ protected override async Task OnWithdrawAsync(Exchan } var result = await MakeJsonRequestAsync("/withdrawals/crypto", null, payload, "POST"); + var feeParsed = decimal.TryParse(result.Fee, out var fee); return new ExchangeWithdrawalResponse { - Id = result.Id + Id = result.Id, + Fee = feeParsed ? fee : (decimal?)null }; } diff --git a/src/ExchangeSharp/API/Exchanges/FTX/ExchangeFTXAPI.cs b/src/ExchangeSharp/API/Exchanges/FTX/ExchangeFTXAPI.cs index bb7708e63..cca51d077 100644 --- a/src/ExchangeSharp/API/Exchanges/FTX/ExchangeFTXAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/FTX/ExchangeFTXAPI.cs @@ -348,7 +348,8 @@ protected override async Task OnWithdrawAsync(Exchan return new ExchangeWithdrawalResponse { - Id = result["id"].ToString() + Id = result["id"].ToString(), + Fee = result.Value("fee") }; } diff --git a/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs b/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs index cb5e7aea6..b8d8c30e5 100644 --- a/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs @@ -456,7 +456,8 @@ protected override async Task OnWithdrawAsync(Exchan return new ExchangeWithdrawalResponse { - Id = result["refid"].ToString() + Id = result["refid"].ToString(), + Fee = result.Value("fee") }; } diff --git a/src/ExchangeSharp/Model/ExchangeWithdrawalResponse.cs b/src/ExchangeSharp/Model/ExchangeWithdrawalResponse.cs index 7ac45b2b0..867203c43 100644 --- a/src/ExchangeSharp/Model/ExchangeWithdrawalResponse.cs +++ b/src/ExchangeSharp/Model/ExchangeWithdrawalResponse.cs @@ -1,4 +1,4 @@ -/* +/* MIT LICENSE Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com @@ -26,11 +26,14 @@ public sealed class ExchangeWithdrawalResponse /// Whether the withdrawal was successful public bool Success { get; set; } = true; - /// Returns a that represents this instance. - /// A that represents this instance. - public override string ToString() + /// Fee for the withdrawal + public decimal? Fee { get; set; } + + /// Returns a that represents this instance. + /// A that represents this instance. + public override string ToString() { return $"Success: {Success} Id: {Id ?? "null"} Message: {Message ?? "null"}"; } } -} \ No newline at end of file +}