Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: deprecated legacy futures #2408

Merged
merged 4 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion constants/announcement.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MILLISECONDS_PER_DAY } from 'sdk/constants/period';

// Shows or hides the home page banner entirely when set to true/false
export const BANNER_ENABLED = true;
export const BANNER_ENABLED = false;
// Sets the link destination for the banner component, or renders the banner as
// plain, un-clickable text if set to a falsey value (`false`, `null`, '', etc...)
export const BANNER_LINK_URL =
Expand Down
4 changes: 1 addition & 3 deletions constants/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export const DEFAULT_DELAYED_CANCEL_BUFFER = 15;

export const CROSS_MARGIN_ENABLED = true;

export const DEFAULT_FUTURES_MARGIN_TYPE = CROSS_MARGIN_ENABLED
? 'cross_margin'
: 'isolated_margin';
export const DEFAULT_FUTURES_MARGIN_TYPE = 'cross_margin';

export const DEFAULT_LEVERAGE = '1';

Expand Down
27 changes: 4 additions & 23 deletions sections/dashboard/MobileDashboard/OpenPositions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import { TabPanel } from 'components/Tab';
import { FuturesAccountTypes } from 'queries/futures/types';
import { SectionHeader, SectionTitle } from 'sections/futures/mobile';
import { selectBalances } from 'state/balances/selectors';
import {
selectFuturesPortfolio,
selectActiveIsolatedPositionsCount,
selectActiveSmartPositionsCount,
} from 'state/futures/selectors';
import { selectFuturesPortfolio, selectActiveSmartPositionsCount } from 'state/futures/selectors';
import { useAppSelector } from 'state/hooks';
import { formatDollars } from 'utils/formatters/number';

