take fiat currency from config

This commit is contained in:
Sebastian 2023-02-18 10:11:23 -03:00
parent a45759e2ad
commit 0ba479c6e7
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 5 additions and 7 deletions

View File

@ -364,7 +364,6 @@ namespace SandboxBackend {
// Contains ratios and fees related to buying
// and selling the circuit currency.
ratios_and_fees: RatiosAndFees;
currency: string;
}
interface RatiosAndFees {
// Exchange rate to buy the circuit currency from fiat.
@ -375,6 +374,9 @@ namespace SandboxBackend {
buy_in_fee: float;
// Fee to subtract after applying the sell ratio.
sell_out_fee: float;
// Fiat currency. That is the currency in which
// cash-out operations ultimately wire money.
fiat_currency: string;
}
interface Cashouts {
// Every string represents a cash-out operation UUID.

View File

@ -288,9 +288,6 @@ export function useRatiosAndFeeConfig(): HttpResponse<
keepPreviousData: true,
});
if (data) {
data.data.currency = "FIAT";
}
if (data) return data;
if (error) return error.info;
return { loading: true };

View File

@ -194,6 +194,7 @@ function CreateCashout({
const sellFee = !config.ratios_and_fees.sell_out_fee
? zero
: Amounts.fromFloat(config.ratios_and_fees.sell_out_fee, balance.currency);
const fiatCurrency = config.ratios_and_fees.fiat_currency;
if (!sellRate || sellRate < 0) return <div>error rate</div>;
@ -220,7 +221,7 @@ function CreateCashout({
const __amount_credit = Amounts.sub(credit_before_fee, sellFee).amount;
const amount_credit = Amounts.parseOrThrow(
`${config.currency}:${Amounts.stringifyValue(__amount_credit)}`,
`${fiatCurrency}:${Amounts.stringifyValue(__amount_credit)}`,
);
const balanceAfter = Amounts.sub(balance, amount_debit).amount;
@ -243,8 +244,6 @@ function CreateCashout({
channel: !form.channel ? i18n.str`required` : undefined,
});
// setErrors(validationResult);
return (
<div>
{error && (