mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
The CoinGecko rate provider is similar to the bitcoin average one, in that you can ask it for a rate from its aggregated sourcing or you can get rates from specific exchanges. I've added support for both. I haven't integrated it or replaced coinaverage just to see if we should use it as the default and switch everyone to it or what other action to take.
60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using BTCPayServer.Rating;
|
|
using BTCPayServer.Services.Rates;
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
namespace BTCPayServer.Models.StoreViewModels
|
|
{
|
|
public class RatesViewModel
|
|
{
|
|
public class TestResultViewModel
|
|
{
|
|
public string CurrencyPair { get; set; }
|
|
public string Rule { get; set; }
|
|
public bool Error { get; set; }
|
|
}
|
|
public void SetExchangeRates(IEnumerable<AvailableRateProvider> supportedList, string preferredExchange)
|
|
{
|
|
var defaultStore = preferredExchange ?? CoinAverageRateProvider.CoinAverageName;
|
|
var chosen = supportedList.FirstOrDefault(f => f.Id == defaultStore) ?? supportedList.FirstOrDefault();
|
|
Exchanges = new SelectList(supportedList, nameof(chosen.Id), nameof(chosen.Name), chosen);
|
|
PreferredExchange = chosen.Id;
|
|
RateSource = chosen.Url;
|
|
}
|
|
|
|
public List<TestResultViewModel> TestRateRules { get; set; }
|
|
|
|
public SelectList Exchanges { get; set; }
|
|
|
|
public bool ShowScripting { get; set; }
|
|
|
|
[Display(Name = "Rate rules")]
|
|
[MaxLength(2000)]
|
|
public string Script { get; set; }
|
|
public string DefaultScript { get; set; }
|
|
public string ScriptTest { get; set; }
|
|
public string DefaultCurrencyPairs { get; set; }
|
|
public string StoreId { get; set; }
|
|
public IEnumerable<AvailableRateProvider> AvailableExchanges { get; set; }
|
|
|
|
[Display(Name = "Add a spread on exchange rate of ... %")]
|
|
[Range(0.0, 100.0)]
|
|
public double Spread
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
[Display(Name = "Preferred price source (eg. bitfinex, bitstamp...)")]
|
|
public string PreferredExchange { get; set; }
|
|
|
|
public string RateSource
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
}
|
|
}
|