Expand All @@ -36,7 +32,7 @@ export type OpenPositionsProps = {
const OpenPositions: React.FC<OpenPositionsProps> = ({ exchangeTokens, exchangeTokenBalances }) => {
const { t } = useTranslation();
const smartPositionsCount = useAppSelector(selectActiveSmartPositionsCount);
const isolatedPositionsCount = useAppSelector(selectActiveIsolatedPositionsCount);

const portfolio = useAppSelector(selectFuturesPortfolio);
const balances = useAppSelector(selectBalances);

Expand All @@ -55,15 +51,6 @@ const OpenPositions: React.FC<OpenPositionsProps> = ({ exchangeTokens, exchangeT
disabled: false,
onClick: () => setActivePositionsTab(PositionsTab.SMART_MARGIN),
},
{
name: PositionsTab.ISOLATED_MARGIN,
label: t('dashboard.overview.positions-tabs.isolated-margin'),
badge: isolatedPositionsCount,
active: activePositionsTab === PositionsTab.ISOLATED_MARGIN,
detail: formatDollars(portfolio.isolatedMarginFutures),
disabled: false,
onClick: () => setActivePositionsTab(PositionsTab.ISOLATED_MARGIN),
},
{
name: PositionsTab.SPOT,
label: t('dashboard.overview.positions-tabs.spot'),
Expand All @@ -77,9 +64,7 @@ const OpenPositions: React.FC<OpenPositionsProps> = ({ exchangeTokens, exchangeT
t,
activePositionsTab,
smartPositionsCount,
isolatedPositionsCount,
portfolio.crossMarginFutures,
portfolio.isolatedMarginFutures,
balances.totalUSDBalance,
exchangeTokenBalances,
setActivePositionsTab,
Expand All @@ -104,10 +89,6 @@ const OpenPositions: React.FC<OpenPositionsProps> = ({ exchangeTokens, exchangeT
<FuturesPositionsTable accountType={FuturesAccountTypes.CROSS_MARGIN} />
</TabPanel>

<TabPanel name={PositionsTab.ISOLATED_MARGIN} activeTab={activePositionsTab}>
<FuturesPositionsTable accountType={FuturesAccountTypes.ISOLATED_MARGIN} />
</TabPanel>

<TabPanel name={MarketsTab.SPOT} activeTab={activePositionsTab}>
<SynthBalancesTable exchangeTokens={exchangeTokens} />
</TabPanel>
Expand All @@ -118,8 +99,8 @@ const OpenPositions: React.FC<OpenPositionsProps> = ({ exchangeTokens, exchangeT
const TabButtonsContainer = styled.div`
display: flex;
margin: 16px 0;
justify-content: space-between;
column-gap: 4px;
justify-content: flex-start;
column-gap: 10px;
`;

export default OpenPositions;
21 changes: 0 additions & 21 deletions sections/dashboard/Overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { sdk } from 'state/config';
import { fetchTokenList } from 'state/exchange/actions';
import { setFuturesAccountType } from 'state/futures/reducer';
import {
selectActiveIsolatedPositionsCount,
selectActiveSmartPositionsCount,
selectFuturesPortfolio,
selectFuturesType,
Expand Down Expand Up @@ -47,7 +46,6 @@ const Overview: FC = () => {
const accountType = useAppSelector(selectFuturesType);
const balances = useAppSelector(selectBalances);
const portfolio = useAppSelector(selectFuturesPortfolio);
const isolatedPositionsCount = useAppSelector(selectActiveIsolatedPositionsCount);
const smartPositionsCount = useAppSelector(selectActiveSmartPositionsCount);

const [activePositionsTab, setActivePositionsTab] = useState<PositionsTab>(
Expand Down Expand Up @@ -143,19 +141,6 @@ const Overview: FC = () => {
dispatch(setFuturesAccountType(FuturesAccountTypes.CROSS_MARGIN));
},
},
{
name: PositionsTab.ISOLATED_MARGIN,
label: t('dashboard.overview.positions-tabs.isolated-margin'),
badge: isolatedPositionsCount,
active: activePositionsTab === PositionsTab.ISOLATED_MARGIN,
titleIcon: <FuturesIcon type="isolated_margin" />,
detail: formatDollars(portfolio.isolatedMarginFutures),
disabled: false,
onClick: () => {
setActivePositionsTab(PositionsTab.ISOLATED_MARGIN);
dispatch(setFuturesAccountType(FuturesAccountTypes.ISOLATED_MARGIN));
},
},
{
name: PositionsTab.SPOT,
label: t('dashboard.overview.positions-tabs.spot'),
Expand All @@ -169,12 +154,10 @@ const Overview: FC = () => {
t,
dispatch,
smartPositionsCount,
isolatedPositionsCount,
exchangeTokens,
balances.totalUSDBalance,
activePositionsTab,
portfolio.crossMarginFutures,
portfolio.isolatedMarginFutures,
setActivePositionsTab,
]);

Expand All @@ -192,10 +175,6 @@ const Overview: FC = () => {
<FuturesPositionsTable accountType={FuturesAccountTypes.CROSS_MARGIN} />
</TabPanel>

<TabPanel name={PositionsTab.ISOLATED_MARGIN} activeTab={activePositionsTab}>
<FuturesPositionsTable accountType={FuturesAccountTypes.ISOLATED_MARGIN} />
</TabPanel>

<TabPanel name={PositionsTab.SPOT} activeTab={activePositionsTab}>
<SynthBalancesTable exchangeTokens={exchangeTokens} />
</TabPanel>
Expand Down
4 changes: 3 additions & 1 deletion sections/shared/Layout/AppLayout/Header/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const Nav: FC = memo(() => {

const getLink = useCallback(
(link: string) => {
return link.indexOf('/market') === 0 ? `/market/?asset=${marketAsset}` : link;
return link.indexOf('/market') === 0
? `/market/?accountType=cross_margin&asset=${marketAsset}`
: link;
},
[marketAsset]
);
Expand Down
17 changes: 1 addition & 16 deletions sections/shared/Layout/AppLayout/Header/constants.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { FunctionComponent } from 'react';

import KwentaYellowIcon from 'assets/svg/brand/logo-yellow.svg';
import { COMPETITION_ENABLED } from 'constants/competition';
import { CROSS_MARGIN_ENABLED, DEFAULT_FUTURES_MARGIN_TYPE } from 'constants/defaults';
import { EXTERNAL_LINKS } from 'constants/links';
import ROUTES from 'constants/routes';

Expand Down Expand Up @@ -78,20 +76,7 @@ export const getMenuLinks = (isMobile: boolean): MenuLinks => [
},
{
i18nLabel: 'header.nav.markets',
link: ROUTES.Markets.Home(DEFAULT_FUTURES_MARGIN_TYPE),
links: CROSS_MARGIN_ENABLED
? [
{
link: ROUTES.Markets.Home('cross_margin'),
i18nLabel: 'header.nav.cross-margin',
Icon: KwentaYellowIcon,
},
{
link: ROUTES.Markets.Home('isolated_margin'),
i18nLabel: 'header.nav.isolated-margin',
},
]
: null,
link: ROUTES.Markets.Home('cross_margin'),
},
{
i18nLabel: 'header.nav.exchange',
Expand Down
2 changes: 1 addition & 1 deletion sections/shared/Layout/HomeLayout/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Banner = memo(() => {
useEffect(
() => {
const currentTime = new Date().getTime();
dispatch(setShowBanner(currentTime - storedTime >= BANNER_WAITING_TIME));
dispatch(setShowBanner(currentTime - storedTime >= BANNER_WAITING_TIME && BANNER_ENABLED));
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[storedTime]
Expand Down