Skip to content

Commit

Permalink
fix: correct exchange rate (#1555)
Browse files Browse the repository at this point in the history
* fix: correct exchange rate

* remove redundant optional chaining

* refactor: simplify exchange rate display

---------

Co-authored-by: Peter <[email protected]>
  • Loading branch information
tomjeatt and peterslany authored Sep 6, 2023
1 parent 9e6ee51 commit 2a73ce6
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/pages/Dashboard/cards/OracleStatusCard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { CurrencyExt } from '@interlay/interbtc-api';
import { Bitcoin, ExchangeRate } from '@interlay/monetary-js';
import clsx from 'clsx';
import { withErrorBoundary } from 'react-error-boundary';
import { useTranslation } from 'react-i18next';
Expand Down Expand Up @@ -33,15 +31,11 @@ const OracleStatusCard = ({ hasLinks }: Props): JSX.Element => {
return <>Loading...</>;
}

const exchangeRate = relayChainExchangeRate
? new ExchangeRate<Bitcoin, CurrencyExt>(Bitcoin, RELAY_CHAIN_NATIVE_TOKEN, relayChainExchangeRate.toBig(), 0, 0)
: 0;

const oracleOnline = oracleStatus && oracleStatus === OracleStatus.ONLINE;

let statusText;
let statusCircleText;
if (exchangeRate === undefined) {
if (relayChainExchangeRate === undefined) {
statusText = t('dashboard.oracles.not_available');
statusCircleText = t('unavailable');
} else if (oracleOnline === true) {
Expand Down Expand Up @@ -88,9 +82,9 @@ const OracleStatusCard = ({ hasLinks }: Props): JSX.Element => {
>
{statusCircleText}
</Ring64Title>
{exchangeRate && (
{relayChainExchangeRate && (
<Ring64Value>
{exchangeRate.toHuman(5)} {RELAY_CHAIN_NATIVE_TOKEN_SYMBOL}
{relayChainExchangeRate.toHuman(5)} {RELAY_CHAIN_NATIVE_TOKEN_SYMBOL}
</Ring64Value>
)}
</Ring64>
Expand Down

2 comments on commit 2a73ce6

@vercel
Copy link

@vercel vercel bot commented on 2a73ce6 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 2a73ce6 Sep 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.