Skip to content

Commit 2ef1f50

Browse files
authored
Withdrawal fee (#691)
1 parent 3344e7e commit 2ef1f50

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

src/ExchangeSharp/API/Exchanges/Bitfinex/ExchangeBitfinexAPI.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,8 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
777777

778778
resp.Id = result[0]["withdrawal_id"].ToStringInvariant();
779779
resp.Message = result[0]["message"].ToStringInvariant();
780+
resp.Fee = result[0].Value<decimal?>("WITHDRAWAL_FEE");
781+
780782
return resp;
781783
}
782784

src/ExchangeSharp/API/Exchanges/Bittrex/ExchangeBittrexAPI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
546546
ExchangeWithdrawalResponse withdrawalResponse = new ExchangeWithdrawalResponse
547547
{
548548
Id = result["id"].ToStringInvariant(),
549-
Message = result["status"].ToStringInvariant()
549+
Message = result["status"].ToStringInvariant(),
550+
Fee = result.Value<decimal?>("txCost")
550551
};
551552

552553
return withdrawalResponse;

src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,10 +670,12 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
670670
}
671671

672672
var result = await MakeJsonRequestAsync<WithdrawalResult>("/withdrawals/crypto", null, payload, "POST");
673+
var feeParsed = decimal.TryParse(result.Fee, out var fee);
673674

674675
return new ExchangeWithdrawalResponse
675676
{
676-
Id = result.Id
677+
Id = result.Id,
678+
Fee = feeParsed ? fee : (decimal?)null
677679
};
678680
}
679681

src/ExchangeSharp/API/Exchanges/FTX/ExchangeFTXAPI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
348348

349349
return new ExchangeWithdrawalResponse
350350
{
351-
Id = result["id"].ToString()
351+
Id = result["id"].ToString(),
352+
Fee = result.Value<decimal?>("fee")
352353
};
353354
}
354355

src/ExchangeSharp/API/Exchanges/Kraken/ExchangeKrakenAPI.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(Exchan
456456

457457
return new ExchangeWithdrawalResponse
458458
{
459-
Id = result["refid"].ToString()
459+
Id = result["refid"].ToString(),
460+
Fee = result.Value<decimal?>("fee")
460461
};
461462
}
462463

src/ExchangeSharp/Model/ExchangeWithdrawalResponse.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
MIT LICENSE
33
44
Copyright 2017 Digital Ruby, LLC - http://www.digitalruby.com
@@ -26,11 +26,14 @@ public sealed class ExchangeWithdrawalResponse
2626
/// <summary>Whether the withdrawal was successful</summary>
2727
public bool Success { get; set; } = true;
2828

29-
/// <summary>Returns a <see cref="System.String" /> that represents this instance.</summary>
30-
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
31-
public override string ToString()
29+
/// <summary>Fee for the withdrawal</summary>
30+
public decimal? Fee { get; set; }
31+
32+
/// <summary>Returns a <see cref="System.String" /> that represents this instance.</summary>
33+
/// <returns>A <see cref="System.String" /> that represents this instance.</returns>
34+
public override string ToString()
3235
{
3336
return $"Success: {Success} Id: {Id ?? "null"} Message: {Message ?? "null"}";
3437
}
3538
}
36-
}
39+
}

0 commit comments

Comments
 (0)