Skip to content

Commit

Permalink
Fix/spot (#2505)
Browse files Browse the repository at this point in the history
* feat: change rsk mainnet endpoint SOV-1537

* fix: change back metamask helper

* fix: RBTC/DLLR

---------

Co-authored-by: soulBit <[email protected]>
  • Loading branch information
creed-victor and soulBit authored Mar 16, 2023
1 parent 099528f commit e143cd7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 32 deletions.
19 changes: 16 additions & 3 deletions src/app/components/PairNavbarInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,25 @@ export const PairNavbarInfo: React.FC<IPairNavbarInfoProps> = ({ pair }) => {
[invertPrice],
);

const low = useMemo(() => normalize(invertPrice ? highPrice : lowPrice), [
highPrice,
invertPrice,
lowPrice,
normalize,
]);
const high = useMemo(() => normalize(invertPrice ? lowPrice : highPrice), [
highPrice,
invertPrice,
lowPrice,
normalize,
]);

return (
<div className="tw-flex tw-items-center tw-justify-around tw-flex-1 tw-text-xs">
<div className="tw-hidden sm:tw-flex tw-items-center tw-text-center tw-flex-row">
{t(translations.pairNavbar.lastTradedPrice)}
<span className="tw-ml-2 tw-font-semibold tw-text-sm tw-text-primary">
{toNumberFormat(normalize(_lastPrice), 8)}
{toNumberFormat(_lastPrice, 8)}
</span>
</div>
<div className="tw-hidden md:tw-flex tw-items-center tw-text-center tw-flex-row">
Expand All @@ -146,7 +159,7 @@ export const PairNavbarInfo: React.FC<IPairNavbarInfoProps> = ({ pair }) => {
<div>
{t(translations.pairNavbar.dayLow)}
<span className="tw-ml-2 tw-font-semibold tw-text-sm tw-text-trade-short">
{toNumberFormat(normalize(lowPrice), 8)}
{toNumberFormat(low, 8)}
</span>
</div>
)}{' '}
Expand All @@ -156,7 +169,7 @@ export const PairNavbarInfo: React.FC<IPairNavbarInfoProps> = ({ pair }) => {
<div>
{t(translations.pairNavbar.dayHigh)}{' '}
<span className="tw-ml-2 tw-font-semibold tw-text-sm tw-text-trade-long">
{toNumberFormat(normalize(highPrice), 8)}
{toNumberFormat(high, 8)}
</span>
</div>
)}
Expand Down
11 changes: 0 additions & 11 deletions src/app/components/TradingChart/datafeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
getTokensFromSymbol,
hasDirectFeed,
queryPairByChunks,
shouldInvertPair,
} from './helpers';
import { CandleDuration } from 'app/pages/PerpetualPage/hooks/graphql/useGetCandles';
import { TradingCandleDictionary } from './dictionary';
Expand Down Expand Up @@ -126,16 +125,6 @@ const tradingChartDataFeeds = (
hasDirectFeed(symbolInfo.name),
);

if (shouldInvertPair(symbolInfo.name) && items) {
items = items.map(item => ({
...item,
open: 1 / item.open,
high: 1 / item.high,
low: 1 / item.low,
close: 1 / item.close,
}));
}

if (!items || items.length === 0) {
onHistoryCallback([], {
noData: true,
Expand Down
8 changes: 1 addition & 7 deletions src/app/components/TradingChart/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ export const shouldInvertPair = (symbolName: string) =>
pairstoInvert.includes(symbolName);

export const hasDirectFeed = (symbolName: string) => {
const [base, quote] = symbolName.split('/') as [Asset, Asset];
if (base === Asset.RBTC && quote === Asset.DLLR) {
return true;
}
const [, quote] = symbolName.split('/') as [Asset, Asset];
return [Asset.RBTC, Asset.XUSD].includes(quote);
};

Expand Down Expand Up @@ -459,9 +456,6 @@ const getTokenAddress = (asset: Asset) =>

export const getTokensFromSymbol = (symbol: string) => {
let [base, quote] = symbol.split('/');
if (shouldInvertPair(symbol)) {
[base, quote] = [quote, base];
}
return {
baseToken: getTokenAddress(base as Asset),
quoteToken: getTokenAddress(quote as Asset),
Expand Down
11 changes: 0 additions & 11 deletions src/app/components/TradingChart/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import {
getTokensFromSymbol,
hasDirectFeed,
queryPairByChunks,
shouldInvertPair,
} from './helpers';

type SubItem = {
Expand Down Expand Up @@ -95,16 +94,6 @@ export class Streaming {
return;
}

if (shouldInvertPair(subscriptionItem.symbolInfo.name) && bar) {
bar = {
...bar,
open: 1 / bar.open,
high: 1 / bar.high,
low: 1 / bar.low,
close: 1 / bar.close,
};
}

// update last bar cache and execute chart callback
subscriptionItem.lastBar = bar;
subscriptionItem.handler(bar);
Expand Down

0 comments on commit e143cd7

Please sign in to comment.