btcpayserver/BTCPayServer/Views/Stores/Rates.cshtml
d11n ed7031981b
Bootstrap v5 migration (#2490)
* Swap bootstrap asset files

* Update themes and color definitions

* Move general bootstrap customizations

* Theme updates

Theme updates

* Remove BuildBundlerMinifier

This lead to an error, because BuildBundlerMinifier and BundlerMinifier.Core seem to conflict here. Details: https://stackoverflow.com/a/61119586

* Rewplace btn-block class with w-100

* Update badge classes

* Remove old font family head variable

* Update margin classes

* Cleanups

* Update float classes

* Update text classes

* Update padding classes

* Update border classes

* UPdate dropdown classes

* Update select classes

* Update neutral custom props

* Update bootstrap and customizations

* Update ChromeDriver; disable smooth scroll

https://github.com/SeleniumHQ/selenium/issues/8295

* Improve alert messages

* Improve bootstrap customizations

* Disable reduced motion

See also 7358282f

* Update Bootstrap data attributes

* Update file inputs

* Update input groups

* Replace deprecated jumbotron class

* Update variables; re-add negative margin util classes

* Update cards

* Update form labels

* Debug alerts

* Fix aria-labelledby associations

* Dropdown-related test fixes

* Fix CanUseWebhooks test

* Test fixes

* Nav updates

* Fix nav usage in wallet send and payouts

* Update alert and modal close buttons

* Re-add backdrop properties

* Upgrade Bootstrap to v5 final

* Update screen reader classes

* Update font-weight classes

* Update monospace font classes

* Update accordians

* Update close icon usage

* Cleanup

* Update scripts and style integrations

* Update input group texts

* Update LN node setup page

* Update more form control classes

* Update inline forms

* Add js specific test

* Upgrade Vue.js

* Remove unused JS

* Upgrade Bootstrap to v5.0.1

* Try container related test updates

* Separate jQuery bundle

* Remove jQuery from LND seed backup page

* Remove unused code

* Refactor email autofill js

* Refactor camera scanner JS

* Re-add tests

* Re-add BuildBundlerMinifier

* Do not minify bundles containing Bootstrap

Details https://github.com/madskristensen/BundlerMinifier/issues/558

* Update bundles

* Cleanup JS test

* Cleanup tests involving dropdowns

* Cleanup tests involving collapses

* Cleanup locale additions in ConfigureCore

* Cleanup bundles

* Remove duplicate status message

* Cleanup formatting

* Fix missing validation scripts

* Remove unused unminified Bootstrap js files

* Fix classic theme

* Fix Casa theme

* Fix PoS validation
2021-05-19 11:39:27 +09:00

198 lines
11 KiB
Text

@model BTCPayServer.Models.StoreViewModels.RatesViewModel
@{
Layout = "../Shared/_NavLayout.cshtml";
ViewData.SetActivePageAndTitle(StoreNavPages.Rates, "Rates", Context.GetStoreData().StoreName);
}
<div class="row">
<div class="col-lg-8">
<h4 class="mb-3">@ViewData["PageTitle"]</h4>
@if (!ViewContext.ModelState.IsValid)
{
<div asp-validation-summary="All" class="text-danger"></div>
}
<form method="post">
<input type="hidden" asp-for="ShowScripting" />
@if (Model.ShowScripting)
{
<div class="form-group">
<h5>Scripting</h5>
<p>Rate script allows you to express precisely how you want to calculate rates for currency pairs.</p>
<p>We are retrieving the rate of each exchange either directly, or via <a href="https://www.coingecko.com/" target="_blank">CoinGecko (free)</a>.</p>
<div class="accordion" id="accordion-info">
<div class="card">
<div class="card-header" id="direct-header">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-bs-toggle="collapse" data-bs-target="#direct-content" aria-expanded="true">
Direct integration
</button>
</h2>
</div>
<div class="collapse" id="direct-content">
<div class="card-body text-muted overflow-auto">
@foreach (var exchange in Model.AvailableExchanges.Where(a => a.Source == BTCPayServer.Rating.RateSource.Direct))
{
<a href="@exchange.Url">@exchange.Id</a><span>&nbsp;</span>
}
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="coingecko-header">
<h2 class="mb-0">
<button class="btn btn-link" type="button" data-bs-toggle="collapse" data-bs-target="#coingecko-content" aria-expanded="true">
Coingecko integration
</button>
</h2>
</div>
<div id="coingecko-content" class="collapse">
<div class="card-body text-muted overflow-auto">
@foreach (var exchange in Model.AvailableExchanges.Where(a => a.Source == BTCPayServer.Rating.RateSource.Coingecko))
{
<a href="@exchange.Url">@exchange.Id</a><span>&nbsp;</span>
}
</div>
</div>
</div>
</div>
</div>
}
@if (Model.TestRateRules != null)
{
<div class="form-group">
<h5>Test results:</h5>
<table class="table table-sm table-responsive-md">
<tbody>
@foreach (var result in Model.TestRateRules)
{
<tr>
@if (result.Error)
{
<th class="small"><span class="text-danger fa fa-times"></span> @result.CurrencyPair</th>
}
else
{
<th class="small"><span class="text-success fa fa-check"></span> @result.CurrencyPair</th>
}
<td class="small">@result.Rule</td>
</tr>
}
</tbody>
</table>
</div>
}
@if (Model.ShowScripting)
{
<div id="help" class="collapse text-start">
<p>
The script language is composed of several rules composed of a currency pair and a mathematic expression.
The example below will use <code>kraken</code> for both <code>LTC_USD</code> and <code>BTC_USD</code> pairs.
</p>
<pre>
<code>
LTC_USD = kraken(LTC_USD);
BTC_USD = kraken(BTC_USD);
</code>
</pre>
<p>However, explicitely setting specific pairs like this can be a bit difficult. Instead, you can define a rule <code>X_X</code> which will match any currency pair. The following example will use <code>kraken</code> for getting the rate of any currency pair.</p>
<pre>
<code>
X_X = kraken(X_X);
</code>
</pre>
<p>However, <code>kraken</code> does not support the <code>BTC_CAD</code> pair. For this reason you can add a rule mapping all <code>X_CAD</code> to <code>ndax</code>, a Canadian exchange.</p>
<pre>
<code>
X_CAD = ndax(X_CAD);
X_X = kraken(X_X);
</code>
</pre>
<p>A given currency pair match the most specific rule. If two rules are matching and are as specific, the first rule will be chosen.</p>
<p>
But now, what if you want to support <code>DOGE</code>? The problem with <code>DOGE</code> is that most exchange do not have any pair for it. But <code>bittrex</code> has a <code>DOGE_BTC</code> pair. <br />
Luckily, the rule engine allow you to reference rules:
</p>
<pre>
<code>
DOGE_X = bittrex(DOGE_BTC) * BTC_X
X_CAD = ndax(X_CAD);
X_X = kraken(X_X);
</code>
</pre>
<p>
With <code>DOGE_USD</code> will be expanded to <code>bittrex(DOGE_BTC) * kraken(BTC_USD)</code>. And <code>DOGE_CAD</code> will be expanded to <code>bittrex(DOGE_BTC) * ndax(BTC_CAD)</code>. <br />
However, we advise you to write it that way to increase coverage so that <code>DOGE_BTC</code> is also supported:
</p>
<pre>
<code>
DOGE_X = DOGE_BTC * BTC_X
DOGE_BTC = bittrex(DOGE_BTC)
X_CAD = ndax(X_CAD);
X_X = kraken(X_X);
</code>
</pre>
<p>
It is worth noting that the inverses of those pairs are automatically supported as well.<br />
It means that the rule <code>USD_DOGE = 1 / DOGE_USD</code> implicitely exists.
</p>
</div>
<div class="form-group">
<label asp-for="Script"></label> <a href="#help" data-bs-toggle="collapse">
<span class="fa fa-question-circle-o text-secondary" title="More information..."></span>
</a>
<textarea asp-for="Script" rows="20" cols="80" class="form-control"></textarea>
<span asp-validation-for="Script" class="text-danger"></span>
<a href="#" onclick="$('#Script').val(defaultScript); return false;">Set to default settings</a>
</div>
<div class="form-group">
<button type="submit" class="btn btn-link" value="scripting-off" name="command">Turn off advanced rate rule scripting</button>
</div>
}
else
{
<div class="form-group">
<label asp-for="PreferredExchange"></label>
<select asp-for="PreferredExchange" asp-items="Model.Exchanges" class="form-select"></select>
<span asp-validation-for="PreferredExchange" class="text-danger"></span>
<p id="PreferredExchangeHelpBlock" class="form-text text-muted">
Current Rates source is <a href="@Model.RateSource" target="_blank">@Model.PreferredExchange</a>.
</p>
</div>
<p>
<button type="submit" class="btn btn-link p-0" value="scripting-on" name="command">Turn on advanced rate rule scripting</button>
</p>
}
<div class="form-group">
<label asp-for="Spread"></label>
<div class="input-group">
<input asp-for="Spread" class="form-control" />
<span class="input-group-text">%</span>
</div>
<span asp-validation-for="Spread" class="text-danger"></span>
</div>
<h4 class="mt-5 mb-3">Testing</h4>
<p>Enter currency pairs which you want to test against your rule (eg. <code>DOGE_USD,DOGE_CAD,BTC_CAD,BTC_USD</code>)</p>
<div class="form-group">
<input placeholder="BTC_USD, BTC_CAD" asp-for="ScriptTest" class="form-control" />
<span asp-validation-for="ScriptTest" class="text-danger"></span>
</div>
<button name="command" value="Test" type="submit" class="btn btn-primary" title="Test">Test</button>
<h4 class="mt-5 mb-3">Default currency pairs</h4>
<p>You can query those pairs via REST by querying <a asp-controller="Rate" asp-action="GetRates2" asp-route-storeId="@Model.StoreId" target="_blank">this link</a> without the need to specify currencyPairs.</p>
<div class="form-group">
<input placeholder="BTC_USD, BTC_CAD" asp-for="DefaultCurrencyPairs" class="form-control" />
<span asp-validation-for="DefaultCurrencyPairs" class="text-danger"></span>
</div>
<button name="command" type="submit" class="btn btn-primary" value="Save">Save</button>
</form>
</div>
</div>
@section PageFootContent {
<script>
var defaultScript = @Safe.Json(Model.DefaultScript);
</script>
<partial name="_ValidationScriptsPartial" />
}