Skip to content

Commit 5946a82

Browse files
authored
Implement OnGetFeesAsync for Coinbase (#704)
* Implement OnGetFeesAsync for Coinbase * Get taker fee in favor or maker fee
1 parent e3ed233 commit 5946a82

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,26 @@ protected override async Task<Dictionary<string, decimal>> OnGetAmountsAvailable
652652
return amounts;
653653
}
654654

655+
protected override async Task<Dictionary<string, decimal>> OnGetFeesAsync()
656+
{
657+
var symbols = await OnGetMarketSymbolsAsync();
658+
659+
Dictionary<string, decimal> fees = new Dictionary<string, decimal>(StringComparer.OrdinalIgnoreCase);
660+
661+
JObject token = await MakeJsonRequestAsync<JObject>("/fees", null, await GetNoncePayloadAsync(), "GET");
662+
/*
663+
* We can chose between maker and taker fee, but currently ExchangeSharp only supports 1 fee rate per symbol.
664+
* Here, we choose taker fee, which are usually higher
665+
*/
666+
decimal makerRate = token["taker_fee_rate"].Value<decimal>(); //percentage between 0 and 1
667+
668+
fees = symbols
669+
.Select(symbol => new KeyValuePair<string, decimal>(symbol, makerRate))
670+
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
671+
672+
return fees;
673+
}
674+
655675
protected override async Task<ExchangeWithdrawalResponse> OnWithdrawAsync(ExchangeWithdrawalRequest request)
656676
{
657677
var nonce = await GenerateNonceAsync();

0 commit comments

Comments
 (0)