mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Fix the ExchangeSharpRateProvider for some pairs
This commit is contained in:
parent
03fbd51fab
commit
499352e51c
@ -44,6 +44,9 @@ namespace BTCPayServer.Services.Rates
|
||||
{
|
||||
if (notFoundSymbols.TryGetValue(ticker.Key, out _))
|
||||
return null;
|
||||
if (ticker.Key.Contains("XMR"))
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
CurrencyPair pair;
|
||||
|
@ -103,16 +103,14 @@ namespace BTCPayServer.Services.Rates
|
||||
var p2 = symbol.Substring(mapped1.KrakenTicker.Length);
|
||||
if (_TickerMapping.TryGetValue(p2, out var mapped2))
|
||||
p2 = mapped2;
|
||||
global = $"{p2}_{mapped1.PayTicker}";
|
||||
global = $"{mapped1.PayTicker}_{p2}";
|
||||
}
|
||||
else
|
||||
{
|
||||
global = await helper.ExchangeMarketSymbolToGlobalMarketSymbolAsync(symbol);
|
||||
var s = global.Split('-');
|
||||
global = $"{s[1]}_{s[0]}";
|
||||
}
|
||||
if (CurrencyPair.TryParse(global, out var pair))
|
||||
result.Add(new PairRate(pair.Inverse(), new BidAsk(ticker.Bid, ticker.Ask)));
|
||||
result.Add(new PairRate(pair, new BidAsk(ticker.Bid, ticker.Ask)));
|
||||
else
|
||||
notFoundSymbols.TryAdd(symbol, symbol);
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ namespace BTCPayServer.Tests
|
||||
{
|
||||
if (name == "kraken")
|
||||
{
|
||||
Assert.Contains(exchangeRates.ByExchange[name], e => e.CurrencyPair == new CurrencyPair("XMR", "BTC"));
|
||||
Assert.Contains(exchangeRates.ByExchange[name], e => e.CurrencyPair == new CurrencyPair("XMR", "BTC") && e.BidAsk.Bid < 1.0m);
|
||||
}
|
||||
// This check if the currency pair is using right currency pair
|
||||
Assert.Contains(exchangeRates.ByExchange[name],
|
||||
@ -153,6 +153,13 @@ namespace BTCPayServer.Tests
|
||||
|
||||
// Kraken emit one request only after first GetRates
|
||||
factory.Providers["kraken"].GetRatesAsync(default).GetAwaiter().GetResult();
|
||||
|
||||
using (var c = new HttpClient())
|
||||
{
|
||||
var p = new ExchangeSharpRateProvider<ExchangeSharp.ExchangeKrakenAPI>(c);
|
||||
var rates = p.GetRatesAsync(default).GetAwaiter().GetResult();
|
||||
Assert.Contains(rates, e => e.CurrencyPair == new CurrencyPair("XXMR", "XXBT") && e.BidAsk.Bid < 1.0m);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
Loading…
Reference in New Issue
Block a user